mirror of
https://github.com/kikobar/mastodon.git
synced 2024-12-24 14:54:13 +00:00
Reports spec for media attachments, clean up method (#2660)
* Add coverage for Report#media_attachments * Direct query on media attachment
This commit is contained in:
parent
b83bc0ae64
commit
5259319cf5
|
@ -13,10 +13,6 @@ class Report < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def media_attachments
|
def media_attachments
|
||||||
media_attachments = []
|
MediaAttachment.where(status_id: status_ids)
|
||||||
statuses.each do |s|
|
|
||||||
media_attachments.concat s.media_attachments
|
|
||||||
end
|
|
||||||
media_attachments
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,4 +10,15 @@ describe Report do
|
||||||
expect(report.statuses).to eq [status]
|
expect(report.statuses).to eq [status]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'media_attachments' do
|
||||||
|
it 'returns media attachments from statuses' do
|
||||||
|
status = Fabricate(:status)
|
||||||
|
media_attachment = Fabricate(:media_attachment, status: status)
|
||||||
|
_other_media_attachment = Fabricate(:media_attachment)
|
||||||
|
report = Fabricate(:report, status_ids: [status.id])
|
||||||
|
|
||||||
|
expect(report.media_attachments).to eq [media_attachment]
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue