statesman 7.4.0 → 7.4.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
  SHA256:
3
- metadata.gz: f0dbcc9fe3c29e715be585f2ddae96bdea9b80ca104daf00ee3378feab681b8e
4
- data.tar.gz: c5824ece991650b8e6e979a9899dbdabc38b18209a79260f2aa9e9f4fda67da2
3
+ metadata.gz: 9dc585aeecc837bf65850c562c9f41524959bd07c5f7f889284f534c260911c3
4
+ data.tar.gz: 807ae19092dcce330131916b825964e5f62ff13f8c4bde2e2140dee9d1f9983d
5
5
  SHA512:
6
- metadata.gz: 98fe2966e48e912b33f1c6d842aa6090782dd32be726532d8178377ffb0f1a551ee3d83eee291de0723c756eb0b1bda65dae73d695a47f8b6bd38106b127615f
7
- data.tar.gz: 6be77a7114e2c3d59e76cfa71de583213ead8a171c5039941698c1e4b0b28b68500acba91d498fb488d33d0e31b3274fa5e373ce81a55f9f70e8e229132de1cf
6
+ metadata.gz: 2688beb079f3b1993bd19b4460834a18a4ca1d5eac9733003c7c5f08c1fd2deb19aeb46103a8f799e89c346ac0704368119ff180ed907928c74587b6a6623ea0
7
+ data.tar.gz: c58db63a374f2474ccc73f0064d9dc089d8e52967b047ef77333fdae9b57eb1798cf428a0e6ec162788eaec99e5758d1bd26118c43944f5edda90261dbcb6845
@@ -67,6 +67,10 @@ module Statesman
67
67
  end
68
68
  end
69
69
 
70
+ def reset
71
+ @last_transition = nil
72
+ end
73
+
70
74
  private
71
75
 
72
76
  # rubocop:disable Metrics/MethodLength
@@ -37,6 +37,10 @@ module Statesman
37
37
  @history
38
38
  end
39
39
 
40
+ def reset
41
+ @history = []
42
+ end
43
+
40
44
  private
41
45
 
42
46
  def next_sort_key
@@ -257,6 +257,10 @@ module Statesman
257
257
  false
258
258
  end
259
259
 
260
+ def reset
261
+ @storage_adapter.reset
262
+ end
263
+
260
264
  private
261
265
 
262
266
  def adapter_class(transition_class)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Statesman
4
- VERSION = "7.4.0"
4
+ VERSION = "7.4.1"
5
5
  end
@@ -355,6 +355,19 @@ describe Statesman::Adapters::ActiveRecord, active_record: true do
355
355
  end
356
356
  end
357
357
 
358
+ it "resets last with #reload" do
359
+ model.save!
360
+ ActiveRecord::Base.transaction do
361
+ model.state_machine.transition_to!(:succeeded)
362
+ # force to cache value in last_transition instance variable
363
+ expect(model.state_machine.current_state).to eq("succeeded")
364
+ raise ActiveRecord::Rollback
365
+ end
366
+ expect(model.state_machine.current_state).to eq("succeeded")
367
+ model.reload
368
+ expect(model.state_machine.current_state).to eq("initial")
369
+ end
370
+
358
371
  context "with a namespaced model" do
359
372
  before do
360
373
  CreateNamespacedARModelMigration.migrate(:up)
@@ -33,6 +33,11 @@ class MyActiveRecordModel < ActiveRecord::Base
33
33
  def metadata
34
34
  super || {}
35
35
  end
36
+
37
+ def reload(*)
38
+ state_machine.reset
39
+ super
40
+ end
36
41
  end
37
42
 
38
43
  class MyActiveRecordModelTransition < ActiveRecord::Base
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: 7.4.0
4
+ version: 7.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - GoCardless
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-26 00:00:00.000000000 Z
11
+ date: 2020-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ammeter
@@ -303,7 +303,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
303
303
  - !ruby/object:Gem::Version
304
304
  version: '0'
305
305
  requirements: []
306
- rubygems_version: 3.1.1
306
+ rubygems_version: 3.2.0.rc.1
307
307
  signing_key:
308
308
  specification_version: 4
309
309
  summary: A statesman-like state machine library