Skip to content

Commit 2d197e5

Browse files
committed
Make sure to restore original value
Refs. #3041
1 parent 940b856 commit 2d197e5

2 files changed

Lines changed: 16 additions & 24 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- Support for jquery-ui-rails 6.x([#2951](https://github.com/sferik/rails_admin/issues/2951), [#3003](https://github.com/sferik/rails_admin/issues/3003))
1212

1313
### Fixed
14+
- Make code reloading work([#3041](https://github.com/sferik/rails_admin/pull/3041))
1415
- Improved support for Rails API mode, requiring needed middlewares in engine's initializer([#2919](https://github.com/sferik/rails_admin/issues/2919), [#3006](https://github.com/sferik/rails_admin/pull/3006))
1516
- Make the link text to uploaded file shorter, instead of showing full url([#2983](https://github.com/sferik/rails_admin/pull/2983))
1617
- Fix duplication of filters on browser back([#2998](https://github.com/sferik/rails_admin/pull/2998))

spec/rails_admin/config_spec.rb

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,9 @@ class RecursivelyEmbedsMany
329329
end
330330

331331
describe "field types code reloading" do
332+
before { Rails.application.config.cache_classes = false }
333+
after { Rails.application.config.cache_classes = true }
334+
332335
let(:config) { described_class.model(Team) }
333336
let(:fields) { described_class.model(Team).edit.fields }
334337

@@ -338,6 +341,7 @@ class RecursivelyEmbedsMany
338341
field :wins, :boolean
339342
end
340343
end
344+
341345
let(:team_config2) do
342346
proc do
343347
field :wins, :toggle
@@ -372,32 +376,19 @@ class Toggle < RailsAdmin::Config::Fields::Base
372376
end
373377

374378
it "updates model config when reloading code for rails 5" do
375-
if defined?(ActiveSupport::Reloader)
376-
Team.send(:rails_admin, &team_config)
377-
378-
# this simulates rails code reloading
379-
Rails.application.config.cache_classes = false
380-
RailsAdmin::Engine.initializers.select do |i|
381-
i.name == "RailsAdmin reload config in development"
382-
end.first.block.call
383-
if defined?(ActiveSupport::Reloader)
384-
Rails.application.executor.wrap do
385-
ActiveSupport::Reloader.new.tap(&:class_unload!).complete!
386-
end
387-
# else
388-
# for Rails 4 not imlemented yet
389-
end
390-
# /end
391-
392-
Team.send(:rails_admin, &team_config3)
393-
expect(fields.map(&:name)).to match_array %i(wins)
379+
Team.send(:rails_admin, &team_config)
394380

395-
# restore setting to previous value
396-
Rails.application.config.cache_classes = true
397-
# else
398-
# pending "for Rails 4 not implemented"
381+
# this simulates rails code reloading
382+
RailsAdmin::Engine.initializers.select do |i|
383+
i.name == "RailsAdmin reload config in development"
384+
end.first.block.call
385+
Rails.application.executor.wrap do
386+
ActiveSupport::Reloader.new.tap(&:class_unload!).complete!
399387
end
400-
end
388+
389+
Team.send(:rails_admin, &team_config3)
390+
expect(fields.map(&:name)).to match_array %i(wins)
391+
end if defined?(ActiveSupport::Reloader)
401392
end
402393
end
403394

0 commit comments

Comments
 (0)