diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-11-08 19:14:34 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-11-08 19:14:34 +0000 |
commit | 1454a711caf68cd687886ea9b8d44b3a027e6cbc (patch) | |
tree | 28b4150f52d46bc5d8ddae934be0faf6ff36d16c | |
parent | fa95501fe5e8c97de4f5960c4eeecfe70d4455f2 (diff) | |
download | redmine-1454a711caf68cd687886ea9b8d44b3a027e6cbc.tar.gz redmine-1454a711caf68cd687886ea9b8d44b3a027e6cbc.zip |
Diff style (inline or side by side) automatically saved as a user preference.
Fixed a Postgres test failure.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@893 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/controllers/repositories_controller.rb | 9 | ||||
-rw-r--r-- | app/views/repositories/diff.rhtml | 2 | ||||
-rw-r--r-- | test/unit/user_test.rb | 4 |
3 files changed, 11 insertions, 4 deletions
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 235754770..8ff464c5b 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -106,7 +106,14 @@ class RepositoriesController < ApplicationController def diff @rev_to = params[:rev_to] ? params[:rev_to].to_i : (@rev - 1) - @diff_type = ('sbs' == params[:type]) ? 'sbs' : 'inline' + @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 @cache_key = "repositories/diff/#{@repository.id}/" + Digest::MD5.hexdigest("#{@path}-#{@rev}-#{@rev_to}-#{@diff_type}") unless read_fragment(@cache_key) diff --git a/app/views/repositories/diff.rhtml b/app/views/repositories/diff.rhtml index 5094f4713..c1c33a495 100644 --- a/app/views/repositories/diff.rhtml +++ b/app/views/repositories/diff.rhtml @@ -8,7 +8,7 @@ <% end %> <% end %> <p><label><%= l(:label_view_diff) %></label> - <%= select_tag 'type', options_for_select([[l(:label_diff_inline), "inline"], [l(:label_diff_side_by_side), "sbs"]], params[:type]), :onchange => "if (this.value != '') {this.form.submit()}" %></p> + <%= select_tag 'type', options_for_select([[l(:label_diff_inline), "inline"], [l(:label_diff_side_by_side), "sbs"]], @diff_type), :onchange => "if (this.value != '') {this.form.submit()}" %></p> <% end %> <div class="autoscroll"> diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index 397bdf68a..82cbbdaa7 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -116,10 +116,10 @@ class UserTest < Test::Unit::TestCase def test_mail_notification_selected @jsmith.mail_notification = false - @jsmith.notified_project_ids = [@jsmith.projects.first.id] + @jsmith.notified_project_ids = [1] @jsmith.save @jsmith.reload - assert @jsmith.projects.first.recipients.include?(@jsmith.mail) + assert Project.find(1).recipients.include?(@jsmith.mail) end def test_mail_notification_none |