context'user is not allowed to push to protected branch'do
beforedo
allow(user_access)
.toreceive(:can_push_to_branch?)
.and_return(false)
end
it'raises an error'do
expect{subject.validate!}.toraise_error(Gitlab::GitAccess::UnauthorizedError,'You are not allowed to push code to protected branches on this project.')
end
end
context'user is allowed to push to protected branch'do
beforedo
allow(user_access)
.toreceive(:can_push_to_branch?)
.and_return(true)
end
it'does not raise an error'do
expect{subject.validate!}.not_toraise_error
end
end
end
context'protected branch creation feature is enabled'do
context'user can push to branch'do
context'user can push to branch'do
beforedo
beforedo
allow(user_access)
allow(user_access)
...
@@ -193,7 +162,6 @@ describe Gitlab::Checks::BranchCheck do
...
@@ -193,7 +162,6 @@ describe Gitlab::Checks::BranchCheck do