state_machines-activerecord 0.4.1 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +8 -37
- data/Appraisals +14 -12
- data/Gemfile +1 -1
- data/LICENSE.txt +1 -1
- data/README.md +38 -6
- data/gemfiles/active_record_5.1.gemfile +1 -1
- data/gemfiles/active_record_5.2.gemfile +14 -0
- data/gemfiles/active_record_6.0.gemfile +14 -0
- data/gemfiles/active_record_6.1.gemfile +14 -0
- data/gemfiles/active_record_edge.gemfile +6 -6
- data/lib/state_machines-activerecord.rb +5 -0
- data/lib/state_machines/integrations/active_record.rb +25 -15
- data/lib/state_machines/integrations/active_record/version.rb +1 -1
- data/state_machines-activerecord.gemspec +4 -3
- data/test/integration_test.rb +0 -4
- data/test/machine_with_dirty_attribute_and_custom_attributes_during_loopback_test.rb +1 -1
- data/test/machine_with_dirty_attribute_and_state_events_test.rb +1 -1
- data/test/machine_with_dirty_attributes_during_loopback_test.rb +1 -1
- data/test/machine_with_event_attributes_on_save_test.rb +2 -2
- data/test/machine_with_initialized_state_test.rb +6 -0
- data/test/machine_with_same_integer_column_default_test.rb +30 -0
- data/test/machine_with_scopes_and_owner_subclass_test.rb +1 -1
- data/test/machine_with_scopes_test.rb +3 -3
- data/test/machine_with_static_initial_state_test.rb +2 -2
- metadata +18 -23
- data/gemfiles/active_record_4.1.gemfile +0 -13
- data/gemfiles/active_record_4.2.gemfile +0 -13
- data/gemfiles/active_record_5.0.gemfile +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d4d6c3db18b13bbece06c33f047109e49d17eb1b97e8d26d8e001ed02a554b7a
|
4
|
+
data.tar.gz: ebd085709c837eb3c76994e23780b884136a338f92b63eb77c8c64620bd1980e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: febb1df5b304114be86875716fb620b7c1b7fe1d0d44bea3c52c92451345e2cf2fb57e11cbd87d9b277079a52ebb9f82734d4174ea6722e8c6d933d274f88f6d
|
7
|
+
data.tar.gz: 3ee22472203164647a9d65ef4a5df8edfeda3874144b57281b9dce79ae210006f171bc02fdcdd24d44afd08ed4b9dff409b61d443a61052a1baeee27d8f3ed16
|
data/.travis.yml
CHANGED
@@ -1,48 +1,19 @@
|
|
1
1
|
language: ruby
|
2
|
-
sudo: false
|
3
2
|
cache: bundler
|
4
3
|
|
5
4
|
rvm:
|
6
|
-
- 2.
|
7
|
-
- 2.
|
8
|
-
- 2.
|
9
|
-
- 2.4.1
|
5
|
+
- 2.5.8
|
6
|
+
- 2.6.6
|
7
|
+
- 2.7.2
|
10
8
|
- jruby
|
11
|
-
- rbx-2
|
12
9
|
|
13
10
|
gemfile:
|
14
|
-
- gemfiles/
|
15
|
-
- gemfiles/
|
11
|
+
- gemfiles/active_record_5.1.gemfile
|
12
|
+
- gemfiles/active_record_5.2.gemfile
|
13
|
+
- gemfiles/active_record_6.0.gemfile
|
14
|
+
- gemfiles/active_record_6.1.gemfile
|
15
|
+
- gemfiles/active_record_edge.gemfile
|
16
16
|
|
17
17
|
matrix:
|
18
|
-
include:
|
19
|
-
- gemfile: gemfiles/active_record_5.0.gemfile
|
20
|
-
rvm: 2.2.7
|
21
|
-
- gemfile: gemfiles/active_record_5.0.gemfile
|
22
|
-
rvm: 2.3.4
|
23
|
-
- gemfile: gemfiles/active_record_5.0.gemfile
|
24
|
-
rvm: 2.4.1
|
25
|
-
- gemfile: gemfiles/active_record_5.1.gemfile
|
26
|
-
rvm: 2.2.7
|
27
|
-
- gemfile: gemfiles/active_record_5.1.gemfile
|
28
|
-
rvm: 2.3.4
|
29
|
-
- gemfile: gemfiles/active_record_5.1.gemfile
|
30
|
-
rvm: 2.4.1
|
31
|
-
- gemfile: gemfiles/active_record_edge.gemfile
|
32
|
-
rvm: 2.2.7
|
33
|
-
- gemfile: gemfiles/active_record_edge.gemfile
|
34
|
-
rvm: 2.3.4
|
35
|
-
- gemfile: gemfiles/active_record_edge.gemfile
|
36
|
-
rvm: 2.4.1
|
37
|
-
exclude:
|
38
|
-
- gemfile: gemfiles/active_record_4.1.gemfile
|
39
|
-
rvm: 2.4.1
|
40
18
|
allow_failures:
|
41
19
|
- rvm: jruby
|
42
|
-
- rvm: rbx-2
|
43
|
-
- gemfile: gemfiles/active_record_edge.gemfile
|
44
|
-
rvm: 2.2.7
|
45
|
-
- gemfile: gemfiles/active_record_edge.gemfile
|
46
|
-
rvm: 2.3.4
|
47
|
-
- gemfile: gemfiles/active_record_edge.gemfile
|
48
|
-
rvm: 2.4.1
|
data/Appraisals
CHANGED
@@ -1,27 +1,29 @@
|
|
1
|
-
appraise "
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
appraise "active_record_5.1" do
|
2
|
+
gem "sqlite3", platforms: [:mri, :rbx]
|
3
|
+
gem "activerecord-jdbcsqlite3-adapter", platform: :jruby
|
4
|
+
gem "activerecord", github: 'rails/rails', branch: '5-1-stable'
|
5
|
+
gem "activemodel", github: 'rails/rails', branch: '5-1-stable'
|
5
6
|
end
|
6
7
|
|
7
|
-
appraise "
|
8
|
+
appraise "active_record_5.2" do
|
8
9
|
gem "sqlite3", platforms: [:mri, :rbx]
|
9
10
|
gem "activerecord-jdbcsqlite3-adapter", platform: :jruby
|
10
|
-
gem "activerecord", github: 'rails/rails', branch: '
|
11
|
+
gem "activerecord", github: 'rails/rails', branch: '5-2-stable'
|
12
|
+
gem "activemodel", github: 'rails/rails', branch: '5-2-stable'
|
11
13
|
end
|
12
14
|
|
13
|
-
appraise
|
15
|
+
appraise 'active_record_6.0' do
|
14
16
|
gem "sqlite3", platforms: [:mri, :rbx]
|
15
17
|
gem "activerecord-jdbcsqlite3-adapter", platform: :jruby
|
16
|
-
gem "activerecord", github: 'rails/rails', branch: '
|
17
|
-
gem "activemodel", github: 'rails/rails', branch: '
|
18
|
+
gem "activerecord", github: 'rails/rails', branch: '6-0-stable'
|
19
|
+
gem "activemodel", github: 'rails/rails', branch: '6-0-stable'
|
18
20
|
end
|
19
21
|
|
20
|
-
appraise
|
22
|
+
appraise 'active_record_6.1' do
|
21
23
|
gem "sqlite3", platforms: [:mri, :rbx]
|
22
24
|
gem "activerecord-jdbcsqlite3-adapter", platform: :jruby
|
23
|
-
gem "activerecord", github: 'rails/rails', branch: '
|
24
|
-
gem "activemodel", github: 'rails/rails', branch: '
|
25
|
+
gem "activerecord", github: 'rails/rails', branch: '6-1-stable'
|
26
|
+
gem "activemodel", github: 'rails/rails', branch: '6-1-stable'
|
25
27
|
end
|
26
28
|
|
27
29
|
appraise "active_record_edge" do
|
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,15 +1,11 @@
|
|
1
|
-
[![Build Status](https://travis-ci.
|
1
|
+
[![Build Status](https://travis-ci.com/state-machines/state_machines-activerecord.svg?branch=master)](https://travis-ci.com/state-machines/state_machines-activerecord)
|
2
2
|
[![Code Climate](https://codeclimate.com/github/state-machines/state_machines-activerecord.svg)](https://codeclimate.com/github/state-machines/state_machines-activerecord)
|
3
3
|
|
4
4
|
# StateMachines Active Record Integration
|
5
5
|
|
6
|
-
The Active Record
|
6
|
+
The Active Record 5.1+ integration adds support for database transactions, automatically
|
7
7
|
saving the record, named scopes, validation errors.
|
8
8
|
|
9
|
-
## Dependencies
|
10
|
-
|
11
|
-
Active Record 4.1+
|
12
|
-
|
13
9
|
## Installation
|
14
10
|
|
15
11
|
Add this line to your application's Gemfile:
|
@@ -26,6 +22,10 @@ Or install it yourself as:
|
|
26
22
|
|
27
23
|
## Usage
|
28
24
|
|
25
|
+
For the complete usage guide, see http://www.rubydoc.info/github/state-machines/state_machines-activerecord/StateMachines/Integrations/ActiveRecord
|
26
|
+
|
27
|
+
### Example
|
28
|
+
|
29
29
|
```ruby
|
30
30
|
class Vehicle < ActiveRecord::Base
|
31
31
|
state_machine :initial => :parked do
|
@@ -64,6 +64,38 @@ Vehicle.with_state(:parked) # also plural #with_states
|
|
64
64
|
Vehicle.without_states(:first_gear, :second_gear) # also singular #without_state
|
65
65
|
```
|
66
66
|
|
67
|
+
### State driven validations
|
68
|
+
|
69
|
+
As mentioned in `StateMachines::Machine#state`, you can define behaviors,
|
70
|
+
like validations, that only execute for certain states. One *important*
|
71
|
+
caveat here is that, due to a constraint in ActiveRecord's validation
|
72
|
+
framework, custom validators will not work as expected when defined to run
|
73
|
+
in multiple states. For example:
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
class Vehicle < ActiveRecord::Base
|
77
|
+
state_machine do
|
78
|
+
state :first_gear, :second_gear do
|
79
|
+
validate :speed_is_legal
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
```
|
84
|
+
|
85
|
+
In this case, the <tt>:speed_is_legal</tt> validation will only get run
|
86
|
+
for the <tt>:second_gear</tt> state. To avoid this, you can define your
|
87
|
+
custom validation like so:
|
88
|
+
|
89
|
+
```ruby
|
90
|
+
class Vehicle < ActiveRecord::Base
|
91
|
+
state_machine do
|
92
|
+
state :first_gear, :second_gear do
|
93
|
+
validate {|vehicle| vehicle.speed_is_legal}
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
```
|
98
|
+
|
67
99
|
## Contributing
|
68
100
|
|
69
101
|
1. Fork it ( https://github.com/state-machines/state_machines-activerecord/fork )
|
@@ -7,7 +7,7 @@ gem "activerecord-jdbcsqlite3-adapter", platform: :jruby
|
|
7
7
|
gem "activerecord", github: "rails/rails", branch: "5-1-stable"
|
8
8
|
gem "activemodel", github: "rails/rails", branch: "5-1-stable"
|
9
9
|
|
10
|
-
platforms :
|
10
|
+
platforms :mri do
|
11
11
|
gem "pry-byebug"
|
12
12
|
end
|
13
13
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "sqlite3", platforms: [:mri, :rbx]
|
6
|
+
gem "activerecord-jdbcsqlite3-adapter", platform: :jruby
|
7
|
+
gem "activerecord", github: "rails/rails", branch: "5-2-stable"
|
8
|
+
gem "activemodel", github: "rails/rails", branch: "5-2-stable"
|
9
|
+
|
10
|
+
platforms :mri do
|
11
|
+
gem "pry-byebug"
|
12
|
+
end
|
13
|
+
|
14
|
+
gemspec path: "../"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "sqlite3", platforms: [:mri, :rbx]
|
6
|
+
gem "activerecord-jdbcsqlite3-adapter", platform: :jruby
|
7
|
+
gem "activerecord", github: "rails/rails", branch: "6-0-stable"
|
8
|
+
gem "activemodel", github: "rails/rails", branch: "6-0-stable"
|
9
|
+
|
10
|
+
platforms :mri do
|
11
|
+
gem "pry-byebug"
|
12
|
+
end
|
13
|
+
|
14
|
+
gemspec path: "../"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "sqlite3", platforms: [:mri, :rbx]
|
6
|
+
gem "activerecord-jdbcsqlite3-adapter", platform: :jruby
|
7
|
+
gem "activerecord", github: "rails/rails", branch: "6-1-stable"
|
8
|
+
gem "activemodel", github: "rails/rails", branch: "6-1-stable"
|
9
|
+
|
10
|
+
platforms :mri do
|
11
|
+
gem "pry-byebug"
|
12
|
+
end
|
13
|
+
|
14
|
+
gemspec path: "../"
|
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
gem "sqlite3", :
|
6
|
-
gem "activerecord-jdbcsqlite3-adapter", :
|
7
|
-
gem "activerecord", :
|
8
|
-
gem "activemodel", :
|
5
|
+
gem "sqlite3", platforms: [:mri, :rbx]
|
6
|
+
gem "activerecord-jdbcsqlite3-adapter", platform: :jruby
|
7
|
+
gem "activerecord", github: "rails/rails", branch: "master"
|
8
|
+
gem "activemodel", github: "rails/rails", branch: "master"
|
9
9
|
|
10
|
-
platforms :
|
10
|
+
platforms :mri do
|
11
11
|
gem "pry-byebug"
|
12
12
|
end
|
13
13
|
|
14
|
-
gemspec :
|
14
|
+
gemspec path: "../"
|
@@ -423,11 +423,7 @@ module StateMachines
|
|
423
423
|
# Classes that inherit from ActiveRecord::Base will automatically use
|
424
424
|
# the ActiveRecord integration.
|
425
425
|
def matching_ancestors
|
426
|
-
|
427
|
-
end
|
428
|
-
|
429
|
-
def locale_path
|
430
|
-
"#{File.dirname(__FILE__)}/active_record/locale.rb"
|
426
|
+
[::ActiveRecord::Base]
|
431
427
|
end
|
432
428
|
end
|
433
429
|
|
@@ -439,10 +435,18 @@ module StateMachines
|
|
439
435
|
end
|
440
436
|
|
441
437
|
# Gets the db default for the machine's attribute
|
442
|
-
|
443
|
-
|
444
|
-
if
|
445
|
-
|
438
|
+
if ::ActiveRecord.gem_version >= Gem::Version.new('4.2.0')
|
439
|
+
def owner_class_attribute_default
|
440
|
+
if owner_class.connected? && owner_class.table_exists?
|
441
|
+
owner_class.column_defaults[attribute.to_s]
|
442
|
+
end
|
443
|
+
end
|
444
|
+
else
|
445
|
+
def owner_class_attribute_default
|
446
|
+
if owner_class.connected? && owner_class.table_exists?
|
447
|
+
if column = owner_class.columns_hash[attribute.to_s]
|
448
|
+
column.default
|
449
|
+
end
|
446
450
|
end
|
447
451
|
end
|
448
452
|
end
|
@@ -450,9 +454,11 @@ module StateMachines
|
|
450
454
|
def define_state_initializer
|
451
455
|
if ::ActiveRecord.gem_version >= Gem::Version.new('5.0.0.alpha')
|
452
456
|
define_helper :instance, <<-end_eval, __FILE__, __LINE__ + 1
|
453
|
-
def initialize(attributes = nil)
|
457
|
+
def initialize(attributes = nil, *)
|
454
458
|
super(attributes) do |*args|
|
455
|
-
|
459
|
+
scoped_attributes = (attributes || {}).merge(self.class.scope_attributes)
|
460
|
+
|
461
|
+
self.class.state_machines.initialize_states(self, {}, scoped_attributes)
|
456
462
|
yield(*args) if block_given?
|
457
463
|
end
|
458
464
|
end
|
@@ -460,8 +466,10 @@ module StateMachines
|
|
460
466
|
elsif ::ActiveRecord.gem_version >= Gem::Version.new('4.2')
|
461
467
|
define_helper :instance, <<-end_eval, __FILE__, __LINE__ + 1
|
462
468
|
def initialize(attributes = nil, options = {})
|
469
|
+
scoped_attributes = (attributes || {}).merge(self.class.scope_attributes)
|
470
|
+
|
463
471
|
super(attributes, options) do |*args|
|
464
|
-
self.class.state_machines.initialize_states(self, {},
|
472
|
+
self.class.state_machines.initialize_states(self, {}, scoped_attributes)
|
465
473
|
yield(*args) if block_given?
|
466
474
|
end
|
467
475
|
end
|
@@ -484,8 +492,10 @@ module StateMachines
|
|
484
492
|
# Initializes dynamic states
|
485
493
|
define_helper :instance, <<-end_eval, __FILE__, __LINE__ + 1
|
486
494
|
def initialize(attributes = nil, options = {})
|
495
|
+
scoped_attributes = (attributes || {}).merge(self.class.scope_attributes)
|
496
|
+
|
487
497
|
super(attributes, options) do |*args|
|
488
|
-
self.class.state_machines.initialize_states(self, {},
|
498
|
+
self.class.state_machines.initialize_states(self, {}, scoped_attributes)
|
489
499
|
yield(*args) if block_given?
|
490
500
|
end
|
491
501
|
end
|
@@ -497,11 +507,11 @@ module StateMachines
|
|
497
507
|
def define_action_hook
|
498
508
|
if action_hook == :save
|
499
509
|
define_helper :instance, <<-end_eval, __FILE__, __LINE__ + 1
|
500
|
-
def save(
|
510
|
+
def save(*, **)
|
501
511
|
self.class.state_machine(#{name.inspect}).send(:around_save, self) { super }
|
502
512
|
end
|
503
513
|
|
504
|
-
def save!(
|
514
|
+
def save!(*, **)
|
505
515
|
result = self.class.state_machine(#{name.inspect}).send(:around_save, self) { super }
|
506
516
|
result || raise(ActiveRecord::RecordInvalid.new(self))
|
507
517
|
end
|
@@ -15,11 +15,12 @@ Gem::Specification.new do |spec|
|
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
17
17
|
spec.test_files = spec.files.grep(/^test\//)
|
18
|
+
spec.required_ruby_version = '>= 2.2.2'
|
18
19
|
spec.require_paths = ['lib']
|
19
20
|
|
20
|
-
spec.add_dependency 'state_machines-activemodel', '>= 0.
|
21
|
-
spec.add_dependency 'activerecord' , '>=
|
22
|
-
spec.add_development_dependency 'rake', '~>
|
21
|
+
spec.add_dependency 'state_machines-activemodel', '>= 0.8.0'
|
22
|
+
spec.add_dependency 'activerecord' , '>= 5.1'
|
23
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
23
24
|
spec.add_development_dependency 'sqlite3', '~> 1.3'
|
24
25
|
spec.add_development_dependency 'appraisal', '>= 1'
|
25
26
|
spec.add_development_dependency 'minitest' , '>= 5.4.0'
|
data/test/integration_test.rb
CHANGED
@@ -22,8 +22,4 @@ class IntegrationTest < BaseTestCase
|
|
22
22
|
def test_should_have_defaults
|
23
23
|
assert_equal({action: :save, use_transactions: true}, StateMachines::Integrations::ActiveRecord.defaults)
|
24
24
|
end
|
25
|
-
|
26
|
-
def test_should_have_a_locale_path
|
27
|
-
assert_not_nil StateMachines::Integrations::ActiveRecord.locale_path
|
28
|
-
end
|
29
25
|
end
|
@@ -212,13 +212,13 @@ class MachineWithEventAttributesOnSaveTest < BaseTestCase
|
|
212
212
|
def test_should_return_nil_on_around_transition_rollback
|
213
213
|
@machine.before_transition { @model.create! }
|
214
214
|
@machine.around_transition { @model.create!; raise ActiveRecord::Rollback }
|
215
|
-
|
215
|
+
assert_nil @record.save
|
216
216
|
assert_equal 0, @model.count
|
217
217
|
end
|
218
218
|
|
219
219
|
def test_should_return_nil_on_before_transition_rollback
|
220
220
|
@machine.before_transition { raise ActiveRecord::Rollback }
|
221
|
-
|
221
|
+
assert_nil @record.save
|
222
222
|
assert_equal 0, @model.count
|
223
223
|
end
|
224
224
|
|
@@ -27,6 +27,12 @@ class MachineWithInitializedStateTest < BaseTestCase
|
|
27
27
|
assert_equal 'idling', record.state
|
28
28
|
end
|
29
29
|
|
30
|
+
def test_should_allow_different_initial_state_when_using_create_with
|
31
|
+
record = @model.create_with(state: 'idling').new
|
32
|
+
|
33
|
+
assert_equal 'idling', record.state
|
34
|
+
end
|
35
|
+
|
30
36
|
def test_should_allow_different_initial_state_when_dynamic
|
31
37
|
@machine.initial_state = lambda { :parked }
|
32
38
|
record = @model.new(:state => 'idling')
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
require 'stringio'
|
3
|
+
|
4
|
+
class MachineWithSameIntegerColumnDefaultTest < BaseTestCase
|
5
|
+
def setup
|
6
|
+
@original_stderr, $stderr = $stderr, StringIO.new
|
7
|
+
|
8
|
+
@model = new_model do
|
9
|
+
connection.add_column table_name, :status, :integer, :default => 1
|
10
|
+
end
|
11
|
+
@machine = StateMachines::Machine.new(@model, :status, :initial => :parked) do
|
12
|
+
state :parked, :value => 1
|
13
|
+
end
|
14
|
+
@record = @model.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_should_use_machine_default
|
18
|
+
assert_equal 1, @record.status
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_should_not_generate_a_warning
|
22
|
+
assert_no_match(/have defined a different default/, $stderr.string)
|
23
|
+
end
|
24
|
+
|
25
|
+
def teardown
|
26
|
+
$stderr = @original_stderr
|
27
|
+
super
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
@@ -20,7 +20,7 @@ class MachineWithScopesAndOwnerSubclassTest < BaseTestCase
|
|
20
20
|
def test_should_only_include_records_without_subclass_states_in_without_scope
|
21
21
|
parked = @subclass.create :state => 'parked'
|
22
22
|
idling = @subclass.create :state => 'idling'
|
23
|
-
|
23
|
+
@subclass.create :state => 'first_gear'
|
24
24
|
|
25
25
|
assert_equal [parked, idling], @subclass.without_states(:first_gear).all
|
26
26
|
end
|
@@ -43,7 +43,7 @@ class MachineWithScopesTest < BaseTestCase
|
|
43
43
|
|
44
44
|
def test_should_only_include_records_without_state_in_singular_without_scope
|
45
45
|
parked = @model.create :state => 'parked'
|
46
|
-
|
46
|
+
@model.create :state => 'idling'
|
47
47
|
|
48
48
|
assert_equal [parked], @model.without_state(:idling).all
|
49
49
|
end
|
@@ -55,13 +55,13 @@ class MachineWithScopesTest < BaseTestCase
|
|
55
55
|
def test_should_only_include_records_without_states_in_plural_without_scope
|
56
56
|
parked = @model.create :state => 'parked'
|
57
57
|
idling = @model.create :state => 'idling'
|
58
|
-
|
58
|
+
@model.create :state => 'first_gear'
|
59
59
|
|
60
60
|
assert_equal [parked, idling], @model.without_states(:first_gear).all
|
61
61
|
end
|
62
62
|
|
63
63
|
def test_should_allow_chaining_scopes
|
64
|
-
|
64
|
+
@model.create :state => 'parked'
|
65
65
|
idling = @model.create :state => 'idling'
|
66
66
|
|
67
67
|
assert_equal [idling], @model.without_state(:parked).with_state(:idling).all
|
@@ -114,7 +114,7 @@ class MachineWithStaticInitialStateTest < BaseTestCase
|
|
114
114
|
MachineWithStaticInitialStateTest.const_set('Owner', owner_model)
|
115
115
|
|
116
116
|
owner = owner_model.create
|
117
|
-
|
117
|
+
@model.create(:state => 'idling', :owner_id => owner.id)
|
118
118
|
assert_equal 'idling', owner.vehicles[0].state
|
119
119
|
end
|
120
120
|
|
@@ -131,7 +131,7 @@ class MachineWithStaticInitialStateTest < BaseTestCase
|
|
131
131
|
MachineWithStaticInitialStateTest.const_set('Owner', owner_model)
|
132
132
|
|
133
133
|
owner = owner_model.create
|
134
|
-
|
134
|
+
@model.create(:state => 'idling', :owner_id => owner.id)
|
135
135
|
assert_equal 'idling', owner.vehicle.state
|
136
136
|
end
|
137
137
|
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: state_machines-activerecord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Abdelkader Boudih
|
8
8
|
- Aaron Pfeifer
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-12-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: state_machines-activemodel
|
@@ -17,48 +17,42 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 0.
|
20
|
+
version: 0.8.0
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 0.
|
27
|
+
version: 0.8.0
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: activerecord
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
35
|
-
- - "<"
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '5.2'
|
34
|
+
version: '5.1'
|
38
35
|
type: :runtime
|
39
36
|
prerelease: false
|
40
37
|
version_requirements: !ruby/object:Gem::Requirement
|
41
38
|
requirements:
|
42
39
|
- - ">="
|
43
40
|
- !ruby/object:Gem::Version
|
44
|
-
version: '
|
45
|
-
- - "<"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '5.2'
|
41
|
+
version: '5.1'
|
48
42
|
- !ruby/object:Gem::Dependency
|
49
43
|
name: rake
|
50
44
|
requirement: !ruby/object:Gem::Requirement
|
51
45
|
requirements:
|
52
46
|
- - "~>"
|
53
47
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
48
|
+
version: '13.0'
|
55
49
|
type: :development
|
56
50
|
prerelease: false
|
57
51
|
version_requirements: !ruby/object:Gem::Requirement
|
58
52
|
requirements:
|
59
53
|
- - "~>"
|
60
54
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
55
|
+
version: '13.0'
|
62
56
|
- !ruby/object:Gem::Dependency
|
63
57
|
name: sqlite3
|
64
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -130,10 +124,10 @@ files:
|
|
130
124
|
- LICENSE.txt
|
131
125
|
- README.md
|
132
126
|
- Rakefile
|
133
|
-
- gemfiles/active_record_4.1.gemfile
|
134
|
-
- gemfiles/active_record_4.2.gemfile
|
135
|
-
- gemfiles/active_record_5.0.gemfile
|
136
127
|
- gemfiles/active_record_5.1.gemfile
|
128
|
+
- gemfiles/active_record_5.2.gemfile
|
129
|
+
- gemfiles/active_record_6.0.gemfile
|
130
|
+
- gemfiles/active_record_6.1.gemfile
|
137
131
|
- gemfiles/active_record_edge.gemfile
|
138
132
|
- lib/state_machines-activerecord.rb
|
139
133
|
- lib/state_machines/integrations/active_record.rb
|
@@ -179,6 +173,7 @@ files:
|
|
179
173
|
- test/machine_with_loopback_test.rb
|
180
174
|
- test/machine_with_non_column_state_attribute_defined_test.rb
|
181
175
|
- test/machine_with_same_column_default_test.rb
|
176
|
+
- test/machine_with_same_integer_column_default_test.rb
|
182
177
|
- test/machine_with_scopes_and_joins_test.rb
|
183
178
|
- test/machine_with_scopes_and_owner_subclass_test.rb
|
184
179
|
- test/machine_with_scopes_test.rb
|
@@ -196,7 +191,7 @@ homepage: https://github.com/state-machines/state_machines-activerecord/
|
|
196
191
|
licenses:
|
197
192
|
- MIT
|
198
193
|
metadata: {}
|
199
|
-
post_install_message:
|
194
|
+
post_install_message:
|
200
195
|
rdoc_options: []
|
201
196
|
require_paths:
|
202
197
|
- lib
|
@@ -204,16 +199,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
204
199
|
requirements:
|
205
200
|
- - ">="
|
206
201
|
- !ruby/object:Gem::Version
|
207
|
-
version:
|
202
|
+
version: 2.2.2
|
208
203
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
209
204
|
requirements:
|
210
205
|
- - ">="
|
211
206
|
- !ruby/object:Gem::Version
|
212
207
|
version: '0'
|
213
208
|
requirements: []
|
214
|
-
|
215
|
-
|
216
|
-
signing_key:
|
209
|
+
rubygems_version: 3.0.3
|
210
|
+
signing_key:
|
217
211
|
specification_version: 4
|
218
212
|
summary: State machines Active Record Integration
|
219
213
|
test_files:
|
@@ -255,6 +249,7 @@ test_files:
|
|
255
249
|
- test/machine_with_loopback_test.rb
|
256
250
|
- test/machine_with_non_column_state_attribute_defined_test.rb
|
257
251
|
- test/machine_with_same_column_default_test.rb
|
252
|
+
- test/machine_with_same_integer_column_default_test.rb
|
258
253
|
- test/machine_with_scopes_and_joins_test.rb
|
259
254
|
- test/machine_with_scopes_and_owner_subclass_test.rb
|
260
255
|
- test/machine_with_scopes_test.rb
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
gem "sqlite3", :platforms => [:mri, :rbx]
|
6
|
-
gem "activerecord-jdbcsqlite3-adapter", :platform => :jruby
|
7
|
-
gem "activerecord", :github => "rails/rails", :branch => "4-1-stable"
|
8
|
-
|
9
|
-
platforms :mri_20, :mri_21 do
|
10
|
-
gem "pry-byebug"
|
11
|
-
end
|
12
|
-
|
13
|
-
gemspec :path => "../"
|
@@ -1,13 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
gem "sqlite3", :platforms => [:mri, :rbx]
|
6
|
-
gem "activerecord-jdbcsqlite3-adapter", :platform => :jruby
|
7
|
-
gem "activerecord", :github => "rails/rails", :branch => "4-2-stable"
|
8
|
-
|
9
|
-
platforms :mri_20, :mri_21 do
|
10
|
-
gem "pry-byebug"
|
11
|
-
end
|
12
|
-
|
13
|
-
gemspec :path => "../"
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
gem "sqlite3", :platforms => [:mri, :rbx]
|
6
|
-
gem "activerecord-jdbcsqlite3-adapter", :platform => :jruby
|
7
|
-
gem "activerecord", :github => "rails/rails", :branch => "5-0-stable"
|
8
|
-
gem "activemodel", :github => "rails/rails", :branch => "5-0-stable"
|
9
|
-
|
10
|
-
platforms :mri_20, :mri_21 do
|
11
|
-
gem "pry-byebug"
|
12
|
-
end
|
13
|
-
|
14
|
-
gemspec :path => "../"
|