state_machines-activemodel 0.5.0 → 0.8.0

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
- SHA1:
3
- metadata.gz: ed10c396e1ecfa0348f197a8ff88cd14b7c50caa
4
- data.tar.gz: 8f10503a48c265778c185a033f456a849be9d38b
2
+ SHA256:
3
+ metadata.gz: 4451c4d642636e3d81d9bb608b8dd78cfbd01bf7340989959e12791ec2fd76e0
4
+ data.tar.gz: a7c86d2041b2e8deefdc809831802b413f1e0a8f7fec7aa867fcd54685262f9d
5
5
  SHA512:
6
- metadata.gz: 88715204d3416f42cc70aa26ea45fe74fb757154b9e6785f421f29266a4f873898da764ab2604ee572e4599ba427ac9306a8e57e03555c4839cf989dc37ba236
7
- data.tar.gz: 936ae8ef8ef2b30e3af943f7368d11316712ea321ae1cf071c0121188bbad1ab0bed28b4b5b424897dc5af6b245778e13199c2a0b2d7a2da2a5a4767d2157e14
6
+ metadata.gz: 2fff7546bfd98859e0a8c5e5eb6e97909a4b5d42a3ade4440c8c21bb7728d4257093532a7b63e140c8418682d0da410f657d8a78db48c1bd13cd5f90ef59ff90
7
+ data.tar.gz: 12bdad22386d96dc415f2eea856c5ca1329cb1fd7f213613102b9cfc0cfcb7da550d1548f633771491cd92b8a8491b390952ec44fb62db7e4cfa1f7e395366cc
@@ -1,45 +1,21 @@
1
1
  language: ruby
2
- sudo: false
3
2
  cache: bundler
4
3
 
5
4
  rvm:
6
- - 2.1
7
- - 2.2.7
8
- - 2.3.4
9
- - 2.4.1
5
+ - 2.5.8
6
+ - 2.6.6
7
+ - 2.7.2
10
8
  - jruby
11
9
  - rbx-2
12
10
 
13
11
  gemfile:
14
- - gemfiles/active_model_4.1.gemfile
15
- - gemfiles/active_model_4.2.gemfile
12
+ - gemfiles/active_model_5.1.gemfile
13
+ - gemfiles/active_model_5.2.gemfile
14
+ - gemfiles/active_model_6.0.gemfile
15
+ - gemfiles/active_model_6.1.gemfile
16
+ - gemfiles/active_model_edge.gemfile
16
17
 
17
18
  matrix:
18
- include:
19
- - gemfile: gemfiles/active_model_5.0.gemfile
20
- rvm: 2.2.7
21
- - gemfile: gemfiles/active_model_5.0.gemfile
22
- rvm: 2.3.4
23
- - gemfile: gemfiles/active_model_5.0.gemfile
24
- rvm: 2.4.1
25
- - gemfile: gemfiles/active_model_5.1.gemfile
26
- rvm: 2.2.7
27
- - gemfile: gemfiles/active_model_5.1.gemfile
28
- rvm: 2.3.4
29
- - gemfile: gemfiles/active_model_5.1.gemfile
30
- rvm: 2.4.1
31
- - gemfile: gemfiles/active_model_edge.gemfile
32
- rvm: 2.2.7
33
- - gemfile: gemfiles/active_model_edge.gemfile
34
- rvm: 2.3.4
35
- - gemfile: gemfiles/active_model_edge.gemfile
36
- rvm: 2.4.1
37
19
  allow_failures:
38
20
  - rvm: jruby
39
21
  - rvm: rbx-2
40
- - gemfile: gemfiles/active_model_edge.gemfile
41
- rvm: 2.2.7
42
- - gemfile: gemfiles/active_model_edge.gemfile
43
- rvm: 2.3.4
44
- - gemfile: gemfiles/active_model_edge.gemfile
45
- rvm: 2.4.1
data/Appraisals CHANGED
@@ -1,18 +1,18 @@
1
1
  # ActiveModel integrations
2
- appraise 'active_model_4.1' do
3
- gem 'activemodel', github: 'rails/rails', branch: '4-1-stable'
2
+ appraise 'active_model_5.1' do
3
+ gem 'activemodel', github: 'rails/rails', branch: '5-1-stable'
4
4
  end
5
5
 
6
- appraise 'active_model_4.2' do
7
- gem 'activemodel', github: 'rails/rails', branch: '4-2-stable'
6
+ appraise 'active_model_5.2' do
7
+ gem 'activemodel', github: 'rails/rails', branch: '5-2-stable'
8
8
  end
9
9
 
10
- appraise 'active_model_5.0' do
11
- gem 'activemodel', github: 'rails/rails', branch: '5-0-stable'
10
+ appraise 'active_model_6.0' do
11
+ gem 'activemodel', github: 'rails/rails', branch: '6-0-stable'
12
12
  end
13
13
 
14
- appraise 'active_model_5.1' do
15
- gem 'activemodel', github: 'rails/rails', branch: '5-1-stable'
14
+ appraise 'active_model_6.1' do
15
+ gem 'activemodel', github: 'rails/rails', branch: '6-1-stable'
16
16
  end
17
17
 
18
18
  appraise 'active_model_edge' do
@@ -1,5 +1,5 @@
1
1
  Copyright (c) 2006-2012 Aaron Pfeifer
2
- Copyright (c) 2014-2015 Abdelkader Boudih
2
+ Copyright (c) 2014-2021 Abdelkader Boudih
3
3
 
4
4
  MIT License
5
5
 
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
- [![Build Status](https://travis-ci.org/state-machines/state_machines-activemodel.svg?branch=master)](https://travis-ci.org/state-machines/state_machines-activemodel)
2
- [![Code Climate](https://codeclimate.com/github/state-machines/state_machines-activemodel.png)](https://codeclimate.com/github/state-machines/state_machines-activemodel)
1
+ [![Build Status](https://travis-ci.com/state-machines/state_machines-activemodel.svg?branch=master)](https://travis-ci.org/state-machines/state_machines-activemodel)
2
+ [![Code Climate](https://codeclimate.com/github/state-machines/state_machines-activemodel.svg)](https://codeclimate.com/github/state-machines/state_machines-activemodel)
3
3
 
4
4
  # StateMachines ActiveModel Integration
5
5
 
@@ -21,6 +21,10 @@ Or install it yourself as:
21
21
 
22
22
  $ gem install state_machines-activemodel
23
23
 
24
+ ## Dependencies
25
+
26
+ Active Model 5.1+
27
+
24
28
  ## Usage
25
29
 
26
30
  ```ruby
@@ -78,11 +82,6 @@ end
78
82
 
79
83
  ```
80
84
 
81
- Dependencies
82
-
83
- Active Model 4.1+
84
-
85
-
86
85
  ## Contributing
87
86
 
88
87
  1. Fork it ( https://github.com/state-machines/state_machines-activemodel/fork )
@@ -2,10 +2,10 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activemodel", :github => "rails/rails", :branch => "4-1-stable"
5
+ gem "activemodel", github: "rails/rails", branch: "5-2-stable"
6
6
 
7
7
  platforms :mri_20, :mri_21 do
8
8
  gem "pry-byebug"
9
9
  end
10
10
 
11
- gemspec :path => "../"
11
+ gemspec path: "../"
@@ -2,10 +2,10 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activemodel", :github => "rails/rails", :branch => "4-2-stable"
5
+ gem "activemodel", github: "rails/rails", branch: "6-0-stable"
6
6
 
7
7
  platforms :mri_20, :mri_21 do
8
8
  gem "pry-byebug"
9
9
  end
10
10
 
11
- gemspec :path => "../"
11
+ gemspec path: "../"
@@ -2,10 +2,10 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activemodel", :github => "rails/rails", :branch => "5-0-stable"
5
+ gem "activemodel", github: "rails/rails", branch: "6-1-stable"
6
6
 
7
7
  platforms :mri_20, :mri_21 do
8
8
  gem "pry-byebug"
9
9
  end
10
10
 
11
- gemspec :path => "../"
11
+ gemspec path: "../"
@@ -2,10 +2,10 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "activemodel", :github => "rails/rails", :branch => "master"
5
+ gem "activemodel", github: "rails/rails", branch: "master"
6
6
 
7
7
  platforms :mri_20, :mri_21 do
8
8
  gem "pry-byebug"
9
9
  end
10
10
 
11
- gemspec :path => "../"
11
+ gemspec path: "../"
@@ -1 +1,6 @@
1
+ require 'active_support'
1
2
  require 'state_machines/integrations/active_model'
3
+
4
+ ActiveSupport.on_load(:i18n) do
5
+ I18n.load_path << File.expand_path('state_machines/integrations/active_model/locale.rb', __dir__)
6
+ end
@@ -380,7 +380,7 @@ module StateMachines
380
380
  end
381
381
 
382
382
  default_options = default_error_message_options(object, attribute, message)
383
- object.errors.add(attribute, message, options.merge(default_options))
383
+ object.errors.add(attribute, message, **options, **default_options)
384
384
  end
385
385
  end
386
386
 
@@ -465,24 +465,6 @@ module StateMachines
465
465
  klass.lookup_ancestors
466
466
  end
467
467
 
468
- # Initializes class-level extensions and defaults for this machine
469
- def after_initialize
470
- super()
471
- load_locale
472
- end
473
-
474
- # Loads any locale files needed for translating validation errors
475
- def load_locale
476
- unless I18n.load_path.include?(locale_path)
477
- I18n.load_path.unshift(locale_path)
478
- I18n.reload!
479
- end
480
- end
481
-
482
- def locale_path
483
- "#{File.dirname(__FILE__)}/active_model/locale.rb"
484
- end
485
-
486
468
  # Skips defining reader/writer methods since this is done automatically
487
469
  def define_state_accessor
488
470
  name = self.name
@@ -1,7 +1,7 @@
1
1
  module StateMachines
2
2
  module Integrations
3
3
  module ActiveModel
4
- VERSION = '0.5.0'
4
+ VERSION = '0.8.0'
5
5
  end
6
6
  end
7
7
  end
@@ -16,9 +16,9 @@ Gem::Specification.new do |spec|
16
16
  spec.files = `git ls-files -z`.split("\x0")
17
17
  spec.test_files = spec.files.grep(/^test\//)
18
18
  spec.require_paths = ['lib']
19
- spec.required_ruby_version = '>= 2.0.0'
19
+ spec.required_ruby_version = '>= 2.2.2'
20
20
  spec.add_dependency 'state_machines', '>= 0.5.0'
21
- spec.add_dependency 'activemodel', '>= 4.1', '< 5.2'
21
+ spec.add_dependency 'activemodel', '>= 5.1'
22
22
 
23
23
  spec.add_development_dependency 'bundler', '>= 1.6'
24
24
  spec.add_development_dependency 'rake', '>= 10'
@@ -6,6 +6,12 @@ class MachineWithDirtyAttributeAndCustomAttributesDuringLoopbackTest < BaseTestC
6
6
  include ActiveModel::Dirty
7
7
  model_attribute :status
8
8
  define_attribute_methods [:status]
9
+
10
+ def save
11
+ super.tap do
12
+ changes_applied
13
+ end
14
+ end
9
15
  end
10
16
  @machine = StateMachines::Machine.new(@model, :status, initial: :parked)
11
17
  @machine.event :park
@@ -21,6 +27,6 @@ class MachineWithDirtyAttributeAndCustomAttributesDuringLoopbackTest < BaseTestC
21
27
  end
22
28
 
23
29
  def test_should_not_track_attribute_changes
24
- assert_equal nil, @record.changes['status']
30
+ assert_nil @record.changes['status']
25
31
  end
26
32
  end
@@ -5,6 +5,12 @@ class MachineWithDirtyAttributeAndStateEventsTest < BaseTestCase
5
5
  @model = new_model do
6
6
  include ActiveModel::Dirty
7
7
  define_attribute_methods [:state]
8
+
9
+ def save
10
+ super.tap do
11
+ changes_applied
12
+ end
13
+ end
8
14
  end
9
15
  @machine = StateMachines::Machine.new(@model, action: :save, initial: :parked)
10
16
  @machine.event :ignite
@@ -18,6 +24,6 @@ class MachineWithDirtyAttributeAndStateEventsTest < BaseTestCase
18
24
  end
19
25
 
20
26
  def test_should_not_track_attribute_change
21
- assert_equal nil, @record.changes['state']
27
+ assert_nil @record.changes['state']
22
28
  end
23
29
  end
@@ -6,6 +6,12 @@ class MachineWithDirtyAttributesAndCustomAttributeTest < BaseTestCase
6
6
  include ActiveModel::Dirty
7
7
  model_attribute :status
8
8
  define_attribute_methods [:status]
9
+
10
+ def save
11
+ super.tap do
12
+ changes_applied
13
+ end
14
+ end
9
15
  end
10
16
  @machine = StateMachines::Machine.new(@model, :status, initial: :parked)
11
17
  @machine.event :ignite
@@ -5,32 +5,14 @@ class MachineWithDirtyAttributesDuringLoopbackTest < BaseTestCase
5
5
  @model = new_model do
6
6
  include ActiveModel::Dirty
7
7
  define_attribute_methods [:state]
8
- end
9
- @machine = StateMachines::Machine.new(@model, initial: :parked)
10
- @machine.event :park
11
-
12
- @record = @model.create
13
-
14
- @transition = StateMachines::Transition.new(@record, @machine, :park, :parked, :parked)
15
- @transition.perform
16
- end
17
-
18
- def test_should_not_include_state_in_changed_attributes
19
- assert_equal [], @record.changed
20
- end
21
8
 
22
- def test_should_not_track_attribute_changes
23
- assert_equal nil, @record.changes['state']
24
- end
25
- end
26
- class MachineWithDirtyAttributeAndCustomAttributesDuringLoopbackTest < BaseTestCase
27
- def setup
28
- @model = new_model do
29
- include ActiveModel::Dirty
30
- model_attribute :status
31
- define_attribute_methods [:status]
9
+ def save
10
+ super.tap do
11
+ changes_applied
12
+ end
13
+ end
32
14
  end
33
- @machine = StateMachines::Machine.new(@model, :status, initial: :parked)
15
+ @machine = StateMachines::Machine.new(@model, initial: :parked)
34
16
  @machine.event :park
35
17
 
36
18
  @record = @model.create
@@ -44,6 +26,6 @@ class MachineWithDirtyAttributeAndCustomAttributesDuringLoopbackTest < BaseTestC
44
26
  end
45
27
 
46
28
  def test_should_not_track_attribute_changes
47
- assert_equal nil, @record.changes['status']
29
+ assert_nil @record.changes['state']
48
30
  end
49
31
  end
@@ -5,6 +5,12 @@ class MachineWithDirtyAttributesTest < BaseTestCase
5
5
  @model = new_model do
6
6
  include ActiveModel::Dirty
7
7
  define_attribute_methods [:state]
8
+
9
+ def save
10
+ super.tap do
11
+ changes_applied
12
+ end
13
+ end
8
14
  end
9
15
  @machine = StateMachines::Machine.new(@model, initial: :parked)
10
16
  @machine.event :ignite
@@ -144,28 +144,8 @@ class MachineWithInternationalizationTest < BaseTestCase
144
144
  assert_equal 'stop', machine.event(:park).human_name
145
145
  end
146
146
 
147
- def test_should_only_add_locale_once_in_load_path
147
+ def test_should_have_locale_once_in_load_path
148
148
  assert_equal 1, I18n.load_path.select { |path| path =~ %r{active_model/locale\.rb$} }.length
149
-
150
- # Create another ActiveModel model that will triger the i18n feature
151
- new_model
152
-
153
- assert_equal 1, I18n.load_path.select { |path| path =~ %r{active_model/locale\.rb$} }.length
154
- end
155
-
156
- def test_should_add_locale_to_beginning_of_load_path
157
- @original_load_path = I18n.load_path
158
- I18n.backend = I18n::Backend::Simple.new
159
-
160
- app_locale = File.dirname(__FILE__) + '/files/en.yml'
161
- default_locale = File.dirname(__FILE__) + '/../lib/state_machines/integrations/active_model/locale.rb'
162
- I18n.load_path = [app_locale]
163
-
164
- StateMachines::Machine.new(@model)
165
-
166
- assert_equal [default_locale, app_locale].map { |path| File.expand_path(path) }, I18n.load_path.map { |path| File.expand_path(path) }
167
- ensure
168
- I18n.load_path = @original_load_path
169
149
  end
170
150
 
171
151
  def test_should_prefer_other_locales_first
@@ -32,7 +32,6 @@ class BaseTestCase < MiniTest::Test
32
32
 
33
33
  def initialize(attrs = {})
34
34
  attrs.each { |attr, value| send("#{attr}=", value) }
35
- @changed_attributes = {}
36
35
  end
37
36
 
38
37
  def attributes
@@ -40,7 +39,6 @@ class BaseTestCase < MiniTest::Test
40
39
  end
41
40
 
42
41
  def save
43
- @changed_attributes = {}
44
42
  true
45
43
  end
46
44
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: state_machines-activemodel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.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: 2017-06-20 00:00:00.000000000 Z
12
+ date: 2020-12-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: state_machines
@@ -31,20 +31,14 @@ dependencies:
31
31
  requirements:
32
32
  - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: '4.1'
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: '4.1'
45
- - - "<"
46
- - !ruby/object:Gem::Version
47
- version: '5.2'
41
+ version: '5.1'
48
42
  - !ruby/object:Gem::Dependency
49
43
  name: bundler
50
44
  requirement: !ruby/object:Gem::Requirement
@@ -130,10 +124,10 @@ files:
130
124
  - LICENSE.txt
131
125
  - README.md
132
126
  - Rakefile
133
- - gemfiles/active_model_4.1.gemfile
134
- - gemfiles/active_model_4.2.gemfile
135
- - gemfiles/active_model_5.0.gemfile
136
127
  - gemfiles/active_model_5.1.gemfile
128
+ - gemfiles/active_model_5.2.gemfile
129
+ - gemfiles/active_model_6.0.gemfile
130
+ - gemfiles/active_model_6.1.gemfile
137
131
  - gemfiles/active_model_edge.gemfile
138
132
  - lib/state_machines-activemodel.rb
139
133
  - lib/state_machines/integrations/active_model.rb
@@ -169,7 +163,7 @@ homepage: https://github.com/state-machines/state_machines-activemodel
169
163
  licenses:
170
164
  - MIT
171
165
  metadata: {}
172
- post_install_message:
166
+ post_install_message:
173
167
  rdoc_options: []
174
168
  require_paths:
175
169
  - lib
@@ -177,16 +171,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
177
171
  requirements:
178
172
  - - ">="
179
173
  - !ruby/object:Gem::Version
180
- version: 2.0.0
174
+ version: 2.2.2
181
175
  required_rubygems_version: !ruby/object:Gem::Requirement
182
176
  requirements:
183
177
  - - ">="
184
178
  - !ruby/object:Gem::Version
185
179
  version: '0'
186
180
  requirements: []
187
- rubyforge_project:
188
- rubygems_version: 2.6.12
189
- signing_key:
181
+ rubygems_version: 3.0.3
182
+ signing_key:
190
183
  specification_version: 4
191
184
  summary: ActiveModel integration for State Machines
192
185
  test_files: