1135 |
1135 |
assert_include 'h1. CookBook documentation v2', @response.body
|
1136 |
1136 |
end
|
1137 |
1137 |
|
1138 |
|
def test_show_filename_should_be_uri_encoded_for_ms_browsers
|
|
1138 |
def test_show_filename_should_be_uri_encoded
|
1139 |
1139 |
@request.session[:user_id] = 2
|
1140 |
1140 |
title = 'Этика_менеджмента'
|
1141 |
1141 |
%w|pdf html txt|.each do |format|
|
... | ... | |
1143 |
1143 |
@request.user_agent = ""
|
1144 |
1144 |
get :show, :params => {:project_id => 1, :id => title, :format => format}
|
1145 |
1145 |
assert_response :success
|
1146 |
|
assert_equal "attachment; filename=\"#{title}.#{format}\"",
|
|
1146 |
ascii_filename = "%3F%3F%3F%3F%3F_%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F%3F.#{format}"
|
|
1147 |
utf8_filename = "%D0%AD%D1%82%D0%B8%D0%BA%D0%B0_%D0%BC%D0%B5%D0%BD%D0%B5%D0%B4%D0%B6%D0%BC%D0%B5%D0%BD%D1%82%D0%B0.#{format}"
|
|
1148 |
assert_equal "attachment; filename=\"#{ascii_filename}\"; filename*=UTF-8''#{utf8_filename}",
|
1147 |
1149 |
@response.headers['Content-Disposition']
|
1148 |
|
# Microsoft's browsers: filename should be URI encoded
|
|
1150 |
# Microsoft's browsers
|
1149 |
1151 |
@request.user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063'
|
1150 |
1152 |
get :show, :params => {:project_id => 1, :id => title, :format => format}
|
1151 |
1153 |
assert_response :success
|
1152 |
|
filename = Addressable::URI.encode("#{title}.#{format}")
|
1153 |
|
assert_equal "attachment; filename=\"#{filename}\"",
|
|
1154 |
assert_equal "attachment; filename=\"#{ascii_filename}\"; filename*=UTF-8''#{utf8_filename}",
|
1154 |
1155 |
@response.headers['Content-Disposition']
|
1155 |
1156 |
end
|
1156 |
1157 |
end
|