You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
3.7 KiB

Spelling (#17705) * spelling: account Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: affiliated Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: appearance Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: autosuggest Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: cacheable Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: component Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: conversations Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: domain.example Clarify what's distinct and use RFC friendly domain space. Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: environment Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: exceeds Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: functional Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: inefficiency Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: not Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: notifications Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: occurring Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: position Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: progress Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: promotable Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: reblogging Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: repetitive Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: resolve Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: saturated Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: similar Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: strategies Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: success Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: targeting Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: thumbnails Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: unauthorized Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: unsensitizes Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: validations Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> * spelling: various Signed-off-by: Josh Soref <jsoref@users.noreply.github.com> Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
2 years ago
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe Report do
  4. describe 'statuses' do
  5. it 'returns the statuses for the report' do
  6. status = Fabricate(:status)
  7. _other = Fabricate(:status)
  8. report = Fabricate(:report, status_ids: [status.id])
  9. expect(report.statuses).to eq [status]
  10. end
  11. end
  12. describe 'media_attachments_count' do
  13. it 'returns count of media attachments in statuses' do
  14. status1 = Fabricate(:status, ordered_media_attachment_ids: [1, 2])
  15. status2 = Fabricate(:status, ordered_media_attachment_ids: [5])
  16. report = Fabricate(:report, status_ids: [status1.id, status2.id])
  17. expect(report.media_attachments_count).to eq 3
  18. end
  19. end
  20. describe 'assign_to_self!' do
  21. subject { report.assigned_account_id }
  22. let(:report) { Fabricate(:report, assigned_account_id: original_account) }
  23. let(:original_account) { Fabricate(:account) }
  24. let(:current_account) { Fabricate(:account) }
  25. before do
  26. report.assign_to_self!(current_account)
  27. end
  28. it 'assigns to a given account' do
  29. expect(subject).to eq current_account.id
  30. end
  31. end
  32. describe 'unassign!' do
  33. subject { report.assigned_account_id }
  34. let(:report) { Fabricate(:report, assigned_account_id: account.id) }
  35. let(:account) { Fabricate(:account) }
  36. before do
  37. report.unassign!
  38. end
  39. it 'unassigns' do
  40. expect(subject).to be_nil
  41. end
  42. end
  43. describe 'resolve!' do
  44. subject(:report) { Fabricate(:report, action_taken_at: nil, action_taken_by_account_id: nil) }
  45. let(:acting_account) { Fabricate(:account) }
  46. before do
  47. report.resolve!(acting_account)
  48. end
  49. it 'records action taken' do
  50. expect(report.action_taken?).to be true
  51. expect(report.action_taken_by_account_id).to eq acting_account.id
  52. end
  53. end
  54. describe 'unresolve!' do
  55. subject(:report) { Fabricate(:report, action_taken_at: Time.now.utc, action_taken_by_account_id: acting_account.id) }
  56. let(:acting_account) { Fabricate(:account) }
  57. before do
  58. report.unresolve!
  59. end
  60. it 'unresolves' do
  61. expect(report.action_taken?).to be false
  62. expect(report.action_taken_by_account_id).to be_nil
  63. end
  64. end
  65. describe 'unresolved?' do
  66. subject { report.unresolved? }
  67. let(:report) { Fabricate(:report, action_taken_at: action_taken) }
  68. context 'if action is taken' do
  69. let(:action_taken) { Time.now.utc }
  70. it { is_expected.to be false }
  71. end
  72. context 'if action not is taken' do
  73. let(:action_taken) { nil }
  74. it { is_expected.to be true }
  75. end
  76. end
  77. describe 'history' do
  78. subject(:action_logs) { report.history }
  79. let(:report) { Fabricate(:report, target_account_id: target_account.id, status_ids: [status.id], created_at: 3.days.ago, updated_at: 1.day.ago) }
  80. let(:target_account) { Fabricate(:account) }
  81. let(:status) { Fabricate(:status) }
  82. before do
  83. Fabricate('Admin::ActionLog', target_type: 'Report', account_id: target_account.id, target_id: report.id, created_at: 2.days.ago)
  84. Fabricate('Admin::ActionLog', target_type: 'Account', account_id: target_account.id, target_id: report.target_account_id, created_at: 2.days.ago)
  85. Fabricate('Admin::ActionLog', target_type: 'Status', account_id: target_account.id, target_id: status.id, created_at: 2.days.ago)
  86. end
  87. it 'returns right logs' do
  88. expect(action_logs.count).to eq 3
  89. end
  90. end
  91. describe 'validations' do
  92. it 'is invalid if comment is longer than 1000 characters' do
  93. report = Fabricate.build(:report, comment: Faker::Lorem.characters(number: 1001))
  94. report.valid?
  95. expect(report).to model_have_error_on_field(:comment)
  96. end
  97. end
  98. end