Replace best_in_place editor on admin settings page (#2789)
* Remove best_in_place * Replace best_in_place usage with rails helpers * Move admin/settings#index to #edit action * Remove click_to__edit from i18n
This commit is contained in:
parent
91ddd345f2
commit
2bd132d458
28 changed files with 117 additions and 97 deletions
|
@ -1,51 +1,65 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Admin::SettingsController, type: :controller do
|
||||
render_views
|
||||
|
||||
before do
|
||||
Rails.cache.clear
|
||||
end
|
||||
|
||||
describe 'When signed in as an admin' do
|
||||
before do
|
||||
sign_in Fabricate(:user, admin: true), scope: :user
|
||||
end
|
||||
|
||||
describe 'GET #index' do
|
||||
describe 'GET #edit' do
|
||||
it 'returns http success' do
|
||||
get :index
|
||||
get :edit
|
||||
|
||||
expect(response).to have_http_status(:success)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'PUT #update' do
|
||||
|
||||
describe 'for a record that doesnt exist' do
|
||||
after do
|
||||
Setting.new_setting_key = nil
|
||||
end
|
||||
|
||||
it 'creates a settings value that didnt exist before' do
|
||||
it 'cannot create a setting value for a non-admin key' do
|
||||
expect(Setting.new_setting_key).to be_nil
|
||||
|
||||
patch :update, params: { id: 'new_setting_key', setting: { value: 'New key value' } }
|
||||
patch :update, params: { new_setting_key: 'New key value' }
|
||||
|
||||
expect(response).to redirect_to(admin_settings_path)
|
||||
expect(Setting.new_setting_key).to eq 'New key value'
|
||||
expect(response).to redirect_to(edit_admin_settings_path)
|
||||
expect(Setting.new_setting_key).to be_nil
|
||||
end
|
||||
|
||||
it 'creates a settings value that didnt exist before for eligible key' do
|
||||
expect(Setting.site_extended_description).to be_blank
|
||||
|
||||
patch :update, params: { site_extended_description: 'New key value' }
|
||||
|
||||
expect(response).to redirect_to(edit_admin_settings_path)
|
||||
expect(Setting.site_extended_description).to eq 'New key value'
|
||||
end
|
||||
end
|
||||
|
||||
it 'updates a settings value' do
|
||||
Setting.site_title = 'Original'
|
||||
patch :update, params: { id: 'site_title', setting: { value: 'New title' } }
|
||||
patch :update, params: { site_title: 'New title' }
|
||||
|
||||
expect(response).to redirect_to(admin_settings_path)
|
||||
expect(response).to redirect_to(edit_admin_settings_path)
|
||||
expect(Setting.site_title).to eq 'New title'
|
||||
end
|
||||
|
||||
it 'typecasts open_registrations to boolean' do
|
||||
Setting.open_registrations = false
|
||||
patch :update, params: { id: 'open_registrations', setting: { value: 'true' } }
|
||||
patch :update, params: { open_registrations: 'true' }
|
||||
|
||||
expect(response).to redirect_to(admin_settings_path)
|
||||
expect(response).to redirect_to(edit_admin_settings_path)
|
||||
expect(Setting.open_registrations).to eq true
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue