Skip to content
Snippets Groups Projects
Commit ac7af45d authored by Marco Wessel's avatar Marco Wessel
Browse files

Add test for default branch protection configuration

parent 20e269cb
No related branches found
No related tags found
1 merge request!314Allow configuring protection of default branch upon first push
Loading
@@ -110,6 +110,24 @@ describe GitPushService do
Loading
@@ -110,6 +110,24 @@ describe GitPushService do
service.execute(project, user, @blankrev, 'newrev', 'refs/heads/master') service.execute(project, user, @blankrev, 'newrev', 'refs/heads/master')
end 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 it "when pushing new commits to existing branch" do
project.should_receive(:execute_hooks) project.should_receive(:execute_hooks)
service.execute(project, user, 'oldrev', 'newrev', 'refs/heads/master') service.execute(project, user, 'oldrev', 'newrev', 'refs/heads/master')
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment