diff options
author | James Lopez <james@jameslopez.es> | 2016-11-16 15:55:20 +0100 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2016-11-17 08:22:59 +0100 |
commit | cbd7d000395ff60fe3726e67ec351bd4d44582ec (patch) | |
tree | f497cc29ef7cb87a9f6bd4334ea536f6b6aa81fd /spec/requests/projects | |
parent | 4844476e77f625829d99b7db2680186939ef660a (diff) | |
download | gitlab-ce-cbd7d000395ff60fe3726e67ec351bd4d44582ec.tar.gz |
added custom date helper and spec and fixed some unrelated spec failures
Diffstat (limited to 'spec/requests/projects')
-rw-r--r-- | spec/requests/projects/cycle_analytics_events_spec.rb | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/spec/requests/projects/cycle_analytics_events_spec.rb b/spec/requests/projects/cycle_analytics_events_spec.rb index 1c78cd368db..705dbb7d1c0 100644 --- a/spec/requests/projects/cycle_analytics_events_spec.rb +++ b/spec/requests/projects/cycle_analytics_events_spec.rb @@ -3,17 +3,18 @@ require 'spec_helper' describe 'cycle analytics events' do let(:user) { create(:user) } let(:project) { create(:project) } + let(:issue) { create(:issue, project: project, created_at: 2.days.ago) } describe 'GET /:namespace/:project/cycle_analytics/events/issues' do before do project.team << [user, :developer] + allow_any_instance_of(Gitlab::ReferenceExtractor).to receive(:issues).and_return([issue]) + 3.times { create_cycle } deploy_master login_as(user) - - allow_any_instance_of(Gitlab::ReferenceExtractor).to receive(:issues).and_return([context]) end it 'lists the issue events' do @@ -31,17 +32,7 @@ describe 'cycle analytics events' do expect(json_response['events']).not_to be_empty - commits = [] - - MergeRequest.all.each do |mr| - mr.merge_request_diff.st_commits.each do |commit| - commits << { date: commit[:authored_date], sha: commit[:id] } - end - end - - newest_sha = commits.sort_by { |k| k['date'] }.first[:sha][0...8] - - expect(json_response['events'].first['short_sha']).to eq(newest_sha) + expect(json_response['events'].first['short_sha']).to eq(MergeRequest.last.commits.first.short_id) end it 'lists the code events' do @@ -49,7 +40,7 @@ describe 'cycle analytics events' do expect(json_response['events']).not_to be_empty - first_mr_iid = Issue.order(created_at: :desc).pluck(:iid).first.to_s + first_mr_iid = MergeRequest.order(created_at: :desc).pluck(:iid).first.to_s expect(json_response['events'].first['iid']).to eq(first_mr_iid) end @@ -67,7 +58,7 @@ describe 'cycle analytics events' do expect(json_response['events']).not_to be_empty - first_mr_iid = Issue.order(created_at: :desc).pluck(:iid).first.to_s + first_mr_iid = MergeRequest.order(created_at: :desc).pluck(:iid).first.to_s expect(json_response['events'].first['iid']).to eq(first_mr_iid) end @@ -132,7 +123,6 @@ describe 'cycle analytics events' do end def create_cycle - issue = create(:issue, project: project, created_at: 2.days.ago) milestone = create(:milestone, project: project) issue.update(milestone: milestone) mr = create_merge_request_closing_issue(issue) |