much-rails 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/much-rails/action/controller.rb +7 -1
- data/lib/much-rails/version.rb +1 -1
- data/test/unit/action/controller_tests.rb +13 -45
- 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: '08eb433f0b2e7fa04acaa6aec285a57d6c2988dc34067cb0ef401992a02125c4'
|
4
|
+
data.tar.gz: dc1a2ddf9997e2aa2577a1100efedb52e4a3d89b2abc5ee6a8150626a5b42129
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5178f432b4f6fd2712036e951742301b52565161e4d1387915315ea5a661beaa5b8d11935ae8eb7f761c76430f7afd1ba2243a0178d5fa7f155ac5a0751a934
|
7
|
+
data.tar.gz: 7aa259619b17110e7ce6ec81defa760b2ae6494b2e4e1eb6677f9ba003d4ad4312f046ff806680c8bbed11b2af92a09d86640cec904be20627fec52870a2ae3b
|
@@ -9,6 +9,8 @@ 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
|
+
|
12
14
|
include MuchRails::Mixin
|
13
15
|
|
14
16
|
mixin_included do
|
@@ -26,7 +28,7 @@ module MuchRails::Action::Controller
|
|
26
28
|
MuchRails::Action::Router::CONTROLLER_CALL_ACTION_METHOD_NAME,
|
27
29
|
) do
|
28
30
|
respond_to do |format|
|
29
|
-
format.public_send(
|
31
|
+
format.public_send(much_rails_action_class_format) do
|
30
32
|
result =
|
31
33
|
much_rails_action_class.call(
|
32
34
|
params: much_rails_action_params,
|
@@ -52,6 +54,10 @@ module MuchRails::Action::Controller
|
|
52
54
|
"::#{params[MuchRails::Action::Router::ACTION_CLASS_PARAM_NAME]}"
|
53
55
|
end
|
54
56
|
|
57
|
+
def much_rails_action_class_format
|
58
|
+
much_rails_action_class.format || DEFAULT_ACTION_CLASS_FORMAT
|
59
|
+
end
|
60
|
+
|
55
61
|
def much_rails_action_params
|
56
62
|
# If a `params_root` value is specified, pull the params from that key and
|
57
63
|
# merge them into the base params.
|
data/lib/much-rails/version.rb
CHANGED
@@ -16,6 +16,10 @@ module MuchRails::Action::Controller
|
|
16
16
|
should "include MuchRails::Mixin" do
|
17
17
|
assert_that(subject).includes(MuchRails::Mixin)
|
18
18
|
end
|
19
|
+
|
20
|
+
should "know its constants" do
|
21
|
+
assert_that(subject::DEFAULT_ACTION_CLASS_FORMAT).equals(:any)
|
22
|
+
end
|
19
23
|
end
|
20
24
|
|
21
25
|
class ReceiverTests < UnitTests
|
@@ -51,6 +55,7 @@ module MuchRails::Action::Controller
|
|
51
55
|
MuchRails::Action::Router::CONTROLLER_NOT_FOUND_METHOD_NAME,
|
52
56
|
)
|
53
57
|
should have_imeths :much_rails_action_class_name
|
58
|
+
should have_imeths :much_rails_action_class_format
|
54
59
|
should have_imeths :much_rails_action_params
|
55
60
|
should have_imeths :require_much_rails_action_class
|
56
61
|
should have_imeths :permit_all_much_rails_action_params
|
@@ -59,6 +64,9 @@ module MuchRails::Action::Controller
|
|
59
64
|
assert_that(subject.much_rails_action_class_name)
|
60
65
|
.equals("::Actions::Show")
|
61
66
|
|
67
|
+
assert_that(subject.much_rails_action_class_format)
|
68
|
+
.equals(unit_module::DEFAULT_ACTION_CLASS_FORMAT)
|
69
|
+
|
62
70
|
assert_that(subject.much_rails_action_params)
|
63
71
|
.equals(
|
64
72
|
nested: { value: "VALUE 1" },
|
@@ -66,6 +74,11 @@ module MuchRails::Action::Controller
|
|
66
74
|
)
|
67
75
|
|
68
76
|
assert_that(subject.much_rails_action_class).equals(Actions::Show)
|
77
|
+
|
78
|
+
Actions::Show.format(:html)
|
79
|
+
receiver = receiver_class.new(params1)
|
80
|
+
assert_that(receiver.much_rails_action_class_format).equals(:html)
|
81
|
+
Actions::Show.format(nil)
|
69
82
|
end
|
70
83
|
end
|
71
84
|
|
@@ -94,49 +107,4 @@ module MuchRails::Action::Controller
|
|
94
107
|
.raises(MuchRails::Action::ActionError)
|
95
108
|
end
|
96
109
|
end
|
97
|
-
|
98
|
-
class FakeController
|
99
|
-
def self.before_action(method_name)
|
100
|
-
before_actions << method_name
|
101
|
-
end
|
102
|
-
|
103
|
-
def self.before_actions
|
104
|
-
@before_actions ||= []
|
105
|
-
end
|
106
|
-
|
107
|
-
attr_reader :params, :head_called_with
|
108
|
-
|
109
|
-
def initialize(params)
|
110
|
-
@params = FakeParams.new(params)
|
111
|
-
self.class.before_actions.each do |before_action|
|
112
|
-
public_send(before_action)
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
def head(*args)
|
117
|
-
@head_called_with = args
|
118
|
-
self
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
class FakeParams
|
123
|
-
def initialize(params)
|
124
|
-
@params = params
|
125
|
-
end
|
126
|
-
|
127
|
-
def permit!
|
128
|
-
@permit_called = true
|
129
|
-
self
|
130
|
-
end
|
131
|
-
|
132
|
-
def [](key)
|
133
|
-
@params[key]
|
134
|
-
end
|
135
|
-
|
136
|
-
def to_h
|
137
|
-
raise "params haven't been permitted" unless @permit_called
|
138
|
-
|
139
|
-
@params
|
140
|
-
end
|
141
|
-
end
|
142
110
|
end
|
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.1.
|
4
|
+
version: 0.1.2
|
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-01-
|
12
|
+
date: 2021-01-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: much-style-guide
|