replace create_uploaded_file in specs

mock_uploaded_file creates a Rack::Test::UploadedFile, which should behave equally to a real uploaded file,
but is also treated correctly by Rack::Test
pull/3032/head
Jan Sandbrink 10 years ago
parent fe74804909
commit bc3437c3b0
  1. 2
      spec/controllers/attachments_controller_spec.rb
  2. 2
      spec/exemplars/attachment_exemplar.rb
  3. 2
      spec/factories/attachment_factory.rb
  4. 2
      spec/factories/file_factory.rb
  5. 2
      spec/legacy/support/legacy_assertions.rb
  6. 4
      spec/legacy/unit/attachment_spec.rb
  7. 2
      spec/legacy/unit/helpers/application_helper_spec.rb

@ -101,7 +101,7 @@ describe AttachmentsController, type: :controller do
end
describe '#show' do
let(:file) { OpenProject::Files.create_uploaded_file name: 'foobar.txt' }
let(:file) { OpenProject::Files.mock_uploaded_file name: 'foobar.txt' }
let(:work_package) { FactoryGirl.create :work_package, project: project }
let(:uploader) { nil }

@ -41,6 +41,6 @@ class Attachment < ActiveRecord::Base
end
def self.generate_file
@file = Test::Files.create_uploaded_file
@file = Test::Files.mock_uploaded_file
end
end

@ -37,7 +37,7 @@ FactoryGirl.define do
content_type 'application/binary'
sequence(:file) do |n|
OpenProject::Files.create_uploaded_file name: filename || "file-#{n}.test",
OpenProject::Files.mock_uploaded_file name: filename || "file-#{n}.test",
content_type: content_type,
binary: true
end

@ -50,7 +50,7 @@ FactoryGirl.define do
binary false
initialize_with do
OpenProject::Files.create_uploaded_file(
OpenProject::Files.mock_uploaded_file(
name: name,
content: content,
content_type: content_type,

@ -49,7 +49,7 @@ module LegacyAssertionsAndHelpers
a.file = uploaded_test_file a.disk_filename, a.attributes['content_type'],
original_filename: a.attributes['filename']
rescue # imaginary file: create it on-the-fly
a.file = create_uploaded_file name: a.attributes['filename'],
a.file = mock_uploaded_file name: a.attributes['filename'],
content_type: a.attributes['content_type']
end

@ -69,8 +69,8 @@ describe Attachment, type: :model do
@issue = WorkPackage.find(1)
response = Attachment.attach_files(
@issue,
'1' => { 'file' => create_uploaded_file, 'description' => 'test 1' },
'2' => { 'file' => create_uploaded_file, 'description' => 'test 2' })
'1' => { 'file' => mock_uploaded_file, 'description' => 'test 1' },
'2' => { 'file' => mock_uploaded_file, 'description' => 'test 2' })
assert response[:unsaved].present?
assert_equal 2, response[:unsaved].length

@ -47,7 +47,7 @@ describe ApplicationHelper, type: :helper do
@issue = FactoryGirl.create :work_package, project: @project, author: @project_member, type: @project.types.first
file = create_uploaded_file name: 'logo.gif',
file = mock_uploaded_file name: 'logo.gif',
content_type: 'image/gif',
content: 'not actually a gif',
binary: true

Loading…
Cancel
Save