governor_background 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/governor_background.gemspec +1 -1
- data/lib/governor_background.rb +1 -1
- data/spec/governor_background/handler_spec.rb +25 -15
- data/spec/governor_background_spec.rb +1 -1
- data/spec/rails_app/Gemfile.lock +1 -1
- metadata +3 -3
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/governor_background.gemspec
CHANGED
data/lib/governor_background.rb
CHANGED
@@ -13,7 +13,7 @@ background.register_model_callback do |base|
|
|
13
13
|
module InstanceMethods
|
14
14
|
private
|
15
15
|
def run_in_background(method, *arguments)
|
16
|
-
GovernorBackground::Handler.run_in_background self, method, arguments
|
16
|
+
GovernorBackground::Handler.run_in_background self, method, *arguments
|
17
17
|
end
|
18
18
|
end
|
19
19
|
base.send :include, InstanceMethods
|
@@ -30,24 +30,34 @@ module GovernorBackground
|
|
30
30
|
@article = Factory(:article, :author => Factory(:user))
|
31
31
|
end
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
context "delayed_job" do
|
34
|
+
it "adds jobs successfully" do
|
35
|
+
expect {
|
36
|
+
Handler.run_in_background(@article, :post)
|
37
|
+
}.to change { ::Delayed::Job.count }.by 1
|
38
|
+
end
|
39
|
+
|
40
|
+
it "handles any number of arguments" do
|
41
|
+
Handler.run_in_background(@article, :post, 1, 2, 3)
|
42
|
+
performer = YAML.load ::Delayed::Job.first.handler
|
43
|
+
performer.arguments.should == [1, 2, 3]
|
44
|
+
end
|
37
45
|
end
|
38
46
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
47
|
+
context "resque" do
|
48
|
+
it "adds jobs successfully" do
|
49
|
+
Handler.use_resque = true
|
50
|
+
Handler.run_in_background(@article, :post)
|
51
|
+
id = JobManager.jobs.first.id
|
52
|
+
Resque::PerformerWithState.should have_queued(id, {:resource => :articles, :id => @article.id, :method_name => :post, :arguments => []}).in(:governor)
|
53
|
+
end
|
45
54
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
55
|
+
it "can accept any number of arguments" do
|
56
|
+
Handler.use_resque = true
|
57
|
+
Handler.run_in_background(@article, :post, 1, 2, 3)
|
58
|
+
id = JobManager.jobs.first.id
|
59
|
+
Resque::PerformerWithState.should have_queued(id, {:resource => :articles, :id => @article.id, :method_name => :post, :arguments => [1, 2, 3]}).in(:governor)
|
60
|
+
end
|
51
61
|
end
|
52
62
|
end
|
53
63
|
end
|
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
3
3
|
describe GovernorBackground do
|
4
4
|
it "passes arguments to the handler" do
|
5
5
|
@article = Factory(:article, :author => Factory(:user))
|
6
|
-
GovernorBackground::Handler.expects(:run_in_background).with(@article, :some_method,
|
6
|
+
GovernorBackground::Handler.expects(:run_in_background).with(@article, :some_method, 1, 2, 3)
|
7
7
|
@article.send(:run_in_background, :some_method, 1, 2, 3)
|
8
8
|
end
|
9
9
|
end
|
data/spec/rails_app/Gemfile.lock
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: governor_background
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 2
|
10
|
+
version: 0.2.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Liam Morley
|