diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-07 15:08:27 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-09-07 15:08:27 +0300 |
commit | a8653790086d284cecffdc35892bb422cd6c9a7b (patch) | |
tree | 8d1f4dc69026a42a47b1026eef2566c7461a52fe /spec/serializers/merge_request_sidebar_extras_entity_spec.rb | |
parent | 444f662b8d8cbe47a8f3fa1db6ed926d64f3def3 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/serializers/merge_request_sidebar_extras_entity_spec.rb')
-rw-r--r-- | spec/serializers/merge_request_sidebar_extras_entity_spec.rb | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/spec/serializers/merge_request_sidebar_extras_entity_spec.rb b/spec/serializers/merge_request_sidebar_extras_entity_spec.rb new file mode 100644 index 00000000000..74e9956c8a0 --- /dev/null +++ b/spec/serializers/merge_request_sidebar_extras_entity_spec.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe MergeRequestSidebarExtrasEntity do + let_it_be(:assignee) { build(:user) } + let_it_be(:reviewer) { build(:user) } + let_it_be(:user) { build(:user) } + let_it_be(:project) { create :project, :repository } + + let(:params) do + { + source_project: project, + target_project: project, + assignees: [assignee], + reviewers: [reviewer] + } + end + + let(:resource) do + build(:merge_request, params) + end + + let(:request) { double('request', current_user: user, project: project) } + + let(:entity) { described_class.new(resource, request: request).as_json } + + describe '#assignees' do + it 'contains assignees attributes' do + expect(entity[:assignees].count).to be 1 + expect(entity[:assignees].first.keys).to include( + :id, :name, :username, :state, :avatar_url, :web_url, :can_merge + ) + end + end + + describe '#reviewers' do + context 'when merge_request_reviewers feature is disabled' do + it 'does not contain reviewers attributes' do + stub_feature_flags(merge_request_reviewers: false) + + expect(entity[:reviewers]).to be_nil + end + end + + context 'when merge_request_reviewers feature is enabled' do + it 'contains reviewers attributes' do + stub_feature_flags(merge_request_reviewers: true) + + expect(entity[:reviewers].count).to be 1 + expect(entity[:reviewers].first.keys).to include( + :id, :name, :username, :state, :avatar_url, :web_url, :can_merge + ) + end + end + end +end |