mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 03:51:07 +08:00
remove useless upload topic direct association
This commit is contained in:
@ -14,64 +14,54 @@ describe UploadsController do
|
||||
|
||||
context '.create' do
|
||||
|
||||
context 'missing params' do
|
||||
it 'raises an error without the topic_id param' do
|
||||
-> { xhr :post, :create }.should raise_error(ActionController::ParameterMissing)
|
||||
let(:logo) do
|
||||
ActionDispatch::Http::UploadedFile.new({
|
||||
filename: 'logo.png',
|
||||
type: 'image/png',
|
||||
tempfile: File.new("#{Rails.root}/spec/fixtures/images/logo.png")
|
||||
})
|
||||
end
|
||||
|
||||
let(:logo_dev) do
|
||||
ActionDispatch::Http::UploadedFile.new({
|
||||
filename: 'logo-dev.png',
|
||||
type: 'image/png',
|
||||
tempfile: File.new("#{Rails.root}/spec/fixtures/images/logo-dev.png")
|
||||
})
|
||||
end
|
||||
|
||||
let(:text_file) do
|
||||
ActionDispatch::Http::UploadedFile.new({
|
||||
filename: 'LICENSE.txt',
|
||||
type: 'text/plain',
|
||||
tempfile: File.new("#{Rails.root}/LICENSE.txt")
|
||||
})
|
||||
end
|
||||
|
||||
let(:files) { [ logo_dev, logo ] }
|
||||
|
||||
context 'with a file' do
|
||||
it 'is succesful' do
|
||||
xhr :post, :create, file: logo
|
||||
response.should be_success
|
||||
end
|
||||
|
||||
it 'supports only images' do
|
||||
xhr :post, :create, file: text_file
|
||||
response.status.should eq 415
|
||||
end
|
||||
end
|
||||
|
||||
context 'correct params' do
|
||||
context 'with some files' do
|
||||
|
||||
let(:logo) do
|
||||
ActionDispatch::Http::UploadedFile.new({
|
||||
filename: 'logo.png',
|
||||
type: 'image/png',
|
||||
tempfile: File.new("#{Rails.root}/spec/fixtures/images/logo.png")
|
||||
})
|
||||
it 'is succesful' do
|
||||
xhr :post, :create, files: files
|
||||
response.should be_success
|
||||
end
|
||||
|
||||
let(:logo_dev) do
|
||||
ActionDispatch::Http::UploadedFile.new({
|
||||
filename: 'logo-dev.png',
|
||||
type: 'image/png',
|
||||
tempfile: File.new("#{Rails.root}/spec/fixtures/images/logo-dev.png")
|
||||
})
|
||||
end
|
||||
|
||||
let(:text_file) do
|
||||
ActionDispatch::Http::UploadedFile.new({
|
||||
filename: 'LICENSE.txt',
|
||||
type: 'text/plain',
|
||||
tempfile: File.new("#{Rails.root}/LICENSE.txt")
|
||||
})
|
||||
end
|
||||
|
||||
let(:files) { [ logo_dev, logo ] }
|
||||
|
||||
context 'with a file' do
|
||||
it 'is succesful' do
|
||||
xhr :post, :create, topic_id: 1234, file: logo
|
||||
response.should be_success
|
||||
end
|
||||
|
||||
it 'supports only images' do
|
||||
xhr :post, :create, topic_id: 1234, file: text_file
|
||||
response.status.should eq 415
|
||||
end
|
||||
end
|
||||
|
||||
context 'with some files' do
|
||||
|
||||
it 'is succesful' do
|
||||
xhr :post, :create, topic_id: 1234, files: files
|
||||
response.should be_success
|
||||
end
|
||||
|
||||
it 'takes the first file' do
|
||||
xhr :post, :create, topic_id: 1234, files: files
|
||||
response.body.should match /logo-dev.png/
|
||||
end
|
||||
|
||||
it 'takes the first file' do
|
||||
xhr :post, :create, files: files
|
||||
response.body.should match /logo-dev.png/
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user