Skip to content

Commit 2ee9f34

Browse files
committed
[TAN-5736] Remove file attachment specs
The file_attachments_as_legacy_files_spec.rb overlapped with other acceptance tests, especially idea_files_spec.rb and project_files_spec.rb. This commit removes the redundant file and integrates the relevant parts into the existing test files to reduce duplication.
1 parent deb1e1e commit 2ee9f34

File tree

3 files changed

+75
-267
lines changed

3 files changed

+75
-267
lines changed

back/spec/acceptance/files/file_attachments_as_legacy_files_spec.rb

Lines changed: 0 additions & 214 deletions
This file was deleted.

back/spec/acceptance/idea_files_spec.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,22 @@
9494

9595
delete 'web_api/v1/ideas/:idea_id/files/:file_id' do
9696
let(:idea_id) { @idea.id }
97-
let(:file_id) { @idea.file_attachments.first.id }
97+
let(:file_attachment) { @idea.file_attachments.first }
98+
let(:file_id) { file_attachment.id }
99+
100+
example 'Delete the file attachment by id and its underlying file' do
101+
file_id = file_attachment.file_id
98102

99-
example 'Delete file attachment from an idea' do
100103
expect { do_request }
101104
.to change(Files::FileAttachment, :count).by(-1)
105+
# Special case: idea files are automatically deleted when detached from their idea
106+
.and change(Files::File, :count).by(-1)
102107
.and not_change(IdeaFile, :count)
103108

104109
assert_status 200
105110

106-
expect { Files::FileAttachment.find(file_id) }
107-
.to raise_error(ActiveRecord::RecordNotFound)
111+
expect { Files::File.find(file_id) }.to raise_error(ActiveRecord::RecordNotFound)
112+
expect { file_attachment.reload }.to raise_error(ActiveRecord::RecordNotFound)
108113
end
109114
end
110115
end

0 commit comments

Comments
 (0)