statesman 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1bb8c427725b16ac0220c6084dedb633125bacbe
4
- data.tar.gz: 69d38a1bb9c59c624c6f2182ec17516cefec51e7
3
+ metadata.gz: 24961b58213c1edf11c804f50ef70a0eb690d0b8
4
+ data.tar.gz: 9817e2fb565978efbeb6f0a90c01f01b8541548a
5
5
  SHA512:
6
- metadata.gz: 3a11a93626877eea776f71a075a868ab33add945898be2affe7c0cb47fb9a461a16bd3d5d9a831b0b9b45a121942bd455c5461dbf0e7187e3735090d4f130ea8
7
- data.tar.gz: f748a6ca2dabfdc3390cbe4dac0def1a04874d93967ac40876a1680b2616f6136c341b7a1c0d10c9b2099271e97d60725c4e263e6a9f4eaefa41194134829592
6
+ metadata.gz: 0f120a2a604f7e8cdad2927790d59eeb81dbd0459107601fe76f871bbf201dba53f5c5b1c4c15e90472a5a32d9ed3cd9aaed88f93e6d6cb1576bfb4cae594c0e
7
+ data.tar.gz: e387129df4c7ac6acb87bf5c7885b16548be3367bcf58f3480d702216c745ac997407548c654eb82eb2ed761cff212711966dd882daafb688638a74737003de9
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## v1.3.1 2 July 2015
2
+
3
+ - Fix `in_state` queries with a custom `transition_name` (patch by [0tsuki](https://github.com/0tsuki))
4
+ - Fix `backfill_most_recent` rake tast for databases that support partial indexes (patch by [greysteil](https://github.com/greysteil))
5
+
1
6
  ## v1.3.0 20 June 2015
2
7
 
3
8
  - Rename `last_transition` alias in `ActiveRecordQueries` to `most_recent_#{model_name}`, to allow merging of two such queries (patch by [@isaacseymour](https://github.com/isaacseymour))
@@ -1,8 +1,8 @@
1
1
  class <%= klass %> < ActiveRecord::Base
2
2
  include Statesman::Adapters::ActiveRecordTransition
3
3
 
4
- <% unless rails_4? %>
4
+ <% unless rails_4? %>
5
5
  attr_accessible :to_state, :metadata, :sort_key
6
- <% end %>
6
+ <% end %>
7
7
  belongs_to :<%= parent_name %><%= class_name_option %>, inverse_of: :<%= table_name %>
8
8
  end
@@ -127,10 +127,10 @@ module Statesman
127
127
  # it has good data
128
128
  def use_most_recent_column?
129
129
  ::ActiveRecord::Base.connection.index_exists?(
130
- transition_name,
130
+ transition_class.table_name,
131
131
  [model_foreign_key, :most_recent],
132
132
  unique: true,
133
- name: "index_#{transition_name}_parent_most_recent"
133
+ name: "index_#{transition_class.table_name}_parent_most_recent"
134
134
  )
135
135
  end
136
136
  end
@@ -1,3 +1,3 @@
1
1
  module Statesman
2
- VERSION = "1.3.0"
2
+ VERSION = "1.3.1"
3
3
  end
@@ -15,7 +15,7 @@ namespace :statesman do
15
15
 
16
16
  parent_class.find_in_batches(batch_size: batch_size) do |models|
17
17
  ActiveRecord::Base.transaction do
18
- if transition_class.columns_hash['most_recent'].null == false
18
+ if Statesman::Adapters::ActiveRecord.database_supports_partial_indexes?
19
19
  # Set all transitions' most_recent to FALSE
20
20
  transition_class.where(parent_fk => models.map(&:id)).
21
21
  update_all(most_recent: false)
@@ -68,7 +68,7 @@ describe Statesman::Adapters::ActiveRecordQueries, active_record: true do
68
68
 
69
69
  it { is_expected.to include model }
70
70
  it { is_expected.not_to include other_model }
71
- its(:to_sql) { is_expected.to include('most_recent') }
71
+ its(:to_sql) { is_expected.to include('.most_recent ') }
72
72
  end
73
73
 
74
74
  context "given multiple states" do
@@ -108,7 +108,7 @@ describe Statesman::Adapters::ActiveRecordQueries, active_record: true do
108
108
  subject { MyActiveRecordModel.not_in_state(:failed) }
109
109
  it { is_expected.to include model }
110
110
  it { is_expected.not_to include other_model }
111
- its(:to_sql) { is_expected.to include('most_recent') }
111
+ its(:to_sql) { is_expected.to include('.most_recent ') }
112
112
  end
113
113
 
114
114
  context "given multiple states" do
@@ -137,6 +137,7 @@ describe Statesman::Adapters::ActiveRecordQueries, active_record: true do
137
137
  subject { MyActiveRecordModel.in_state(:succeeded) }
138
138
 
139
139
  it { is_expected.to include model }
140
+ its(:to_sql) { is_expected.not_to include('.most_recent ') }
140
141
  end
141
142
 
142
143
  context "given multiple states" do
@@ -166,6 +167,7 @@ describe Statesman::Adapters::ActiveRecordQueries, active_record: true do
166
167
  subject { MyActiveRecordModel.not_in_state(:failed) }
167
168
  it { is_expected.to include model }
168
169
  it { is_expected.not_to include other_model }
170
+ its(:to_sql) { is_expected.not_to include('.most_recent ') }
169
171
  end
170
172
 
171
173
  context "given multiple states" do
@@ -185,4 +187,33 @@ describe Statesman::Adapters::ActiveRecordQueries, active_record: true do
185
187
  end
186
188
  end
187
189
  end
190
+
191
+ context "with a transition name" do
192
+ before do
193
+ MyActiveRecordModel.send(:has_many,
194
+ :custom_name,
195
+ class_name: 'MyActiveRecordModelTransition')
196
+ MyActiveRecordModel.class_eval do
197
+ def self.transition_name
198
+ :custom_name
199
+ end
200
+ end
201
+ end
202
+
203
+ context "with a most_recent column" do
204
+ describe ".in_state" do
205
+ subject(:query) { MyActiveRecordModel.in_state(:succeeded) }
206
+ specify { expect { query }.to_not raise_error }
207
+ end
208
+ end
209
+
210
+ context "without a most_recent column" do
211
+ before { drop_most_recent_column }
212
+
213
+ describe ".in_state" do
214
+ subject(:query) { MyActiveRecordModel.in_state(:succeeded) }
215
+ specify { expect { query }.to_not raise_error }
216
+ end
217
+ end
218
+ end
188
219
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: statesman
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harry Marr
@@ -9,202 +9,202 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-06-20 00:00:00.000000000 Z
12
+ date: 2015-07-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - "~>"
18
+ - - ~>
19
19
  - !ruby/object:Gem::Version
20
20
  version: '1.3'
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - "~>"
25
+ - - ~>
26
26
  - !ruby/object:Gem::Version
27
27
  version: '1.3'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rake
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ">="
32
+ - - '>='
33
33
  - !ruby/object:Gem::Version
34
34
  version: '0'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - ">="
39
+ - - '>='
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rspec
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - "~>"
46
+ - - ~>
47
47
  - !ruby/object:Gem::Version
48
48
  version: '3.1'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - "~>"
53
+ - - ~>
54
54
  - !ruby/object:Gem::Version
55
55
  version: '3.1'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: rspec-rails
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - "~>"
60
+ - - ~>
61
61
  - !ruby/object:Gem::Version
62
62
  version: '3.1'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - "~>"
67
+ - - ~>
68
68
  - !ruby/object:Gem::Version
69
69
  version: '3.1'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rspec-its
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - "~>"
74
+ - - ~>
75
75
  - !ruby/object:Gem::Version
76
76
  version: '1.1'
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - "~>"
81
+ - - ~>
82
82
  - !ruby/object:Gem::Version
83
83
  version: '1.1'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: guard-rspec
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - "~>"
88
+ - - ~>
89
89
  - !ruby/object:Gem::Version
90
90
  version: '4.3'
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - "~>"
95
+ - - ~>
96
96
  - !ruby/object:Gem::Version
97
97
  version: '4.3'
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: rubocop
100
100
  requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
- - - "~>"
102
+ - - ~>
103
103
  - !ruby/object:Gem::Version
104
104
  version: 0.30.0
105
105
  type: :development
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
- - - "~>"
109
+ - - ~>
110
110
  - !ruby/object:Gem::Version
111
111
  version: 0.30.0
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: guard-rubocop
114
114
  requirement: !ruby/object:Gem::Requirement
115
115
  requirements:
116
- - - "~>"
116
+ - - ~>
117
117
  - !ruby/object:Gem::Version
118
118
  version: '1.2'
119
119
  type: :development
120
120
  prerelease: false
121
121
  version_requirements: !ruby/object:Gem::Requirement
122
122
  requirements:
123
- - - "~>"
123
+ - - ~>
124
124
  - !ruby/object:Gem::Version
125
125
  version: '1.2'
126
126
  - !ruby/object:Gem::Dependency
127
127
  name: sqlite3
128
128
  requirement: !ruby/object:Gem::Requirement
129
129
  requirements:
130
- - - "~>"
130
+ - - ~>
131
131
  - !ruby/object:Gem::Version
132
132
  version: '1.3'
133
133
  type: :development
134
134
  prerelease: false
135
135
  version_requirements: !ruby/object:Gem::Requirement
136
136
  requirements:
137
- - - "~>"
137
+ - - ~>
138
138
  - !ruby/object:Gem::Version
139
139
  version: '1.3'
140
140
  - !ruby/object:Gem::Dependency
141
141
  name: mongoid
142
142
  requirement: !ruby/object:Gem::Requirement
143
143
  requirements:
144
- - - ">="
144
+ - - '>='
145
145
  - !ruby/object:Gem::Version
146
146
  version: '3.1'
147
147
  type: :development
148
148
  prerelease: false
149
149
  version_requirements: !ruby/object:Gem::Requirement
150
150
  requirements:
151
- - - ">="
151
+ - - '>='
152
152
  - !ruby/object:Gem::Version
153
153
  version: '3.1'
154
154
  - !ruby/object:Gem::Dependency
155
155
  name: rails
156
156
  requirement: !ruby/object:Gem::Requirement
157
157
  requirements:
158
- - - ">="
158
+ - - '>='
159
159
  - !ruby/object:Gem::Version
160
160
  version: '3.2'
161
161
  type: :development
162
162
  prerelease: false
163
163
  version_requirements: !ruby/object:Gem::Requirement
164
164
  requirements:
165
- - - ">="
165
+ - - '>='
166
166
  - !ruby/object:Gem::Version
167
167
  version: '3.2'
168
168
  - !ruby/object:Gem::Dependency
169
169
  name: pg
170
170
  requirement: !ruby/object:Gem::Requirement
171
171
  requirements:
172
- - - "~>"
172
+ - - ~>
173
173
  - !ruby/object:Gem::Version
174
174
  version: '0.18'
175
175
  type: :development
176
176
  prerelease: false
177
177
  version_requirements: !ruby/object:Gem::Requirement
178
178
  requirements:
179
- - - "~>"
179
+ - - ~>
180
180
  - !ruby/object:Gem::Version
181
181
  version: '0.18'
182
182
  - !ruby/object:Gem::Dependency
183
183
  name: mysql2
184
184
  requirement: !ruby/object:Gem::Requirement
185
185
  requirements:
186
- - - "~>"
186
+ - - ~>
187
187
  - !ruby/object:Gem::Version
188
188
  version: '0.3'
189
189
  type: :development
190
190
  prerelease: false
191
191
  version_requirements: !ruby/object:Gem::Requirement
192
192
  requirements:
193
- - - "~>"
193
+ - - ~>
194
194
  - !ruby/object:Gem::Version
195
195
  version: '0.3'
196
196
  - !ruby/object:Gem::Dependency
197
197
  name: ammeter
198
198
  requirement: !ruby/object:Gem::Requirement
199
199
  requirements:
200
- - - "~>"
200
+ - - ~>
201
201
  - !ruby/object:Gem::Version
202
202
  version: '1.1'
203
203
  type: :development
204
204
  prerelease: false
205
205
  version_requirements: !ruby/object:Gem::Requirement
206
206
  requirements:
207
- - - "~>"
207
+ - - ~>
208
208
  - !ruby/object:Gem::Version
209
209
  version: '1.1'
210
210
  description: A statesmanlike state machine library
@@ -214,9 +214,9 @@ executables: []
214
214
  extensions: []
215
215
  extra_rdoc_files: []
216
216
  files:
217
- - ".gitignore"
218
- - ".rubocop.yml"
219
- - ".travis.yml"
217
+ - .gitignore
218
+ - .rubocop.yml
219
+ - .travis.yml
220
220
  - CHANGELOG.md
221
221
  - CONTRIBUTING.md
222
222
  - Gemfile
@@ -288,17 +288,17 @@ require_paths:
288
288
  - lib
289
289
  required_ruby_version: !ruby/object:Gem::Requirement
290
290
  requirements:
291
- - - ">="
291
+ - - '>='
292
292
  - !ruby/object:Gem::Version
293
293
  version: '0'
294
294
  required_rubygems_version: !ruby/object:Gem::Requirement
295
295
  requirements:
296
- - - ">="
296
+ - - '>='
297
297
  - !ruby/object:Gem::Version
298
298
  version: '0'
299
299
  requirements: []
300
300
  rubyforge_project:
301
- rubygems_version: 2.4.1
301
+ rubygems_version: 2.2.2
302
302
  signing_key:
303
303
  specification_version: 4
304
304
  summary: A statesmanlike state machine library
@@ -326,4 +326,3 @@ test_files:
326
326
  - spec/support/active_record.rb
327
327
  - spec/support/generators_shared_examples.rb
328
328
  - spec/support/mongoid.rb
329
- has_rdoc: