introduce setting to have default for auto hide notifications

pull/6377/head
Jens Ulferts 6 years ago
parent a0ab2f9032
commit f31388d7f9
No known key found for this signature in database
GPG Key ID: 3CAA4B1182CF5308
  1. 2
      app/models/user_preference.rb
  2. 14
      app/views/settings/_users.html.erb
  3. 3
      config/locales/en.yml
  4. 3
      config/settings.yml
  5. 10
      spec/models/user_preference_spec.rb
  6. 13
      spec/support/shared/with_settings.rb

@ -69,7 +69,7 @@ class UserPreference < ActiveRecord::Base
end end
def auto_hide_popups? def auto_hide_popups?
others[:auto_hide_popups] || false others.fetch(:auto_hide_popups) { Setting.default_auto_hide_popups? }
end end
def warn_on_leaving_unsaved? def warn_on_leaving_unsaved?

@ -29,7 +29,17 @@ See docs/COPYRIGHT.rdoc for more details.
<%= styled_form_tag({ action: 'edit', tab: 'users' }, class: 'admin-settings--form') do %> <%= styled_form_tag({ action: 'edit', tab: 'users' }, class: 'admin-settings--form') do %>
<div class ="form--section"> <div class="form--fieldset">
<legend class="form--fieldset-legend"><%= t(:'settings.user.default_preferences')%></legend>
<div class="form--field">
<%= setting_check_box :default_auto_hide_popups, label: 'activerecord.attributes.user_preference.auto_hide_popups' %>
</div>
</div>
<div class="form--fieldset">
<legend class="form--fieldset-legend"><%= t(:'settings.user.deletion')%></legend>
<div class="form--field"> <div class="form--field">
<%= setting_check_box :users_deletable_by_admins %> <%= setting_check_box :users_deletable_by_admins %>
</div> </div>
@ -39,7 +49,6 @@ See docs/COPYRIGHT.rdoc for more details.
</div> </div>
</div> </div>
<fieldset class="form--fieldset">
<fieldset id="consent_settings" class="form--fieldset"> <fieldset id="consent_settings" class="form--fieldset">
<legend class="form--fieldset-legend"><%= I18n.t(:label_consent_settings) %></legend> <legend class="form--fieldset-legend"><%= I18n.t(:label_consent_settings) %></legend>
@ -75,6 +84,5 @@ See docs/COPYRIGHT.rdoc for more details.
</span> </span>
</div> </div>
</fieldset> </fieldset>
</fieldset>
<%= styled_button_tag l(:button_save), class: '-highlight -with-icon icon-checkmark' %> <%= styled_button_tag l(:button_save), class: '-highlight -with-icon icon-checkmark' %>
<% end %> <% end %>

@ -2067,6 +2067,9 @@ en:
passwords: "Passwords" passwords: "Passwords"
session: "Session" session: "Session"
brute_force_prevention: "Automated user blocking" brute_force_prevention: "Automated user blocking"
user:
default_preferences: "Default preferences"
deletion: "Deletion"
text_formatting: text_formatting:
textile: 'Textile' textile: 'Textile'

@ -167,6 +167,9 @@ available_languages:
- ru - ru
default_language: default_language:
default: en default: en
default_auto_hide_popups:
default: 1
format: boolean
email_login: # use email address as login, hide login in registration form email_login: # use email address as login, hide login in registration form
default: 0 default: 0
host_name: host_name:

@ -45,8 +45,16 @@ describe UserPreference do
expect(subject.others[:no_self_notified]).to be_truthy expect(subject.others[:no_self_notified]).to be_truthy
end end
context 'with default setting auto_hide_popups to false', with_settings: { default_auto_hide_popups: false } do
it 'disables auto hide popups' do it 'disables auto hide popups' do
expect(subject.auto_hide_popups).to eql(false) expect(subject.auto_hide_popups).to be_falsey
end
end
context 'with default setting auto_hide_popups to true', with_settings: { default_auto_hide_popups: true } do
it 'disables auto hide popups' do
expect(subject.auto_hide_popups).to be_truthy
end
end end
end end

@ -46,8 +46,21 @@ RSpec.configure do |config|
settings = aggregate_mocked_settings(example, settings) settings = aggregate_mocked_settings(example, settings)
settings.each do |k, v| settings.each do |k, v|
bare, questionmarked = if k.to_s.ends_with?('?')
[k.to_s[0..-2].to_sym, k]
else
[k, "#{k}?".to_sym]
end
raise "#{k} is not a valid setting" unless Setting.available_settings[bare.to_s]
if Setting.available_settings[bare.to_s]['format'] == 'boolean'
allow(Setting).to receive(bare).and_return(v)
allow(Setting).to receive(questionmarked).and_return(v)
else
allow(Setting).to receive(k).and_return(v) allow(Setting).to receive(k).and_return(v)
end end
end end
end end
end
end end

Loading…
Cancel
Save