1
0

report_spec.rb 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. require 'rails_helper'
  2. describe Report do
  3. describe 'statuses' do
  4. it 'returns the statuses for the report' do
  5. status = Fabricate(:status)
  6. _other = Fabricate(:status)
  7. report = Fabricate(:report, status_ids: [status.id])
  8. expect(report.statuses).to eq [status]
  9. end
  10. end
  11. describe 'media_attachments' do
  12. it 'returns media attachments from statuses' do
  13. status = Fabricate(:status)
  14. media_attachment = Fabricate(:media_attachment, status: status)
  15. _other_media_attachment = Fabricate(:media_attachment)
  16. report = Fabricate(:report, status_ids: [status.id])
  17. expect(report.media_attachments).to eq [media_attachment]
  18. end
  19. end
  20. describe 'validatiions' do
  21. it 'has a valid fabricator' do
  22. report = Fabricate(:report)
  23. report.valid?
  24. expect(report).to be_valid
  25. end
  26. it 'is invalid if comment is longer than 1000 characters' do
  27. report = Fabricate.build(:report, comment: Faker::Lorem.characters(1001))
  28. report.valid?
  29. expect(report).to model_have_error_on_field(:comment)
  30. end
  31. end
  32. end