diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-17 14:59:07 +0300 |
commit | 8b573c94895dc0ac0e1d9d59cf3e8745e8b539ca (patch) | |
tree | 544930fb309b30317ae9797a9683768705d664c4 /spec/requests/projects/cycle_analytics_events_spec.rb | |
parent | 4b1de649d0168371549608993deac953eb692019 (diff) |
Add latest changes from gitlab-org/gitlab@13-7-stable-eev13.7.0-rc42
Diffstat (limited to 'spec/requests/projects/cycle_analytics_events_spec.rb')
-rw-r--r-- | spec/requests/projects/cycle_analytics_events_spec.rb | 143 |
1 files changed, 76 insertions, 67 deletions
diff --git a/spec/requests/projects/cycle_analytics_events_spec.rb b/spec/requests/projects/cycle_analytics_events_spec.rb index 3f57b8ba67b..f8fa9459467 100644 --- a/spec/requests/projects/cycle_analytics_events_spec.rb +++ b/spec/requests/projects/cycle_analytics_events_spec.rb @@ -7,108 +7,115 @@ RSpec.describe 'value stream analytics events' do let(:project) { create(:project, :repository, public_builds: false) } let(:issue) { create(:issue, project: project, created_at: 2.days.ago) } - describe 'GET /:namespace/:project/value_stream_analytics/events/issues' do - before do - project.add_developer(user) + shared_examples 'value stream analytics events examples' do + describe 'GET /:namespace/:project/value_stream_analytics/events/issues' do + before do + project.add_developer(user) - 3.times do |count| - travel_to(Time.now + count.days) do - create_cycle + 3.times do |count| + travel_to(Time.now + count.days) do + create_cycle + end end - end - - deploy_master(user, project) - - login_as(user) - end - - it 'lists the issue events' do - get project_cycle_analytics_issue_path(project, format: :json) - first_issue_iid = project.issues.sort_by_attribute(:created_desc).pluck(:iid).first.to_s + deploy_master(user, project) - expect(json_response['events']).not_to be_empty - expect(json_response['events'].first['iid']).to eq(first_issue_iid) - end + login_as(user) + end - it 'lists the plan events' do - get project_cycle_analytics_plan_path(project, format: :json) + it 'lists the issue events' do + get project_cycle_analytics_issue_path(project, format: :json) - first_issue_iid = project.issues.sort_by_attribute(:created_desc).pluck(:iid).first.to_s + 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['iid']).to eq(first_issue_iid) - end + expect(json_response['events']).not_to be_empty + expect(json_response['events'].first['iid']).to eq(first_issue_iid) + end - it 'lists the code events' do - get project_cycle_analytics_code_path(project, format: :json) + it 'lists the plan events' do + get project_cycle_analytics_plan_path(project, format: :json) - expect(json_response['events']).not_to be_empty + first_issue_iid = project.issues.sort_by_attribute(:created_desc).pluck(:iid).first.to_s - first_mr_iid = project.merge_requests.sort_by_attribute(:created_desc).pluck(:iid).first.to_s + expect(json_response['events']).not_to be_empty + expect(json_response['events'].first['iid']).to eq(first_issue_iid) + end - expect(json_response['events'].first['iid']).to eq(first_mr_iid) - end + it 'lists the code events' do + get project_cycle_analytics_code_path(project, format: :json) - it 'lists the test events', :sidekiq_might_not_need_inline do - get project_cycle_analytics_test_path(project, format: :json) + expect(json_response['events']).not_to be_empty - expect(json_response['events']).not_to be_empty - expect(json_response['events'].first['date']).not_to be_empty - end + first_mr_iid = project.merge_requests.sort_by_attribute(:created_desc).pluck(:iid).first.to_s - it 'lists the review events' do - get project_cycle_analytics_review_path(project, format: :json) + expect(json_response['events'].first['iid']).to eq(first_mr_iid) + end - first_mr_iid = project.merge_requests.sort_by_attribute(:created_desc).pluck(:iid).first.to_s + it 'lists the test events', :sidekiq_inline do + get project_cycle_analytics_test_path(project, format: :json) - expect(json_response['events']).not_to be_empty - expect(json_response['events'].first['iid']).to eq(first_mr_iid) - end + expect(json_response['events']).not_to be_empty + expect(json_response['events'].first['date']).not_to be_empty + end - it 'lists the staging events', :sidekiq_might_not_need_inline do - get project_cycle_analytics_staging_path(project, format: :json) + it 'lists the review events' do + get project_cycle_analytics_review_path(project, format: :json) - expect(json_response['events']).not_to be_empty - expect(json_response['events'].first['date']).not_to be_empty - end + first_mr_iid = project.merge_requests.sort_by_attribute(:created_desc).pluck(:iid).first.to_s - context 'specific branch' do - it 'lists the test events', :sidekiq_might_not_need_inline do - branch = project.merge_requests.first.source_branch + expect(json_response['events']).not_to be_empty + expect(json_response['events'].first['iid']).to eq(first_mr_iid) + end - get project_cycle_analytics_test_path(project, format: :json, branch: branch) + it 'lists the staging events', :sidekiq_inline do + get project_cycle_analytics_staging_path(project, format: :json) expect(json_response['events']).not_to be_empty expect(json_response['events'].first['date']).not_to be_empty end - end - context 'with private project and builds' do - before do - project.members.last.update(access_level: Gitlab::Access::GUEST) - end + context 'with private project and builds' do + before do + project.members.last.update(access_level: Gitlab::Access::GUEST) + end - it 'does not list the test events' do - get project_cycle_analytics_test_path(project, format: :json) + it 'does not list the test events' do + get project_cycle_analytics_test_path(project, format: :json) - expect(response).to have_gitlab_http_status(:not_found) - end + expect(response).to have_gitlab_http_status(:not_found) + end - it 'does not list the staging events' do - get project_cycle_analytics_staging_path(project, format: :json) + it 'does not list the staging events' do + get project_cycle_analytics_staging_path(project, format: :json) - expect(response).to have_gitlab_http_status(:not_found) - end + expect(response).to have_gitlab_http_status(:not_found) + end - it 'lists the issue events' do - get project_cycle_analytics_issue_path(project, format: :json) + it 'lists the issue events' do + get project_cycle_analytics_issue_path(project, format: :json) - expect(response).to have_gitlab_http_status(:ok) + expect(response).to have_gitlab_http_status(:ok) + end end end end + describe 'when new_project_level_vsa_backend feature flag is off' do + before do + stub_feature_flags(new_project_level_vsa_backend: false, thing: project) + end + + it_behaves_like 'value stream analytics events examples' + end + + describe 'when new_project_level_vsa_backend feature flag is on' do + before do + stub_feature_flags(new_project_level_vsa_backend: true, thing: project) + end + + it_behaves_like 'value stream analytics events examples' + end + def create_cycle milestone = create(:milestone, project: project) issue.update(milestone: milestone) @@ -123,5 +130,7 @@ RSpec.describe 'value stream analytics events' do merge_merge_requests_closing_issue(user, project, issue) ProcessCommitWorker.new.perform(project.id, user.id, mr.commits.last.to_hash) + + mr.metrics.update!(latest_build_started_at: 1.hour.ago, latest_build_finished_at: Time.now) end end |