summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-10-20 10:08:53 +0200
committerJames Lopez <james@jameslopez.es>2016-11-17 08:22:55 +0100
commit1a4ff5d720fa0ec65f925ef381fced3d5f9a040f (patch)
tree554f05d5d011c0ca9a9ac2bd3765834f8a8693ce /spec
parent72660d58af13b4a768840307d2870ac08dd088ef (diff)
downloadgitlab-ce-1a4ff5d720fa0ec65f925ef381fced3d5f9a040f.tar.gz
Added code events spec and logic. Also fixed SQL issues and refactored the code a bit.
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/cycle_analytics/events_spec.rb30
1 files changed, 29 insertions, 1 deletions
diff --git a/spec/lib/gitlab/cycle_analytics/events_spec.rb b/spec/lib/gitlab/cycle_analytics/events_spec.rb
index 4f8ba465d71..4a329737c7e 100644
--- a/spec/lib/gitlab/cycle_analytics/events_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/events_spec.rb
@@ -43,7 +43,35 @@ describe Gitlab::CycleAnalytics::Events do
end
it 'has the total time' do
- expect(subject.plan_events.first['total_time']).to eq('2 days')
+ expect(subject.plan_events.first['total_time']).to eq('less than a minute')
+ end
+ end
+
+ describe '#code_events' do
+ let!(:context) { create(:issue, project: project, created_at: 2.days.ago) }
+
+ before do
+ create_commit_referencing_issue(context)
+ end
+
+ it 'has the total time' do
+ expect(subject.code_events.first['total_time']).to eq('2 days')
+ end
+
+ it 'has a title' do
+ expect(subject.code_events.first['title']).to eq('Awesome merge_request')
+ end
+
+ it 'has an iid' do
+ expect(subject.code_events.first['iid']).to eq(context.iid.to_s)
+ end
+
+ it 'has a created_at timestamp' do
+ expect(subject.code_events.first['created_at']).to end_with('ago')
+ end
+
+ it "has the author's name" do
+ expect(subject.code_events.first['name']).to eq(context.author.name)
end
end