OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
readd diff_type to user preferences
ulfertsbb9befbcb9f1
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rbindex 7b0ec95394e..936758a0503 100644--- a/app/controllers/repositories_controller.rb+++ b/app/controllers/repositories_controller.rb@@ -259,14 +259,7 @@ class RepositoriesController < ApplicationControllertype: 'text/x-patch',disposition: 'attachment'else- @diff_type = params[:type] || User.current.pref[:diff_type] || 'inline'- @diff_type = 'inline' unless %w(inline sbs).include?(@diff_type)-- # Save diff type as user preference- if User.current.logged? && @diff_type != User.current.pref[:diff_type]- User.current.pref[:diff_type] = @diff_type- User.current.preference.save- end+ @diff_type = diff_type_persisted@cache_key = "repositories/diff/#{@repository.id}/" +Digest::MD5.hexdigest("#{@path}-#{@rev}-#{@rev_to}-#{@diff_type}")@@ -497,6 +490,21 @@ class RepositoriesController < ApplicationController# rails looking for e.g text when .txt is asked forrender 'entry', formats: [:html]end++ def diff_type_persisted+ preferences = current_user.pref++ diff_type = params[:type] || preferences.diff_type+ diff_type = 'inline' unless %w(inline sbs).include?(diff_type)++ # Save diff type as user preference+ if current_user.logged? && diff_type != preferences.diff_type+ preferences.diff_type = diff_type+ preferences.save+ end++ diff_type+ endendclass Datediff --git a/app/models/user_preference.rb b/app/models/user_preference.rbindex ba052f349f3..9c861ea653d 100644--- a/app/models/user_preference.rb+++ b/app/models/user_preference.rb@@ -85,6 +85,10 @@ class UserPreference < ApplicationRecordcomments_sorting == 'desc'end+ def diff_type+ settings.fetch(:diff_type, 'inline')+ end+def hide_mailsettings.fetch(:hide_mail, true)enddiff --git a/config/schemas/user_preferences.schema.json b/config/schemas/user_preferences.schema.jsonindex ee1931c0e6f..aa9d71eab74 100644--- a/config/schemas/user_preferences.schema.json+++ b/config/schemas/user_preferences.schema.json@@ -22,6 +22,10 @@"auto_hide_popups": {"type": "boolean"},+ "diff_type": {+ "type": "string",+ "enum": ["inline", "sbs"]+ },"workdays": {"type": "array","items": {diff --git a/spec/models/user_preference_spec.rb b/spec/models/user_preference_spec.rbindex 68534f8fbff..7a878fcad91 100644--- a/spec/models/user_preference_spec.rb+++ b/spec/models/user_preference_spec.rb@@ -140,6 +140,27 @@ describe UserPreference doendend+ describe '#diff_type' do+ it 'can be set and written' do+ expect(subject.diff_type)+ .to eql 'inline'++ subject.diff_type = 'sbs'++ expect(subject.diff_type)+ .to eql 'sbs'+ end++ context 'with a new pref instance' do+ subject { described_class.new }++ it 'defaults to `inline`' do+ expect(subject.diff_type)+ .to eql 'inline'+ end+ end+ end+describe '#daily_reminders' docontext 'without reminders being stored' doit 'uses the defaults' do