mirror of
https://github.com/mastodon/mastodon.git
synced 2026-05-22 08:38:04 -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
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
61 lines
1.7 KiB
Ruby
61 lines
1.7 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
RSpec.describe Admin::CollectionBatchAction do
|
|
subject do
|
|
described_class.new(
|
|
current_account:,
|
|
collection_ids:,
|
|
report_id:,
|
|
type:
|
|
)
|
|
end
|
|
|
|
let(:account) { Fabricate(:account) }
|
|
let(:target_account) { Fabricate(:account) }
|
|
let(:current_account) { Fabricate(:admin_user).account }
|
|
let(:collection) { Fabricate(:collection, account: account) }
|
|
let(:collection_ids) { [collection.id] }
|
|
let(:report) { Fabricate(:report, account: target_account, target_account: account) }
|
|
let(:type) { 'report' }
|
|
|
|
before 'create collection report' do
|
|
report.collections << collection
|
|
report.save!
|
|
end
|
|
|
|
describe '#save!' do
|
|
context 'when with_report? is true' do
|
|
let(:other_collection) { Fabricate(:collection, account: account) }
|
|
let(:report_id) { report.id }
|
|
|
|
it 'creates no report and adds the collection to the existing report' do
|
|
collection_ids << other_collection.id
|
|
|
|
expect { subject.save! }.to_not change(Report, :count)
|
|
expect(report.collections).to include(other_collection)
|
|
end
|
|
end
|
|
|
|
context 'when with_report? is false' do
|
|
let(:report_id) { nil }
|
|
|
|
it 'creates a new report from the collection_ids' do
|
|
expect { subject.save! }.to change(Report, :count).by(1)
|
|
expect(Report.last.collections).to include(collection)
|
|
end
|
|
end
|
|
|
|
context 'when type is remove_from_report' do
|
|
let(:report_id) { report.id }
|
|
let(:type) { 'remove_from_report' }
|
|
|
|
it 'does not remove report but removes collection' do
|
|
expect { subject.save! }.to change { report.reload.collections }.to([])
|
|
.and not_change(Report, :count)
|
|
end
|
|
end
|
|
end
|
|
end
|