* Add default_settings class method to ScopedSettings ScopedSettings was extended to use value of unscoped setting instead of only using defaults set in config/settings.yml for selected settings. This adds possibility for admins to set default values of users' settings, for example default theme (as requested in #7092). * Add ability to change an instance default theme Closes #7092
This commit is contained in:
parent
d1c2c917d9
commit
6cb3514d64
6 changed files with 51 additions and 3 deletions
|
@ -92,6 +92,39 @@ describe ApplicationController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'helper_method :current_theme' do
|
||||
it 'returns "default" when theme wasn\'t changed in admin settings' do
|
||||
allow(Setting).to receive(:default_settings).and_return({'theme' => 'default'})
|
||||
|
||||
expect(controller.view_context.current_theme).to eq 'default'
|
||||
end
|
||||
|
||||
it 'returns instances\'s theme when user is not signed in' do
|
||||
allow(Setting).to receive(:[]).with('theme').and_return 'contrast'
|
||||
|
||||
expect(controller.view_context.current_theme).to eq 'contrast'
|
||||
end
|
||||
|
||||
it 'returns instances\'s default theme when user didn\'t set theme' do
|
||||
current_user = Fabricate(:user)
|
||||
sign_in current_user
|
||||
|
||||
allow(Setting).to receive(:[]).with('theme').and_return 'contrast'
|
||||
|
||||
expect(controller.view_context.current_theme).to eq 'contrast'
|
||||
end
|
||||
|
||||
it 'returns user\'s theme when it is set' do
|
||||
current_user = Fabricate(:user)
|
||||
current_user.settings['theme'] = 'mastodon-light'
|
||||
sign_in current_user
|
||||
|
||||
allow(Setting).to receive(:[]).with('theme').and_return 'contrast'
|
||||
|
||||
expect(controller.view_context.current_theme).to eq 'mastodon-light'
|
||||
end
|
||||
end
|
||||
|
||||
context 'ActionController::RoutingError' do
|
||||
subject do
|
||||
routes.draw { get 'routing_error' => 'anonymous#routing_error' }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue