diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bf4ce0f..9e09c4b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,8 +10,8 @@ jobs: strategy: fail-fast: false matrix: - ruby: [3.3] - gemfile: [activerecord-6.0.Gemfile, activerecord-6.1.Gemfile, activerecord-7.0.Gemfile, activerecord-7.1.Gemfile] + ruby: [3.3, 3.4] + gemfile: [activerecord-7.1.Gemfile, activerecord-7.2.Gemfile] env: BUNDLE_GEMFILE: gemfiles/${{matrix.gemfile}} steps: diff --git a/README.md b/README.md index b7f64ef..a2094e7 100644 --- a/README.md +++ b/README.md @@ -215,6 +215,33 @@ end Changelog --------- +### Next + +* Ensure other changed attributes will stored together with state change. + + - to avoid a second write query + + before: + ```rb + def event + o.title = 'new title' + o.save + end + ``` + + now: + ```rb + def event + o.title = 'new title' + end + ``` + +* Add Ruby 3.4 to test matrix + + - retires: ruby < 3.3, rails < 7.1 + +* Defines actual passing state + ### New in the version 6.0.0 * GH-14 retire Ruby 2.6 and Rails 5.* and older since they have reached end of diff --git a/gemfiles/activerecord-6.1.Gemfile b/gemfiles/activerecord-6.1.Gemfile deleted file mode 100644 index 976ec33..0000000 --- a/gemfiles/activerecord-6.1.Gemfile +++ /dev/null @@ -1,3 +0,0 @@ -eval_gemfile File.join(File.dirname(__FILE__), "../Gemfile") - -gem 'activerecord', '~> 6.1.0' diff --git a/gemfiles/activerecord-6.0.Gemfile b/gemfiles/activerecord-7.2.Gemfile similarity index 65% rename from gemfiles/activerecord-6.0.Gemfile rename to gemfiles/activerecord-7.2.Gemfile index f32ff01..89de6d6 100644 --- a/gemfiles/activerecord-6.0.Gemfile +++ b/gemfiles/activerecord-7.2.Gemfile @@ -1,3 +1,2 @@ eval_gemfile File.join(File.dirname(__FILE__), "../Gemfile") - -gem 'activerecord', '~> 6.0.0' +gem 'activerecord', '~> 7.2.0' diff --git a/lib/workflow-activerecord.rb b/lib/workflow-activerecord.rb index 1b4d29e..9e57191 100644 --- a/lib/workflow-activerecord.rb +++ b/lib/workflow-activerecord.rb @@ -18,8 +18,8 @@ def load_workflow_state # On transition the new workflow state is immediately saved in the # database. def persist_workflow_state(new_value) - # Rails 3.1 or newer - update_column self.class.workflow_column, new_value + assign_attributes(self.class.workflow_column => new_value) + save end private diff --git a/test/persistence_test.rb b/test/persistence_test.rb index 113630b..bf6e24b 100644 --- a/test/persistence_test.rb +++ b/test/persistence_test.rb @@ -48,13 +48,13 @@ def assert_state(title, expected_state, klass = PersistenceTestOrder) o end - test 'ensure other dirty attributes are not saved on state change' do + test 'ensure other dirty attributes are also saved on state change' do o = assert_state 'order6', 'accepted' o.title = 'going to change the title' assert o.changed? o.ship! - assert o.changed?, 'title should not be saved and the change still stay pending' + # assert o.changed?, 'title should not be saved and the change still stay pending' + assert o.reload.title, 'going to change the title' end - end diff --git a/workflow_activerecord.gemspec b/workflow_activerecord.gemspec index 548f422..067efdd 100644 --- a/workflow_activerecord.gemspec +++ b/workflow_activerecord.gemspec @@ -23,18 +23,18 @@ Gem::Specification.new do |gem| "README.md" ] - rails_versions = ['>= 6.0'] + rails_versions = ['>= 6.0', '< 8.0'] - gem.required_ruby_version = '>= 2.7' + gem.required_ruby_version = '>= 3.3' gem.add_runtime_dependency 'workflow', '~> 3.0' gem.add_runtime_dependency 'activerecord', rails_versions - gem.add_development_dependency 'rdoc', '~> 6.4' - gem.add_development_dependency 'bundler', '~> 2.3' - gem.add_development_dependency 'mocha', '~> 2.2' - gem.add_development_dependency 'rake', '~> 13.1' - gem.add_development_dependency 'minitest', '~> 5.21' - gem.add_development_dependency 'sqlite3', '~> 1.3' + gem.add_development_dependency 'rdoc'#, '~> 6.4' + gem.add_development_dependency 'bundler'#, '~> 2.3' + gem.add_development_dependency 'mocha'#, '~> 2.2' + gem.add_development_dependency 'rake'#, '~> 13.1' + gem.add_development_dependency 'minitest'#, '~> 5.21' + gem.add_development_dependency 'sqlite3'#, '~> 1.3' end