0001-Allow-to-download-javascript-attachments-again.patch

Holger Just, 2016-07-19 17:47

Download (3.53 KB)

View differences:

app/controllers/attachments_controller.rb
22 22
  before_action :delete_authorize, :only => :destroy
23 23
  before_action :authorize_global, :only => :upload
24 24

  
25
  # Disable check for same origin requests for JS files, i.e. attachments with
26
  # MIME type text/javascript.
27
  skip_after_filter :verify_same_origin_request, :only => :download
28

  
25 29
  accept_api_auth :show, :download, :thumbnail, :upload, :destroy
26 30

  
27 31
  def show
test/fixtures/attachments.yml
267 267
  filename: root_attachment.txt
268 268
  filesize: 54
269 269
  author_id: 2
270
attachments_021:
271
  created_on: 2016-07-19 15:07:27 +02:00
272
  downloads: 0
273
  content_type: text/javascript
274
  disk_filename: 160719150727_script.js
275
  disk_directory: "2016/07"
276
  container_id: 3
277
  digest: bc279813fab770379fd219f1722ccc3a
278
  id: 21
279
  container_type: Issue
280
  filesize: 16
281
  filename: script.js
282
  author_id: 2
test/fixtures/files/2016/07/160719150727_script.js
1
alert('Hello');
test/functional/attachments_controller_test.rb
252 252
    set_tmp_attachments_directory
253 253
  end
254 254

  
255
  def test_download_js_file
256
    get :download, :id => 21
257
    assert_response :success
258
    assert_equal 'text/javascript', @response.content_type
259
    set_tmp_attachments_directory
260
  end
261

  
255 262
  def test_download_version_file_with_issue_tracking_disabled
256 263
    Project.find(1).disable_module! :issue_tracking
257 264
    get :download, :id => 9
test/integration/api_test/issues_test.rb
296 296
    get '/issues/3.xml?include=attachments'
297 297

  
298 298
    assert_select 'issue attachments[type=array]' do
299
      assert_select 'attachment', 4
299
      assert_select 'attachment', 5
300 300
      assert_select 'attachment id', :text => '1' do
301 301
        assert_select '~ filename', :text => 'error281.txt'
302 302
        assert_select '~ content_url', :text => 'http://www.example.com/attachments/download/1/error281.txt'
303
-