Use around hook to restore context in Admin::SettingsController spec (#3428)
parent
2d39560dc1
commit
67bc58dd60
|
@ -47,6 +47,13 @@ RSpec.describe Admin::SettingsController, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context do
|
||||||
|
around do |example|
|
||||||
|
site_title = Setting.site_title
|
||||||
|
example.run
|
||||||
|
Setting.site_title = site_title
|
||||||
|
end
|
||||||
|
|
||||||
it 'updates a settings value' do
|
it 'updates a settings value' do
|
||||||
Setting.site_title = 'Original'
|
Setting.site_title = 'Original'
|
||||||
patch :update, params: { site_title: 'New title' }
|
patch :update, params: { site_title: 'New title' }
|
||||||
|
@ -54,6 +61,14 @@ RSpec.describe Admin::SettingsController, type: :controller do
|
||||||
expect(response).to redirect_to(edit_admin_settings_path)
|
expect(response).to redirect_to(edit_admin_settings_path)
|
||||||
expect(Setting.site_title).to eq 'New title'
|
expect(Setting.site_title).to eq 'New title'
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context do
|
||||||
|
around do |example|
|
||||||
|
open_registrations = Setting.open_registrations
|
||||||
|
example.run
|
||||||
|
Setting.open_registrations = open_registrations
|
||||||
|
end
|
||||||
|
|
||||||
it 'typecasts open_registrations to boolean' do
|
it 'typecasts open_registrations to boolean' do
|
||||||
Setting.open_registrations = false
|
Setting.open_registrations = false
|
||||||
|
@ -65,3 +80,4 @@ RSpec.describe Admin::SettingsController, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in New Issue