Fix Projects::UploadService spec
For reasons unknown, this spec was passing a project's repository as the first argument to `Projects::UploadService`, while it was expecting the project itself. Previously this wasn't a problem because `FileUploader` only needed the object to respond to `path_with_namespace`, which Repository and Project both did. But now because of `Upload` and its polymorphic association, it expects the object to respond to `primary_key`.
This commit is contained in:
parent
c72648ca07
commit
2cfb67dfef
|
@ -10,7 +10,7 @@ describe Projects::UploadService, services: true do
|
||||||
context 'for valid gif file' do
|
context 'for valid gif file' do
|
||||||
before do
|
before do
|
||||||
gif = fixture_file_upload(Rails.root + 'spec/fixtures/banana_sample.gif', 'image/gif')
|
gif = fixture_file_upload(Rails.root + 'spec/fixtures/banana_sample.gif', 'image/gif')
|
||||||
@link_to_file = upload_file(@project.repository, gif)
|
@link_to_file = upload_file(@project, gif)
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(@link_to_file).to have_key(:alt) }
|
it { expect(@link_to_file).to have_key(:alt) }
|
||||||
|
@ -23,7 +23,7 @@ describe Projects::UploadService, services: true do
|
||||||
before do
|
before do
|
||||||
png = fixture_file_upload(Rails.root + 'spec/fixtures/dk.png',
|
png = fixture_file_upload(Rails.root + 'spec/fixtures/dk.png',
|
||||||
'image/png')
|
'image/png')
|
||||||
@link_to_file = upload_file(@project.repository, png)
|
@link_to_file = upload_file(@project, png)
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(@link_to_file).to have_key(:alt) }
|
it { expect(@link_to_file).to have_key(:alt) }
|
||||||
|
@ -35,7 +35,7 @@ describe Projects::UploadService, services: true do
|
||||||
context 'for valid jpg file' do
|
context 'for valid jpg file' do
|
||||||
before do
|
before do
|
||||||
jpg = fixture_file_upload(Rails.root + 'spec/fixtures/rails_sample.jpg', 'image/jpg')
|
jpg = fixture_file_upload(Rails.root + 'spec/fixtures/rails_sample.jpg', 'image/jpg')
|
||||||
@link_to_file = upload_file(@project.repository, jpg)
|
@link_to_file = upload_file(@project, jpg)
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(@link_to_file).to have_key(:alt) }
|
it { expect(@link_to_file).to have_key(:alt) }
|
||||||
|
@ -47,7 +47,7 @@ describe Projects::UploadService, services: true do
|
||||||
context 'for txt file' do
|
context 'for txt file' do
|
||||||
before do
|
before do
|
||||||
txt = fixture_file_upload(Rails.root + 'spec/fixtures/doc_sample.txt', 'text/plain')
|
txt = fixture_file_upload(Rails.root + 'spec/fixtures/doc_sample.txt', 'text/plain')
|
||||||
@link_to_file = upload_file(@project.repository, txt)
|
@link_to_file = upload_file(@project, txt)
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(@link_to_file).to have_key(:alt) }
|
it { expect(@link_to_file).to have_key(:alt) }
|
||||||
|
@ -60,14 +60,14 @@ describe Projects::UploadService, services: true do
|
||||||
before do
|
before do
|
||||||
txt = fixture_file_upload(Rails.root + 'spec/fixtures/doc_sample.txt', 'text/plain')
|
txt = fixture_file_upload(Rails.root + 'spec/fixtures/doc_sample.txt', 'text/plain')
|
||||||
allow(txt).to receive(:size) { 1000.megabytes.to_i }
|
allow(txt).to receive(:size) { 1000.megabytes.to_i }
|
||||||
@link_to_file = upload_file(@project.repository, txt)
|
@link_to_file = upload_file(@project, txt)
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(@link_to_file).to eq(nil) }
|
it { expect(@link_to_file).to eq(nil) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def upload_file(repository, file)
|
def upload_file(project, file)
|
||||||
Projects::UploadService.new(repository, file).execute
|
Projects::UploadService.new(project, file).execute
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue