Skip to content

Commit

Permalink
Make sure to restore original value
Browse files Browse the repository at this point in the history
Refs. #3041
  • Loading branch information
mshibuya committed Jul 17, 2018
1 parent 940b856 commit 2d197e5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 24 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- 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))

### Fixed
- Make code reloading work([#3041](https://github.com/sferik/rails_admin/pull/3041))
- 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))
- Make the link text to uploaded file shorter, instead of showing full url([#2983](https://github.com/sferik/rails_admin/pull/2983))
- Fix duplication of filters on browser back([#2998](https://github.com/sferik/rails_admin/pull/2998))
Expand Down
39 changes: 15 additions & 24 deletions spec/rails_admin/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,9 @@ class RecursivelyEmbedsMany
end

describe "field types code reloading" do
before { Rails.application.config.cache_classes = false }
after { Rails.application.config.cache_classes = true }

let(:config) { described_class.model(Team) }
let(:fields) { described_class.model(Team).edit.fields }

Expand All @@ -338,6 +341,7 @@ class RecursivelyEmbedsMany
field :wins, :boolean
end
end

let(:team_config2) do
proc do
field :wins, :toggle
Expand Down Expand Up @@ -372,32 +376,19 @@ class Toggle < RailsAdmin::Config::Fields::Base
end

it "updates model config when reloading code for rails 5" do
if defined?(ActiveSupport::Reloader)
Team.send(:rails_admin, &team_config)

# this simulates rails code reloading
Rails.application.config.cache_classes = false
RailsAdmin::Engine.initializers.select do |i|
i.name == "RailsAdmin reload config in development"
end.first.block.call
if defined?(ActiveSupport::Reloader)
Rails.application.executor.wrap do
ActiveSupport::Reloader.new.tap(&:class_unload!).complete!
end
# else
# for Rails 4 not imlemented yet
end
# /end

Team.send(:rails_admin, &team_config3)
expect(fields.map(&:name)).to match_array %i(wins)
Team.send(:rails_admin, &team_config)

# restore setting to previous value
Rails.application.config.cache_classes = true
# else
# pending "for Rails 4 not implemented"
# this simulates rails code reloading
RailsAdmin::Engine.initializers.select do |i|
i.name == "RailsAdmin reload config in development"
end.first.block.call
Rails.application.executor.wrap do
ActiveSupport::Reloader.new.tap(&:class_unload!).complete!
end
end

Team.send(:rails_admin, &team_config3)
expect(fields.map(&:name)).to match_array %i(wins)
end if defined?(ActiveSupport::Reloader)
end
end

Expand Down

0 comments on commit 2d197e5

Please sign in to comment.