BigW Consortium Gitlab

Commit e109166d by Timothy Andrew

Fix spec failures.

parent 8747f29d
......@@ -527,7 +527,11 @@ class MergeRequest < ActiveRecord::Base
# Return the set of issues that will be closed if this merge request is accepted.
def closes_issues(current_user = self.author)
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).
closed_by_message(messages.join("\n"))
......
......@@ -197,7 +197,7 @@ describe Ci::Pipeline, models: true do
time = Time.now
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
it 'clears the build end time' do
......@@ -213,7 +213,7 @@ describe Ci::Pipeline, models: true do
time = Time.now
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
......
......@@ -13,7 +13,7 @@ describe Issue::Metrics, models: true do
metrics = subject.metrics
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
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
metrics = subject.metrics
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
......@@ -36,7 +36,7 @@ describe Issue::Metrics, models: true do
metrics = subject.metrics
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
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
metrics = subject.metrics
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
......
......@@ -12,7 +12,7 @@ describe MergeRequest::Metrics, models: true do
metrics = subject.metrics
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
......@@ -190,7 +190,7 @@ describe CreateDeploymentService, services: true do
time = Time.now
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
it "doesn't set the time if the deploy's environment is not 'production'" do
......@@ -216,13 +216,13 @@ describe CreateDeploymentService, services: true do
time = Time.now
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
service = described_class.new(project, user, params)
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
......
......@@ -364,7 +364,7 @@ describe GitPushService, services: true do
it 'sets the metric for referenced issues' do
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
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