Skip to content

Commit

Permalink
Fix RailsAdmin::Config.reset didn't clear the effect of previous (inc…
Browse files Browse the repository at this point in the history
…luded|excluded)_models

Fixes #3305
  • Loading branch information
mshibuya committed Oct 9, 2021
1 parent 3c10b09 commit 1190d51
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/rails_admin/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ def reset
@parent_controller = '::ActionController::Base'
@forgery_protection_settings = {with: :exception}
RailsAdmin::Config::Actions.reset
RailsAdmin::AbstractModel.reset
end

# Reset a provided model's configuration.
Expand Down
19 changes: 19 additions & 0 deletions spec/rails_admin/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,25 @@ class RecursivelyEmbedsMany
end
end

describe '.reset' do
before do
RailsAdmin.config do |config|
config.included_models = ['Player', 'Team']
end
RailsAdmin::AbstractModel.all
RailsAdmin::Config.reset
RailsAdmin.config do |config|
config.excluded_models = ['Player']
end
end
subject { RailsAdmin::AbstractModel.all.map { |am| am.model.name } }

it 'refreshes the result of RailsAdmin::AbstractModel.all' do
expect(subject).not_to include 'Player'
expect(subject).to include 'Team'
end
end

describe "field types code reloading" do
before { Rails.application.config.cache_classes = false }
after { Rails.application.config.cache_classes = true }
Expand Down
1 change: 0 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ def password_digest(password)

DatabaseCleaner.start
RailsAdmin::Config.reset
RailsAdmin::AbstractModel.reset
end

config.after(:each) do
Expand Down

0 comments on commit 1190d51

Please sign in to comment.