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

44 lines
1.2 KiB
Ruby

# frozen_string_literal: true
require 'rails_helper'
RSpec.describe UpdateCollectionService do
subject { described_class.new }
let(:collection) { Fabricate(:collection) }
describe '#call' do
context 'when given valid parameters' do
it 'updates the collection' do
subject.call(collection, { name: 'Newly updated name' })
expect(collection.name).to eq 'Newly updated name'
end
context 'when something actually changed' do
it 'federates an `Update` activity', feature: :collections_federation do
subject.call(collection, { name: 'updated' })
expect(ActivityPub::AccountRawDistributionWorker).to have_enqueued_sidekiq_job
end
end
context 'when nothing changed' do
it 'does not federate an activity', feature: :collections_federation do
subject.call(collection, { name: collection.name })
expect(ActivityPub::AccountRawDistributionWorker).to_not have_enqueued_sidekiq_job
end
end
end
context 'when given invalid parameters' do
it 'raises an exception' do
expect do
subject.call(collection, { name: '' })
end.to raise_error(ActiveRecord::RecordInvalid)
end
end
end
end