mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-30 10:58:31 -05:00
FIX: don't mess with fixtures when running the specs
This commit is contained in:
parent
186ce78cb5
commit
b5c57fa947
8 changed files with 18 additions and 13 deletions
|
@ -3,7 +3,7 @@ require "avatar_upload_service"
|
|||
|
||||
describe AvatarUploadService do
|
||||
|
||||
let(:logo) { File.new("#{Rails.root}/spec/fixtures/images/logo.png") }
|
||||
let(:logo) { file_from_fixtures("logo.png") }
|
||||
|
||||
let(:file) do
|
||||
ActionDispatch::Http::UploadedFile.new({ filename: 'logo.png', tempfile: logo })
|
||||
|
|
|
@ -6,7 +6,7 @@ describe FileStore::LocalStore do
|
|||
let(:store) { FileStore::LocalStore.new }
|
||||
|
||||
let(:upload) { build(:upload) }
|
||||
let(:uploaded_file) { File.new("#{Rails.root}/spec/fixtures/images/logo.png") }
|
||||
let(:uploaded_file) { file_from_fixtures("logo.png") }
|
||||
|
||||
let(:optimized_image) { build(:optimized_image) }
|
||||
let(:avatar) { build(:upload) }
|
||||
|
|
|
@ -7,13 +7,13 @@ describe FileStore::S3Store do
|
|||
let(:store) { FileStore::S3Store.new }
|
||||
|
||||
let(:upload) { build(:upload) }
|
||||
let(:uploaded_file) { File.new("#{Rails.root}/spec/fixtures/images/logo.png") }
|
||||
let(:uploaded_file) { file_from_fixtures("logo.png") }
|
||||
|
||||
let(:optimized_image) { build(:optimized_image) }
|
||||
let(:optimized_image_file) { File.new("#{Rails.root}/spec/fixtures/images/logo.png") }
|
||||
let(:optimized_image_file) { file_from_fixtures("logo.png") }
|
||||
|
||||
let(:avatar) { build(:upload) }
|
||||
let(:avatar_file) { File.new("#{Rails.root}/spec/fixtures/images/logo-dev.png") }
|
||||
let(:avatar_file) { file_from_fixtures("logo-dev.png") }
|
||||
|
||||
before(:each) do
|
||||
SiteSetting.stubs(:s3_upload_bucket).returns("S3_Upload_Bucket")
|
||||
|
|
|
@ -103,7 +103,7 @@ describe CategoriesController do
|
|||
describe "logged in" do
|
||||
let!(:user) { log_in(:admin) }
|
||||
|
||||
let(:logo) { File.new("#{Rails.root}/spec/fixtures/images/logo.png") }
|
||||
let(:logo) { file_from_fixtures("logo.png") }
|
||||
let(:upload) do
|
||||
ActionDispatch::Http::UploadedFile.new({ filename: 'logo.png', tempfile: logo })
|
||||
end
|
||||
|
|
|
@ -15,14 +15,14 @@ describe UploadsController do
|
|||
let(:logo) do
|
||||
ActionDispatch::Http::UploadedFile.new({
|
||||
filename: 'logo.png',
|
||||
tempfile: File.new("#{Rails.root}/spec/fixtures/images/logo.png")
|
||||
tempfile: file_from_fixtures("logo.png")
|
||||
})
|
||||
end
|
||||
|
||||
let(:logo_dev) do
|
||||
ActionDispatch::Http::UploadedFile.new({
|
||||
filename: 'logo-dev.png',
|
||||
tempfile: File.new("#{Rails.root}/spec/fixtures/images/logo-dev.png")
|
||||
tempfile: file_from_fixtures("logo-dev.png")
|
||||
})
|
||||
end
|
||||
|
||||
|
|
|
@ -1113,7 +1113,7 @@ describe UsersController do
|
|||
|
||||
let!(:user) { log_in }
|
||||
|
||||
let(:logo) { File.new("#{Rails.root}/spec/fixtures/images/logo.png") }
|
||||
let(:logo) { file_from_fixtures("logo.png") }
|
||||
|
||||
let(:user_image) do
|
||||
ActionDispatch::Http::UploadedFile.new({ filename: 'logo.png', tempfile: logo })
|
||||
|
|
|
@ -15,10 +15,9 @@ describe Upload do
|
|||
let(:user_id) { 1 }
|
||||
let(:url) { "http://domain.com" }
|
||||
|
||||
let(:image_path) { "#{Rails.root}/spec/fixtures/images/logo.png" }
|
||||
let(:image) { File.new(image_path) }
|
||||
let(:image_filename) { File.basename(image_path) }
|
||||
let(:image_filesize) { File.size(image_path) }
|
||||
let(:image) { file_from_fixtures("logo.png") }
|
||||
let(:image_filename) { "logo.png" }
|
||||
let(:image_filesize) { File.size(image) }
|
||||
let(:image_sha1) { Digest::SHA1.file(image).hexdigest }
|
||||
|
||||
let(:attachment_path) { __FILE__ }
|
||||
|
|
|
@ -110,6 +110,12 @@ Spork.prefork do
|
|||
Time.stubs(:now).returns(Time.parse(now.to_s))
|
||||
end
|
||||
|
||||
def file_from_fixtures(filename)
|
||||
FileUtils.mkdir_p("#{Rails.root}/tmp/spec") unless Dir.exists?("#{Rails.root}/tmp/spec")
|
||||
FileUtils.cp("#{Rails.root}/spec/fixtures/images/#{filename}", "#{Rails.root}/tmp/spec/#{filename}")
|
||||
File.new("#{Rails.root}/tmp/spec/#{filename}")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Spork.each_run do
|
||||
|
|
Loading…
Reference in a new issue