Commit 356b2d2b authored by Rémy Coutable's avatar Rémy Coutable

Get rid of `is_image` in FileUploader

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent c266c7fa
...@@ -42,7 +42,6 @@ class FileUploader < CarrierWave::Uploader::Base ...@@ -42,7 +42,6 @@ class FileUploader < CarrierWave::Uploader::Base
{ {
alt: filename, alt: filename,
url: self.secure_url, url: self.secure_url,
is_image: image_or_video?,
markdown: markdown markdown: markdown
} }
end end
......
...@@ -850,7 +850,6 @@ Parameters: ...@@ -850,7 +850,6 @@ Parameters:
{ {
"alt": "dk", "alt": "dk",
"url": "/uploads/66dbcd21ec5d24ed6ea225176098d52b/dk.png", "url": "/uploads/66dbcd21ec5d24ed6ea225176098d52b/dk.png",
"is_image": true,
"markdown": "![dk](/uploads/66dbcd21ec5d24ed6ea225176098d52b/dk.png)" "markdown": "![dk](/uploads/66dbcd21ec5d24ed6ea225176098d52b/dk.png)"
} }
``` ```
......
...@@ -14,9 +14,9 @@ describe Projects::UploadsController do ...@@ -14,9 +14,9 @@ describe Projects::UploadsController do
context "without params['file']" do context "without params['file']" do
it "returns an error" do it "returns an error" do
post :create, post :create,
namespace_id: project.namespace.to_param, namespace_id: project.namespace.to_param,
project_id: project.to_param, project_id: project.to_param,
format: :json format: :json
expect(response).to have_http_status(422) expect(response).to have_http_status(422)
end end
...@@ -34,23 +34,21 @@ describe Projects::UploadsController do ...@@ -34,23 +34,21 @@ describe Projects::UploadsController do
it 'returns a content with original filename, new link, and correct type.' do it 'returns a content with original filename, new link, and correct type.' do
expect(response.body).to match '\"alt\":\"rails_sample\"' expect(response.body).to match '\"alt\":\"rails_sample\"'
expect(response.body).to match "\"url\":\"/uploads" expect(response.body).to match "\"url\":\"/uploads"
expect(response.body).to match '\"is_image\":true'
end end
end end
context 'with valid non-image file' do context 'with valid non-image file' do
before do before do
post :create, post :create,
namespace_id: project.namespace.to_param, namespace_id: project.namespace.to_param,
project_id: project.to_param, project_id: project.to_param,
file: txt, file: txt,
format: :json format: :json
end end
it 'returns a content with original filename, new link, and correct type.' do it 'returns a content with original filename, new link, and correct type.' do
expect(response.body).to match '\"alt\":\"doc_sample.txt\"' expect(response.body).to match '\"alt\":\"doc_sample.txt\"'
expect(response.body).to match "\"url\":\"/uploads" expect(response.body).to match "\"url\":\"/uploads"
expect(response.body).to match '\"is_image\":false'
end end
end end
end end
......
...@@ -11,7 +11,6 @@ describe Gitlab::Email::AttachmentUploader, lib: true do ...@@ -11,7 +11,6 @@ describe Gitlab::Email::AttachmentUploader, lib: true do
link = links.first link = links.first
expect(link).not_to be_nil expect(link).not_to be_nil
expect(link[:is_image]).to be_truthy
expect(link[:alt]).to eq("bricks") expect(link[:alt]).to eq("bricks")
expect(link[:url]).to include("bricks.png") expect(link[:url]).to include("bricks.png")
end end
......
...@@ -115,7 +115,6 @@ describe Gitlab::Email::Receiver, lib: true do ...@@ -115,7 +115,6 @@ describe Gitlab::Email::Receiver, lib: true do
[ [
{ {
url: "uploads/image.png", url: "uploads/image.png",
is_image: true,
alt: "image", alt: "image",
markdown: markdown markdown: markdown
} }
......
...@@ -396,7 +396,6 @@ describe API::API, api: true do ...@@ -396,7 +396,6 @@ describe API::API, api: true do
expect(json_response['alt']).to eq("dk") expect(json_response['alt']).to eq("dk")
expect(json_response['url']).to start_with("/uploads/") expect(json_response['url']).to start_with("/uploads/")
expect(json_response['url']).to end_with("/dk.png") expect(json_response['url']).to end_with("/dk.png")
expect(json_response['is_image']).to eq(true)
end end
end end
......
...@@ -35,8 +35,6 @@ describe Projects::DownloadService, services: true do ...@@ -35,8 +35,6 @@ describe Projects::DownloadService, services: true do
it { expect(@link_to_file).to have_key(:alt) } it { expect(@link_to_file).to have_key(:alt) }
it { expect(@link_to_file).to have_key(:url) } it { expect(@link_to_file).to have_key(:url) }
it { expect(@link_to_file).to have_key(:is_image) }
it { expect(@link_to_file[:is_image]).to be true }
it { expect(@link_to_file[:url]).to match('rails_sample.jpg') } it { expect(@link_to_file[:url]).to match('rails_sample.jpg') }
it { expect(@link_to_file[:alt]).to eq('rails_sample') } it { expect(@link_to_file[:alt]).to eq('rails_sample') }
end end
...@@ -49,8 +47,6 @@ describe Projects::DownloadService, services: true do ...@@ -49,8 +47,6 @@ describe Projects::DownloadService, services: true do
it { expect(@link_to_file).to have_key(:alt) } it { expect(@link_to_file).to have_key(:alt) }
it { expect(@link_to_file).to have_key(:url) } it { expect(@link_to_file).to have_key(:url) }
it { expect(@link_to_file).to have_key(:is_image) }
it { expect(@link_to_file[:is_image]).to be false }
it { expect(@link_to_file[:url]).to match('doc_sample.txt') } it { expect(@link_to_file[:url]).to match('doc_sample.txt') }
it { expect(@link_to_file[:alt]).to eq('doc_sample.txt') } it { expect(@link_to_file[:alt]).to eq('doc_sample.txt') }
end end
......
...@@ -15,9 +15,7 @@ describe Projects::UploadService, services: true do ...@@ -15,9 +15,7 @@ describe Projects::UploadService, services: true do
it { expect(@link_to_file).to have_key(:alt) } it { expect(@link_to_file).to have_key(:alt) }
it { expect(@link_to_file).to have_key(:url) } it { expect(@link_to_file).to have_key(:url) }
it { expect(@link_to_file).to have_key(:is_image) }
it { expect(@link_to_file).to have_value('banana_sample') } it { expect(@link_to_file).to have_value('banana_sample') }
it { expect(@link_to_file[:is_image]).to equal(true) }
it { expect(@link_to_file[:url]).to match('banana_sample.gif') } it { expect(@link_to_file[:url]).to match('banana_sample.gif') }
end end
...@@ -31,8 +29,6 @@ describe Projects::UploadService, services: true do ...@@ -31,8 +29,6 @@ describe Projects::UploadService, services: true do
it { expect(@link_to_file).to have_key(:alt) } it { expect(@link_to_file).to have_key(:alt) }
it { expect(@link_to_file).to have_key(:url) } it { expect(@link_to_file).to have_key(:url) }
it { expect(@link_to_file).to have_value('dk') } it { expect(@link_to_file).to have_value('dk') }
it { expect(@link_to_file).to have_key(:is_image) }
it { expect(@link_to_file[:is_image]).to equal(true) }
it { expect(@link_to_file[:url]).to match('dk.png') } it { expect(@link_to_file[:url]).to match('dk.png') }
end end
...@@ -44,9 +40,7 @@ describe Projects::UploadService, services: true do ...@@ -44,9 +40,7 @@ describe Projects::UploadService, services: true do
it { expect(@link_to_file).to have_key(:alt) } it { expect(@link_to_file).to have_key(:alt) }
it { expect(@link_to_file).to have_key(:url) } it { expect(@link_to_file).to have_key(:url) }
it { expect(@link_to_file).to have_key(:is_image) }
it { expect(@link_to_file).to have_value('rails_sample') } it { expect(@link_to_file).to have_value('rails_sample') }
it { expect(@link_to_file[:is_image]).to equal(true) }
it { expect(@link_to_file[:url]).to match('rails_sample.jpg') } it { expect(@link_to_file[:url]).to match('rails_sample.jpg') }
end end
...@@ -58,9 +52,7 @@ describe Projects::UploadService, services: true do ...@@ -58,9 +52,7 @@ describe Projects::UploadService, services: true do
it { expect(@link_to_file).to have_key(:alt) } it { expect(@link_to_file).to have_key(:alt) }
it { expect(@link_to_file).to have_key(:url) } it { expect(@link_to_file).to have_key(:url) }
it { expect(@link_to_file).to have_key(:is_image) }
it { expect(@link_to_file).to have_value('doc_sample.txt') } it { expect(@link_to_file).to have_value('doc_sample.txt') }
it { expect(@link_to_file[:is_image]).to equal(false) }
it { expect(@link_to_file[:url]).to match('doc_sample.txt') } it { expect(@link_to_file[:url]).to match('doc_sample.txt') }
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment