Skip to content

Commit 420fa1a

Browse files
Add Rails 8 support
1 parent ee22510 commit 420fa1a

File tree

6 files changed

+128
-4
lines changed

6 files changed

+128
-4
lines changed

.github/workflows/test.yml

+3
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ jobs:
7474
gemfile: Gemfile.6.1.pg
7575
- ruby: 3.3.0
7676
gemfile: Gemfile.7.1.pg
77+
- ruby: 3.3.6
78+
gemfile: Gemfile.8.0.pg
79+
7780
env:
7881
BUNDLE_GEMFILE: "${{ matrix.gemfile }}"
7982
steps:

Gemfile.8.0.pg

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
source 'https://rubygems.org'
2+
3+
# Runtime dependencies
4+
gem 'activerecord', '~>8.0.0'
5+
gem 'i18n'
6+
gem 'pg'
7+
8+
# Development dependencies
9+
gem 'rake'
10+
gem 'database_cleaner'
11+
gem 'rspec'
12+
gem 'rspec_candy'
13+
gem 'gemika', '~> 0.8.0'
14+
15+
# Gem under test
16+
gem 'assignable_values', :path => '.'

Gemfile.8.0.pg.lock

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
PATH
2+
remote: .
3+
specs:
4+
assignable_values (1.1.0)
5+
activerecord (>= 2.3)
6+
7+
GEM
8+
remote: https://rubygems.org/
9+
specs:
10+
activemodel (8.0.0.1)
11+
activesupport (= 8.0.0.1)
12+
activerecord (8.0.0.1)
13+
activemodel (= 8.0.0.1)
14+
activesupport (= 8.0.0.1)
15+
timeout (>= 0.4.0)
16+
activesupport (8.0.0.1)
17+
base64
18+
benchmark (>= 0.3)
19+
bigdecimal
20+
concurrent-ruby (~> 1.0, >= 1.3.1)
21+
connection_pool (>= 2.2.5)
22+
drb
23+
i18n (>= 1.6, < 2)
24+
logger (>= 1.4.2)
25+
minitest (>= 5.1)
26+
securerandom (>= 0.3)
27+
tzinfo (~> 2.0, >= 2.0.5)
28+
uri (>= 0.13.1)
29+
base64 (0.2.0)
30+
benchmark (0.4.0)
31+
bigdecimal (3.1.8)
32+
concurrent-ruby (1.3.4)
33+
connection_pool (2.4.1)
34+
database_cleaner (2.1.0)
35+
database_cleaner-active_record (>= 2, < 3)
36+
database_cleaner-active_record (2.2.0)
37+
activerecord (>= 5.a)
38+
database_cleaner-core (~> 2.0.0)
39+
database_cleaner-core (2.0.1)
40+
diff-lcs (1.5.1)
41+
drb (2.2.1)
42+
gemika (0.8.3)
43+
i18n (1.14.6)
44+
concurrent-ruby (~> 1.0)
45+
logger (1.6.3)
46+
minitest (5.25.4)
47+
pg (1.5.9)
48+
rake (13.2.1)
49+
rspec (3.13.0)
50+
rspec-core (~> 3.13.0)
51+
rspec-expectations (~> 3.13.0)
52+
rspec-mocks (~> 3.13.0)
53+
rspec-core (3.13.2)
54+
rspec-support (~> 3.13.0)
55+
rspec-expectations (3.13.3)
56+
diff-lcs (>= 1.2.0, < 2.0)
57+
rspec-support (~> 3.13.0)
58+
rspec-mocks (3.13.2)
59+
diff-lcs (>= 1.2.0, < 2.0)
60+
rspec-support (~> 3.13.0)
61+
rspec-support (3.13.2)
62+
rspec_candy (0.5.1)
63+
rspec
64+
sneaky-save
65+
securerandom (0.4.0)
66+
sneaky-save (0.1.3)
67+
activerecord (>= 3.2.0)
68+
timeout (0.4.2)
69+
tzinfo (2.0.6)
70+
concurrent-ruby (~> 1.0)
71+
uri (1.0.2)
72+
73+
PLATFORMS
74+
ruby
75+
x86_64-linux
76+
77+
DEPENDENCIES
78+
activerecord (~> 8.0.0)
79+
assignable_values!
80+
database_cleaner
81+
gemika (~> 0.8.0)
82+
i18n
83+
pg
84+
rake
85+
rspec
86+
rspec_candy
87+
88+
BUNDLED WITH
89+
2.5.22

lib/assignable_values/active_record/restriction/scalar_attribute.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def define_humanized_assignable_values_instance_method
8888

8989
unless multiple
9090
define_method :"humanized_#{restriction.property.to_s.pluralize}" do
91-
ActiveSupport::Deprecation.warn("humanized_<value>s is deprecated, use humanized_assignable_<value>s instead", caller)
91+
ActiveSupport::Deprecation.new.warn("humanized_<value>s is deprecated, use humanized_assignable_<value>s instead", caller)
9292
restriction.humanized_assignable_values(self)
9393
end
9494
end

lib/assignable_values/humanizable_string.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def initialize(string, humanization)
88
end
99

1010
def humanized
11-
ActiveSupport::Deprecation.warn("assignable_<value>.humanized is deprecated, use humanized_assignable_<value>s.humanized instead", caller)
11+
ActiveSupport::Deprecation.new.warn("assignable_<value>.humanized is deprecated, use humanized_assignable_<value>s.humanized instead", caller)
1212
@humanization
1313
end
1414

spec/assignable_values/active_record_spec.rb

+18-2
Original file line numberDiff line numberDiff line change
@@ -1277,9 +1277,17 @@ def genres
12771277
%w[pop rock]
12781278
end
12791279
end
1280-
ActiveSupport::Deprecation.should_receive(:warn)
1280+
deprecation_instance = instance_double(ActiveSupport::Deprecation)
1281+
allow(ActiveSupport::Deprecation).to receive(:new).and_return(deprecation_instance)
1282+
allow(deprecation_instance).to receive(:warn)
1283+
12811284
genres = klass.new.humanized_genres
12821285
genres.collect(&:humanized).should == ['Pop music', 'Rock music']
1286+
1287+
expect(deprecation_instance).to have_received(:warn).with(
1288+
"humanized_<value>s is deprecated, use humanized_assignable_<value>s instead",
1289+
instance_of(Array)
1290+
)
12831291
end
12841292

12851293
it "should define a method #humanized on assignable string values, which return up the value's' translation" do
@@ -1288,8 +1296,16 @@ def genres
12881296
%w[pop rock]
12891297
end
12901298
end
1291-
ActiveSupport::Deprecation.should_receive(:warn).at_least(:once)
1299+
deprecation_instance = instance_double(ActiveSupport::Deprecation)
1300+
allow(ActiveSupport::Deprecation).to receive(:new).and_return(deprecation_instance)
1301+
allow(deprecation_instance).to receive(:warn)
1302+
12921303
klass.new.assignable_genres.collect(&:humanized).should == ['Pop music', 'Rock music']
1304+
1305+
expect(deprecation_instance).to have_received(:warn).with(
1306+
"assignable_<value>.humanized is deprecated, use humanized_assignable_<value>s.humanized instead",
1307+
instance_of(Array)
1308+
).at_least(:once)
12931309
end
12941310

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

0 commit comments

Comments
 (0)