mirror of
https://github.com/mastodon/mastodon.git
synced 2026-05-06 22:08:07 -05:00
Some checks failed
Check i18n / check-i18n (push) Waiting to run
Chromatic / Check for relevant changes (push) Waiting to run
Chromatic / Run Chromatic (push) Blocked by required conditions
Check formatting / lint (push) Waiting to run
CSS Linting / lint (push) Waiting to run
Haml Linting / lint (push) Waiting to run
JavaScript Linting / lint (push) Waiting to run
Ruby Linting / lint (push) Waiting to run
JavaScript Testing / test (push) Waiting to run
Historical data migration test / test (14-alpine) (push) Waiting to run
Historical data migration test / test (15-alpine) (push) Waiting to run
Historical data migration test / test (16-alpine) (push) Waiting to run
Historical data migration test / test (17-alpine) (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / test (3.4) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.4) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.29) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.19.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.29) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.4, docker.elastic.co/elasticsearch/elasticsearch:7.17.29) (push) Blocked by required conditions
Bundler Audit / security (push) Has been cancelled
CodeQL / Analyze (actions) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
CodeQL / Analyze (ruby) (push) Has been cancelled
131 lines
3.6 KiB
Ruby
131 lines
3.6 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
RSpec.describe 'Admin Report Notes' do
|
|
let(:user) { Fabricate(:admin_user) }
|
|
|
|
before { sign_in user }
|
|
|
|
describe 'Creating notes' do
|
|
context 'when report is unresolved' do
|
|
let(:report) { Fabricate(:report, action_taken_at: nil, action_taken_by_account_id: nil) }
|
|
|
|
context 'when resolve is selected' do
|
|
it 'creates a report note and resolves report' do
|
|
visit admin_report_path(report)
|
|
|
|
fill_in 'report_note_content', with: 'Report note text'
|
|
expect { submit_form }
|
|
.to change(ReportNote, :count).by(1)
|
|
expect(report.reload)
|
|
.to be_action_taken
|
|
expect(page)
|
|
.to have_text(success_message)
|
|
end
|
|
|
|
def submit_form
|
|
click_on I18n.t('admin.reports.notes.create_and_resolve')
|
|
end
|
|
end
|
|
|
|
context 'when resolve is not selected' do
|
|
it 'creates a report note and does not resolve report' do
|
|
visit admin_report_path(report)
|
|
|
|
fill_in 'report_note_content', with: 'Report note text'
|
|
expect { submit_form }
|
|
.to change(ReportNote, :count).by(1)
|
|
expect(report.reload)
|
|
.to_not be_action_taken
|
|
expect(page)
|
|
.to have_text(success_message)
|
|
end
|
|
|
|
def submit_form
|
|
click_on I18n.t('admin.reports.notes.create')
|
|
end
|
|
end
|
|
end
|
|
|
|
context 'when report is resolved' do
|
|
let(:report) { Fabricate(:report, action_taken_at: Time.current, action_taken_by_account_id: user.account.id) }
|
|
|
|
context 'when create_and_unresolve flag is on' do
|
|
it 'creates a report note and unresolves report' do
|
|
visit admin_report_path(report)
|
|
|
|
fill_in 'report_note_content', with: 'Report note text'
|
|
expect { submit_form }
|
|
.to change(ReportNote, :count).by(1)
|
|
expect(report.reload)
|
|
.to_not be_action_taken
|
|
expect(page)
|
|
.to have_text(success_message)
|
|
end
|
|
|
|
def submit_form
|
|
click_on I18n.t('admin.reports.notes.create_and_unresolve')
|
|
end
|
|
end
|
|
|
|
context 'when create_and_unresolve flag is false' do
|
|
it 'creates a report note and does not unresolve report' do
|
|
visit admin_report_path(report)
|
|
|
|
fill_in 'report_note_content', with: 'Report note text'
|
|
expect { submit_form }
|
|
.to change(ReportNote, :count).by(1)
|
|
expect(report.reload)
|
|
.to be_action_taken
|
|
expect(page)
|
|
.to have_text(success_message)
|
|
end
|
|
|
|
def submit_form
|
|
click_on I18n.t('admin.reports.notes.create')
|
|
end
|
|
end
|
|
end
|
|
|
|
context 'when content is not valid' do
|
|
let(:report) { Fabricate(:report) }
|
|
|
|
it 'does not create a note' do
|
|
visit admin_report_path(report)
|
|
|
|
fill_in 'report_note_content', with: ''
|
|
expect { submit_form }
|
|
.to_not change(ReportNote, :count)
|
|
expect(page)
|
|
.to have_text(/error below/)
|
|
end
|
|
|
|
def submit_form
|
|
click_on I18n.t('admin.reports.notes.create')
|
|
end
|
|
end
|
|
|
|
def success_message
|
|
I18n.t('admin.report_notes.created_msg')
|
|
end
|
|
end
|
|
|
|
describe 'Removing notes' do
|
|
let!(:report_note) { Fabricate(:report_note) }
|
|
|
|
it 'deletes note' do
|
|
visit admin_report_path(report_note.report)
|
|
|
|
expect { delete_note }
|
|
.to change(ReportNote, :count).by(-1)
|
|
expect(page)
|
|
.to have_text(I18n.t('admin.report_notes.destroyed_msg'))
|
|
end
|
|
|
|
def delete_note
|
|
click_on I18n.t('admin.reports.notes.delete')
|
|
end
|
|
end
|
|
end
|