Skip to content

Commit

Permalink
Add Rails 8 support
Browse files Browse the repository at this point in the history
  • Loading branch information
martinschaflitzl1 committed Jan 9, 2025
1 parent ee22510 commit 420fa1a
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ jobs:
gemfile: Gemfile.6.1.pg
- ruby: 3.3.0
gemfile: Gemfile.7.1.pg
- ruby: 3.3.6
gemfile: Gemfile.8.0.pg

env:
BUNDLE_GEMFILE: "${{ matrix.gemfile }}"
steps:
Expand Down
16 changes: 16 additions & 0 deletions Gemfile.8.0.pg
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
source 'https://rubygems.org'

# Runtime dependencies
gem 'activerecord', '~>8.0.0'
gem 'i18n'
gem 'pg'

# Development dependencies
gem 'rake'
gem 'database_cleaner'
gem 'rspec'
gem 'rspec_candy'
gem 'gemika', '~> 0.8.0'

# Gem under test
gem 'assignable_values', :path => '.'
89 changes: 89 additions & 0 deletions Gemfile.8.0.pg.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
PATH
remote: .
specs:
assignable_values (1.1.0)
activerecord (>= 2.3)

GEM
remote: https://rubygems.org/
specs:
activemodel (8.0.0.1)
activesupport (= 8.0.0.1)
activerecord (8.0.0.1)
activemodel (= 8.0.0.1)
activesupport (= 8.0.0.1)
timeout (>= 0.4.0)
activesupport (8.0.0.1)
base64
benchmark (>= 0.3)
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
uri (>= 0.13.1)
base64 (0.2.0)
benchmark (0.4.0)
bigdecimal (3.1.8)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
database_cleaner (2.1.0)
database_cleaner-active_record (>= 2, < 3)
database_cleaner-active_record (2.2.0)
activerecord (>= 5.a)
database_cleaner-core (~> 2.0.0)
database_cleaner-core (2.0.1)
diff-lcs (1.5.1)
drb (2.2.1)
gemika (0.8.3)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
logger (1.6.3)
minitest (5.25.4)
pg (1.5.9)
rake (13.2.1)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.2)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.2)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.2)
rspec_candy (0.5.1)
rspec
sneaky-save
securerandom (0.4.0)
sneaky-save (0.1.3)
activerecord (>= 3.2.0)
timeout (0.4.2)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
uri (1.0.2)

PLATFORMS
ruby
x86_64-linux

DEPENDENCIES
activerecord (~> 8.0.0)
assignable_values!
database_cleaner
gemika (~> 0.8.0)
i18n
pg
rake
rspec
rspec_candy

BUNDLED WITH
2.5.22
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def define_humanized_assignable_values_instance_method

unless multiple
define_method :"humanized_#{restriction.property.to_s.pluralize}" do
ActiveSupport::Deprecation.warn("humanized_<value>s is deprecated, use humanized_assignable_<value>s instead", caller)
ActiveSupport::Deprecation.new.warn("humanized_<value>s is deprecated, use humanized_assignable_<value>s instead", caller)
restriction.humanized_assignable_values(self)
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/assignable_values/humanizable_string.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def initialize(string, humanization)
end

def humanized
ActiveSupport::Deprecation.warn("assignable_<value>.humanized is deprecated, use humanized_assignable_<value>s.humanized instead", caller)
ActiveSupport::Deprecation.new.warn("assignable_<value>.humanized is deprecated, use humanized_assignable_<value>s.humanized instead", caller)
@humanization
end

Expand Down
20 changes: 18 additions & 2 deletions spec/assignable_values/active_record_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1277,9 +1277,17 @@ def genres
%w[pop rock]
end
end
ActiveSupport::Deprecation.should_receive(:warn)
deprecation_instance = instance_double(ActiveSupport::Deprecation)
allow(ActiveSupport::Deprecation).to receive(:new).and_return(deprecation_instance)
allow(deprecation_instance).to receive(:warn)

genres = klass.new.humanized_genres
genres.collect(&:humanized).should == ['Pop music', 'Rock music']

expect(deprecation_instance).to have_received(:warn).with(
"humanized_<value>s is deprecated, use humanized_assignable_<value>s instead",
instance_of(Array)
)
end

it "should define a method #humanized on assignable string values, which return up the value's' translation" do
Expand All @@ -1288,8 +1296,16 @@ def genres
%w[pop rock]
end
end
ActiveSupport::Deprecation.should_receive(:warn).at_least(:once)
deprecation_instance = instance_double(ActiveSupport::Deprecation)
allow(ActiveSupport::Deprecation).to receive(:new).and_return(deprecation_instance)
allow(deprecation_instance).to receive(:warn)

klass.new.assignable_genres.collect(&:humanized).should == ['Pop music', 'Rock music']

expect(deprecation_instance).to have_received(:warn).with(
"assignable_<value>.humanized is deprecated, use humanized_assignable_<value>s.humanized instead",
instance_of(Array)
).at_least(:once)
end

it 'should not define a method #humanized on values that are not strings' do
Expand Down

0 comments on commit 420fa1a

Please sign in to comment.