dalliance 0.2.0 → 0.2.1

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.
@@ -2,7 +2,7 @@ module Dalliance
2
2
  module VERSION
3
3
  MAJOR = 0
4
4
  MINOR = 2
5
- TINY = 0
5
+ TINY = 1
6
6
  PRE = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
@@ -8,6 +8,11 @@ module Dalliance
8
8
  def perform
9
9
  instance_klass.constantize.find(instance_id).dalliance_process(true)
10
10
  end
11
+
12
+ #Delayed job automatically retries, so rescue the error
13
+ def self.rescue_error?
14
+ true
15
+ end
11
16
  end
12
17
  end
13
18
  end
@@ -8,6 +8,11 @@ module Dalliance
8
8
  def self.perform(instance_klass, instance_id)
9
9
  instance_klass.constantize.find(instance_id).dalliance_process(true)
10
10
  end
11
+
12
+ #Resque fails, so don't rescue the error
13
+ def self.rescue_error?
14
+ false
15
+ end
11
16
  end
12
17
  end
13
18
  end
data/lib/dalliance.rb CHANGED
@@ -151,7 +151,7 @@ module Dalliance
151
151
  error_dalliance!
152
152
 
153
153
  #Don't raise the error if we're backgound_processing...
154
- raise e unless backgound_processing
154
+ raise e unless backgound_processing && self.class.dalliance_options[:worker_class].rescue_error?
155
155
  ensure
156
156
  if self.class.dalliance_options[:dalliance_progress_meter] && dalliance_progress_meter
157
157
  #Works with optimistic locking...
@@ -40,12 +40,18 @@ describe DallianceModel do
40
40
  end
41
41
 
42
42
  it "should call the dalliance_method w/ a Delayed::Worker" do
43
+ Resque::Stat.clear(:processed)
44
+ Resque::Stat.clear(:failed)
45
+
43
46
  subject.dalliance_background_process
44
47
  Resque::Worker.new(:dalliance).process
45
48
  subject.reload
46
49
 
47
50
  subject.should be_successful
48
51
  Resque.size(:dalliance).should == 0
52
+
53
+ Resque::Stat[:processed].should == 1
54
+ Resque::Stat[:failed].should == 0
49
55
  end
50
56
 
51
57
  it "should set the dalliance_status to completed" do
@@ -113,11 +119,17 @@ describe DallianceModel do
113
119
  end
114
120
 
115
121
  it "should NOT raise an error" do
122
+ Resque::Stat.clear(:processed)
123
+ Resque::Stat.clear(:failed)
124
+
116
125
  subject.dalliance_background_process
117
126
 
118
127
  Resque::Worker.new(:dalliance).process
119
128
 
120
129
  Resque.size(:dalliance).should == 0
130
+
131
+ Resque::Stat[:processed].should == 1
132
+ Resque::Stat[:failed].should == 1
121
133
  end
122
134
 
123
135
  it "should store the error" do
data/spec/spec_helper.rb CHANGED
@@ -29,3 +29,5 @@ end
29
29
 
30
30
  #We don't need a full rails app to test...
31
31
  require 'support/active_record'
32
+
33
+ #NOTE: Resque tests require REDIS $redis-server
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dalliance
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-20 00:00:00.000000000 Z
12
+ date: 2013-01-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord