mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-19 15:01:14 +00:00
attachment: fix that diff type is not saved in user preference (#10152)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8761 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
af50c1e13e
commit
2789cf2506
@ -29,6 +29,11 @@ class AttachmentsController < ApplicationController
|
|||||||
@diff = File.new(@attachment.diskfile, "rb").read
|
@diff = File.new(@attachment.diskfile, "rb").read
|
||||||
@diff_type = params[:type] || User.current.pref[:diff_type] || 'inline'
|
@diff_type = params[:type] || User.current.pref[:diff_type] || 'inline'
|
||||||
@diff_type = 'inline' unless %w(inline sbs).include?(@diff_type)
|
@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
|
||||||
render :action => 'diff'
|
render :action => 'diff'
|
||||||
elsif @attachment.is_text? && @attachment.filesize <= Setting.file_max_size_displayed.to_i.kilobyte
|
elsif @attachment.is_text? && @attachment.filesize <= Setting.file_max_size_displayed.to_i.kilobyte
|
||||||
@content = File.new(@attachment.diskfile, "rb").read
|
@content = File.new(@attachment.diskfile, "rb").read
|
||||||
|
|||||||
@ -95,6 +95,21 @@ class AttachmentsControllerTest < ActionController::TestCase
|
|||||||
set_tmp_attachments_directory
|
set_tmp_attachments_directory
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_save_diff_type
|
||||||
|
@request.session[:user_id] = 1 # admin
|
||||||
|
user = User.find(1)
|
||||||
|
get :show, :id => 5
|
||||||
|
assert_response :success
|
||||||
|
assert_template 'diff'
|
||||||
|
user.reload
|
||||||
|
assert_equal "inline", user.pref[:diff_type]
|
||||||
|
get :show, :id => 5, :type => 'sbs'
|
||||||
|
assert_response :success
|
||||||
|
assert_template 'diff'
|
||||||
|
user.reload
|
||||||
|
assert_equal "sbs", user.pref[:diff_type]
|
||||||
|
end
|
||||||
|
|
||||||
def test_show_text_file
|
def test_show_text_file
|
||||||
get :show, :id => 4
|
get :show, :id => 4
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user