summaryrefslogtreecommitdiff
path: root/spec/services
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2015-05-21 17:49:06 -0400
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-06-22 12:13:46 +0200
commit5a9ede472150ec78f8410ae15cf782095c8f056c (patch)
tree5cbdbfb971329960011e8b3a3544e583f9551f6c /spec/services
parentdad88568f34bfda5f7fe34672bc5099c80226138 (diff)
downloadgitlab-ce-5a9ede472150ec78f8410ae15cf782095c8f056c.tar.gz
Update mock and stub syntax for specs
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/git_push_service_spec.rb26
1 files changed, 16 insertions, 10 deletions
diff --git a/spec/services/git_push_service_spec.rb b/spec/services/git_push_service_spec.rb
index d0941fa2e07..648b2afd7fb 100644
--- a/spec/services/git_push_service_spec.rb
+++ b/spec/services/git_push_service_spec.rb
@@ -124,7 +124,8 @@ describe GitPushService do
end
it "when pushing a branch for the first time with default branch protection disabled" do
- ApplicationSetting.any_instance.stub(default_branch_protection: 0)
+ allow_any_instance_of(ApplicationSetting).
+ to receive(:default_branch_protection).and_return(0)
expect(project).to receive(:execute_hooks)
expect(project.default_branch).to eq("master")
@@ -133,7 +134,8 @@ describe GitPushService do
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)
+ allow_any_instance_of(ApplicationSetting).
+ to receive(:default_branch_protection).and_return(1)
expect(project).to receive(:execute_hooks)
expect(project.default_branch).to eq("master")
@@ -154,13 +156,13 @@ describe GitPushService do
let(:commit) { project.commit }
before do
- commit.stub({
+ allow(commit).to receive_messages(
safe_message: "this commit \n mentions ##{issue.id}",
references: [issue],
author_name: commit_author.name,
author_email: commit_author.email
- })
- project.repository.stub(commits_between: [commit])
+ )
+ allow(project.repository).to receive(:commits_between).and_return([commit])
end
it "creates a note if a pushed commit mentions an issue" do
@@ -178,7 +180,10 @@ describe GitPushService do
end
it "defaults to the pushing user if the commit's author is not known" do
- commit.stub(author_name: 'unknown name', author_email: 'unknown@email.com')
+ allow(commit).to receive_messages(
+ author_name: 'unknown name',
+ author_email: 'unknown@email.com'
+ )
expect(Note).to receive(:create_cross_reference_note).with(issue, commit, user)
service.execute(project, user, @oldrev, @newrev, @ref)
@@ -201,14 +206,15 @@ describe GitPushService do
let(:closing_commit) { project.commit }
before do
- closing_commit.stub({
+ allow(closing_commit).to receive_messages(
issue_closing_regex: /^([Cc]loses|[Ff]ixes) #\d+/,
safe_message: "this is some work.\n\ncloses ##{issue.iid}",
author_name: commit_author.name,
author_email: commit_author.email
- })
+ )
- project.repository.stub(commits_between: [closing_commit])
+ allow(project.repository).to receive(:commits_between).
+ and_return([closing_commit])
end
it "closes issues with commit messages" do
@@ -224,7 +230,7 @@ describe GitPushService do
end
it "doesn't close issues when pushed to non-default branches" do
- project.stub(default_branch: 'durf')
+ allow(project).to receive(:default_branch).and_return('durf')
# The push still shouldn't create cross-reference notes.
expect {