diff options
author | David Yip <yipdw@member.fsf.org> | 2018-05-03 17:23:44 -0500 |
---|---|---|
committer | David Yip <yipdw@member.fsf.org> | 2018-05-03 17:23:44 -0500 |
commit | c816701550d7cdb593371dc47d0b9430c78308b0 (patch) | |
tree | cc4417d14de20e69fd5f9a58d66f84af4a623329 /spec/models/report_spec.rb | |
parent | 3a47842223ff93d8c057f804809f1b111dfd6f76 (diff) | |
parent | a7e71bbd08e089938fbf20ddef5768c2f3ee0702 (diff) |
Merge remote-tracking branch 'origin/master' into gs-master
Conflicts: .travis.yml Gemfile.lock README.md app/controllers/settings/follower_domains_controller.rb app/controllers/statuses_controller.rb app/javascript/mastodon/locales/ja.json app/lib/feed_manager.rb app/models/media_attachment.rb app/models/mute.rb app/models/status.rb app/services/mute_service.rb app/views/home/index.html.haml app/views/stream_entries/_simple_status.html.haml config/locales/ca.yml config/locales/en.yml config/locales/es.yml config/locales/fr.yml config/locales/nl.yml config/locales/pl.yml config/locales/pt-BR.yml config/themes.yml
Diffstat (limited to 'spec/models/report_spec.rb')
-rw-r--r-- | spec/models/report_spec.rb | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/spec/models/report_spec.rb b/spec/models/report_spec.rb index d40ebf6dc..a0cd0800d 100644 --- a/spec/models/report_spec.rb +++ b/spec/models/report_spec.rb @@ -22,6 +22,101 @@ describe Report do end end + describe 'assign_to_self!' do + subject { report.assigned_account_id } + + let(:report) { Fabricate(:report, assigned_account_id: original_account) } + let(:original_account) { Fabricate(:account) } + let(:current_account) { Fabricate(:account) } + + before do + report.assign_to_self!(current_account) + end + + it 'assigns to a given account' do + is_expected.to eq current_account.id + end + end + + describe 'unassign!' do + subject { report.assigned_account_id } + + let(:report) { Fabricate(:report, assigned_account_id: account.id) } + let(:account) { Fabricate(:account) } + + before do + report.unassign! + end + + it 'unassigns' do + is_expected.to be_nil + end + end + + describe 'resolve!' do + subject(:report) { Fabricate(:report, action_taken: false, action_taken_by_account_id: nil) } + + let(:acting_account) { Fabricate(:account) } + + before do + report.resolve!(acting_account) + end + + it 'records action taken' do + expect(report).to have_attributes(action_taken: true, action_taken_by_account_id: acting_account.id) + end + end + + describe 'unresolve!' do + subject(:report) { Fabricate(:report, action_taken: true, action_taken_by_account_id: acting_account.id) } + + let(:acting_account) { Fabricate(:account) } + + before do + report.unresolve! + end + + it 'unresolves' do + expect(report).to have_attributes(action_taken: false, action_taken_by_account_id: nil) + end + end + + describe 'unresolved?' do + subject { report.unresolved? } + + let(:report) { Fabricate(:report, action_taken: action_taken) } + + context 'if action is taken' do + let(:action_taken) { true } + + it { is_expected.to be false } + end + + context 'if action not is taken' do + let(:action_taken) { false } + + it { is_expected.to be true } + end + end + + describe 'history' do + subject(:action_logs) { report.history } + + let(:report) { Fabricate(:report, target_account_id: target_account.id, status_ids: [status.id], created_at: 3.days.ago, updated_at: 1.day.ago) } + let(:target_account) { Fabricate(:account) } + let(:status) { Fabricate(:status) } + + before do + Fabricate('Admin::ActionLog', target_type: 'Report', account_id: target_account.id, target_id: report.id, created_at: 2.days.ago) + Fabricate('Admin::ActionLog', target_type: 'Account', account_id: target_account.id, target_id: report.target_account_id, created_at: 2.days.ago) + Fabricate('Admin::ActionLog', target_type: 'Status', account_id: target_account.id, target_id: status.id, created_at: 2.days.ago) + end + + it 'returns right logs' do + expect(action_logs.count).to eq 3 + end + end + describe 'validatiions' do it 'has a valid fabricator' do report = Fabricate(:report) |