spec/unit/devise_spec.rb in activeadmin-1.0.0.pre4 vs spec/unit/devise_spec.rb in activeadmin-1.0.0.pre5

- old
+ new

@@ -1,8 +1,8 @@ require 'rails_helper' -describe ActiveAdmin::Devise::Controller do +RSpec.describe ActiveAdmin::Devise::Controller do let(:controller_class) do klass = Class.new do def self.layout(*); end def self.helper(*); end @@ -10,14 +10,26 @@ klass.send(:include, ActiveAdmin::Devise::Controller) klass end let(:controller) { controller_class.new } + let(:action_controller_config) { Rails.configuration.action_controller } + def with_temp_relative_url_root(relative_url_root) + previous_relative_url_root = action_controller_config[:relative_url_root] + action_controller_config[:relative_url_root] = relative_url_root + + yield + ensure + action_controller_config[:relative_url_root] = previous_relative_url_root + end + context 'with a RAILS_RELATIVE_URL_ROOT set' do - before { Rails.configuration.action_controller[:relative_url_root] = '/foo' } + around do |example| + with_temp_relative_url_root('/foo') { example.call } + end it "should set the root path to the default namespace" do expect(controller.root_path).to eq "/foo/admin" end @@ -28,10 +40,12 @@ end context 'without a RAILS_RELATIVE_URL_ROOT set' do - before { Rails.configuration.action_controller[:relative_url_root] = nil } + around do |example| + with_temp_relative_url_root(nil) { example.call } + end it "should set the root path to the default namespace" do expect(controller.root_path).to eq "/admin" end