From f8acc7ea77bb52531b11abea5eabd68a38236cff Mon Sep 17 00:00:00 2001 From: James Lopez <james@jameslopez.es> Date: Fri, 21 Oct 2016 09:44:04 +0200 Subject: [PATCH] fixing spec failures --- lib/gitlab/cycle_analytics/events.rb | 8 ++++---- lib/gitlab/database/date_time.rb | 2 +- spec/lib/gitlab/cycle_analytics/events_spec.rb | 11 ++++++----- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/gitlab/cycle_analytics/events.rb b/lib/gitlab/cycle_analytics/events.rb index 42ef864c916..a16c15ed3a8 100644 --- a/lib/gitlab/cycle_analytics/events.rb +++ b/lib/gitlab/cycle_analytics/events.rb @@ -13,7 +13,7 @@ module Gitlab def issue_events # TODO figure out what the frontend needs for displaying the avatar - @fetcher.fetch_issue_events { |event| parse_event(event) } + @fetcher.fetch_issue_events.each { |event| parse_event(event) } end def plan_events @@ -25,7 +25,7 @@ module Gitlab end def code_events - @fetcher.fetch_code_events { |event| parse_event(event) } + @fetcher.fetch_code_events.each { |event| parse_event(event) } end def test_events @@ -39,13 +39,13 @@ module Gitlab @fetcher.fetch_review_events.each { |event| parse_event(event) } end + private + def parse_event(event) event['total_time'] = distance_of_time_in_words(event['total_time'].to_f) event['created_at'] = interval_in_words(event['created_at']) end - private - def first_time_reference_commit(commits, event) st_commit = YAML.load(commits).detect do |commit| commit['created_at'] == event['first_mentioned_in_commit_at'] diff --git a/lib/gitlab/database/date_time.rb b/lib/gitlab/database/date_time.rb index 38a6fd4276b..25e56998038 100644 --- a/lib/gitlab/database/date_time.rb +++ b/lib/gitlab/database/date_time.rb @@ -8,7 +8,7 @@ module Gitlab # Note: For MySQL, the interval is returned in seconds. # For PostgreSQL, the interval is returned as an INTERVAL type. def subtract_datetimes(query_so_far, start_time_attrs, end_time_attrs, as) - diff_fn = subtract_datetimes_diff(query_so_far, end_time_attrs, start_time_attrs) + diff_fn = subtract_datetimes_diff(query_so_far, start_time_attrs, end_time_attrs) query_so_far.project(diff_fn.as(as)) end diff --git a/spec/lib/gitlab/cycle_analytics/events_spec.rb b/spec/lib/gitlab/cycle_analytics/events_spec.rb index ae1172cd653..17db46f0d4a 100644 --- a/spec/lib/gitlab/cycle_analytics/events_spec.rb +++ b/spec/lib/gitlab/cycle_analytics/events_spec.rb @@ -78,10 +78,12 @@ describe Gitlab::CycleAnalytics::Events do describe '#test_events' do let!(:context) { create(:issue, project: project, created_at: 2.days.ago) } let(:merge_request) { MergeRequest.first } - let!(:pipeline) { create(:ci_pipeline, - ref: merge_request.source_branch, - sha: merge_request.diff_head_sha, - project: context.project) } + let!(:pipeline) do + create(:ci_pipeline, + ref: merge_request.source_branch, + sha: merge_request.diff_head_sha, + project: context.project) + end before do pipeline.run! @@ -121,7 +123,6 @@ describe Gitlab::CycleAnalytics::Events do end end - def setup(context) milestone = create(:milestone, project: project) context.update(milestone: milestone) -- GitLab