@@ -29,6 +29,11 class AttachmentsController < ApplicationController | |||
|
29 | 29 | @diff = File.new(@attachment.diskfile, "rb").read |
|
30 | 30 | @diff_type = params[:type] || User.current.pref[:diff_type] || 'inline' |
|
31 | 31 | @diff_type = 'inline' unless %w(inline sbs).include?(@diff_type) |
|
32 | # Save diff type as user preference | |
|
33 | if User.current.logged? && @diff_type != User.current.pref[:diff_type] | |
|
34 | User.current.pref[:diff_type] = @diff_type | |
|
35 | User.current.preference.save | |
|
36 | end | |
|
32 | 37 | render :action => 'diff' |
|
33 | 38 | elsif @attachment.is_text? && @attachment.filesize <= Setting.file_max_size_displayed.to_i.kilobyte |
|
34 | 39 | @content = File.new(@attachment.diskfile, "rb").read |
@@ -95,6 +95,21 class AttachmentsControllerTest < ActionController::TestCase | |||
|
95 | 95 | set_tmp_attachments_directory |
|
96 | 96 | end |
|
97 | 97 | |
|
98 | def test_save_diff_type | |
|
99 | @request.session[:user_id] = 1 # admin | |
|
100 | user = User.find(1) | |
|
101 | get :show, :id => 5 | |
|
102 | assert_response :success | |
|
103 | assert_template 'diff' | |
|
104 | user.reload | |
|
105 | assert_equal "inline", user.pref[:diff_type] | |
|
106 | get :show, :id => 5, :type => 'sbs' | |
|
107 | assert_response :success | |
|
108 | assert_template 'diff' | |
|
109 | user.reload | |
|
110 | assert_equal "sbs", user.pref[:diff_type] | |
|
111 | end | |
|
112 | ||
|
98 | 113 | def test_show_text_file |
|
99 | 114 | get :show, :id => 4 |
|
100 | 115 | assert_response :success |
General Comments 0
You need to be logged in to leave comments.
Login now