statesman 8.0.1 → 8.0.2

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
  SHA256:
3
- metadata.gz: aa4a88371cc60e6698eb820b60096f681fbaedf8dbbbec5991d47db81daf695d
4
- data.tar.gz: b67153a87f62722deb2053ddf661e79e7918fca5339f9a6829a086e30a2abf02
3
+ metadata.gz: 1b67b01e36452d54ed3a46731198cf31b62bc4b96c658f1555c1246a859a369a
4
+ data.tar.gz: d6bedd395500f7a079c8a7a3dda16c48f78b532dbd37bf9242644d1fb6f5186c
5
5
  SHA512:
6
- metadata.gz: ac43c11e5dc1791bac7a00ba8e84b459daad104be9c9b460626c7569e4b9bdf215f0d080b5151ff754ee109640e70d1ca6cec4b958acfeadd974aab6962f16fd
7
- data.tar.gz: 965b0a4020631cb18c39ce6af8870f3e165c87058aaf25f40f217a71d51cf65345818f974569191156a5ed94021c63595cf049c45fa11b62e132b1631e6d3d46
6
+ metadata.gz: 573dd79df9f8bbf958cfca8bd2a2477b10904916d43917fb269b41f154bde0f40e8bda641f5984c56772d1aa918bbfd84f8a14be881917370167ee1f3c4d6324
7
+ data.tar.gz: 9440bfaa20b003060c9dfa152d93c7142cff6ffa6ffc56ae52e966c1f96fdd95bd47d9e411987802bc986c7b6557223ce8696ffe446468735b360ed80d130ca3
data/.circleci/config.yml CHANGED
@@ -86,34 +86,6 @@ jobs:
86
86
  - POSTGRES_DB=statesman_test
87
87
  - POSTGRES_PASSWORD=statesman
88
88
  steps: *steps
89
- build-ruby265-rails-main-mysql:
90
- docker:
91
- - image: circleci/ruby:2.6.5-node
92
- environment:
93
- - RAILS_VERSION=main
94
- - DATABASE_URL=mysql2://root@127.0.0.1/statesman_test
95
- - DATABASE_DEPENDENCY_PORT=3306
96
- - image: circleci/mysql:5.7.18
97
- environment:
98
- - MYSQL_ALLOW_EMPTY_PASSWORD=true
99
- - MYSQL_USER=root
100
- - MYSQL_PASSWORD=
101
- - MYSQL_DATABASE=statesman_test
102
- steps: *steps
103
- build-ruby265-rails-main-postgres:
104
- docker:
105
- - image: circleci/ruby:2.6.5-node
106
- environment:
107
- - RAILS_VERSION=main
108
- - DATABASE_URL=postgres://postgres@localhost/statesman_test
109
- - EXCLUDE_MONGOID=true
110
- - DATABASE_DEPENDENCY_PORT=5432
111
- - image: circleci/postgres:9.6
112
- environment:
113
- - POSTGRES_USER=postgres
114
- - POSTGRES_DB=statesman_test
115
- - POSTGRES_PASSWORD=statesman
116
- steps: *steps
117
89
 
118
90
  build-ruby270-rails-602-mysql:
119
91
  docker:
@@ -179,8 +151,6 @@ workflows:
179
151
  - build-ruby249-rails-524-postgres
180
152
  - build-ruby265-rails-602-mysql
181
153
  - build-ruby265-rails-602-postgres
182
- - build-ruby265-rails-main-mysql
183
- - build-ruby265-rails-main-postgres
184
154
  - build-ruby270-rails-602-mysql
185
155
  - build-ruby270-rails-602-postgres
186
156
  - build-ruby270-rails-main-mysql
data/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## v8.0.2 30th March 2021
2
+
3
+ ### Changed
4
+
5
+ - Fixed a bug where the `history` of a model was left in an incorrect state after a transition
6
+ conflict [#433](https://github.com/gocardless/statesman/pull/433)
7
+
8
+ ## v8.0.1 20th January 2021
9
+
10
+ ### Changed
11
+
12
+ - Fixed `no implicit conversion of nil into String` error when quoting null values
13
+ [#427](https://github.com/gocardless/statesman/pull/427)
14
+
1
15
  ## v8.0.0 6th January 2021
2
16
 
3
17
  ### Added
@@ -24,16 +38,16 @@
24
38
 
25
39
  ### Changed
26
40
 
27
- - Use correct Arel for null [#409](https://github.com/gocardless/statesman/pull/#409)
41
+ - Use correct Arel for null [#409](https://github.com/gocardless/statesman/pull/409)
28
42
 
29
43
  ## v7.2.0, 19th May 2020
30
44
 
31
45
  ### Changed
32
46
 
33
- - Set non-empty password for postgres tests [#398](https://github.com/gocardless/statesman/pull/#398)
34
- - Handle transitions differently for MySQL [#399](https://github.com/gocardless/statesman/pull/#399)
35
- - pg requirement from >= 0.18, <= 1.1 to >= 0.18, <= 1.3 [#400](https://github.com/gocardless/statesman/pull/#400)
36
- - Lazily enable mysql gaplock protection [#402](https://github.com/gocardless/statesman/pull/#402)
47
+ - Set non-empty password for postgres tests [#398](https://github.com/gocardless/statesman/pull/398)
48
+ - Handle transitions differently for MySQL [#399](https://github.com/gocardless/statesman/pull/399)
49
+ - pg requirement from >= 0.18, <= 1.1 to >= 0.18, <= 1.3 [#400](https://github.com/gocardless/statesman/pull/400)
50
+ - Lazily enable mysql gaplock protection [#402](https://github.com/gocardless/statesman/pull/402)
37
51
 
38
52
  ## v7.1.0, 10th Feb 2020
39
53
 
@@ -86,7 +100,7 @@
86
100
  to
87
101
  ```ruby
88
102
  include Statesman::Adapters::ActiveRecordQueries[
89
- initial_state: :inital,
103
+ initial_state: :initial,
90
104
  transition_class: MyTransition
91
105
  ]
92
106
  ```
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- <p align="center"><img src="http://f.cl.ly/items/410n2A0S3l1W0i3i0o2K/statesman.png" alt="Statesman"></p>
1
+ <p align="center"><img src="https://user-images.githubusercontent.com/110275/106792848-96e4ee80-664e-11eb-8fd1-16ff24b41eb2.png" alt="Statesman" width="512"></p>
2
2
 
3
3
  A statesmanlike state machine library.
4
4
 
@@ -42,7 +42,13 @@ module Statesman
42
42
  def create(from, to, metadata = {})
43
43
  create_transition(from.to_s, to.to_s, metadata)
44
44
  rescue ::ActiveRecord::RecordNotUnique => e
45
- raise TransitionConflictError, e.message if transition_conflict_error? e
45
+ if transition_conflict_error? e
46
+ # The history has the invalid transition on the end of it, which means
47
+ # `current_state` would then be incorrect. We force a reload of the history to
48
+ # avoid this.
49
+ transitions_for_parent.reload
50
+ raise TransitionConflictError, e.message
51
+ end
46
52
 
47
53
  raise
48
54
  ensure
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Statesman
4
- VERSION = "8.0.1"
4
+ VERSION = "8.0.2"
5
5
  end
@@ -130,6 +130,31 @@ describe Statesman::Adapters::ActiveRecord, active_record: true do
130
130
  expect { adapter.create(:y, :z) }.
131
131
  to raise_exception(Statesman::TransitionConflictError)
132
132
  end
133
+
134
+ it "does not pollute the state when the transition fails" do
135
+ # this increments the sort_key in the database
136
+ adapter.create(:x, :y)
137
+
138
+ # we then pre-load the transitions for efficiency
139
+ preloaded_model = MyActiveRecordModel.
140
+ includes(:my_active_record_model_transitions).
141
+ find(model.id)
142
+
143
+ adapter2 = described_class.
144
+ new(MyActiveRecordModelTransition, preloaded_model, observer)
145
+
146
+ # Now we generate a race
147
+ adapter.create(:y, :z)
148
+ expect { adapter2.create(:y, :a) }.
149
+ to raise_error(Statesman::TransitionConflictError)
150
+
151
+ # The preloaded adapter should discard the preloaded info
152
+ expect(adapter2.last).to have_attributes(to_state: "z")
153
+ expect(adapter2.history).to contain_exactly(
154
+ have_attributes(to_state: "y"),
155
+ have_attributes(to_state: "z"),
156
+ )
157
+ end
133
158
  end
134
159
 
135
160
  context "when other exceptions occur" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: statesman
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.0.1
4
+ version: 8.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - GoCardless
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-20 00:00:00.000000000 Z
11
+ date: 2021-03-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ammeter