[26237] Add configuration option for default comment order (#5896)

https://community.openproject.com/wp/26237
https://community.openproject.com/wp/25932


[ci skip]
pull/5899/head
Oliver Günther 7 years ago committed by GitHub
parent fdff837e85
commit fc50bb72a1
  1. 2
      app/models/user_preference.rb
  2. 4
      config/configuration.yml.example
  3. 1
      lib/open_project/client_preference_extractor.rb
  4. 3
      lib/open_project/configuration.rb
  5. 2
      spec/lib/open_project/client_preference_extractor_spec.rb
  6. 22
      spec/lib/open_project/configuration_spec.rb
  7. 2
      spec_legacy/unit/user_preference_spec.rb

@ -45,7 +45,7 @@ class UserPreference < ActiveRecord::Base
end
def comments_sorting
others[:comments_sorting]
others.fetch(:comments_sorting, OpenProject::Configuration.default_comment_sort_order)
end
def comments_sorting=(order)

@ -208,6 +208,10 @@ default:
# possible values are :cookie_store, :cache_store, :active_record_store
session_store: :cache_store
# Default comment sorting for new users
# Note, does not change saved preferences of existing users
# default_comment_sort_order: 'asc'
# If the session store is :active_record_store, the following configuration settings
# are available

@ -46,6 +46,7 @@ module OpenProject
def user_preferences(user = User.current)
pref = user.pref.clone
pref[:comments_sorting] = user.pref.comments_sorting
map_timezone_to_tz!(pref)
end

@ -66,6 +66,9 @@ module OpenProject
'rails_force_ssl' => false,
'rails_asset_host' => nil,
# user configuration
'default_comment_sort_order' => 'asc',
# email configuration
'email_delivery_configuration' => 'inapp',
'email_delivery_method' => nil,

@ -36,7 +36,7 @@ describe OpenProject::ClientPreferenceExtractor do
shared_examples_for 'preference with timezone' do
before do
expect(user).to receive(:pref) { pref }
allow(user).to receive(:pref) { pref }
end
subject { extractor.user_preferences(user) }

@ -30,23 +30,23 @@ require 'spec_helper'
describe OpenProject::Configuration do
describe '.load_config_from_file' do
let(:config) { Hash.new }
before do
expect(File).to receive(:file?).with('file').and_return(true)
expect(File).to receive(:read).and_return("
default:
let(:file_contents) {
<<-EOS
default:
test:
somesetting: foo
")
somesetting: foo
EOS
}
before do
allow(File).to receive(:read).and_call_original
allow(File).to receive(:read).with('configfilename').and_return(file_contents)
allow(File).to receive(:file?).with('configfilename').and_return(true)
OpenProject::Configuration.send(:load_config_from_file, 'file', 'test', config)
OpenProject::Configuration.load(file: 'configfilename')
end
it 'should merge the config from the file into the given config hash' do
expect(config['somesetting']).to eq('foo')
expect(OpenProject::Configuration['somesetting']).to eq('foo')
expect(OpenProject::Configuration[:somesetting]).to eq('foo')
expect(OpenProject::Configuration.somesetting).to eq('foo')

@ -61,7 +61,7 @@ describe UserPreference do
it 'should update_with_method' do
user = FactoryGirl.create :user
assert_equal nil, user.pref.comments_sorting
assert_equal OpenProject::Configuration.default_comment_sort_order, user.pref.comments_sorting
user.pref.comments_sorting = 'value'
assert user.pref.save

Loading…
Cancel
Save