Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails 7 support #117

Merged
merged 1 commit into from
Jun 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions .github/workflows/rspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,42 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: [jruby, 2.6, 2.7]
ruby: [jruby, 2.6, 2.7, 3.0, 3.1]

gemfile: [
"gemfiles/jruby.gemfile",
"gemfiles/rails_5_2.gemfile",
"gemfiles/rails_6_0.gemfile",
"gemfiles/rails_6_2.gemfile"
"gemfiles/rails_6_2.gemfile",
"gemfiles/rails_7_0.gemfile"
]

allow_failures:
- false

exclude:
- ruby: jruby
gemfile: gemfiles/rails_5_2.gemfile
- ruby: jruby
gemfile: gemfiles/rails_6_0.gemfile
- ruby: jruby
gemfile: gemfiles/rails_6_2.gemfile
- ruby: jruby
gemfile: gemfiles/rails_7_0.gemfile
- ruby: jruby
gemfile: gemfiles/railsmaster.gemfile

- ruby: 2.5
gemfile: gemfiles/jruby.gemfile
- ruby: 2.6
gemfile: gemfiles/jruby.gemfile
- ruby: 2.7
gemfile: gemfiles/jruby.gemfile
- ruby: ruby-head
- ruby: 3.0
gemfile: gemfiles/jruby.gemfile
- ruby: 3.1
gemfile: gemfiles/jruby.gemfile

- ruby: 2.6
gemfile: gemfiles/rails_7_0.gemfile
- ruby: 2.6
gemfile: gemfiles/railsmaster.gemfile

include:
- ruby: ruby-head
gemfile: gemfiles/railsmaster.gemfile
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## master

- [PR #117](https://github.com/DmitryTsepelev/store_model/pull/117) Rails 7 support ([@DmitryTsepelev])
- [PR #112](https://github.com/DmitryTsepelev/store_model/pull/111) Fix validation for cast attributes ([@zk475811])

## 0.13.0 (2022-02-11)
Expand Down
6 changes: 0 additions & 6 deletions gemfiles/rails_5_2.gemfile

This file was deleted.

6 changes: 6 additions & 0 deletions gemfiles/rails_7_0.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source "https://rubygems.org"

gem "sqlite3", "~> 1.4.0"
gem "activerecord", "~> 7.0.3"

gemspec path: "../"
14 changes: 11 additions & 3 deletions lib/store_model/ext/active_model/attributes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,17 @@ def attribute(*)
end
end

def write_attribute(*)
super.tap do |value|
assign_parent_to_store_model_relation(value)
if Rails::VERSION::MAJOR >= 7
def _write_attribute(*)
super.tap do |value|
assign_parent_to_store_model_relation(value)
end
end
else
def write_attribute(*)
super.tap do |value|
assign_parent_to_store_model_relation(value)
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@
if Rails::VERSION::MAJOR < 6 || Rails::VERSION::MAJOR == 6 && Rails::VERSION::MINOR.zero?
expect(record.errors.messages).to eq(name: ["can't be blank"], color: ["can't be blank"])
expect(record.errors.full_messages).to eq(["Name can't be blank", "Color can't be blank"])
elsif Rails::VERSION::MAJOR == 7
expect(record.errors.messages).to eq(
name: ["can't be blank"], configuration: ["is invalid", "Color can't be blank"]
)
expect(record.errors.full_messages).to eq(
["Name can't be blank", "Configuration is invalid", "Configuration Color can't be blank"]
)
else
expect(record.errors.messages).to eq(
name: ["can't be blank"], configuration: ["Color can't be blank"]
Expand Down