diff options
author | Adam Hegyi <ahegyi@gitlab.com> | 2019-07-11 06:48:50 +0200 |
---|---|---|
committer | Adam Hegyi <ahegyi@gitlab.com> | 2019-07-11 15:52:55 +0200 |
commit | dfe906209e2238b82c84c9fb435498cae2f3d43e (patch) | |
tree | 514cf0cd3595fffe175b9cc5eb88dee4881186a8 /spec/uploaders | |
parent | 0cd59a756cdee7aac8915f3e96ba4f065e5cbc9c (diff) | |
download | gitlab-ce-dfe906209e2238b82c84c9fb435498cae2f3d43e.tar.gz |
Queries for Upload should be scoped by model
Diffstat (limited to 'spec/uploaders')
-rw-r--r-- | spec/uploaders/records_uploads_spec.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/uploaders/records_uploads_spec.rb b/spec/uploaders/records_uploads_spec.rb index 42352f9b9f8..6134137d2b7 100644 --- a/spec/uploaders/records_uploads_spec.rb +++ b/spec/uploaders/records_uploads_spec.rb @@ -85,6 +85,27 @@ describe RecordsUploads do expect { existing.reload }.to raise_error(ActiveRecord::RecordNotFound) expect(Upload.count).to eq(1) end + + it 'does not affect other uploads with different model but the same path' do + project = create(:project) + other_project = create(:project) + + uploader = RecordsUploadsExampleUploader.new(other_project) + + upload_for_project = Upload.create!( + path: File.join('uploads', 'rails_sample.jpg'), + size: 512.kilobytes, + model: project, + uploader: uploader.class.to_s + ) + + uploader.store!(upload_fixture('rails_sample.jpg')) + + upload_for_project_fresh = Upload.find(upload_for_project.id) + + expect(upload_for_project).to eq(upload_for_project_fresh) + expect(Upload.count).to eq(2) + end end describe '#destroy_upload callback' do |