Commit f9492554 authored by Micaël Bergeron's avatar Micaël Bergeron

fix specs

parent 1883c596
...@@ -471,6 +471,14 @@ module Gitlab ...@@ -471,6 +471,14 @@ module Gitlab
private private
def parent_ids=(shas)
@parent_ids = case shas
when String then JSON.parse(shas)
else
shas
end
end
def init_from_hash(hash) def init_from_hash(hash)
raw_commit = hash.symbolize_keys raw_commit = hash.symbolize_keys
......
...@@ -74,11 +74,9 @@ describe ProcessCommitWorker do ...@@ -74,11 +74,9 @@ describe ProcessCommitWorker do
describe '#process_commit_message' do describe '#process_commit_message' do
context 'when pushing to the default branch' do context 'when pushing to the default branch' do
it 'closes issues that should be closed per the commit message' do it 'closes issues that should be closed per the commit message' do
allow(commit).to receive(:safe_message) allow(commit).to receive(:safe_message).and_return("Closes #{issue.to_reference}")
.and_return("Closes #{issue.to_reference}")
expect(worker).to receive(:close_issues) expect(worker).to receive(:close_issues).with(project, user, user, commit, [issue])
.with(project, user, user, commit, [issue])
worker.process_commit_message(project, commit, user, user, true) worker.process_commit_message(project, commit, user, user, true)
end end
...@@ -86,8 +84,7 @@ describe ProcessCommitWorker do ...@@ -86,8 +84,7 @@ describe ProcessCommitWorker do
context 'when pushing to a non-default branch' do context 'when pushing to a non-default branch' do
it 'does not close any issues' do it 'does not close any issues' do
allow(commit).to receive(:safe_message) allow(commit).to receive(:safe_message).and_return("Closes #{issue.to_reference}")
.and_return("Closes #{issue.to_reference}")
expect(worker).not_to receive(:close_issues) expect(worker).not_to receive(:close_issues)
...@@ -128,8 +125,7 @@ describe ProcessCommitWorker do ...@@ -128,8 +125,7 @@ describe ProcessCommitWorker do
describe '#update_issue_metrics' do describe '#update_issue_metrics' do
it 'updates any existing issue metrics' do it 'updates any existing issue metrics' do
allow(commit).to receive(:safe_message) allow(commit).to receive(:safe_message).and_return("Closes #{issue.to_reference}")
.and_return("Closes #{issue.to_reference}")
worker.update_issue_metrics(commit, user) worker.update_issue_metrics(commit, user)
...@@ -139,10 +135,10 @@ describe ProcessCommitWorker do ...@@ -139,10 +135,10 @@ describe ProcessCommitWorker do
end end
it "doesn't execute any queries with false conditions" do it "doesn't execute any queries with false conditions" do
allow(commit).to receive(:safe_message) allow(commit).to receive(:safe_message).and_return("Lorem Ipsum")
.and_return("Lorem Ipsum")
expect { worker.update_issue_metrics(commit, user) }.not_to make_queries_matching(/WHERE (?:1=0|0=1)/) expect { worker.update_issue_metrics(commit, user) }
.not_to make_queries_matching(/WHERE (?:1=0|0=1)/)
end end
end end
...@@ -154,8 +150,9 @@ describe ProcessCommitWorker do ...@@ -154,8 +150,9 @@ describe ProcessCommitWorker do
end end
it 'parses date strings into Time instances' do it 'parses date strings into Time instances' do
commit = worker commit = worker.build_commit(project,
.build_commit(project, id: '123', authored_date: Time.now.to_s) id: '123',
authored_date: Time.now.to_s)
expect(commit.authored_date).to be_an_instance_of(Time) expect(commit.authored_date).to be_an_instance_of(Time)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment