mastodon/spec/requests/admin/collections_spec.rb
Pia B. 07a05e1edf
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
CodeQL / Analyze (actions) (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Crowdin / Upload translations / upload-translations (push) Waiting to run
Check formatting / lint (push) Waiting to run
CSS Linting / lint (push) Waiting to run
JavaScript Linting / lint (push) Waiting to run
JavaScript Testing / test (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
Haml Linting / lint (push) Has been cancelled
Ruby Linting / lint (push) Has been cancelled
Historical data migration test / test (14-alpine) (push) Has been cancelled
Historical data migration test / test (15-alpine) (push) Has been cancelled
Historical data migration test / test (16-alpine) (push) Has been cancelled
Historical data migration test / test (17-alpine) (push) Has been cancelled
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Has been cancelled
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.29) (push) Has been cancelled
Ruby Testing / Elastic Search integration testing (3.4, docker.elastic.co/elasticsearch/elasticsearch:7.17.29) (push) Has been cancelled
Add batch remove for collections in reports (#39020)
2026-05-18 14:53:40 +00:00

87 lines
2.8 KiB
Ruby

# frozen_string_literal: true
require 'rails_helper'
RSpec.describe 'Admin Collections' do
let(:account) { Fabricate(:account) }
let(:other_account) { Fabricate(:account) }
let(:collection) { Fabricate(:collection, account: account) }
let(:unreported_collection) { Fabricate(:collection, account: account) }
let(:second_collection) { Fabricate(:collection, account: account) }
let(:report) { Fabricate(:report, account: other_account, target_account: account) }
before do
sign_in Fabricate(:admin_user)
end
describe 'GET /admin/accounts/:account_id/collections/:id' do
let(:collection) { Fabricate(:collection) }
it 'returns success' do
get admin_account_collection_path(collection.account_id, collection)
expect(response)
.to have_http_status(200)
end
end
describe 'GET /admin/accounts/:account_id/collections/' do
it 'returns http success' do
get admin_account_collections_path(account_id: account.id, id: collection.id)
expect(response).to have_http_status(200)
end
end
describe 'POST /admin/accounts/:account_id/collections/batch' do
subject { post batch_admin_account_collections_path(:account_id => account.id, :report_id => report_id, action_from_button => '', :admin_collection_batch_action => { collection_ids: [collection.id, second_collection.id] }) }
context 'with a valid report' do
let(:report_id) { report.id }
let(:action_from_button) { 'report' }
it 'redirects to the report page' do
report.collections << collection
subject
expect(response).to redirect_to(admin_report_path(report.id))
expect(response.body).to be_empty
expect(response).to have_http_status(302)
end
end
context 'with an invalid report' do
let(:report_id) { nil }
let(:action_from_button) { 'report' }
it 'redirects to the account collections page' do
subject
expect(response).to redirect_to(admin_account_collections_path(account.id))
expect(response).to have_http_status(302)
end
end
context 'with valid remove_from_report' do
let(:report_id) { report.id }
let(:action_from_button) { 'remove_from_report' }
before do
report.collections << [second_collection, unreported_collection]
end
it 'redirects to the account collections page' do
subject
expect(response).to redirect_to(admin_report_path(report.id))
end
end
context 'with invalid remove_from_report' do
let(:report_id) { nil }
let(:action_from_button) { 'remove_from_report' }
it 'redirects to the account collections page' do
subject
expect(response).to redirect_to(admin_account_collections_path(account.id))
end
end
end
end