class-action 1.2.2 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/class_action/version.rb +1 -1
- data/lib/class_action.rb +1 -1
- data/spec/class_action/rspec/have_class_action_matcher_spec.rb +8 -7
- data/spec/class_action_spec.rb +10 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 67491f2d4f05fd11241fe72316be24fa55fc9518
|
4
|
+
data.tar.gz: 98af8db4cebf73ad4574a043fa2ef8cb4bb968e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f0e565aaecce1dc7cf0c70a0c5bef3fcecca5cddb4f60659bc0c9eb758861453aa04fdf86da08bf2b31dc82a4b370831fdf7f9a808516f8a243126efcd1f2f4
|
7
|
+
data.tar.gz: a7441cf402af025f1130e092199f74f2403aba1e66b2773b52c67c665d72e636ae896c7a3c9c35052c5cf2ea96a70d05cfe6dc3d2cb61ba39db4d9d66b4099fa
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/lib/class_action/version.rb
CHANGED
data/lib/class_action.rb
CHANGED
@@ -24,7 +24,7 @@ module ClassAction
|
|
24
24
|
|
25
25
|
def class_action(*actions, klass: nil)
|
26
26
|
actions.each do |action|
|
27
|
-
action_class = klass || const_get(action.to_s.camelize)
|
27
|
+
action_class = klass || const_get("#{action.to_s.camelize}Action")
|
28
28
|
raise ArgumentError, "ClassAction does not support anonymous classes" if action_class.name.nil?
|
29
29
|
|
30
30
|
class_eval <<-RUBY, __FILE__, __LINE__+1
|
@@ -4,7 +4,11 @@ require 'class_action/rspec'
|
|
4
4
|
describe ClassAction::RSpec::HaveClassActionMatcher do
|
5
5
|
|
6
6
|
class ClassActionTestController < ActionController::Base
|
7
|
-
class
|
7
|
+
class IndexAction < ClassAction::Action
|
8
|
+
end
|
9
|
+
class Index2Action < ClassAction::Action
|
10
|
+
end
|
11
|
+
class OtherIndex2Action < ClassAction::Action
|
8
12
|
end
|
9
13
|
end
|
10
14
|
|
@@ -52,16 +56,13 @@ describe ClassAction::RSpec::HaveClassActionMatcher do
|
|
52
56
|
|
53
57
|
it "should fail if the controller's index action uses a different class" do
|
54
58
|
ClassActionTestController.class_eval do
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
class_action :index2, Index2
|
59
|
+
class_action :index2, klass: ClassActionTestController::OtherIndex2Action
|
59
60
|
end
|
60
61
|
|
61
|
-
expect { expect(controller).to have_class_action(:index2).using_class(ClassActionTestController::
|
62
|
+
expect { expect(controller).to have_class_action(:index2).using_class(ClassActionTestController::Index2Action) }.to \
|
62
63
|
raise_error(
|
63
64
|
RSpec::Expectations::ExpectationNotMetError,
|
64
|
-
"expected action ClassActionTestController#index2 to use class ClassActionTestController::
|
65
|
+
"expected action ClassActionTestController#index2 to use class ClassActionTestController::Index2Action, but it used ClassActionTestController::OtherIndex2Action"
|
65
66
|
)
|
66
67
|
end
|
67
68
|
end
|
data/spec/class_action_spec.rb
CHANGED
@@ -14,10 +14,10 @@ describe ClassAction do
|
|
14
14
|
@logger ||= Logger.new(STDOUT)
|
15
15
|
end
|
16
16
|
|
17
|
-
class
|
17
|
+
class ShowAction < ClassAction::Action
|
18
18
|
end
|
19
19
|
|
20
|
-
class
|
20
|
+
class OtherShowAction < ClassAction::Action
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -43,9 +43,9 @@ describe ClassAction do
|
|
43
43
|
|
44
44
|
context "when executing the action" do
|
45
45
|
let(:action) { action = double(:action, :_execute => nil) }
|
46
|
-
before { expect(ClassActionTestController::
|
46
|
+
before { expect(ClassActionTestController::ShowAction).to receive(:new).with(controller).and_return(action) }
|
47
47
|
|
48
|
-
it "should try to instantiate TestController::
|
48
|
+
it "should try to instantiate TestController::ShowAction and execute it" do
|
49
49
|
expect(action).to receive(:_execute)
|
50
50
|
controller.show
|
51
51
|
end
|
@@ -71,13 +71,13 @@ describe ClassAction do
|
|
71
71
|
context "giving another action class" do
|
72
72
|
before do
|
73
73
|
ClassActionTestController.class_eval do
|
74
|
-
class_action :show, klass: ClassActionTestController::
|
74
|
+
class_action :show, klass: ClassActionTestController::OtherShowAction
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
78
|
it "should try to instantiate the given action class when executed" do
|
79
|
-
action = ClassActionTestController::
|
80
|
-
expect(ClassActionTestController::
|
79
|
+
action = ClassActionTestController::OtherShowAction.new(controller)
|
80
|
+
expect(ClassActionTestController::OtherShowAction).to receive(:new).with(controller).and_return(action)
|
81
81
|
controller.show
|
82
82
|
|
83
83
|
expect(controller.class_action).to be(action)
|
@@ -89,7 +89,7 @@ describe ClassAction do
|
|
89
89
|
describe "respond mime injection" do
|
90
90
|
|
91
91
|
before do
|
92
|
-
ClassActionTestController::
|
92
|
+
ClassActionTestController::ShowAction.class_eval do
|
93
93
|
respond_to :html
|
94
94
|
end
|
95
95
|
end
|
@@ -160,7 +160,7 @@ describe ClassAction do
|
|
160
160
|
end
|
161
161
|
|
162
162
|
it "should leave everything alone if the class action has no responders" do
|
163
|
-
allow(ClassActionTestController::
|
163
|
+
allow(ClassActionTestController::ShowAction).to receive(:_responders).and_return({})
|
164
164
|
|
165
165
|
ClassActionTestController.class_eval do
|
166
166
|
respond_to :json
|
@@ -173,7 +173,7 @@ describe ClassAction do
|
|
173
173
|
end
|
174
174
|
|
175
175
|
it "should leave everything alone if the class action has an 'any' responder" do
|
176
|
-
ClassActionTestController::
|
176
|
+
ClassActionTestController::ShowAction.class_eval do
|
177
177
|
respond_to_any
|
178
178
|
end
|
179
179
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: class-action
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joost Lubach
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|