Skip to content

Commit ee60311

Browse files
committed
Add tests for Fields::Types::Enum#enum when no bindings provided
A lack of tests for these code paths led to a regression for legacy enums in Rails Admin 3.0 (#3651). This tests the code path using `abstract_model` that was fixed by @fuegas in the previous commit.
1 parent 3833827 commit ee60311

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

spec/rails_admin/config/fields/types/enum_spec.rb

+12-2
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,15 @@ def color_list
6363
Team.send(:remove_method, :color_list)
6464
end
6565

66-
it 'allows configuration' do
66+
it 'allows configuration by enum_method when bindings provide object' do
6767
is_expected.to be_a(RailsAdmin::Config::Fields::Types::Enum)
6868
expect(subject.with(object: Team.new).enum).to eq %w[blue green red]
6969
end
70+
71+
it 'allows configuration by enum_method when no bindings provided' do
72+
is_expected.to be_a(RailsAdmin::Config::Fields::Types::Enum)
73+
expect(subject.enum).to eq %w[blue green red]
74+
end
7075
end
7176

7277
describe 'the enum class method' do
@@ -87,10 +92,15 @@ def color_list
8792
Team.instance_eval { undef :color_list }
8893
end
8994

90-
it 'allows configuration' do
95+
it 'allows configuration by enum_method when bindings provide object' do
9196
is_expected.to be_a(RailsAdmin::Config::Fields::Types::Enum)
9297
expect(subject.with(object: Team.new).enum).to eq %w[blue green red]
9398
end
99+
100+
it 'allows configuration by enum_method when no bindings provided' do
101+
is_expected.to be_a(RailsAdmin::Config::Fields::Types::Enum)
102+
expect(subject.enum).to eq %w[blue green red]
103+
end
94104
end
95105

96106
describe 'when overriding enum configuration' do

0 commit comments

Comments
 (0)