summaryrefslogtreecommitdiff
path: root/qa/qa/specs/features
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2018-04-23 17:42:56 +0800
committerLin Jen-Shin <godfat@godfat.org>2018-04-23 17:42:56 +0800
commit1421469e221a14b9250d162f42e3b418528a501d (patch)
tree671d36b1d1e8c0d1b541c524bbb98c2e8f334864 /qa/qa/specs/features
parent71c6be4abb180c98b75174d4569695aee46e2b5d (diff)
parent508ad87ed70bb74da01f8da4ffc5fbe7cb137db9 (diff)
downloadgitlab-ce-1421469e221a14b9250d162f42e3b418528a501d.tar.gz
Merge remote-tracking branch 'upstream/master' into qa-add-more-key-tests
* upstream/master: (166 commits) Flowdock uses Gitaly, not Grit Removes 'no job log' from trace action Fix missing namespace for some internal users Dedupe yarn dependencies Downgrade MySQL CI service from 8.0 to 5.7 Atomic internal ids for all models Add documentation on how to configure Redis Sentinel by persistent class Update CHANGELOG.md for 10.7.0 Update index.md Resolve "Text from the diff is showing within a table header inside the discussion after the discussion is resolved" Don't include lfs_file_locks data in export bundle Documentation: Frontend Building Checklist Fix a documentation typo for GitLab pages Refactored activity calendar Add an API endpoint to download git repository snapshots Fix issues without links when added from boards new issue modal Respect visibility options and description when importing project from template Resolve "Improve tooltips of collapsed sidebars" Update Container Scanning documentation Fix typo in vue.md ...
Diffstat (limited to 'qa/qa/specs/features')
-rw-r--r--qa/qa/specs/features/repository/protected_branches_spec.rb63
1 files changed, 63 insertions, 0 deletions
diff --git a/qa/qa/specs/features/repository/protected_branches_spec.rb b/qa/qa/specs/features/repository/protected_branches_spec.rb
new file mode 100644
index 00000000000..88fa4994e32
--- /dev/null
+++ b/qa/qa/specs/features/repository/protected_branches_spec.rb
@@ -0,0 +1,63 @@
+module QA
+ feature 'branch protection support', :core do
+ given(:branch_name) { 'protected-branch' }
+ given(:commit_message) { 'Protected push commit message' }
+ given(:project) do
+ Factory::Resource::Project.fabricate! do |resource|
+ resource.name = 'protected-branch-project'
+ end
+ end
+ given(:location) do
+ Page::Project::Show.act do
+ choose_repository_clone_http
+ repository_location
+ end
+ end
+
+ before do
+ Runtime::Browser.visit(:gitlab, Page::Main::Login)
+ Page::Main::Login.act { sign_in_using_credentials }
+ end
+
+ scenario 'user is able to protect a branch' do
+ protected_branch = Factory::Resource::Branch.fabricate! do |resource|
+ resource.branch_name = branch_name
+ resource.project = project
+ resource.allow_to_push = true
+ resource.protected = true
+ end
+
+ expect(protected_branch.name).to have_content(branch_name)
+ expect(protected_branch.push_allowance).to have_content('Developers + Masters')
+ end
+
+ scenario 'users without authorization cannot push to protected branch' do
+ Factory::Resource::Branch.fabricate! do |resource|
+ resource.branch_name = branch_name
+ resource.project = project
+ resource.allow_to_push = false
+ resource.protected = true
+ end
+
+ project.visit!
+
+ Git::Repository.perform do |repository|
+ repository.location = location
+ repository.use_default_credentials
+
+ repository.act do
+ clone
+ configure_identity('GitLab QA', 'root@gitlab.com')
+ checkout('protected-branch')
+ commit_file('README.md', 'readme content', 'Add a readme')
+ push_changes('protected-branch')
+ end
+
+ expect(repository.push_error)
+ .to match(/remote\: GitLab\: You are not allowed to push code to protected branches on this project/)
+ expect(repository.push_error)
+ .to match(/\[remote rejected\] #{branch_name} -> #{branch_name} \(pre-receive hook declined\)/)
+ end
+ end
+ end
+end