summaryrefslogtreecommitdiff
path: root/spec/services
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-09-19 16:52:33 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-09-19 16:52:33 +0800
commit4c89392528311dacb29c51bb52313cf09f7a57fb (patch)
tree395c760be4e018bcd1a5e19804aa15de300947ea /spec/services
parente0dbd81642d06bc196e8f909e249fd17051d77e3 (diff)
parent1e7ea64e6237f32173f429dfd490c39ccb6b4f7b (diff)
downloadgitlab-ce-4c89392528311dacb29c51bb52313cf09f7a57fb.tar.gz
Merge remote-tracking branch 'upstream/master' into pipeline-emails
* upstream/master: (97 commits) Add missing spec for ProtectedBranches::CreateService Add specs that target status failure Return created status Document how to download the latest build artifacts Clarify why GH integration is the preferred importing method Refactor GitHub importing documentation Update GitHub importer documentation to reflect current importer state Formatting fix in doc/ci/examples/README.md Refactor boards_spec.rb to avoid code duplication Replace contributions calendar timezone payload with dates Use oj gem for faster JSON processing Render invalid template for merge requests without source project and open Bump fog-aws and other dependent modules Fix API notes endpoint when posting only emoji Doesnt run JS if active element doesnt exist Add missing CHANGELOG entry Remove schema annotations completely fixed incorrect reference to @repository.root_ref in _readme.html.haml. #22083 Scrolls active tab into middle of nav on mobile MergeRequest#environments now returns an empty array when diff_head_commit is nil ...
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/protected_branches/create_service_spec.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/services/protected_branches/create_service_spec.rb b/spec/services/protected_branches/create_service_spec.rb
new file mode 100644
index 00000000000..7d4eff3b6ef
--- /dev/null
+++ b/spec/services/protected_branches/create_service_spec.rb
@@ -0,0 +1,23 @@
+require 'spec_helper'
+
+describe ProtectedBranches::CreateService, services: true do
+ let(:project) { create(:empty_project) }
+ let(:user) { project.owner }
+ let(:params) do
+ {
+ name: 'master',
+ merge_access_levels_attributes: [ { access_level: Gitlab::Access::MASTER } ],
+ push_access_levels_attributes: [ { access_level: Gitlab::Access::MASTER } ]
+ }
+ end
+
+ describe '#execute' do
+ subject(:service) { described_class.new(project, user, params) }
+
+ it 'creates a new protected branch' do
+ expect { service.execute }.to change(ProtectedBranch, :count).by(1)
+ expect(project.protected_branches.last.push_access_levels.map(&:access_level)).to eq([Gitlab::Access::MASTER])
+ expect(project.protected_branches.last.merge_access_levels.map(&:access_level)).to eq([Gitlab::Access::MASTER])
+ end
+ end
+end