diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-01-08 15:10:26 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-01-08 15:10:26 +0000 |
commit | 6e734c809b18a0470d81c78e1ecd9b3f8278de89 (patch) | |
tree | 882251dce981323bc3c6e305cbc0f41aa4c39aae /spec/frontend/fixtures | |
parent | 9157fbe06fde892c647403f477ce31c888cbc822 (diff) | |
download | gitlab-ce-6e734c809b18a0470d81c78e1ecd9b3f8278de89.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/fixtures')
-rw-r--r-- | spec/frontend/fixtures/project_analytics.rb | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/spec/frontend/fixtures/project_analytics.rb b/spec/frontend/fixtures/project_analytics.rb new file mode 100644 index 00000000000..f0be5e8b97d --- /dev/null +++ b/spec/frontend/fixtures/project_analytics.rb @@ -0,0 +1,69 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe 'Project Analytics (JavaScript fixtures)' do + include ApiHelpers + include JavaScriptFixturesHelpers + + let_it_be(:reporter) { create(:user) } + let_it_be(:project) { create(:project, :repository) } + let_it_be(:environment) { create(:environment, project: project, name: 'production') } + + let!(:deployments) do + [ + 1.minute.ago, + 2.days.ago, + 3.days.ago, + 3.days.ago, + 3.days.ago, + 8.days.ago, + 32.days.ago, + 91.days.ago + ].map do |finished_at| + create(:deployment, + :success, + project: project, + environment: environment, + finished_at: finished_at) + end + end + + before do + stub_licensed_features(project_activity_analytics: true) + project.add_reporter(reporter) + sign_in(reporter) + end + + after(:all) do + remove_repository(project) + end + + describe API::Analytics::ProjectDeploymentFrequency, type: :request do + before(:all) do + clean_frontend_fixtures('api/project_analytics/') + end + + let(:shared_params) { { environment: environment.name, interval: 'daily' } } + + def make_request(additional_query_params:) + params = shared_params.merge(additional_query_params) + get api("/projects/#{project.id}/analytics/deployment_frequency?#{params.to_query}", reporter) + end + + it 'api/project_analytics/daily_deployment_frequencies_for_last_week.json' do + make_request(additional_query_params: { from: 1.week.ago }) + expect(response).to be_successful + end + + it 'api/project_analytics/daily_deployment_frequencies_for_last_month.json' do + make_request(additional_query_params: { from: 1.month.ago }) + expect(response).to be_successful + end + + it 'api/project_analytics/daily_deployment_frequencies_for_last_90_days.json' do + make_request(additional_query_params: { from: 90.days.ago }) + expect(response).to be_successful + end + end +end |