Commit 1d6068a1 authored by James Lopez's avatar James Lopez

fix specs - issue events working

parent c545968e
......@@ -11,9 +11,14 @@ module Gitlab
def issue_events
@fetcher.fetch_issues.each do |event|
event['issue_diff'] = distance_of_time_in_words(event['issue_diff'].to_f)
event['issue_diff'] = interval_in_words(event['issue_diff'])
event['created_at'] = interval_in_words(event['created_at'])
end
end
def interval_in_words(diff)
"#{distance_of_time_in_words( diff.to_f)} ago"
end
end
end
end
......@@ -16,7 +16,7 @@ module Gitlab
project(extract_epoch(diff_fn).as('issue_diff'), *issue_projections).
order(issue_table[:created_at].desc)
ActiveRecord::Base.connection.execute(query.to_sql)
ActiveRecord::Base.connection.execute(query.to_sql).to_a
end
def metric_attributes
......
......@@ -15,23 +15,23 @@ describe Gitlab::CycleAnalytics::Events do
let!(:context) { create(:issue, project: project, created_at: 2.days.ago) }
it 'has an issue diff' do
expect(subject.issue_events['issue_diff']).to eq('2 days ago')
expect(subject.issue_events.first['issue_diff']).to eq('2 days ago')
end
it 'has a title' do
expect(subject.issue_events['title']).to eq(context.title)
expect(subject.issue_events.first['title']).to eq(context.title)
end
it 'has an iid' do
expect(subject.issue_events['iid']).to eq(context.iid.to_s)
expect(subject.issue_events.first['iid']).to eq(context.iid.to_s)
end
it 'has a created_at timestamp' do
expect(subject.issue_events['created_at']).to eq('2 days ago')
expect(subject.issue_events.first['created_at']).to end_with('ago')
end
it "has the author's name" do
expect(subject.issue_events['name']).to eq(context.author.name)
expect(subject.issue_events.first['name']).to eq(context.author.name)
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