much-rails 0.2.8 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/much-rails/action.rb +11 -3
- data/lib/much-rails/action/controller.rb +12 -10
- data/lib/much-rails/action/router.rb +24 -9
- data/lib/much-rails/version.rb +1 -1
- data/test/support/fake_action_controller.rb +17 -6
- data/test/unit/action/controller_tests.rb +20 -7
- data/test/unit/action/router_tests.rb +11 -11
- data/test/unit/action/unprocessable_entity_result_tests.rb +1 -1
- data/test/unit/action_tests.rb +61 -9
- data/test/unit/change_action_tests.rb +7 -50
- data/test/unit/destroy_action_tests.rb +1 -7
- data/test/unit/save_action_tests.rb +1 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba7d46f07c2592e152fe836a0cff5a7bf8061e9f531aac1c6a748f1365cc383b
|
4
|
+
data.tar.gz: 19e41c6e470a0021b6b78ea9c7eff7e6e530758d0522a591b4f8623b610f9fa2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37bdf6aa9a624f270cd53e5ba22f3e400f331b9b91c29aed2c6169627350f9c49e2f929ff6b9bc83665c789953559f67f546c11fd4cc9660814b46f61bfb2bb9
|
7
|
+
data.tar.gz: eb78925cf707aef2f6484665963da6dee38f495cad04de680f7ea349292eae41b77bdd36f014b05a2e5fcda48e8c8d03b23485f60786020100794f4d1cb3c15f
|
data/lib/much-rails/action.rb
CHANGED
@@ -31,7 +31,7 @@ module MuchRails::Action
|
|
31
31
|
|
32
32
|
add_config :much_rails_action
|
33
33
|
|
34
|
-
attr_reader :params, :
|
34
|
+
attr_reader :params, :request, :errors
|
35
35
|
end
|
36
36
|
|
37
37
|
mixin_class_methods do
|
@@ -112,9 +112,8 @@ module MuchRails::Action
|
|
112
112
|
end
|
113
113
|
|
114
114
|
mixin_instance_methods do
|
115
|
-
def initialize(params: nil,
|
115
|
+
def initialize(params: nil, request: nil)
|
116
116
|
@params = params.to_h.with_indifferent_access
|
117
|
-
@current_session = current_session
|
118
117
|
@request = request
|
119
118
|
@errors = Hash.new{ |hash, key| hash[key] = [] }
|
120
119
|
end
|
@@ -150,8 +149,17 @@ module MuchRails::Action
|
|
150
149
|
@much_rails_successful_action
|
151
150
|
end
|
152
151
|
|
152
|
+
def controller_session=(value)
|
153
|
+
@controller_session = value
|
154
|
+
end
|
155
|
+
|
153
156
|
private
|
154
157
|
|
158
|
+
def controller_session
|
159
|
+
@controller_session ||=
|
160
|
+
request&.env&.[]("action_controller.instance")&.session
|
161
|
+
end
|
162
|
+
|
155
163
|
def default_action_success_result
|
156
164
|
MuchRails::Action::HeadResult.new(:ok)
|
157
165
|
end
|
@@ -9,30 +9,31 @@ module MuchRails::Action; end
|
|
9
9
|
# MuchRails::Action::Controller defines the behaviors for controllers processing
|
10
10
|
# MuchRails::Actions.
|
11
11
|
module MuchRails::Action::Controller
|
12
|
-
DEFAULT_ACTION_CLASS_FORMAT = :any
|
13
|
-
|
14
12
|
include MuchRails::Mixin
|
15
13
|
|
14
|
+
def self.DEFAULT_ACTION_CLASS_FORMAT
|
15
|
+
:any
|
16
|
+
end
|
17
|
+
|
16
18
|
mixin_included do
|
17
19
|
attr_reader :much_rails_action_class
|
18
20
|
|
19
|
-
|
21
|
+
prepend_before_action(
|
20
22
|
:require_much_rails_action_class,
|
21
|
-
only: MuchRails::Action::Router
|
23
|
+
only: MuchRails::Action::Router.CONTROLLER_CALL_ACTION_METHOD_NAME,
|
22
24
|
)
|
23
25
|
before_action :permit_all_much_rails_action_params
|
24
26
|
end
|
25
27
|
|
26
28
|
mixin_instance_methods do
|
27
29
|
define_method(
|
28
|
-
MuchRails::Action::Router
|
30
|
+
MuchRails::Action::Router.CONTROLLER_CALL_ACTION_METHOD_NAME,
|
29
31
|
) do
|
30
32
|
respond_to do |format|
|
31
33
|
format.public_send(much_rails_action_class_format) do
|
32
34
|
result =
|
33
35
|
much_rails_action_class.call(
|
34
36
|
params: much_rails_action_params,
|
35
|
-
current_session: current_session,
|
36
37
|
request: request,
|
37
38
|
)
|
38
39
|
instance_exec(result, &result.execute_block)
|
@@ -41,7 +42,7 @@ module MuchRails::Action::Controller
|
|
41
42
|
end
|
42
43
|
|
43
44
|
define_method(
|
44
|
-
MuchRails::Action::Router
|
45
|
+
MuchRails::Action::Router.CONTROLLER_NOT_FOUND_METHOD_NAME,
|
45
46
|
) do
|
46
47
|
respond_to do |format|
|
47
48
|
format.html do
|
@@ -51,11 +52,12 @@ module MuchRails::Action::Controller
|
|
51
52
|
end
|
52
53
|
|
53
54
|
def much_rails_action_class_name
|
54
|
-
"::#{params[MuchRails::Action::Router
|
55
|
+
"::#{params[MuchRails::Action::Router.ACTION_CLASS_PARAM_NAME]}"
|
55
56
|
end
|
56
57
|
|
57
58
|
def much_rails_action_class_format
|
58
|
-
much_rails_action_class.format ||
|
59
|
+
much_rails_action_class.format ||
|
60
|
+
MuchRails::Action::Controller.DEFAULT_ACTION_CLASS_FORMAT
|
59
61
|
end
|
60
62
|
|
61
63
|
def much_rails_action_params
|
@@ -67,7 +69,7 @@ module MuchRails::Action::Controller
|
|
67
69
|
params
|
68
70
|
.to_h
|
69
71
|
.except(
|
70
|
-
MuchRails::Action::Router
|
72
|
+
MuchRails::Action::Router.ACTION_CLASS_PARAM_NAME,
|
71
73
|
:controller,
|
72
74
|
:action,
|
73
75
|
),
|
@@ -6,10 +6,21 @@ module MuchRails; end
|
|
6
6
|
module MuchRails::Action; end
|
7
7
|
|
8
8
|
class MuchRails::Action::Router < MuchRails::Action::BaseRouter
|
9
|
-
DEFAULT_CONTROLLER_NAME
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
def self.DEFAULT_CONTROLLER_NAME
|
10
|
+
"application"
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.CONTROLLER_CALL_ACTION_METHOD_NAME
|
14
|
+
:much_rails_call_action
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.CONTROLLER_NOT_FOUND_METHOD_NAME
|
18
|
+
:much_rails_not_found
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.ACTION_CLASS_PARAM_NAME
|
22
|
+
:much_rails_action_class_name
|
23
|
+
end
|
13
24
|
|
14
25
|
def self.url_class
|
15
26
|
MuchRails::Action::Router::URL
|
@@ -38,7 +49,7 @@ class MuchRails::Action::Router < MuchRails::Action::BaseRouter
|
|
38
49
|
def initialize(name = nil, controller_name: nil, &block)
|
39
50
|
super(name, &block)
|
40
51
|
|
41
|
-
@controller_name = controller_name || DEFAULT_CONTROLLER_NAME
|
52
|
+
@controller_name = controller_name || self.class.DEFAULT_CONTROLLER_NAME
|
42
53
|
end
|
43
54
|
|
44
55
|
# Example:
|
@@ -49,8 +60,10 @@ class MuchRails::Action::Router < MuchRails::Action::BaseRouter
|
|
49
60
|
# end
|
50
61
|
def apply_to(application_routes_draw_scope)
|
51
62
|
validate!
|
52
|
-
draw_url_to
|
53
|
-
|
63
|
+
draw_url_to =
|
64
|
+
"#{controller_name}##{self.class.CONTROLLER_NOT_FOUND_METHOD_NAME}"
|
65
|
+
draw_route_to =
|
66
|
+
"#{controller_name}##{self.class.CONTROLLER_CALL_ACTION_METHOD_NAME}"
|
54
67
|
|
55
68
|
definition_names = Set.new
|
56
69
|
|
@@ -63,7 +76,8 @@ class MuchRails::Action::Router < MuchRails::Action::BaseRouter
|
|
63
76
|
as: (definition.name if definition_names.add?(definition.name)),
|
64
77
|
defaults:
|
65
78
|
definition.default_params.merge({
|
66
|
-
ACTION_CLASS_PARAM_NAME =>
|
79
|
+
self.class.ACTION_CLASS_PARAM_NAME =>
|
80
|
+
request_type_action.class_name,
|
67
81
|
"format" => request_type_action.format,
|
68
82
|
}),
|
69
83
|
constraints: request_type_action.constraints_lambda,
|
@@ -79,7 +93,8 @@ class MuchRails::Action::Router < MuchRails::Action::BaseRouter
|
|
79
93
|
as: (definition.name if definition_names.add?(definition.name)),
|
80
94
|
defaults:
|
81
95
|
definition.default_params.merge({
|
82
|
-
ACTION_CLASS_PARAM_NAME =>
|
96
|
+
self.class.ACTION_CLASS_PARAM_NAME =>
|
97
|
+
definition.default_action_class_name,
|
83
98
|
"format" => definition.default_action_format,
|
84
99
|
}),
|
85
100
|
)
|
data/lib/much-rails/version.rb
CHANGED
@@ -13,20 +13,31 @@ module FakeActionController
|
|
13
13
|
end
|
14
14
|
|
15
15
|
mixin_class_methods do
|
16
|
-
def before_action(
|
17
|
-
|
16
|
+
def before_action(*args, &block)
|
17
|
+
before_action_calls << Assert::StubCall.new(*args, &block)
|
18
18
|
end
|
19
19
|
|
20
|
-
def
|
21
|
-
|
20
|
+
def prepend_before_action(*args, &block)
|
21
|
+
prepend_before_action_calls << Assert::StubCall.new(*args, &block)
|
22
|
+
end
|
23
|
+
|
24
|
+
def before_action_calls
|
25
|
+
@before_action_calls ||= []
|
26
|
+
end
|
27
|
+
|
28
|
+
def prepend_before_action_calls
|
29
|
+
@prepend_before_action_calls ||= []
|
22
30
|
end
|
23
31
|
end
|
24
32
|
|
25
33
|
mixin_instance_methods do
|
26
34
|
def initialize(params)
|
27
35
|
@params = FakeParams.new(params)
|
28
|
-
self.class.
|
29
|
-
public_send(
|
36
|
+
self.class.prepend_before_action_calls.each do |before_action_call|
|
37
|
+
public_send(before_action_call.args.first)
|
38
|
+
end
|
39
|
+
self.class.before_action_calls.each do |before_action_call|
|
40
|
+
public_send(before_action_call.args.first)
|
30
41
|
end
|
31
42
|
end
|
32
43
|
|
@@ -17,8 +17,8 @@ module MuchRails::Action::Controller
|
|
17
17
|
assert_that(subject).includes(MuchRails::Mixin)
|
18
18
|
end
|
19
19
|
|
20
|
-
should "know its
|
21
|
-
assert_that(subject
|
20
|
+
should "know its attributes" do
|
21
|
+
assert_that(subject.DEFAULT_ACTION_CLASS_FORMAT).equals(:any)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
@@ -29,6 +29,19 @@ module MuchRails::Action::Controller
|
|
29
29
|
let(:receiver_class) do
|
30
30
|
Class.new{ include FakeActionController }
|
31
31
|
end
|
32
|
+
|
33
|
+
should "be configured as expected" do
|
34
|
+
assert_that(subject.prepend_before_action_calls.size).equals(1)
|
35
|
+
assert_that(subject.prepend_before_action_calls.last.args)
|
36
|
+
.equals([
|
37
|
+
:require_much_rails_action_class,
|
38
|
+
only: MuchRails::Action::Router.CONTROLLER_CALL_ACTION_METHOD_NAME,
|
39
|
+
])
|
40
|
+
|
41
|
+
assert_that(subject.before_action_calls.size).equals(1)
|
42
|
+
assert_that(subject.before_action_calls.last.args)
|
43
|
+
.equals([:permit_all_much_rails_action_params])
|
44
|
+
end
|
32
45
|
end
|
33
46
|
|
34
47
|
class ReceiverInitTests < ReceiverTests
|
@@ -41,7 +54,7 @@ module MuchRails::Action::Controller
|
|
41
54
|
|
42
55
|
let(:params1) do
|
43
56
|
{
|
44
|
-
MuchRails::Action::Router
|
57
|
+
MuchRails::Action::Router.ACTION_CLASS_PARAM_NAME => "Actions::Show",
|
45
58
|
controller: "actions",
|
46
59
|
action: "show",
|
47
60
|
nested: {
|
@@ -53,10 +66,10 @@ module MuchRails::Action::Controller
|
|
53
66
|
should have_readers :much_rails_action_class
|
54
67
|
|
55
68
|
should have_imeths(
|
56
|
-
MuchRails::Action::Router
|
69
|
+
MuchRails::Action::Router.CONTROLLER_CALL_ACTION_METHOD_NAME,
|
57
70
|
)
|
58
71
|
should have_imeths(
|
59
|
-
MuchRails::Action::Router
|
72
|
+
MuchRails::Action::Router.CONTROLLER_NOT_FOUND_METHOD_NAME,
|
60
73
|
)
|
61
74
|
should have_imeths :much_rails_action_class_name
|
62
75
|
should have_imeths :much_rails_action_class_format
|
@@ -69,7 +82,7 @@ module MuchRails::Action::Controller
|
|
69
82
|
.equals("::Actions::Show")
|
70
83
|
|
71
84
|
assert_that(subject.much_rails_action_class_format)
|
72
|
-
.equals(unit_module
|
85
|
+
.equals(unit_module.DEFAULT_ACTION_CLASS_FORMAT)
|
73
86
|
|
74
87
|
assert_that(subject.much_rails_action_params)
|
75
88
|
.equals(
|
@@ -91,7 +104,7 @@ module MuchRails::Action::Controller
|
|
91
104
|
|
92
105
|
let(:params1) do
|
93
106
|
{
|
94
|
-
MuchRails::Action::Router
|
107
|
+
MuchRails::Action::Router.ACTION_CLASS_PARAM_NAME =>
|
95
108
|
"Actions::Unknown",
|
96
109
|
}
|
97
110
|
end
|
@@ -16,17 +16,17 @@ class MuchRails::Action::Router
|
|
16
16
|
|
17
17
|
should have_imeths :url_class
|
18
18
|
|
19
|
-
should "be
|
19
|
+
should "be configured as expected" do
|
20
20
|
assert_that(subject < MuchRails::Action::BaseRouter).is_true
|
21
21
|
end
|
22
22
|
|
23
|
-
should "know its
|
24
|
-
assert_that(subject
|
25
|
-
assert_that(subject
|
23
|
+
should "know its attributes" do
|
24
|
+
assert_that(subject.DEFAULT_CONTROLLER_NAME).equals("application")
|
25
|
+
assert_that(subject.CONTROLLER_CALL_ACTION_METHOD_NAME)
|
26
26
|
.equals(:much_rails_call_action)
|
27
|
-
assert_that(subject
|
27
|
+
assert_that(subject.CONTROLLER_NOT_FOUND_METHOD_NAME)
|
28
28
|
.equals(:much_rails_not_found)
|
29
|
-
assert_that(subject
|
29
|
+
assert_that(subject.ACTION_CLASS_PARAM_NAME)
|
30
30
|
.equals(:much_rails_action_class_name)
|
31
31
|
assert_that(subject.url_class).equals(unit_class::URL)
|
32
32
|
end
|
@@ -64,7 +64,7 @@ class MuchRails::Action::Router
|
|
64
64
|
|
65
65
|
should "know its attributes" do
|
66
66
|
assert_that(subject.controller_name)
|
67
|
-
.equals(unit_class
|
67
|
+
.equals(unit_class.DEFAULT_CONTROLLER_NAME)
|
68
68
|
|
69
69
|
router = unit_class.new(controller_name: controller_name1)
|
70
70
|
assert_that(router.controller_name).equals(controller_name1)
|
@@ -99,13 +99,13 @@ class MuchRails::Action::Router
|
|
99
99
|
|
100
100
|
expected_draw_url_to =
|
101
101
|
"#{subject.controller_name}"\
|
102
|
-
"##{unit_class
|
102
|
+
"##{unit_class.CONTROLLER_NOT_FOUND_METHOD_NAME}"
|
103
103
|
expected_draw_route_to =
|
104
104
|
"#{subject.controller_name}"\
|
105
|
-
"##{unit_class
|
105
|
+
"##{unit_class.CONTROLLER_CALL_ACTION_METHOD_NAME}"
|
106
106
|
expected_default_defaults =
|
107
107
|
{
|
108
|
-
unit_class
|
108
|
+
unit_class.ACTION_CLASS_PARAM_NAME => default_class_name,
|
109
109
|
"format" => :html,
|
110
110
|
}
|
111
111
|
|
@@ -117,7 +117,7 @@ class MuchRails::Action::Router
|
|
117
117
|
as: url_name,
|
118
118
|
defaults:
|
119
119
|
{
|
120
|
-
unit_class
|
120
|
+
unit_class.ACTION_CLASS_PARAM_NAME => request_type_class_name,
|
121
121
|
"format" => :html,
|
122
122
|
},
|
123
123
|
constraints: request_type_proc,
|
@@ -20,7 +20,7 @@ class MuchRails::Action::UnprocessableEntityResult
|
|
20
20
|
let(:controller1){ FakeController.new(params1) }
|
21
21
|
let(:params1) do
|
22
22
|
{
|
23
|
-
MuchRails::Action::Router
|
23
|
+
MuchRails::Action::Router.ACTION_CLASS_PARAM_NAME => "Actions::Show",
|
24
24
|
}
|
25
25
|
end
|
26
26
|
let(:errors1) do
|
data/test/unit/action_tests.rb
CHANGED
@@ -176,11 +176,7 @@ module MuchRails::Action
|
|
176
176
|
class InitTests < ReceiverTests
|
177
177
|
desc "when init"
|
178
178
|
subject do
|
179
|
-
receiver_class.new(
|
180
|
-
params: params1,
|
181
|
-
current_session: current_session1,
|
182
|
-
request: request1,
|
183
|
-
)
|
179
|
+
receiver_class.new(params: params1, request: request1)
|
184
180
|
end
|
185
181
|
|
186
182
|
let(:receiver_class) do
|
@@ -218,6 +214,10 @@ module MuchRails::Action
|
|
218
214
|
on_after_call do
|
219
215
|
@after_call_called = true
|
220
216
|
end
|
217
|
+
|
218
|
+
def action_controller_session
|
219
|
+
controller_session
|
220
|
+
end
|
221
221
|
end
|
222
222
|
end
|
223
223
|
|
@@ -234,16 +234,41 @@ module MuchRails::Action
|
|
234
234
|
active: "true",
|
235
235
|
}
|
236
236
|
end
|
237
|
-
let(:
|
238
|
-
let(:request1){ "REQUEST 1" }
|
237
|
+
let(:request1){ FakeRequest.new }
|
239
238
|
|
240
|
-
should have_readers :params, :
|
239
|
+
should have_readers :params, :request, :errors
|
240
|
+
should have_writers :controller_session
|
241
241
|
should have_imeths :on_call, :valid_action?, :successful_action?
|
242
242
|
|
243
243
|
should "know its attributes" do
|
244
244
|
assert_that(subject.params).equals(params1.with_indifferent_access)
|
245
|
-
assert_that(subject.current_session).equals(current_session1)
|
246
245
|
assert_that(subject.request).equals(request1)
|
246
|
+
assert_that(subject.action_controller_session).is_a(FakeSession)
|
247
|
+
|
248
|
+
receiver = receiver_class.new(params: params1)
|
249
|
+
assert_that(receiver.action_controller_session).is_nil
|
250
|
+
|
251
|
+
controller_session = FakeRequest.new
|
252
|
+
receiver.controller_session = controller_session
|
253
|
+
assert_that(receiver.action_controller_session).is(controller_session)
|
254
|
+
|
255
|
+
receiver =
|
256
|
+
receiver_class.new(params: params1, request: FakeRequestWithNoEnv.new)
|
257
|
+
assert_that(receiver.action_controller_session).is_nil
|
258
|
+
|
259
|
+
receiver =
|
260
|
+
receiver_class.new(
|
261
|
+
params: params1,
|
262
|
+
request: FakeRequestWithNoControllerInstance.new,
|
263
|
+
)
|
264
|
+
assert_that(receiver.action_controller_session).is_nil
|
265
|
+
|
266
|
+
receiver =
|
267
|
+
receiver_class.new(
|
268
|
+
params: params1,
|
269
|
+
request: FakeRequestWithNoControllerInstance.new,
|
270
|
+
)
|
271
|
+
assert_that(receiver.action_controller_session).is_nil
|
247
272
|
end
|
248
273
|
|
249
274
|
should "return the expected Result" do
|
@@ -409,4 +434,31 @@ module MuchRails::Action
|
|
409
434
|
assert_that(result.errors[:custom_validation]).includes("ERROR1")
|
410
435
|
end
|
411
436
|
end
|
437
|
+
|
438
|
+
class FakeController
|
439
|
+
def session
|
440
|
+
FakeSession.new
|
441
|
+
end
|
442
|
+
end
|
443
|
+
|
444
|
+
class FakeSession
|
445
|
+
end
|
446
|
+
|
447
|
+
class FakeRequest
|
448
|
+
def env
|
449
|
+
{ "action_controller.instance" => FakeController.new }
|
450
|
+
end
|
451
|
+
end
|
452
|
+
|
453
|
+
class FakeRequestWithNoControllerInstance
|
454
|
+
def env
|
455
|
+
{ "action_controller.instance" => nil }
|
456
|
+
end
|
457
|
+
end
|
458
|
+
|
459
|
+
class FakeRequestWithNoEnv
|
460
|
+
def env
|
461
|
+
nil
|
462
|
+
end
|
463
|
+
end
|
412
464
|
end
|
@@ -57,14 +57,7 @@ module MuchRails::ChangeAction
|
|
57
57
|
|
58
58
|
class InitTests < ReceiverTests
|
59
59
|
desc "when init"
|
60
|
-
subject{ receiver_class.new(params: {}) }
|
61
|
-
subject do
|
62
|
-
receiver_class.new(
|
63
|
-
params: {},
|
64
|
-
current_session: nil,
|
65
|
-
request: nil,
|
66
|
-
)
|
67
|
-
end
|
60
|
+
subject{ receiver_class.new(params: {}, request: nil) }
|
68
61
|
|
69
62
|
setup do
|
70
63
|
Assert.stub(subject, :any_unextracted_change_result_validation_errors?) do
|
@@ -84,13 +77,7 @@ module MuchRails::ChangeAction
|
|
84
77
|
|
85
78
|
class RecordErrorsWithResultExceptionTests < InitTests
|
86
79
|
desc "with record errors and a result exception"
|
87
|
-
subject
|
88
|
-
receiver_class.new(
|
89
|
-
params: {},
|
90
|
-
current_session: nil,
|
91
|
-
request: nil,
|
92
|
-
)
|
93
|
-
end
|
80
|
+
subject{ receiver_class.new(params: {}, request: nil) }
|
94
81
|
|
95
82
|
setup do
|
96
83
|
Assert.stub(subject, :any_unextracted_change_result_validation_errors?) do
|
@@ -118,13 +105,7 @@ module MuchRails::ChangeAction
|
|
118
105
|
|
119
106
|
class RecordErrorsWithNoResultExceptionTests < InitTests
|
120
107
|
desc "with record errors and no result exception"
|
121
|
-
subject
|
122
|
-
receiver_class.new(
|
123
|
-
params: {},
|
124
|
-
current_session: nil,
|
125
|
-
request: nil,
|
126
|
-
)
|
127
|
-
end
|
108
|
+
subject{ receiver_class.new(params: {}, request: nil) }
|
128
109
|
|
129
110
|
setup do
|
130
111
|
Assert.stub(subject, :any_unextracted_change_result_validation_errors?) do
|
@@ -149,13 +130,7 @@ module MuchRails::ChangeAction
|
|
149
130
|
|
150
131
|
class ChangeResultMethodTests < InitTests
|
151
132
|
desc "#change_result method"
|
152
|
-
subject
|
153
|
-
receiver_class.new(
|
154
|
-
params: {},
|
155
|
-
current_session: nil,
|
156
|
-
request: nil,
|
157
|
-
)
|
158
|
-
end
|
133
|
+
subject{ receiver_class.new(params: {}, request: nil) }
|
159
134
|
|
160
135
|
should "memoize and return the expected Result" do
|
161
136
|
result = subject.change_result
|
@@ -178,13 +153,7 @@ module MuchRails::ChangeAction
|
|
178
153
|
|
179
154
|
class AnyUnextractedChangeResultValidationErrorsMethodTests < ReceiverTests
|
180
155
|
desc "#any_unextracted_change_result_validation_errors? method"
|
181
|
-
subject
|
182
|
-
receiver_class.new(
|
183
|
-
params: {},
|
184
|
-
current_session: nil,
|
185
|
-
request: nil,
|
186
|
-
)
|
187
|
-
end
|
156
|
+
subject{ receiver_class.new(params: {}, request: nil) }
|
188
157
|
|
189
158
|
let(:receiver_class) do
|
190
159
|
Class.new do
|
@@ -205,13 +174,7 @@ module MuchRails::ChangeAction
|
|
205
174
|
class NoValidationErrorsTests <
|
206
175
|
AnyUnextractedChangeResultValidationErrorsMethodTests
|
207
176
|
desc "with no validation errors"
|
208
|
-
subject
|
209
|
-
receiver_class.new(
|
210
|
-
params: {},
|
211
|
-
current_session: nil,
|
212
|
-
request: nil,
|
213
|
-
)
|
214
|
-
end
|
177
|
+
subject{ receiver_class.new(params: {}, request: nil) }
|
215
178
|
|
216
179
|
let(:receiver_class) do
|
217
180
|
Class.new do
|
@@ -232,13 +195,7 @@ module MuchRails::ChangeAction
|
|
232
195
|
class ValidationErrorsTests <
|
233
196
|
AnyUnextractedChangeResultValidationErrorsMethodTests
|
234
197
|
desc "with validation errors"
|
235
|
-
subject
|
236
|
-
receiver_class.new(
|
237
|
-
params: {},
|
238
|
-
current_session: nil,
|
239
|
-
request: nil,
|
240
|
-
)
|
241
|
-
end
|
198
|
+
subject{ receiver_class.new(params: {}, request: nil) }
|
242
199
|
|
243
200
|
let(:receiver_class) do
|
244
201
|
Class.new do
|
@@ -50,13 +50,7 @@ module MuchRails::DestroyAction
|
|
50
50
|
|
51
51
|
class InitTests < ReceiverTests
|
52
52
|
desc "when init"
|
53
|
-
subject
|
54
|
-
receiver_class.new(
|
55
|
-
params: {},
|
56
|
-
current_session: nil,
|
57
|
-
request: nil,
|
58
|
-
)
|
59
|
-
end
|
53
|
+
subject{ receiver_class.new(params: {}, request: nil) }
|
60
54
|
|
61
55
|
should have_imeths :destroy_result
|
62
56
|
|
@@ -50,13 +50,7 @@ module MuchRails::SaveAction
|
|
50
50
|
|
51
51
|
class InitTests < ReceiverTests
|
52
52
|
desc "when init"
|
53
|
-
subject
|
54
|
-
receiver_class.new(
|
55
|
-
params: {},
|
56
|
-
current_session: nil,
|
57
|
-
request: nil,
|
58
|
-
)
|
59
|
-
end
|
53
|
+
subject{ receiver_class.new(params: {}, request: nil) }
|
60
54
|
|
61
55
|
should have_imeths :save_result
|
62
56
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: much-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kelly Redding
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-05-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: much-style-guide
|