summaryrefslogtreecommitdiff
path: root/spec/features/protected_branches_spec.rb
diff options
context:
space:
mode:
authorTimothy Andrew <mail@timothyandrew.net>2016-07-08 14:18:50 +0530
committerTimothy Andrew <mail@timothyandrew.net>2016-07-29 15:20:39 +0530
commit9fa661472e5e1e2edc91032a6093a3516974e27e (patch)
tree4721d5a5e098363e99c6e50eb344f30793a88018 /spec/features/protected_branches_spec.rb
parent12387b4d2c6abbe1de2fc6b0776207d9135c29f0 (diff)
downloadgitlab-ce-9fa661472e5e1e2edc91032a6093a3516974e27e.tar.gz
Update protected branches spec to work with the `select`s.
1. Get the existing spec passing. 2. Add specs for all the access control options, both while creating and updating protected branches. 3. Show a flash notice when updating protected branches, primarily so the spec knows when the update is done.
Diffstat (limited to 'spec/features/protected_branches_spec.rb')
-rw-r--r--spec/features/protected_branches_spec.rb75
1 files changed, 75 insertions, 0 deletions
diff --git a/spec/features/protected_branches_spec.rb b/spec/features/protected_branches_spec.rb
index d94dee0c797..087e3677169 100644
--- a/spec/features/protected_branches_spec.rb
+++ b/spec/features/protected_branches_spec.rb
@@ -81,4 +81,79 @@ feature 'Projected Branches', feature: true, js: true do
end
end
end
+
+ describe "access control" do
+ [
+ ['developers', 'Developers + Masters'],
+ ['masters', 'Masters'],
+ ['no_one', 'No one']
+ ].each do |access_type_id, access_type_name|
+ it "allows creating protected branches that #{access_type_name} can push to" do
+ visit namespace_project_protected_branches_path(project.namespace, project)
+ set_protected_branch_name('master')
+ within('.new_protected_branch') do
+ find(".allowed-to-push").click
+ click_on access_type_name
+ end
+ click_on "Protect"
+
+ expect(ProtectedBranch.count).to eq(1)
+ expect(ProtectedBranch.last.allowed_to_push).to eq(access_type_id)
+ end
+
+ # This spec fails on PhantomJS versions below 2.0, which don't support `PATCH` requests.
+ # https://github.com/ariya/phantomjs/issues/11384
+ it "allows updating protected branches so that #{access_type_name} can push to them" do
+ visit namespace_project_protected_branches_path(project.namespace, project)
+ set_protected_branch_name('master')
+ click_on "Protect"
+
+ expect(ProtectedBranch.count).to eq(1)
+
+ within(".protected-branches-list") do
+ find(".allowed-to-push").click
+ within('.dropdown-menu.push') { click_on access_type_name }
+ end
+
+ expect(page).to have_content "Updated protected branch"
+ expect(ProtectedBranch.last.allowed_to_push).to eq(access_type_id)
+ end
+ end
+
+ [
+ ['developers', 'Developers + Masters'],
+ ['masters', 'Masters']
+ ].each do |access_type_id, access_type_name|
+ it "allows creating protected branches that #{access_type_name} can merge to" do
+ visit namespace_project_protected_branches_path(project.namespace, project)
+ set_protected_branch_name('master')
+ within('.new_protected_branch') do
+ find(".allowed-to-merge").click
+ click_on access_type_name
+ end
+ click_on "Protect"
+
+ expect(ProtectedBranch.count).to eq(1)
+ expect(ProtectedBranch.last.allowed_to_merge).to eq(access_type_id)
+ end
+
+ # This spec fails on PhantomJS versions below 2.0, which don't support `PATCH` requests.
+ # https://github.com/ariya/phantomjs/issues/11384
+ it "allows updating protected branches so that #{access_type_name} can merge to them" do
+ visit namespace_project_protected_branches_path(project.namespace, project)
+ set_protected_branch_name('master')
+ click_on "Protect"
+
+ expect(ProtectedBranch.count).to eq(1)
+
+ within(".protected-branches-list") do
+ find(".allowed-to-merge").click
+ within('.dropdown-menu.merge') { click_on access_type_name }
+ end
+
+ expect(page).to have_content "Updated protected branch"
+ expect(ProtectedBranch.last.allowed_to_merge).to eq(access_type_id)
+ end
+ end
+ end
end