diff options
author | Marco Wessel <marco@poop.nl> | 2015-01-31 09:10:17 +0100 |
---|---|---|
committer | Marco Wessel <marco@poop.nl> | 2015-01-31 09:10:26 +0100 |
commit | ac7af45d8987422c2a529d3d87eae6d9bd608e12 (patch) | |
tree | 3d6b3055429b7b1f2506aac1da5794b58ded0310 /spec | |
parent | 20e269cb925cfad58cce0b19e17aa15075c4481e (diff) | |
download | gitlab-ce-ac7af45d8987422c2a529d3d87eae6d9bd608e12.tar.gz |
Add test for default branch protection configuration
Diffstat (limited to 'spec')
-rw-r--r-- | spec/services/git_push_service_spec.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/services/git_push_service_spec.rb b/spec/services/git_push_service_spec.rb index 02c8133d2c6..3a75d65b5bc 100644 --- a/spec/services/git_push_service_spec.rb +++ b/spec/services/git_push_service_spec.rb @@ -110,6 +110,24 @@ describe GitPushService do service.execute(project, user, @blankrev, 'newrev', 'refs/heads/master') end + it "when pushing a branch for the first time with default branch protection disabled" do + ApplicationSetting.any_instance.stub(default_branch_protection: 0) + + project.should_receive(:execute_hooks) + project.default_branch.should == "master" + project.protected_branches.should_not_receive(:create) + service.execute(project, user, @blankrev, 'newrev', 'refs/heads/master') + end + + it "when pushing a branch for the first time with default branch protection set to 'developers can push'" do + ApplicationSetting.any_instance.stub(default_branch_protection: 1) + + project.should_receive(:execute_hooks) + project.default_branch.should == "master" + project.protected_branches.should_receive(:create).with({ name: "master", developers_can_push: true }) + service.execute(project, user, @blankrev, 'newrev', 'refs/heads/master') + end + it "when pushing new commits to existing branch" do project.should_receive(:execute_hooks) service.execute(project, user, 'oldrev', 'newrev', 'refs/heads/master') |