diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
commit | 6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch) | |
tree | 78be5963ec075d80116a932011d695dd33910b4e /spec/services/award_emojis | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'spec/services/award_emojis')
-rw-r--r-- | spec/services/award_emojis/copy_service_spec.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/services/award_emojis/copy_service_spec.rb b/spec/services/award_emojis/copy_service_spec.rb new file mode 100644 index 00000000000..e85c548968e --- /dev/null +++ b/spec/services/award_emojis/copy_service_spec.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe AwardEmojis::CopyService do + let_it_be(:from_awardable) do + create(:issue, award_emoji: [ + build(:award_emoji, name: 'thumbsup'), + build(:award_emoji, name: 'thumbsdown') + ]) + 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 |