debian-mirror-gitlab/spec/services/award_emojis/copy_service_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 lines
1.1 KiB
Ruby
Raw Normal View History

2020-10-24 23:57:45 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-05-27 22:25:52 +05:30
RSpec.describe AwardEmojis::CopyService, feature_category: :team_planning do
2020-10-24 23:57:45 +05:30
let_it_be(:from_awardable) do
2022-11-25 23:54:43 +05:30
create(
:issue,
award_emoji: [
build(:award_emoji, name: 'thumbsup'),
build(:award_emoji, name: 'thumbsdown')
])
2020-10-24 23:57:45 +05:30
end
describe '#initialize' do
it 'validates that we cannot copy AwardEmoji to the same Awardable' do
expect { described_class.new(from_awardable, from_awardable) }.to raise_error(ArgumentError)
end
end
describe '#execute' do
let(:to_awardable) { create(:issue) }
subject(:execute_service) { described_class.new(from_awardable, to_awardable).execute }
it 'copies AwardEmojis', :aggregate_failures do
expect { execute_service }.to change { AwardEmoji.count }.by(2)
expect(to_awardable.award_emoji.map(&:name)).to match_array(%w(thumbsup thumbsdown))
end
it 'returns success', :aggregate_failures do
expect(execute_service).to be_kind_of(ServiceResponse)
expect(execute_service).to be_success
end
end
end