summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMałgorzata Ksionek <mksionek@gitlab.com>2019-06-01 18:08:50 +0200
committerMałgorzata Ksionek <mksionek@gitlab.com>2019-06-14 13:26:27 +0200
commit1984287f2f2d5d976803c715e3d7477a3116ff56 (patch)
treefcb1e027363f432b77f091967a119fd898ac5dd5
parenta22c8d054e4191165ba9f4b5c1d6c72479d9a0b0 (diff)
downloadgitlab-ce-1984287f2f2d5d976803c715e3d7477a3116ff56.tar.gz
Fix multiple specs
-rw-r--r--lib/gitlab/cycle_analytics/plan_base_query.rb4
-rw-r--r--spec/features/cycle_analytics_spec.rb2
-rw-r--r--spec/lib/gitlab/cycle_analytics/events_spec.rb29
-rw-r--r--spec/requests/projects/cycle_analytics_events_spec.rb4
4 files changed, 26 insertions, 13 deletions
diff --git a/lib/gitlab/cycle_analytics/plan_base_query.rb b/lib/gitlab/cycle_analytics/plan_base_query.rb
index d0a17353b79..d8c11ba4c30 100644
--- a/lib/gitlab/cycle_analytics/plan_base_query.rb
+++ b/lib/gitlab/cycle_analytics/plan_base_query.rb
@@ -8,10 +8,10 @@ module Gitlab
.project(issue_table[:project_id].as("project_id"))
.where(issue_table[:project_id].in(project_ids))
.where(issue_table[:created_at].gteq(@options[:from])) # rubocop:disable Gitlab/ModuleWithInstanceVariables
- .where((issue_metrics_table[:first_added_to_board_at]).not_eq(nil).or(issue_metrics_table[:first_associated_with_milestone_at].not_eq(nil)))
+ .where(issue_metrics_table[:first_added_to_board_at].not_eq(nil).or(issue_metrics_table[:first_associated_with_milestone_at].not_eq(nil)))
.where(issue_metrics_table[:first_mentioned_in_commit_at].not_eq(nil))
- query
+ query
end
end
end
diff --git a/spec/features/cycle_analytics_spec.rb b/spec/features/cycle_analytics_spec.rb
index 48edc764a8e..4108a0f370d 100644
--- a/spec/features/cycle_analytics_spec.rb
+++ b/spec/features/cycle_analytics_spec.rb
@@ -58,7 +58,7 @@ describe 'Cycle Analytics', :js do
expect_issue_to_be_present
click_stage('Plan')
- expect(find('.stage-events')).to have_content(mr.commits.last.title)
+ expect_issue_to_be_present
click_stage('Code')
expect_merge_request_to_be_present
diff --git a/spec/lib/gitlab/cycle_analytics/events_spec.rb b/spec/lib/gitlab/cycle_analytics/events_spec.rb
index 397dd4e5d2c..2bea1859bc0 100644
--- a/spec/lib/gitlab/cycle_analytics/events_spec.rb
+++ b/spec/lib/gitlab/cycle_analytics/events_spec.rb
@@ -53,20 +53,28 @@ describe 'cycle analytics events' do
describe '#plan_events' do
let(:stage) { :plan }
- it 'has a title' do
- expect(events.first[:title]).not_to be_nil
+ before do
+ create_commit_referencing_issue(context)
end
- it 'has a sha short ID' do
- expect(events.first[:short_sha]).not_to be_nil
+ it 'has the total time' do
+ expect(events.first[:total_time]).not_to be_empty
+ end
+
+ it 'has a title' do
+ expect(events.first[:title]).to eq(context.title)
end
it 'has the URL' do
- expect(events.first[:commit_url]).not_to be_nil
+ expect(events.first[:url]).not_to be_nil
end
- it 'has the total time' do
- expect(events.first[:total_time]).not_to be_empty
+ it 'has an iid' do
+ expect(events.first[:iid]).to eq(context.iid.to_s)
+ end
+
+ it 'has a created_at timestamp' do
+ expect(events.first[:created_at]).to end_with('ago')
end
it "has the author's URL" do
@@ -78,12 +86,13 @@ describe 'cycle analytics events' do
end
it "has the author's name" do
- expect(events.first[:author][:name]).not_to be_nil
+ expect(events.first[:author][:name]).to eq(context.author.name)
end
end
describe '#code_events' do
let(:stage) { :code }
+ let!(:merge_request) { MergeRequest.first }
before do
create_commit_referencing_issue(context)
@@ -180,6 +189,10 @@ describe 'cycle analytics events' do
let(:stage) { :review }
let!(:context) { create(:issue, project: project, created_at: 2.days.ago) }
+ before do
+ merge_merge_requests_closing_issue(user, project, context)
+ end
+
it 'has the total time' do
expect(events.first[:total_time]).not_to be_empty
end
diff --git a/spec/requests/projects/cycle_analytics_events_spec.rb b/spec/requests/projects/cycle_analytics_events_spec.rb
index 49412b628b3..25390f8a23e 100644
--- a/spec/requests/projects/cycle_analytics_events_spec.rb
+++ b/spec/requests/projects/cycle_analytics_events_spec.rb
@@ -32,10 +32,10 @@ describe 'cycle analytics events' do
it 'lists the plan events' do
get project_cycle_analytics_plan_path(project, format: :json)
- first_mr_short_sha = project.merge_requests.sort_by_attribute(:created_asc).first.commits.first.short_id
+ first_issue_iid = project.issues.sort_by_attribute(:created_desc).pluck(:iid).first.to_s
expect(json_response['events']).not_to be_empty
- expect(json_response['events'].first['short_sha']).to eq(first_mr_short_sha)
+ expect(json_response['events'].first['iid']).to eq(first_issue_iid)
end
it 'lists the code events' do