diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-17 14:33:21 +0300 |
commit | 7021455bd1ed7b125c55eb1b33c5a01f2bc55ee0 (patch) | |
tree | 5bdc2229f5198d516781f8d24eace62fc7e589e9 /spec/lib/gitlab/github_import/representation | |
parent | 185b095e93520f96e9cfc31d9c3e69b498cdab7c (diff) |
Add latest changes from gitlab-org/gitlab@15-6-stable-eev15.6.0-rc42
Diffstat (limited to 'spec/lib/gitlab/github_import/representation')
-rw-r--r-- | spec/lib/gitlab/github_import/representation/protected_branch_spec.rb | 15 | ||||
-rw-r--r-- | spec/lib/gitlab/github_import/representation/pull_requests/review_requests_spec.rb | 49 |
2 files changed, 61 insertions, 3 deletions
diff --git a/spec/lib/gitlab/github_import/representation/protected_branch_spec.rb b/spec/lib/gitlab/github_import/representation/protected_branch_spec.rb index 30b29659eee..60cae79459e 100644 --- a/spec/lib/gitlab/github_import/representation/protected_branch_spec.rb +++ b/spec/lib/gitlab/github_import/representation/protected_branch_spec.rb @@ -24,6 +24,10 @@ RSpec.describe Gitlab::GithubImport::Representation::ProtectedBranch do it 'includes the protected branch required_pull_request_reviews' do expect(protected_branch.required_pull_request_reviews).to eq true end + + it 'includes the protected branch require_code_owner_reviews' do + expect(protected_branch.require_code_owner_reviews).to eq true + end end end @@ -35,7 +39,10 @@ RSpec.describe Gitlab::GithubImport::Representation::ProtectedBranch do keyword_init: true ) enabled_setting = Struct.new(:enabled, keyword_init: true) - required_pull_request_reviews = Struct.new(:url, :dismissal_restrictions, keyword_init: true) + required_pull_request_reviews = Struct.new( + :url, :dismissal_restrictions, :require_code_owner_reviews, + keyword_init: true + ) response.new( url: 'https://example.com/branches/main/protection', allow_force_pushes: enabled_setting.new( @@ -49,7 +56,8 @@ RSpec.describe Gitlab::GithubImport::Representation::ProtectedBranch do ), required_pull_request_reviews: required_pull_request_reviews.new( url: 'https://example.com/branches/main/protection/required_pull_request_reviews', - dismissal_restrictions: {} + dismissal_restrictions: {}, + require_code_owner_reviews: true ) ) end @@ -67,7 +75,8 @@ RSpec.describe Gitlab::GithubImport::Representation::ProtectedBranch do 'allow_force_pushes' => true, 'required_conversation_resolution' => true, 'required_signatures' => true, - 'required_pull_request_reviews' => true + 'required_pull_request_reviews' => true, + 'require_code_owner_reviews' => true } end diff --git a/spec/lib/gitlab/github_import/representation/pull_requests/review_requests_spec.rb b/spec/lib/gitlab/github_import/representation/pull_requests/review_requests_spec.rb new file mode 100644 index 00000000000..0393f692a69 --- /dev/null +++ b/spec/lib/gitlab/github_import/representation/pull_requests/review_requests_spec.rb @@ -0,0 +1,49 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Gitlab::GithubImport::Representation::PullRequests::ReviewRequests do + shared_examples 'Review requests' do + it 'returns an instance of Review Request' do + expect(review_requests).to be_an_instance_of(described_class) + end + + context 'for returned Review Requests' do + it 'includes merge request id' do + expect(review_requests.merge_request_id).to eq(merge_request_id) + end + + it 'includes reviewers' do + expect(review_requests.users.size).to eq 2 + + user = review_requests.users[0] + expect(user).to be_an_instance_of(Gitlab::GithubImport::Representation::User) + expect(user.id).to eq(4) + expect(user.login).to eq('alice') + end + end + end + + let(:merge_request_id) { 6501124486 } + let(:response) do + { + 'merge_request_id' => merge_request_id, + 'users' => [ + { 'id' => 4, 'login' => 'alice' }, + { 'id' => 5, 'login' => 'bob' } + ] + } + end + + describe '.from_api_response' do + it_behaves_like 'Review requests' do + let(:review_requests) { described_class.from_api_response(response) } + end + end + + describe '.from_json_hash' do + it_behaves_like 'Review requests' do + let(:review_requests) { described_class.from_json_hash(response) } + end + end +end |