dalliance 0.5.1 → 0.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +107 -0
  3. data/Appraisals +10 -14
  4. data/Gemfile +1 -1
  5. data/README.rdoc +13 -1
  6. data/dalliance.gemspec +4 -4
  7. data/gemfiles/rails_5.0.gemfile +1 -1
  8. data/gemfiles/rails_5.0.gemfile.lock +116 -89
  9. data/gemfiles/rails_5.1.gemfile +1 -1
  10. data/gemfiles/rails_5.1.gemfile.lock +115 -88
  11. data/gemfiles/{rails_4.2.gemfile → rails_5.2.gemfile} +2 -2
  12. data/gemfiles/rails_5.2.gemfile.lock +209 -0
  13. data/gemfiles/{rails_4.0.gemfile → rails_6.0.gemfile} +2 -2
  14. data/gemfiles/rails_6.0.gemfile.lock +225 -0
  15. data/gemfiles/{rails_3.2.gemfile → rails_6.1.gemfile} +2 -2
  16. data/gemfiles/rails_6.1.gemfile.lock +233 -0
  17. data/lib/dalliance.rb +83 -22
  18. data/lib/dalliance/engine.rb +1 -1
  19. data/lib/dalliance/progress_meter.rb +5 -5
  20. data/lib/dalliance/version.rb +2 -2
  21. data/lib/dalliance/workers/delayed_job.rb +20 -9
  22. data/lib/dalliance/workers/resque.rb +17 -9
  23. data/spec/dalliance/asynchronous_delayed_job_spec.rb +42 -0
  24. data/spec/dalliance/asynchronous_resque_spec.rb +54 -0
  25. data/spec/dalliance/dalliance_spec.rb +2 -2
  26. data/spec/dalliance/synchronous_spec.rb +56 -1
  27. data/spec/spec_helper.rb +2 -0
  28. data/spec/support/active_record.rb +7 -1
  29. metadata +60 -21
  30. data/gemfiles/rails_3.1.gemfile +0 -12
  31. data/gemfiles/rails_3.1.gemfile.lock +0 -149
  32. data/gemfiles/rails_3.2.gemfile.lock +0 -146
  33. data/gemfiles/rails_4.0.gemfile.lock +0 -134
  34. data/gemfiles/rails_4.1.gemfile +0 -12
  35. data/gemfiles/rails_4.1.gemfile.lock +0 -140
  36. data/gemfiles/rails_4.2.gemfile.lock +0 -168
@@ -35,6 +35,61 @@ RSpec.describe DallianceModel do
35
35
  end
36
36
  end
37
37
 
38
+ context 'reprocess' do
39
+ context 'without having already processed' do
40
+ it 'raises an error' do
41
+ expect { subject.dalliance_background_reprocess }
42
+ .to raise_error(
43
+ StateMachine::InvalidTransition,
44
+ /^Cannot transition dalliance_status via :reprocess_dalliance from :pending.*/
45
+ )
46
+ end
47
+ end
48
+
49
+ context 'when the model has already processed' do
50
+ before do
51
+ DallianceModel.dalliance_options[:dalliance_method] = :dalliance_success_method
52
+ subject.dalliance_background_process
53
+ subject.reload
54
+ end
55
+
56
+ it 'calls the dalliance_reprocess method' do
57
+ expect { subject.dalliance_background_reprocess }
58
+ .to change(subject, :reprocessed_count)
59
+ .from(0)
60
+ .to(1)
61
+ end
62
+
63
+ it 'can call the dalliance_reprocess method many times in succession' do
64
+ expect { 10.times { subject.dalliance_background_reprocess } }
65
+ .to change(subject, :reprocessed_count)
66
+ .from(0)
67
+ .to(10)
68
+ end
69
+
70
+ it 'sets the dalliance_status to completed' do
71
+ expect { subject.dalliance_background_reprocess }
72
+ .not_to change { subject.reload.dalliance_status }
73
+ .from('completed')
74
+ end
75
+
76
+ it 'sets the dalliance_progress to 100' do
77
+ expect { subject.dalliance_background_reprocess }
78
+ .not_to change { subject.reload.dalliance_progress }
79
+ .from(100)
80
+ end
81
+
82
+ it 'increases the total processing time counter' do
83
+ original_duration = subject.dalliance_duration
84
+ subject.dalliance_background_reprocess
85
+ Delayed::Worker.new(:queues => [:dalliance]).work_off
86
+ subject.reload
87
+
88
+ expect(subject.dalliance_duration).to be_between(original_duration, Float::INFINITY)
89
+ end
90
+ end
91
+ end
92
+
38
93
  context "raise error" do
39
94
  before(:all) do
40
95
  DallianceModel.dalliance_options[:dalliance_method] = :dalliance_error_method
@@ -121,7 +176,7 @@ RSpec.describe DallianceModel do
121
176
  end
122
177
  end
123
178
 
124
- context "destroy" do
179
+ context "destroy" do
125
180
  it "should return false when pending?" do
126
181
  subject.update_column(:dalliance_status, 'pending')
127
182
  expect(subject.destroy).to be_falsey
data/spec/spec_helper.rb CHANGED
@@ -4,10 +4,12 @@ require 'bundler/setup'
4
4
  #Automatically included in a rails app...
5
5
  require 'active_support'
6
6
 
7
+ # rubocop:disable Lint/SuppressedException
7
8
  begin
8
9
  require 'active_job'
9
10
  rescue LoadError
10
11
  end
12
+ # rubocop:enable Lint/SuppressedException
11
13
 
12
14
  require 'state_machine'
13
15
  require 'byebug'
@@ -35,9 +35,10 @@ ActiveRecord::Schema.define do
35
35
  create_table :dalliance_models, :force => true do |t|
36
36
  t.text :dalliance_error_hash
37
37
  t.string :dalliance_status, :string, :null => false, :default => 'pending'
38
- t.integer :dalliance_duration
38
+ t.decimal :dalliance_duration
39
39
 
40
40
  t.boolean :successful, :default => false
41
+ t.integer :reprocessed_count, default: 0
41
42
  end
42
43
  end
43
44
 
@@ -47,12 +48,17 @@ class DallianceModel < ActiveRecord::Base
47
48
  include Dalliance::Glue
48
49
 
49
50
  dalliance :dalliance_success_method,
51
+ reprocess_method: :dalliance_reprocess_method,
50
52
  :logger => nil
51
53
 
52
54
  def dalliance_success_method
53
55
  update_attribute(:successful, true)
54
56
  end
55
57
 
58
+ def dalliance_reprocess_method
59
+ update_attribute(:reprocessed_count, self.reprocessed_count + 1)
60
+ end
61
+
56
62
  def dalliance_error_method
57
63
  raise RuntimeError
58
64
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dalliance
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Sullivan
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-23 00:00:00.000000000 Z
11
+ date: 2021-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -16,20 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '3.2'
19
+ version: '5.0'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '5.2'
22
+ version: '6.2'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- version: '3.2'
29
+ version: '5.0'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '5.2'
32
+ version: '6.2'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: state_machine
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -114,6 +114,48 @@ dependencies:
114
114
  - - ">="
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0'
117
+ - !ruby/object:Gem::Dependency
118
+ name: bundler-audit
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ - !ruby/object:Gem::Dependency
132
+ name: rubocop
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: '0.78'
138
+ type: :development
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - "~>"
143
+ - !ruby/object:Gem::Version
144
+ version: '0.78'
145
+ - !ruby/object:Gem::Dependency
146
+ name: rspec_junit_formatter
147
+ requirement: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - ">="
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ type: :development
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ">="
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
117
159
  description: " Background processing for ActiveRecord using a 'delayable' worker and
118
160
  a state_machine "
119
161
  email:
@@ -122,6 +164,7 @@ executables: []
122
164
  extensions: []
123
165
  extra_rdoc_files: []
124
166
  files:
167
+ - ".circleci/config.yml"
125
168
  - ".gitignore"
126
169
  - ".rspec"
127
170
  - Appraisals
@@ -131,20 +174,16 @@ files:
131
174
  - Rakefile
132
175
  - config/locales/en.yml
133
176
  - dalliance.gemspec
134
- - gemfiles/rails_3.1.gemfile
135
- - gemfiles/rails_3.1.gemfile.lock
136
- - gemfiles/rails_3.2.gemfile
137
- - gemfiles/rails_3.2.gemfile.lock
138
- - gemfiles/rails_4.0.gemfile
139
- - gemfiles/rails_4.0.gemfile.lock
140
- - gemfiles/rails_4.1.gemfile
141
- - gemfiles/rails_4.1.gemfile.lock
142
- - gemfiles/rails_4.2.gemfile
143
- - gemfiles/rails_4.2.gemfile.lock
144
177
  - gemfiles/rails_5.0.gemfile
145
178
  - gemfiles/rails_5.0.gemfile.lock
146
179
  - gemfiles/rails_5.1.gemfile
147
180
  - gemfiles/rails_5.1.gemfile.lock
181
+ - gemfiles/rails_5.2.gemfile
182
+ - gemfiles/rails_5.2.gemfile.lock
183
+ - gemfiles/rails_6.0.gemfile
184
+ - gemfiles/rails_6.0.gemfile.lock
185
+ - gemfiles/rails_6.1.gemfile
186
+ - gemfiles/rails_6.1.gemfile.lock
148
187
  - lib/dalliance.rb
149
188
  - lib/dalliance/engine.rb
150
189
  - lib/dalliance/progress_meter.rb
@@ -167,7 +206,7 @@ files:
167
206
  homepage: https://github.com/annkissam/dalliance
168
207
  licenses: []
169
208
  metadata: {}
170
- post_install_message:
209
+ post_install_message:
171
210
  rdoc_options: []
172
211
  require_paths:
173
212
  - lib
@@ -182,9 +221,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
221
  - !ruby/object:Gem::Version
183
222
  version: '0'
184
223
  requirements: []
185
- rubyforge_project: dalliance
186
- rubygems_version: 2.6.14
187
- signing_key:
224
+ rubyforge_project:
225
+ rubygems_version: 2.7.6
226
+ signing_key:
188
227
  specification_version: 4
189
228
  summary: Wrapper for an ActiveRecord model with a single ascynhronous method
190
229
  test_files:
@@ -1,12 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "http://rubygems.org"
4
-
5
- gem "appraisal"
6
- gem "rails", "~> 3.1.0"
7
-
8
- group :development, :test do
9
- gem "byebug"
10
- end
11
-
12
- gemspec :path => "../"
@@ -1,149 +0,0 @@
1
- PATH
2
- remote: ../
3
- specs:
4
- dalliance (0.3.3)
5
- activerecord (>= 3.1, < 5.0)
6
- activesupport (>= 3.1, < 5.0)
7
- state_machine
8
-
9
- GEM
10
- remote: http://rubygems.org/
11
- specs:
12
- actionmailer (3.1.12)
13
- actionpack (= 3.1.12)
14
- mail (~> 2.4.4)
15
- actionpack (3.1.12)
16
- activemodel (= 3.1.12)
17
- activesupport (= 3.1.12)
18
- builder (~> 3.0.0)
19
- erubis (~> 2.7.0)
20
- i18n (~> 0.6)
21
- rack (~> 1.3.6)
22
- rack-cache (~> 1.2)
23
- rack-mount (~> 0.8.2)
24
- rack-test (~> 0.6.1)
25
- sprockets (~> 2.0.4)
26
- activemodel (3.1.12)
27
- activesupport (= 3.1.12)
28
- builder (~> 3.0.0)
29
- i18n (~> 0.6)
30
- activerecord (3.1.12)
31
- activemodel (= 3.1.12)
32
- activesupport (= 3.1.12)
33
- arel (~> 2.2.3)
34
- tzinfo (~> 0.3.29)
35
- activeresource (3.1.12)
36
- activemodel (= 3.1.12)
37
- activesupport (= 3.1.12)
38
- activesupport (3.1.12)
39
- multi_json (~> 1.0)
40
- appraisal (1.0.2)
41
- bundler
42
- rake
43
- thor (>= 0.14.0)
44
- arel (2.2.3)
45
- builder (3.0.4)
46
- byebug (9.0.5)
47
- delayed_job (4.0.6)
48
- activesupport (>= 3.0, < 5.0)
49
- delayed_job_active_record (4.0.3)
50
- activerecord (>= 3.0, < 5.0)
51
- delayed_job (>= 3.0, < 4.1)
52
- diff-lcs (1.2.5)
53
- erubis (2.7.0)
54
- hike (1.2.3)
55
- i18n (0.7.0)
56
- json (1.8.2)
57
- mail (2.4.4)
58
- i18n (>= 0.4.0)
59
- mime-types (~> 1.16)
60
- treetop (~> 1.4.8)
61
- mime-types (1.25.1)
62
- mono_logger (1.1.0)
63
- multi_json (1.10.1)
64
- polyglot (0.3.5)
65
- rack (1.3.10)
66
- rack-cache (1.2)
67
- rack (>= 0.4)
68
- rack-mount (0.8.3)
69
- rack (>= 1.0.0)
70
- rack-protection (1.5.3)
71
- rack
72
- rack-ssl (1.3.4)
73
- rack
74
- rack-test (0.6.3)
75
- rack (>= 1.0)
76
- rails (3.1.12)
77
- actionmailer (= 3.1.12)
78
- actionpack (= 3.1.12)
79
- activerecord (= 3.1.12)
80
- activeresource (= 3.1.12)
81
- activesupport (= 3.1.12)
82
- bundler (~> 1.0)
83
- railties (= 3.1.12)
84
- railties (3.1.12)
85
- actionpack (= 3.1.12)
86
- activesupport (= 3.1.12)
87
- rack-ssl (~> 1.3.2)
88
- rake (>= 0.8.7)
89
- rdoc (~> 3.4)
90
- thor (~> 0.14.6)
91
- rake (10.4.2)
92
- rdoc (3.12.2)
93
- json (~> 1.4)
94
- redis (3.2.0)
95
- redis-namespace (1.5.1)
96
- redis (~> 3.0, >= 3.0.4)
97
- resque (1.25.2)
98
- mono_logger (~> 1.0)
99
- multi_json (~> 1.0)
100
- redis-namespace (~> 1.3)
101
- sinatra (>= 0.9.2)
102
- vegas (~> 0.1.2)
103
- rspec (3.1.0)
104
- rspec-core (~> 3.1.0)
105
- rspec-expectations (~> 3.1.0)
106
- rspec-mocks (~> 3.1.0)
107
- rspec-core (3.1.7)
108
- rspec-support (~> 3.1.0)
109
- rspec-expectations (3.1.2)
110
- diff-lcs (>= 1.2.0, < 2.0)
111
- rspec-support (~> 3.1.0)
112
- rspec-mocks (3.1.3)
113
- rspec-support (~> 3.1.0)
114
- rspec-support (3.1.2)
115
- sinatra (1.3.3)
116
- rack (~> 1.3, >= 1.3.6)
117
- rack-protection (~> 1.2)
118
- tilt (~> 1.3, >= 1.3.3)
119
- sprockets (2.0.5)
120
- hike (~> 1.2)
121
- rack (~> 1.0)
122
- tilt (~> 1.1, != 1.3.0)
123
- sqlite3 (1.3.10)
124
- state_machine (1.2.0)
125
- thor (0.14.6)
126
- tilt (1.4.1)
127
- treetop (1.4.15)
128
- polyglot
129
- polyglot (>= 0.3.1)
130
- tzinfo (0.3.42)
131
- vegas (0.1.11)
132
- rack (>= 1.0.0)
133
-
134
- PLATFORMS
135
- ruby
136
-
137
- DEPENDENCIES
138
- appraisal
139
- byebug
140
- dalliance!
141
- delayed_job (>= 3.0.0)
142
- delayed_job_active_record
143
- rails (~> 3.1.0)
144
- resque
145
- rspec (>= 3.0.0)
146
- sqlite3
147
-
148
- BUNDLED WITH
149
- 1.13.1
@@ -1,146 +0,0 @@
1
- PATH
2
- remote: ..
3
- specs:
4
- dalliance (0.4.0)
5
- rails (>= 3.2, <= 5.1.4)
6
- state_machine
7
-
8
- GEM
9
- remote: http://rubygems.org/
10
- specs:
11
- actionmailer (3.2.21)
12
- actionpack (= 3.2.21)
13
- mail (~> 2.5.4)
14
- actionpack (3.2.21)
15
- activemodel (= 3.2.21)
16
- activesupport (= 3.2.21)
17
- builder (~> 3.0.0)
18
- erubis (~> 2.7.0)
19
- journey (~> 1.0.4)
20
- rack (~> 1.4.5)
21
- rack-cache (~> 1.2)
22
- rack-test (~> 0.6.1)
23
- sprockets (~> 2.2.1)
24
- activemodel (3.2.21)
25
- activesupport (= 3.2.21)
26
- builder (~> 3.0.0)
27
- activerecord (3.2.21)
28
- activemodel (= 3.2.21)
29
- activesupport (= 3.2.21)
30
- arel (~> 3.0.2)
31
- tzinfo (~> 0.3.29)
32
- activeresource (3.2.21)
33
- activemodel (= 3.2.21)
34
- activesupport (= 3.2.21)
35
- activesupport (3.2.21)
36
- i18n (~> 0.6, >= 0.6.4)
37
- multi_json (~> 1.0)
38
- appraisal (1.0.2)
39
- bundler
40
- rake
41
- thor (>= 0.14.0)
42
- arel (3.0.3)
43
- builder (3.0.4)
44
- byebug (9.0.5)
45
- delayed_job (4.0.6)
46
- activesupport (>= 3.0, < 5.0)
47
- delayed_job_active_record (4.0.3)
48
- activerecord (>= 3.0, < 5.0)
49
- delayed_job (>= 3.0, < 4.1)
50
- diff-lcs (1.2.5)
51
- erubis (2.7.0)
52
- hike (1.2.3)
53
- i18n (0.7.0)
54
- journey (1.0.4)
55
- json (1.8.2)
56
- mail (2.5.4)
57
- mime-types (~> 1.16)
58
- treetop (~> 1.4.8)
59
- mime-types (1.25.1)
60
- mono_logger (1.1.0)
61
- multi_json (1.10.1)
62
- polyglot (0.3.5)
63
- rack (1.4.5)
64
- rack-cache (1.2)
65
- rack (>= 0.4)
66
- rack-protection (1.5.3)
67
- rack
68
- rack-ssl (1.3.4)
69
- rack
70
- rack-test (0.6.3)
71
- rack (>= 1.0)
72
- rails (3.2.21)
73
- actionmailer (= 3.2.21)
74
- actionpack (= 3.2.21)
75
- activerecord (= 3.2.21)
76
- activeresource (= 3.2.21)
77
- activesupport (= 3.2.21)
78
- bundler (~> 1.0)
79
- railties (= 3.2.21)
80
- railties (3.2.21)
81
- actionpack (= 3.2.21)
82
- activesupport (= 3.2.21)
83
- rack-ssl (~> 1.3.2)
84
- rake (>= 0.8.7)
85
- rdoc (~> 3.4)
86
- thor (>= 0.14.6, < 2.0)
87
- rake (10.4.2)
88
- rdoc (3.12.2)
89
- json (~> 1.4)
90
- redis (3.2.0)
91
- redis-namespace (1.5.1)
92
- redis (~> 3.0, >= 3.0.4)
93
- resque (1.25.2)
94
- mono_logger (~> 1.0)
95
- multi_json (~> 1.0)
96
- redis-namespace (~> 1.3)
97
- sinatra (>= 0.9.2)
98
- vegas (~> 0.1.2)
99
- rspec (3.1.0)
100
- rspec-core (~> 3.1.0)
101
- rspec-expectations (~> 3.1.0)
102
- rspec-mocks (~> 3.1.0)
103
- rspec-core (3.1.7)
104
- rspec-support (~> 3.1.0)
105
- rspec-expectations (3.1.2)
106
- diff-lcs (>= 1.2.0, < 2.0)
107
- rspec-support (~> 3.1.0)
108
- rspec-mocks (3.1.3)
109
- rspec-support (~> 3.1.0)
110
- rspec-support (3.1.2)
111
- sinatra (1.4.5)
112
- rack (~> 1.4)
113
- rack-protection (~> 1.4)
114
- tilt (~> 1.3, >= 1.3.4)
115
- sprockets (2.2.3)
116
- hike (~> 1.2)
117
- multi_json (~> 1.0)
118
- rack (~> 1.0)
119
- tilt (~> 1.1, != 1.3.0)
120
- sqlite3 (1.3.10)
121
- state_machine (1.2.0)
122
- thor (0.19.1)
123
- tilt (1.4.1)
124
- treetop (1.4.15)
125
- polyglot
126
- polyglot (>= 0.3.1)
127
- tzinfo (0.3.42)
128
- vegas (0.1.11)
129
- rack (>= 1.0.0)
130
-
131
- PLATFORMS
132
- ruby
133
-
134
- DEPENDENCIES
135
- appraisal
136
- byebug
137
- dalliance!
138
- delayed_job (>= 3.0.0)
139
- delayed_job_active_record
140
- rails (~> 3.2.0)
141
- resque
142
- rspec (>= 3.0.0)
143
- sqlite3
144
-
145
- BUNDLED WITH
146
- 1.16.0