BigW Consortium Gitlab

Commit e109166d by Timothy Andrew

Fix spec failures.

parent 8747f29d
...@@ -527,7 +527,11 @@ class MergeRequest < ActiveRecord::Base ...@@ -527,7 +527,11 @@ class MergeRequest < ActiveRecord::Base
# Return the set of issues that will be closed if this merge request is accepted. # Return the set of issues that will be closed if this merge request is accepted.
def closes_issues(current_user = self.author) def closes_issues(current_user = self.author)
if target_branch == project.default_branch if target_branch == project.default_branch
messages = commits.map(&:safe_message) << description messages = if merge_request_diff
commits.map(&:safe_message) << description
else
[description]
end
Gitlab::ClosingIssueExtractor.new(project, current_user). Gitlab::ClosingIssueExtractor.new(project, current_user).
closed_by_message(messages.join("\n")) closed_by_message(messages.join("\n"))
......
...@@ -197,7 +197,7 @@ describe Ci::Pipeline, models: true do ...@@ -197,7 +197,7 @@ describe Ci::Pipeline, models: true do
time = Time.now time = Time.now
Timecop.freeze(time) { build.run } Timecop.freeze(time) { build.run }
expect(merge_request.metrics.latest_build_started_at).to eq(time) expect(merge_request.metrics.latest_build_started_at).to be_within(1.second).of(time)
end end
it 'clears the build end time' do it 'clears the build end time' do
...@@ -213,7 +213,7 @@ describe Ci::Pipeline, models: true do ...@@ -213,7 +213,7 @@ describe Ci::Pipeline, models: true do
time = Time.now time = Time.now
Timecop.freeze(time) { build.success } Timecop.freeze(time) { build.success }
expect(merge_request.metrics.latest_build_finished_at).to eq(time) expect(merge_request.metrics.latest_build_finished_at).to be_within(1.second).of(time)
end end
end end
end end
......
...@@ -13,7 +13,7 @@ describe Issue::Metrics, models: true do ...@@ -13,7 +13,7 @@ describe Issue::Metrics, models: true do
metrics = subject.metrics metrics = subject.metrics
expect(metrics).to be_present expect(metrics).to be_present
expect(metrics.first_associated_with_milestone_at).to eq(time) expect(metrics.first_associated_with_milestone_at).to be_within(1.second).of(time)
end end
it "does not record the second time an issue is associated with a milestone" do it "does not record the second time an issue is associated with a milestone" do
...@@ -24,7 +24,7 @@ describe Issue::Metrics, models: true do ...@@ -24,7 +24,7 @@ describe Issue::Metrics, models: true do
metrics = subject.metrics metrics = subject.metrics
expect(metrics).to be_present expect(metrics).to be_present
expect(metrics.first_associated_with_milestone_at).to eq(time) expect(metrics.first_associated_with_milestone_at).to be_within(1.second).of(time)
end end
end end
...@@ -36,7 +36,7 @@ describe Issue::Metrics, models: true do ...@@ -36,7 +36,7 @@ describe Issue::Metrics, models: true do
metrics = subject.metrics metrics = subject.metrics
expect(metrics).to be_present expect(metrics).to be_present
expect(metrics.first_added_to_board_at).to eq(time) expect(metrics.first_added_to_board_at).to be_within(1.second).of(time)
end end
it "does not record the second time an issue is associated with a list label" do it "does not record the second time an issue is associated with a list label" do
...@@ -48,7 +48,7 @@ describe Issue::Metrics, models: true do ...@@ -48,7 +48,7 @@ describe Issue::Metrics, models: true do
metrics = subject.metrics metrics = subject.metrics
expect(metrics).to be_present expect(metrics).to be_present
expect(metrics.first_added_to_board_at).to eq(time) expect(metrics.first_added_to_board_at).to be_within(1.second).of(time)
end end
end end
end end
......
...@@ -12,7 +12,7 @@ describe MergeRequest::Metrics, models: true do ...@@ -12,7 +12,7 @@ describe MergeRequest::Metrics, models: true do
metrics = subject.metrics metrics = subject.metrics
expect(metrics).to be_present expect(metrics).to be_present
expect(metrics.merged_at).to eq(time) expect(metrics.merged_at).to be_within(1.second).of(time)
end end
end end
end end
...@@ -190,7 +190,7 @@ describe CreateDeploymentService, services: true do ...@@ -190,7 +190,7 @@ describe CreateDeploymentService, services: true do
time = Time.now time = Time.now
Timecop.freeze(time) { service.execute } Timecop.freeze(time) { service.execute }
expect(merge_request.metrics.first_deployed_to_production_at).to eq(time) expect(merge_request.metrics.first_deployed_to_production_at).to be_within(1.second).of(time)
end end
it "doesn't set the time if the deploy's environment is not 'production'" do it "doesn't set the time if the deploy's environment is not 'production'" do
...@@ -216,13 +216,13 @@ describe CreateDeploymentService, services: true do ...@@ -216,13 +216,13 @@ describe CreateDeploymentService, services: true do
time = Time.now time = Time.now
Timecop.freeze(time) { service.execute } Timecop.freeze(time) { service.execute }
expect(merge_request.reload.metrics.first_deployed_to_production_at).to eq(time) expect(merge_request.reload.metrics.first_deployed_to_production_at).to be_within(1.second).of(time)
# Current deploy # Current deploy
service = described_class.new(project, user, params) service = described_class.new(project, user, params)
Timecop.freeze(time + 12.hours) { service.execute } Timecop.freeze(time + 12.hours) { service.execute }
expect(merge_request.reload.metrics.first_deployed_to_production_at).to eq(time) expect(merge_request.reload.metrics.first_deployed_to_production_at).to be_within(1.second).of(time)
end end
end end
......
...@@ -364,7 +364,7 @@ describe GitPushService, services: true do ...@@ -364,7 +364,7 @@ describe GitPushService, services: true do
it 'sets the metric for referenced issues' do it 'sets the metric for referenced issues' do
execute_service(project, user, @oldrev, @newrev, @ref) execute_service(project, user, @oldrev, @newrev, @ref)
expect(issue.metrics.first_mentioned_in_commit_at).to eq(commit_time) expect(issue.metrics.first_mentioned_in_commit_at).to be_within(1.second).of(commit_time)
end end
it 'does not set the metric for non-referenced issues' do it 'does not set the metric for non-referenced issues' do
......
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