fix specs - issue events working

This commit is contained in:
James Lopez 2016-10-18 10:06:42 +02:00
parent c545968ece
commit 1d6068a1c3
3 changed files with 12 additions and 7 deletions

View file

@ -11,9 +11,14 @@ module Gitlab
def issue_events def issue_events
@fetcher.fetch_issues.each do |event| @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
end end
def interval_in_words(diff)
"#{distance_of_time_in_words( diff.to_f)} ago"
end
end end
end end
end end

View file

@ -16,7 +16,7 @@ module Gitlab
project(extract_epoch(diff_fn).as('issue_diff'), *issue_projections). project(extract_epoch(diff_fn).as('issue_diff'), *issue_projections).
order(issue_table[:created_at].desc) order(issue_table[:created_at].desc)
ActiveRecord::Base.connection.execute(query.to_sql) ActiveRecord::Base.connection.execute(query.to_sql).to_a
end end
def metric_attributes def metric_attributes

View file

@ -15,23 +15,23 @@ describe Gitlab::CycleAnalytics::Events do
let!(:context) { create(:issue, project: project, created_at: 2.days.ago) } let!(:context) { create(:issue, project: project, created_at: 2.days.ago) }
it 'has an issue diff' do 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 end
it 'has a title' do 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 end
it 'has an iid' do 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 end
it 'has a created_at timestamp' do 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 end
it "has the author's name" do 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
end end