Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/qa/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-06-18 14:18:50 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-06-18 14:18:50 +0300
commit8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch)
treea77e7fe7a93de11213032ed4ab1f33a3db51b738 /qa/spec
parent00b35af3db1abfe813a778f643dad221aad51fca (diff)
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'qa/spec')
-rw-r--r--qa/spec/runtime/feature_spec.rb31
-rw-r--r--qa/spec/scenario/test/instance/airgapped_spec.rb8
-rw-r--r--qa/spec/support/shared_examples/merge_with_code_owner_shared_examples.rb71
3 files changed, 110 insertions, 0 deletions
diff --git a/qa/spec/runtime/feature_spec.rb b/qa/spec/runtime/feature_spec.rb
index 94638d99b01..db3c2f65963 100644
--- a/qa/spec/runtime/feature_spec.rb
+++ b/qa/spec/runtime/feature_spec.rb
@@ -25,6 +25,21 @@ describe QA::Runtime::Feature do
end
end
+ describe '.enable_and_verify' do
+ it 'enables a feature flag' do
+ allow(described_class).to receive(:get).and_return(response_get)
+
+ expect(QA::Runtime::API::Request).to receive(:new)
+ .with(api_client, "/features/a-flag").and_return(request)
+ expect(described_class).to receive(:post)
+ .with(request.url, { value: true }).and_return(response_post)
+ expect(QA::Runtime::API::Request).to receive(:new)
+ .with(api_client, "/features").and_return(request)
+
+ subject.enable_and_verify('a-flag')
+ end
+ end
+
describe '.disable' do
it 'disables a feature flag' do
expect(QA::Runtime::API::Request)
@@ -40,6 +55,22 @@ describe QA::Runtime::Feature do
end
end
+ describe '.disable_and_verify' do
+ it 'disables a feature flag' do
+ allow(described_class).to receive(:get)
+ .and_return(Struct.new(:code, :body).new(200, '[{ "name": "a-flag", "state": "off" }]'))
+
+ expect(QA::Runtime::API::Request).to receive(:new)
+ .with(api_client, "/features/a-flag").and_return(request)
+ expect(described_class).to receive(:post)
+ .with(request.url, { value: false }).and_return(response_post)
+ expect(QA::Runtime::API::Request).to receive(:new)
+ .with(api_client, "/features").and_return(request)
+
+ subject.disable_and_verify('a-flag')
+ end
+ end
+
describe '.enabled?' do
it 'returns a feature flag state' do
expect(QA::Runtime::API::Request)
diff --git a/qa/spec/scenario/test/instance/airgapped_spec.rb b/qa/spec/scenario/test/instance/airgapped_spec.rb
new file mode 100644
index 00000000000..0c4167eafff
--- /dev/null
+++ b/qa/spec/scenario/test/instance/airgapped_spec.rb
@@ -0,0 +1,8 @@
+# frozen_string_literal: true
+
+describe QA::Scenario::Test::Instance::Airgapped do
+ describe '#perform' do
+ it_behaves_like 'a QA scenario class' do
+ end
+ end
+end
diff --git a/qa/spec/support/shared_examples/merge_with_code_owner_shared_examples.rb b/qa/spec/support/shared_examples/merge_with_code_owner_shared_examples.rb
new file mode 100644
index 00000000000..feaeb78815d
--- /dev/null
+++ b/qa/spec/support/shared_examples/merge_with_code_owner_shared_examples.rb
@@ -0,0 +1,71 @@
+# frozen_string_literal: true
+
+module QA
+ shared_examples 'code owner merge request' do
+ let(:branch_name) { 'new-branch' }
+
+ it 'is approved and merged' do
+ # Require one approval from any eligible user on any branch
+ # This will confirm that this type of unrestricted approval is
+ # also satisfied when a code owner grants approval
+ Page::Project::Menu.perform(&:go_to_general_settings)
+ Page::Project::Settings::Main.perform do |main|
+ main.expand_merge_request_approvals_settings do |settings|
+ settings.set_default_number_of_approvals_required(1)
+ end
+ end
+
+ Resource::Repository::Commit.fabricate_via_api! do |commit|
+ commit.project = project
+ commit.commit_message = 'Add CODEOWNERS'
+ commit.add_files(
+ [
+ {
+ file_path: 'CODEOWNERS',
+ content: <<~CONTENT
+ README.md @#{codeowner}
+ CONTENT
+ }
+ ]
+ )
+ end
+
+ # Require approval from code owners on master
+ Resource::ProtectedBranch.fabricate! do |protected_branch|
+ protected_branch.project = project
+ protected_branch.branch_name = 'master'
+ protected_branch.new_branch = false
+ protected_branch.require_code_owner_approval = true
+ end
+
+ # Push a change to the file with a CODEOWNERS rule
+ Resource::Repository::Push.fabricate! do |push|
+ push.repository_http_uri = project.repository_http_location.uri
+ push.branch_name = branch_name
+ push.file_name = 'README.md'
+ push.file_content = 'Updated'
+ end
+
+ merge_request = Resource::MergeRequest.fabricate! do |merge_request|
+ merge_request.project = project
+ merge_request.target_new_branch = false
+ merge_request.source_branch = branch_name
+ merge_request.no_preparation = true
+ end
+
+ Flow::Login.while_signed_in(as: approver) do
+ merge_request.visit!
+
+ Page::MergeRequest::Show.perform do |merge_request|
+ expect(merge_request.approvals_required_from).to include('Code Owners')
+ expect(merge_request).not_to be_mergeable
+
+ merge_request.click_approve
+ merge_request.merge!
+
+ expect(merge_request).to be_merged
+ end
+ end
+ end
+ end
+end