diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2018-04-10 10:25:59 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2018-04-10 10:25:59 +0000 |
commit | 33a4439e8f079303fcf7c71267936e5c8f694958 (patch) | |
tree | 828c3c6dc55058e95927d36a3a03db9fd0263766 /spec | |
parent | 2db218f8bf186c509c927ce3e9d0502fee4f8349 (diff) | |
parent | 174950b6562226beed7eef135a2450bfee60e21f (diff) | |
download | gitlab-ce-33a4439e8f079303fcf7c71267936e5c8f694958.tar.gz |
Merge branch 'master' into 'stuartnelson3/gitlab-ce-stn/issue-due-email'
# Conflicts:
# db/schema.rb
Diffstat (limited to 'spec')
398 files changed, 20799 insertions, 12041 deletions
diff --git a/spec/controllers/dashboard_controller_spec.rb b/spec/controllers/dashboard_controller_spec.rb index 97c2c3fb940..3458d679107 100644 --- a/spec/controllers/dashboard_controller_spec.rb +++ b/spec/controllers/dashboard_controller_spec.rb @@ -11,9 +11,11 @@ describe DashboardController do describe 'GET issues' do it_behaves_like 'issuables list meta-data', :issue, :issues + it_behaves_like 'issuables requiring filter', :issues end describe 'GET merge requests' do it_behaves_like 'issuables list meta-data', :merge_request, :merge_requests + it_behaves_like 'issuables requiring filter', :merge_requests end end diff --git a/spec/controllers/profiles_controller_spec.rb b/spec/controllers/profiles_controller_spec.rb index 03cbbb21e62..de6ef919221 100644 --- a/spec/controllers/profiles_controller_spec.rb +++ b/spec/controllers/profiles_controller_spec.rb @@ -84,6 +84,35 @@ describe ProfilesController, :request_store do expect(user.username).to eq(new_username) end + it 'updates a username using JSON request' do + sign_in(user) + + put :update_username, + user: { username: new_username }, + format: :json + + expect(response.status).to eq(200) + expect(json_response['message']).to eq('Username successfully changed') + end + + it 'renders an error message when the username was not updated' do + sign_in(user) + + put :update_username, + user: { username: 'invalid username.git' }, + format: :json + + expect(response.status).to eq(422) + expect(json_response['message']).to match(/Username change failed/) + end + + it 'raises a correct error when the username is missing' do + sign_in(user) + + expect { put :update_username, user: { gandalf: 'you shall not pass' } } + .to raise_error(ActionController::ParameterMissing) + end + context 'with legacy storage' do it 'moves dependent projects to new namespace' do project = create(:project_empty_repo, :legacy_storage, namespace: namespace) diff --git a/spec/controllers/projects/branches_controller_spec.rb b/spec/controllers/projects/branches_controller_spec.rb index 3b9e06cb5ad..16fb377b002 100644 --- a/spec/controllers/projects/branches_controller_spec.rb +++ b/spec/controllers/projects/branches_controller_spec.rb @@ -398,6 +398,22 @@ describe Projects::BranchesController do end end + # We need :request_store because Gitaly only counts the queries whenever + # `RequestStore.active?` in GitalyClient.enforce_gitaly_request_limits + # And the main goal of this test is making sure TooManyInvocationsError + # was not raised whenever the cache is enabled yet cold. + context 'when cache is enabled yet cold', :request_store do + it 'return with a status 200' do + get :index, + namespace_id: project.namespace, + project_id: project, + state: 'all', + format: :html + + expect(response).to have_gitlab_http_status(200) + end + end + context 'when branch contains an invalid UTF-8 sequence' do before do project.repository.create_branch("wrong-\xE5-utf8-sequence") @@ -414,7 +430,7 @@ describe Projects::BranchesController do end end - context 'when depreated sort/search/page parameters are specified' do + context 'when deprecated sort/search/page parameters are specified' do it 'returns with a status 301 when sort specified' do get :index, namespace_id: project.namespace, diff --git a/spec/controllers/projects/discussions_controller_spec.rb b/spec/controllers/projects/discussions_controller_spec.rb index fcb0c2f28c8..53647749a60 100644 --- a/spec/controllers/projects/discussions_controller_spec.rb +++ b/spec/controllers/projects/discussions_controller_spec.rb @@ -16,6 +16,53 @@ describe Projects::DiscussionsController do } end + describe 'GET show' do + before do + sign_in user + end + + context 'when user is not authorized to read the MR' do + it 'returns 404' do + get :show, request_params, format: :json + + expect(response).to have_gitlab_http_status(404) + end + end + + context 'when user is authorized to read the MR' do + before do + project.add_reporter(user) + end + + it 'returns status 200' do + get :show, request_params, format: :json + + expect(response).to have_gitlab_http_status(200) + end + + it 'returns status 404 if MR does not exists' do + merge_request.destroy! + + get :show, request_params, format: :json + + expect(response).to have_gitlab_http_status(404) + end + end + + context 'when user is authorized but note is LegacyDiffNote' do + before do + project.add_developer(user) + note.update!(type: 'LegacyDiffNote') + end + + it 'returns status 200' do + get :show, request_params, format: :json + + expect(response).to have_gitlab_http_status(200) + end + end + end + describe 'POST resolve' do before do sign_in user diff --git a/spec/controllers/projects/issues_controller_spec.rb b/spec/controllers/projects/issues_controller_spec.rb index 9918d52e402..01b5506b64b 100644 --- a/spec/controllers/projects/issues_controller_spec.rb +++ b/spec/controllers/projects/issues_controller_spec.rb @@ -974,7 +974,7 @@ describe Projects::IssuesController do it 'returns discussion json' do get :discussions, namespace_id: project.namespace, project_id: project, id: issue.iid - expect(json_response.first.keys).to match_array(%w[id reply_id expanded notes diff_discussion individual_note resolvable resolve_with_issue_path resolved]) + expect(json_response.first.keys).to match_array(%w[id reply_id expanded notes diff_discussion individual_note resolvable resolved]) end context 'with cross-reference system note', :request_store do diff --git a/spec/controllers/projects/jobs_controller_spec.rb b/spec/controllers/projects/jobs_controller_spec.rb index 31046c202e6..b9a979044fe 100644 --- a/spec/controllers/projects/jobs_controller_spec.rb +++ b/spec/controllers/projects/jobs_controller_spec.rb @@ -513,13 +513,30 @@ describe Projects::JobsController do end end + context 'when job has a trace in database' do + let(:job) { create(:ci_build, pipeline: pipeline) } + + before do + job.update_column(:trace, 'Sample trace') + end + + it 'send a trace file' do + response = subject + + expect(response).to have_gitlab_http_status(:ok) + expect(response.content_type).to eq 'text/plain; charset=utf-8' + expect(response.body).to eq 'Sample trace' + end + end + context 'when job does not have a trace file' do let(:job) { create(:ci_build, pipeline: pipeline) } it 'returns not_found' do response = subject - expect(response).to have_gitlab_http_status(:not_found) + expect(response).to have_gitlab_http_status(:ok) + expect(response.body).to eq '' end end diff --git a/spec/controllers/projects/pipelines_settings_controller_spec.rb b/spec/controllers/projects/pipelines_settings_controller_spec.rb index 913b9bd804a..694896b6bcf 100644 --- a/spec/controllers/projects/pipelines_settings_controller_spec.rb +++ b/spec/controllers/projects/pipelines_settings_controller_spec.rb @@ -11,82 +11,11 @@ describe Projects::PipelinesSettingsController do sign_in(user) end - describe 'PATCH update' do - subject do - patch :update, - namespace_id: project.namespace.to_param, - project_id: project, - project: { - auto_devops_attributes: params - } - end - - context 'when updating the auto_devops settings' do - let(:params) { { enabled: '', domain: 'mepmep.md' } } - - it 'redirects to the settings page' do - subject - - expect(response).to have_gitlab_http_status(302) - expect(flash[:notice]).to eq("Pipelines settings for '#{project.name}' were successfully updated.") - end - - context 'following the instance default' do - let(:params) { { enabled: '' } } - - it 'allows enabled to be set to nil' do - subject - project_auto_devops.reload - - expect(project_auto_devops.enabled).to be_nil - end - end - - context 'when run_auto_devops_pipeline is true' do - before do - expect_any_instance_of(Projects::UpdateService).to receive(:run_auto_devops_pipeline?).and_return(true) - end - - context 'when the project repository is empty' do - it 'sets a warning flash' do - expect(subject).to set_flash[:warning] - end - - it 'does not queue a CreatePipelineWorker' do - expect(CreatePipelineWorker).not_to receive(:perform_async).with(project.id, user.id, project.default_branch, :web, any_args) - - subject - end - end - - context 'when the project repository is not empty' do - let(:project) { create(:project, :repository) } - - it 'sets a success flash' do - allow(CreatePipelineWorker).to receive(:perform_async).with(project.id, user.id, project.default_branch, :web, any_args) - - expect(subject).to set_flash[:success] - end - - it 'queues a CreatePipelineWorker' do - expect(CreatePipelineWorker).to receive(:perform_async).with(project.id, user.id, project.default_branch, :web, any_args) - - subject - end - end - end - - context 'when run_auto_devops_pipeline is not true' do - before do - expect_any_instance_of(Projects::UpdateService).to receive(:run_auto_devops_pipeline?).and_return(false) - end - - it 'does not queue a CreatePipelineWorker' do - expect(CreatePipelineWorker).not_to receive(:perform_async).with(project.id, user.id, :web, any_args) + describe 'GET show' do + it 'redirects with 302 status code' do + get :show, namespace_id: project.namespace, project_id: project - subject - end - end + expect(response).to have_gitlab_http_status(302) end end end diff --git a/spec/controllers/projects/repositories_controller_spec.rb b/spec/controllers/projects/repositories_controller_spec.rb index 04d16e98913..c3b71458e38 100644 --- a/spec/controllers/projects/repositories_controller_spec.rb +++ b/spec/controllers/projects/repositories_controller_spec.rb @@ -6,7 +6,7 @@ describe Projects::RepositoriesController do describe "GET archive" do context 'as a guest' do it 'responds with redirect in correct format' do - get :archive, namespace_id: project.namespace, project_id: project, format: "zip", ref: 'master' + get :archive, namespace_id: project.namespace, project_id: project, id: "master", format: "zip" expect(response.header["Content-Type"]).to start_with('text/html') expect(response).to be_redirect @@ -22,7 +22,20 @@ describe Projects::RepositoriesController do end it "uses Gitlab::Workhorse" do - get :archive, namespace_id: project.namespace, project_id: project, ref: "master", format: "zip" + get :archive, namespace_id: project.namespace, project_id: project, id: "master", format: "zip" + + expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-archive:") + end + + it 'responds with redirect to the short name archive if fully qualified' do + get :archive, namespace_id: project.namespace, project_id: project, id: "master/#{project.path}-master", format: "zip" + + expect(assigns(:ref)).to eq("master") + expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-archive:") + end + + it 'handles legacy queries with no ref' do + get :archive, namespace_id: project.namespace, project_id: project, format: "zip" expect(response.header[Gitlab::Workhorse::SEND_DATA_HEADER]).to start_with("git-archive:") end @@ -33,7 +46,7 @@ describe Projects::RepositoriesController do end it "renders Not Found" do - get :archive, namespace_id: project.namespace, project_id: project, ref: "master", format: "zip" + get :archive, namespace_id: project.namespace, project_id: project, id: "master", format: "zip" expect(response).to have_gitlab_http_status(404) end diff --git a/spec/controllers/projects/settings/ci_cd_controller_spec.rb b/spec/controllers/projects/settings/ci_cd_controller_spec.rb index 293e76798ae..7dae9b85d78 100644 --- a/spec/controllers/projects/settings/ci_cd_controller_spec.rb +++ b/spec/controllers/projects/settings/ci_cd_controller_spec.rb @@ -1,8 +1,9 @@ require('spec_helper') describe Projects::Settings::CiCdController do - let(:project) { create(:project, :public, :access_requestable) } - let(:user) { create(:user) } + set(:user) { create(:user) } + set(:project_auto_devops) { create(:project_auto_devops) } + let(:project) { project_auto_devops.project } before do project.add_master(user) @@ -55,4 +56,107 @@ describe Projects::Settings::CiCdController do end end end + + describe 'PATCH update' do + let(:params) { { ci_config_path: '' } } + + subject do + patch :update, + namespace_id: project.namespace.to_param, + project_id: project, + project: params + end + + it 'redirects to the settings page' do + subject + + expect(response).to have_gitlab_http_status(302) + expect(flash[:notice]).to eq("Pipelines settings for '#{project.name}' were successfully updated.") + end + + context 'when updating the auto_devops settings' do + let(:params) { { auto_devops_attributes: { enabled: '', domain: 'mepmep.md' } } } + + context 'following the instance default' do + let(:params) { { auto_devops_attributes: { enabled: '' } } } + + it 'allows enabled to be set to nil' do + subject + project_auto_devops.reload + + expect(project_auto_devops.enabled).to be_nil + end + end + + context 'when run_auto_devops_pipeline is true' do + before do + expect_any_instance_of(Projects::UpdateService).to receive(:run_auto_devops_pipeline?).and_return(true) + end + + context 'when the project repository is empty' do + it 'sets a warning flash' do + expect(subject).to set_flash[:warning] + end + + it 'does not queue a CreatePipelineWorker' do + expect(CreatePipelineWorker).not_to receive(:perform_async).with(project.id, user.id, project.default_branch, :web, any_args) + + subject + end + end + + context 'when the project repository is not empty' do + let(:project) { create(:project, :repository) } + + it 'sets a success flash' do + allow(CreatePipelineWorker).to receive(:perform_async).with(project.id, user.id, project.default_branch, :web, any_args) + + expect(subject).to set_flash[:success] + end + + it 'queues a CreatePipelineWorker' do + expect(CreatePipelineWorker).to receive(:perform_async).with(project.id, user.id, project.default_branch, :web, any_args) + + subject + end + end + end + + context 'when run_auto_devops_pipeline is not true' do + before do + expect_any_instance_of(Projects::UpdateService).to receive(:run_auto_devops_pipeline?).and_return(false) + end + + it 'does not queue a CreatePipelineWorker' do + expect(CreatePipelineWorker).not_to receive(:perform_async).with(project.id, user.id, :web, any_args) + + subject + end + end + end + + context 'when updating general settings' do + context 'when build_timeout_human_readable is not specified' do + let(:params) { { build_timeout_human_readable: '' } } + + it 'set default timeout' do + subject + + project.reload + expect(project.build_timeout).to eq(3600) + end + end + + context 'when build_timeout_human_readable is specified' do + let(:params) { { build_timeout_human_readable: '1h 30m' } } + + it 'set specified timeout' do + subject + + project.reload + expect(project.build_timeout).to eq(5400) + end + end + end + end end diff --git a/spec/factories/ci/build_metadata.rb b/spec/factories/ci/build_metadata.rb deleted file mode 100644 index 66bbd977b88..00000000000 --- a/spec/factories/ci/build_metadata.rb +++ /dev/null @@ -1,9 +0,0 @@ -FactoryBot.define do - factory :ci_build_metadata, class: Ci::BuildMetadata do - build factory: :ci_build - - after(:build) do |build_metadata, _| - build_metadata.project ||= build_metadata.build.project - end - end -end diff --git a/spec/factories/ci/builds.rb b/spec/factories/ci/builds.rb index f6ba3a581ca..fdacbe6c3f1 100644 --- a/spec/factories/ci/builds.rb +++ b/spec/factories/ci/builds.rb @@ -62,6 +62,7 @@ FactoryBot.define do end trait :pending do + queued_at 'Di 29. Okt 09:50:59 CET 2013' status 'pending' end @@ -237,5 +238,10 @@ FactoryBot.define do trait :protected do protected true end + + trait :script_failure do + failed + failure_reason 1 + end end end diff --git a/spec/factories/deploy_tokens.rb b/spec/factories/deploy_tokens.rb new file mode 100644 index 00000000000..5fea4a9d5a6 --- /dev/null +++ b/spec/factories/deploy_tokens.rb @@ -0,0 +1,14 @@ +FactoryBot.define do + factory :deploy_token do + token { SecureRandom.hex(50) } + sequence(:name) { |n| "PDT #{n}" } + read_repository true + read_registry true + revoked false + expires_at { 5.days.from_now } + + trait :revoked do + revoked true + end + end +end diff --git a/spec/factories/project_deploy_tokens.rb b/spec/factories/project_deploy_tokens.rb new file mode 100644 index 00000000000..4866cb58d88 --- /dev/null +++ b/spec/factories/project_deploy_tokens.rb @@ -0,0 +1,6 @@ +FactoryBot.define do + factory :project_deploy_token do + project + deploy_token + end +end diff --git a/spec/factories/project_hooks.rb b/spec/factories/project_hooks.rb index 493b7bc021c..a448d565e4b 100644 --- a/spec/factories/project_hooks.rb +++ b/spec/factories/project_hooks.rb @@ -15,6 +15,7 @@ FactoryBot.define do issues_events true confidential_issues_events true note_events true + confidential_note_events true job_events true pipeline_events true wiki_page_events true diff --git a/spec/factories/users_star_projects.rb b/spec/factories/users_star_projects.rb new file mode 100644 index 00000000000..6afd08a2084 --- /dev/null +++ b/spec/factories/users_star_projects.rb @@ -0,0 +1,6 @@ +FactoryBot.define do + factory :users_star_project do + project + user + end +end diff --git a/spec/features/admin/admin_settings_spec.rb b/spec/features/admin/admin_settings_spec.rb index c89bc54cad4..846b8040be6 100644 --- a/spec/features/admin/admin_settings_spec.rb +++ b/spec/features/admin/admin_settings_spec.rb @@ -120,6 +120,73 @@ feature 'Admin updates settings' do expect(page).to have_content "Application settings saved successfully" end + scenario 'Change Performance bar settings' do + group = create(:group) + + page.within('.as-performance-bar') do + check 'Enable the Performance Bar' + fill_in 'Allowed group', with: group.path + click_on 'Save changes' + end + + expect(page).to have_content "Application settings saved successfully" + expect(find_field('Enable the Performance Bar')).to be_checked + expect(find_field('Allowed group').value).to eq group.path + + page.within('.as-performance-bar') do + uncheck 'Enable the Performance Bar' + click_on 'Save changes' + end + + expect(page).to have_content 'Application settings saved successfully' + expect(find_field('Enable the Performance Bar')).not_to be_checked + expect(find_field('Allowed group').value).to be_nil + end + + scenario 'Change Background jobs settings' do + page.within('.as-background') do + fill_in 'Throttling Factor', with: 1 + click_button 'Save changes' + end + + expect(Gitlab::CurrentSettings.sidekiq_throttling_factor).to eq(1) + expect(page).to have_content "Application settings saved successfully" + end + + scenario 'Change Spam settings' do + page.within('.as-spam') do + check 'Enable reCAPTCHA' + fill_in 'reCAPTCHA Site Key', with: 'key' + fill_in 'reCAPTCHA Private Key', with: 'key' + fill_in 'IPs per user', with: 15 + click_button 'Save changes' + end + + expect(page).to have_content "Application settings saved successfully" + expect(Gitlab::CurrentSettings.recaptcha_enabled).to be true + expect(Gitlab::CurrentSettings.unique_ips_limit_per_user).to eq(15) + end + + scenario 'Configure web terminal' do + page.within('.as-terminal') do + fill_in 'Max session time', with: 15 + click_button 'Save changes' + end + + expect(page).to have_content "Application settings saved successfully" + expect(Gitlab::CurrentSettings.terminal_max_session_time).to eq(15) + end + + scenario 'Enable outbound requests' do + page.within('.as-outbound') do + check 'Allow requests to the local network from hooks and services' + click_button 'Save changes' + end + + expect(page).to have_content "Application settings saved successfully" + expect(Gitlab::CurrentSettings.allow_local_requests_from_hooks_and_services).to be true + end + scenario 'Change Slack Notifications Service template settings' do first(:link, 'Service Templates').click click_link 'Slack notifications' @@ -172,29 +239,6 @@ feature 'Admin updates settings' do expect(find_field('ED25519 SSH keys').value).to eq(forbidden) end - scenario 'Change Performance Bar settings' do - group = create(:group) - - check 'Enable the Performance Bar' - fill_in 'Allowed group', with: group.path - - click_on 'Save' - - expect(page).to have_content 'Application settings saved successfully' - - expect(find_field('Enable the Performance Bar')).to be_checked - expect(find_field('Allowed group').value).to eq group.path - - uncheck 'Enable the Performance Bar' - - click_on 'Save' - - expect(page).to have_content 'Application settings saved successfully' - - expect(find_field('Enable the Performance Bar')).not_to be_checked - expect(find_field('Allowed group').value).to be_nil - end - def check_all_events page.check('Active') page.check('Push') diff --git a/spec/features/atom/dashboard_issues_spec.rb b/spec/features/atom/dashboard_issues_spec.rb index d673bac4995..fb6c71ce997 100644 --- a/spec/features/atom/dashboard_issues_spec.rb +++ b/spec/features/atom/dashboard_issues_spec.rb @@ -13,17 +13,26 @@ describe "Dashboard Issues Feed" do end describe "atom feed" do - it "renders atom feed via personal access token" do + it "returns 400 if no filter is used" do personal_access_token = create(:personal_access_token, user: user) visit issues_dashboard_path(:atom, private_token: personal_access_token.token) expect(response_headers['Content-Type']).to have_content('application/atom+xml') + expect(page.status_code).to eq(400) + end + + it "renders atom feed via personal access token" do + personal_access_token = create(:personal_access_token, user: user) + + visit issues_dashboard_path(:atom, private_token: personal_access_token.token, assignee_id: user.id) + + expect(response_headers['Content-Type']).to have_content('application/atom+xml') expect(body).to have_selector('title', text: "#{user.name} issues") end it "renders atom feed via RSS token" do - visit issues_dashboard_path(:atom, rss_token: user.rss_token) + visit issues_dashboard_path(:atom, rss_token: user.rss_token, assignee_id: user.id) expect(response_headers['Content-Type']).to have_content('application/atom+xml') expect(body).to have_selector('title', text: "#{user.name} issues") @@ -44,7 +53,7 @@ describe "Dashboard Issues Feed" do let!(:issue2) { create(:issue, author: user, assignees: [assignee], project: project2, description: 'test desc') } it "renders issue fields" do - visit issues_dashboard_path(:atom, rss_token: user.rss_token) + visit issues_dashboard_path(:atom, rss_token: user.rss_token, assignee_id: assignee.id) entry = find(:xpath, "//feed/entry[contains(summary/text(),'#{issue2.title}')]") @@ -67,7 +76,7 @@ describe "Dashboard Issues Feed" do end it "renders issue label and milestone info" do - visit issues_dashboard_path(:atom, rss_token: user.rss_token) + visit issues_dashboard_path(:atom, rss_token: user.rss_token, assignee_id: assignee.id) entry = find(:xpath, "//feed/entry[contains(summary/text(),'#{issue1.title}')]") diff --git a/spec/features/dashboard/issues_filter_spec.rb b/spec/features/dashboard/issues_filter_spec.rb index 8759950e013..bab34ac9346 100644 --- a/spec/features/dashboard/issues_filter_spec.rb +++ b/spec/features/dashboard/issues_filter_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' feature 'Dashboard Issues filtering', :js do - include SortingHelper + include Spec::Support::Helpers::Features::SortingHelpers let(:user) { create(:user) } let(:project) { create(:project) } @@ -17,6 +17,12 @@ feature 'Dashboard Issues filtering', :js do visit_issues end + context 'without any filter' do + it 'shows error message' do + expect(page).to have_content 'Please select at least one filter to see results' + end + end + context 'filtering by milestone' do it 'shows all issues with no milestone' do show_milestone_dropdown @@ -27,15 +33,6 @@ feature 'Dashboard Issues filtering', :js do expect(page).to have_selector('.issue', count: 1) end - it 'shows all issues with any milestone' do - show_milestone_dropdown - - click_link 'Any Milestone' - - expect(page).to have_issuable_counts(open: 2, closed: 0, all: 2) - expect(page).to have_selector('.issue', count: 2) - end - it 'shows all issues with the selected milestone' do show_milestone_dropdown @@ -68,13 +65,6 @@ feature 'Dashboard Issues filtering', :js do let(:label) { create(:label, project: project) } let!(:label_link) { create(:label_link, label: label, target: issue) } - it 'shows all issues without filter' do - page.within 'ul.content-list' do - expect(page).to have_content issue.title - expect(page).to have_content issue2.title - end - end - it 'shows all issues with the selected label' do page.within '.labels-filter' do find('.dropdown').click @@ -89,15 +79,19 @@ feature 'Dashboard Issues filtering', :js do end context 'sorting' do - it 'shows sorted issues' do - sorting_by('Created date') - visit_issues + before do + visit_issues(assignee_id: user.id) + end + + it 'remembers last sorting value' do + sort_by('Created date') + visit_issues(assignee_id: user.id) expect(find('.issues-filters')).to have_content('Created date') end it 'keeps sorting issues after visiting Projects Issues page' do - sorting_by('Created date') + sort_by('Created date') visit project_issues_path(project) expect(find('.issues-filters')).to have_content('Created date') diff --git a/spec/features/dashboard/issues_spec.rb b/spec/features/dashboard/issues_spec.rb index 8d1d5a51750..e41a2e4ce09 100644 --- a/spec/features/dashboard/issues_spec.rb +++ b/spec/features/dashboard/issues_spec.rb @@ -51,15 +51,6 @@ RSpec.describe 'Dashboard Issues' do expect(page).not_to have_content(other_issue.title) end - it 'shows all issues' do - click_link('Reset filters') - - expect(page).to have_content(authored_issue.title) - expect(page).to have_content(authored_issue_on_public_project.title) - expect(page).to have_content(assigned_issue.title) - expect(page).to have_content(other_issue.title) - end - it 'state filter tabs work' do find('#state-closed').click expect(page).to have_current_path(issues_dashboard_url(assignee_id: current_user.id, state: 'closed'), url: true) diff --git a/spec/features/dashboard/merge_requests_spec.rb b/spec/features/dashboard/merge_requests_spec.rb index c8f3a8449f5..0965b745c03 100644 --- a/spec/features/dashboard/merge_requests_spec.rb +++ b/spec/features/dashboard/merge_requests_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' feature 'Dashboard Merge Requests' do + include Spec::Support::Helpers::Features::SortingHelpers include FilterItemSelectHelper - include SortingHelper include ProjectForksHelper let(:current_user) { create :user } @@ -103,19 +103,15 @@ feature 'Dashboard Merge Requests' do expect(page).not_to have_content(other_merge_request.title) end - it 'shows all merge requests', :js do + it 'shows error message without filter', :js do filter_item_select('Any Assignee', '.js-assignee-search') filter_item_select('Any Author', '.js-author-search') - expect(page).to have_content(authored_merge_request.title) - expect(page).to have_content(authored_merge_request_from_fork.title) - expect(page).to have_content(assigned_merge_request.title) - expect(page).to have_content(assigned_merge_request_from_fork.title) - expect(page).to have_content(other_merge_request.title) + expect(page).to have_content('Please select at least one filter to see results') end it 'shows sorted merge requests' do - sorting_by('Created date') + sort_by('Created date') visit merge_requests_dashboard_path(assignee_id: current_user.id) @@ -123,7 +119,7 @@ feature 'Dashboard Merge Requests' do end it 'keeps sorting merge requests after visiting Projects MR page' do - sorting_by('Created date') + sort_by('Created date') visit project_merge_requests_path(project) diff --git a/spec/features/groups/settings/group_badges_spec.rb b/spec/features/groups/settings/group_badges_spec.rb new file mode 100644 index 00000000000..92217294446 --- /dev/null +++ b/spec/features/groups/settings/group_badges_spec.rb @@ -0,0 +1,124 @@ +require 'spec_helper' + +feature 'Group Badges' do + include WaitForRequests + + let(:user) { create(:user) } + let(:group) { create(:group) } + let(:badge_link_url) { 'https://gitlab.com/gitlab-org/gitlab-ee/commits/master'} + let(:badge_image_url) { 'https://gitlab.com/gitlab-org/gitlab-ee/badges/master/build.svg'} + let!(:badge_1) { create(:group_badge, group: group) } + let!(:badge_2) { create(:group_badge, group: group) } + + before do + group.add_owner(user) + sign_in(user) + + visit(group_settings_badges_path(group)) + end + + it 'shows a list of badges', :js do + page.within '.badge-settings' do + wait_for_requests + + rows = all('.panel-body > div') + expect(rows.length).to eq 2 + expect(rows[0]).to have_content badge_1.link_url + expect(rows[1]).to have_content badge_2.link_url + end + end + + context 'adding a badge', :js do + it 'user can preview a badge' do + page.within '.badge-settings form' do + fill_in 'badge-link-url', with: badge_link_url + fill_in 'badge-image-url', with: badge_image_url + within '#badge-preview' do + expect(find('a')[:href]).to eq badge_link_url + expect(find('a img')[:src]).to eq badge_image_url + end + end + end + + it do + page.within '.badge-settings' do + fill_in 'badge-link-url', with: badge_link_url + fill_in 'badge-image-url', with: badge_image_url + + click_button 'Add badge' + wait_for_requests + + within '.panel-body' do + expect(find('a')[:href]).to eq badge_link_url + expect(find('a img')[:src]).to eq badge_image_url + end + end + end + end + + context 'editing a badge', :js do + it 'form is shown when clicking edit button in list' do + page.within '.badge-settings' do + wait_for_requests + rows = all('.panel-body > div') + expect(rows.length).to eq 2 + rows[1].find('[aria-label="Edit"]').click + + within 'form' do + expect(find('#badge-link-url').value).to eq badge_2.link_url + expect(find('#badge-image-url').value).to eq badge_2.image_url + end + end + end + + it 'updates a badge when submitting the edit form' do + page.within '.badge-settings' do + wait_for_requests + rows = all('.panel-body > div') + expect(rows.length).to eq 2 + rows[1].find('[aria-label="Edit"]').click + within 'form' do + fill_in 'badge-link-url', with: badge_link_url + fill_in 'badge-image-url', with: badge_image_url + + click_button 'Save changes' + wait_for_requests + end + + rows = all('.panel-body > div') + expect(rows.length).to eq 2 + expect(rows[1]).to have_content badge_link_url + end + end + end + + context 'deleting a badge', :js do + def click_delete_button(badge_row) + badge_row.find('[aria-label="Delete"]').click + end + + it 'shows a modal when deleting a badge' do + wait_for_requests + rows = all('.panel-body > div') + expect(rows.length).to eq 2 + + click_delete_button(rows[1]) + + expect(find('.modal .modal-title')).to have_content 'Delete badge?' + end + + it 'deletes a badge when confirming the modal' do + wait_for_requests + rows = all('.panel-body > div') + expect(rows.length).to eq 2 + click_delete_button(rows[1]) + + find('.modal .btn-danger').click + wait_for_requests + + rows = all('.panel-body > div') + expect(rows.length).to eq 1 + expect(rows[0]).to have_content badge_1.link_url + end + end +end diff --git a/spec/features/issuables/discussion_lock_spec.rb b/spec/features/issuables/discussion_lock_spec.rb index ecbe51a7bc2..7ea29ff252b 100644 --- a/spec/features/issuables/discussion_lock_spec.rb +++ b/spec/features/issuables/discussion_lock_spec.rb @@ -14,7 +14,7 @@ describe 'Discussion Lock', :js do project.add_developer(user) end - context 'when the discussion is unlocked' do + context 'when the discussion is unlocked' do it 'the user can lock the issue' do visit project_issue_path(project, issue) diff --git a/spec/features/issues/filtered_search/filter_issues_spec.rb b/spec/features/issues/filtered_search/filter_issues_spec.rb index b3c50964810..08ba91a2682 100644 --- a/spec/features/issues/filtered_search/filter_issues_spec.rb +++ b/spec/features/issues/filtered_search/filter_issues_spec.rb @@ -22,15 +22,6 @@ describe 'Filter issues', :js do end end - def expect_issues_list_count(open_count, closed_count = 0) - all_count = open_count + closed_count - - expect(page).to have_issuable_counts(open: open_count, closed: closed_count, all: all_count) - page.within '.issues-list' do - expect(page).to have_selector('.issue', count: open_count) - end - end - before do project.add_master(user) diff --git a/spec/features/issues/form_spec.rb b/spec/features/issues/form_spec.rb index 38c618d300e..4625a50b8d9 100644 --- a/spec/features/issues/form_spec.rb +++ b/spec/features/issues/form_spec.rb @@ -226,6 +226,23 @@ describe 'New/edit issue', :js do expect(page).to have_selector('.atwho-view') end + + describe 'milestone' do + let!(:milestone) { create(:milestone, title: '"><img src=x onerror=alert(document.domain)>', project: project) } + + it 'escapes milestone' do + click_button 'Milestone' + + page.within '.issue-milestone' do + click_link milestone.title + end + + page.within '.js-milestone-select' do + expect(page).to have_content milestone.title + expect(page).not_to have_selector 'img' + end + end + end end context 'edit issue' do diff --git a/spec/features/issues/issue_sidebar_spec.rb b/spec/features/issues/issue_sidebar_spec.rb index b835558b142..27551bb70ee 100644 --- a/spec/features/issues/issue_sidebar_spec.rb +++ b/spec/features/issues/issue_sidebar_spec.rb @@ -161,6 +161,50 @@ feature 'Issue Sidebar' do end end end + + context 'interacting with collapsed sidebar', :js do + collapsed_sidebar_selector = 'aside.right-sidebar.right-sidebar-collapsed' + expanded_sidebar_selector = 'aside.right-sidebar.right-sidebar-expanded' + confidentiality_sidebar_block = '.block.confidentiality' + lock_sidebar_block = '.block.lock' + collapsed_sidebar_block_icon = '.sidebar-collapsed-icon' + + before do + resize_screen_sm + end + + it 'confidentiality block expands then collapses sidebar' do + expect(page).to have_css(collapsed_sidebar_selector) + + page.within(confidentiality_sidebar_block) do + find(collapsed_sidebar_block_icon).click + end + + expect(page).to have_css(expanded_sidebar_selector) + + page.within(confidentiality_sidebar_block) do + page.find('button', text: 'Cancel').click + end + + expect(page).to have_css(collapsed_sidebar_selector) + end + + it 'lock block expands then collapses sidebar' do + expect(page).to have_css(collapsed_sidebar_selector) + + page.within(lock_sidebar_block) do + find(collapsed_sidebar_block_icon).click + end + + expect(page).to have_css(expanded_sidebar_selector) + + page.within(lock_sidebar_block) do + page.find('button', text: 'Cancel').click + end + + expect(page).to have_css(collapsed_sidebar_selector) + end + end end context 'as a guest' do diff --git a/spec/features/issues/spam_issues_spec.rb b/spec/features/issues/spam_issues_spec.rb index a75ca1d42b3..73022afbda2 100644 --- a/spec/features/issues/spam_issues_spec.rb +++ b/spec/features/issues/spam_issues_spec.rb @@ -34,9 +34,6 @@ describe 'New issue', :js do click_button 'Submit issue' - # reCAPTCHA alerts when it can't contact the server, so just accept it and move on - page.driver.browser.switch_to.alert.accept - # it is impossible to test recaptcha automatically and there is no possibility to fill in recaptcha # recaptcha verification is skipped in test environment and it always returns true expect(page).not_to have_content('issue title') diff --git a/spec/features/issues/user_uses_slash_commands_spec.rb b/spec/features/issues/user_uses_slash_commands_spec.rb index ea7a97d02a0..ff2a0e15719 100644 --- a/spec/features/issues/user_uses_slash_commands_spec.rb +++ b/spec/features/issues/user_uses_slash_commands_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' feature 'Issues > User uses quick actions', :js do - include QuickActionsHelpers + include Spec::Support::Helpers::Features::NotesHelpers it_behaves_like 'issuable record that supports quick actions in its description and notes', :issue do let(:issuable) { create(:issue, project: project) } @@ -36,7 +36,7 @@ feature 'Issues > User uses quick actions', :js do context 'when the current user can update the due date' do it 'does not create a note, and sets the due date accordingly' do - write_note("/due 2016-08-28") + add_note("/due 2016-08-28") expect(page).not_to have_content '/due 2016-08-28' expect(page).to have_content 'Commands applied' @@ -57,7 +57,7 @@ feature 'Issues > User uses quick actions', :js do end it 'does not create a note, and sets the due date accordingly' do - write_note("/due 2016-08-28") + add_note("/due 2016-08-28") expect(page).not_to have_content 'Commands applied' @@ -75,7 +75,7 @@ feature 'Issues > User uses quick actions', :js do it 'does not create a note, and removes the due date accordingly' do expect(issue.due_date).to eq Date.new(2016, 8, 28) - write_note("/remove_due_date") + add_note("/remove_due_date") expect(page).not_to have_content '/remove_due_date' expect(page).to have_content 'Commands applied' @@ -96,7 +96,7 @@ feature 'Issues > User uses quick actions', :js do end it 'does not create a note, and sets the due date accordingly' do - write_note("/remove_due_date") + add_note("/remove_due_date") expect(page).not_to have_content 'Commands applied' @@ -111,7 +111,7 @@ feature 'Issues > User uses quick actions', :js do let(:issue) { create(:issue, project: project) } it 'does not recognize the command nor create a note' do - write_note("/wip") + add_note("/wip") expect(page).not_to have_content '/wip' end @@ -123,7 +123,7 @@ feature 'Issues > User uses quick actions', :js do context 'when the current user can update issues' do it 'does not create a note, and marks the issue as a duplicate' do - write_note("/duplicate ##{original_issue.to_reference}") + add_note("/duplicate ##{original_issue.to_reference}") expect(page).not_to have_content "/duplicate #{original_issue.to_reference}" expect(page).to have_content 'Commands applied' @@ -143,7 +143,7 @@ feature 'Issues > User uses quick actions', :js do end it 'does not create a note, and does not mark the issue as a duplicate' do - write_note("/duplicate ##{original_issue.to_reference}") + add_note("/duplicate ##{original_issue.to_reference}") expect(page).not_to have_content 'Commands applied' expect(page).not_to have_content "marked this issue as a duplicate of #{original_issue.to_reference}" @@ -166,7 +166,7 @@ feature 'Issues > User uses quick actions', :js do end it 'moves the issue' do - write_note("/move #{target_project.full_path}") + add_note("/move #{target_project.full_path}") expect(page).to have_content 'Commands applied' expect(issue.reload).to be_closed @@ -186,7 +186,7 @@ feature 'Issues > User uses quick actions', :js do end it 'does not move the issue' do - write_note("/move #{project_unauthorized.full_path}") + add_note("/move #{project_unauthorized.full_path}") expect(page).not_to have_content 'Commands applied' expect(issue.reload).to be_open @@ -200,7 +200,7 @@ feature 'Issues > User uses quick actions', :js do end it 'does not move the issue' do - write_note("/move not/valid") + add_note("/move not/valid") expect(page).not_to have_content 'Commands applied' expect(issue.reload).to be_open @@ -223,7 +223,7 @@ feature 'Issues > User uses quick actions', :js do end it 'applies the commands to both issues and moves the issue' do - write_note("/label ~#{bug.title} ~#{wontfix.title}\n\n/milestone %\"#{milestone.title}\"\n\n/move #{target_project.full_path}") + add_note("/label ~#{bug.title} ~#{wontfix.title}\n\n/milestone %\"#{milestone.title}\"\n\n/move #{target_project.full_path}") expect(page).to have_content 'Commands applied' expect(issue.reload).to be_closed @@ -242,7 +242,7 @@ feature 'Issues > User uses quick actions', :js do end it 'moves the issue and applies the commands to both issues' do - write_note("/move #{target_project.full_path}\n\n/label ~#{bug.title} ~#{wontfix.title}\n\n/milestone %\"#{milestone.title}\"") + add_note("/move #{target_project.full_path}\n\n/label ~#{bug.title} ~#{wontfix.title}\n\n/milestone %\"#{milestone.title}\"") expect(page).to have_content 'Commands applied' expect(issue.reload).to be_closed diff --git a/spec/features/labels_hierarchy_spec.rb b/spec/features/labels_hierarchy_spec.rb new file mode 100644 index 00000000000..3e05e7b7f38 --- /dev/null +++ b/spec/features/labels_hierarchy_spec.rb @@ -0,0 +1,305 @@ +require 'spec_helper' + +feature 'Labels Hierarchy', :js, :nested_groups do + include FilteredSearchHelpers + + let!(:user) { create(:user) } + let!(:grandparent) { create(:group) } + let!(:parent) { create(:group, parent: grandparent) } + let!(:child) { create(:group, parent: parent) } + let!(:project_1) { create(:project, namespace: parent) } + + let!(:grandparent_group_label) { create(:group_label, group: grandparent, title: 'Label_1') } + let!(:parent_group_label) { create(:group_label, group: parent, title: 'Label_2') } + let!(:child_group_label) { create(:group_label, group: child, title: 'Label_3') } + let!(:project_label_1) { create(:label, project: project_1, title: 'Label_4') } + + before do + grandparent.add_owner(user) + + sign_in(user) + end + + shared_examples 'assigning labels from sidebar' do + it 'can assign all ancestors labels' do + [grandparent_group_label, parent_group_label, project_label_1].each do |label| + page.within('.block.labels') do + find('.edit-link').click + end + + wait_for_requests + + find('a.label-item', text: label.title).click + find('.dropdown-menu-close-icon').click + + wait_for_requests + + expect(page).to have_selector('span.label', text: label.title) + end + end + + it 'does not find child group labels on dropdown' do + page.within('.block.labels') do + find('.edit-link').click + end + + wait_for_requests + + expect(page).not_to have_selector('span.label', text: child_group_label.title) + end + end + + shared_examples 'filtering by ancestor labels for projects' do |board = false| + it 'filters by ancestor labels' do + [grandparent_group_label, parent_group_label, project_label_1].each do |label| + select_label_on_dropdown(label.title) + + wait_for_requests + + if board + expect(page).to have_selector('.card-title') do |card| + expect(card).to have_selector('a', text: labeled_issue.title) + end + else + expect_issues_list_count(1) + expect(page).to have_selector('span.issue-title-text', text: labeled_issue.title) + end + end + end + + it 'does not filter by descendant group labels' do + filtered_search.set("label:") + + wait_for_requests + + expect(page).not_to have_selector('.btn-link', text: child_group_label.title) + end + end + + shared_examples 'filtering by ancestor labels for groups' do |board = false| + let(:project_2) { create(:project, namespace: parent) } + let!(:project_label_2) { create(:label, project: project_2, title: 'Label_4') } + + let(:project_3) { create(:project, namespace: child) } + let!(:group_label_3) { create(:group_label, group: child, title: 'Label_5') } + let!(:project_label_3) { create(:label, project: project_3, title: 'Label_6') } + + let!(:labeled_issue_2) { create(:labeled_issue, project: project_2, labels: [grandparent_group_label, parent_group_label, project_label_2]) } + let!(:labeled_issue_3) { create(:labeled_issue, project: project_3, labels: [grandparent_group_label, parent_group_label, group_label_3]) } + + let!(:issue_2) { create(:issue, project: project_2) } + + it 'filters by ancestors and current group labels' do + [grandparent_group_label, parent_group_label].each do |label| + select_label_on_dropdown(label.title) + + wait_for_requests + + if board + expect(page).to have_selector('.card-title') do |card| + expect(card).to have_selector('a', text: labeled_issue.title) + end + + expect(page).to have_selector('.card-title') do |card| + expect(card).to have_selector('a', text: labeled_issue_2.title) + end + else + expect_issues_list_count(3) + expect(page).to have_selector('span.issue-title-text', text: labeled_issue.title) + expect(page).to have_selector('span.issue-title-text', text: labeled_issue_2.title) + expect(page).to have_selector('span.issue-title-text', text: labeled_issue_3.title) + end + end + end + + it 'filters by descendant group labels' do + wait_for_requests + + select_label_on_dropdown(group_label_3.title) + + if board + expect(page).to have_selector('.card-title') do |card| + expect(card).not_to have_selector('a', text: labeled_issue_2.title) + end + + expect(page).to have_selector('.card-title') do |card| + expect(card).to have_selector('a', text: labeled_issue_3.title) + end + else + expect_issues_list_count(1) + expect(page).to have_selector('span.issue-title-text', text: labeled_issue_3.title) + end + end + + it 'does not filter by descendant group project labels' do + filtered_search.set("label:") + + wait_for_requests + + expect(page).not_to have_selector('.btn-link', text: project_label_3.title) + end + end + + context 'when creating new issuable' do + before do + visit new_project_issue_path(project_1) + end + + it 'should be able to assign ancestor group labels' do + fill_in 'issue_title', with: 'new created issue' + fill_in 'issue_description', with: 'new issue description' + + find(".js-label-select").click + wait_for_requests + + find('a.label-item', text: grandparent_group_label.title).click + find('a.label-item', text: parent_group_label.title).click + find('a.label-item', text: project_label_1.title).click + + find('.btn-create').click + + expect(page.find('.issue-details h2.title')).to have_content('new created issue') + expect(page).to have_selector('span.label', text: grandparent_group_label.title) + expect(page).to have_selector('span.label', text: parent_group_label.title) + expect(page).to have_selector('span.label', text: project_label_1.title) + end + end + + context 'issuable sidebar' do + let!(:issue) { create(:issue, project: project_1) } + + context 'on issue sidebar' do + before do + visit project_issue_path(project_1, issue) + end + + it_behaves_like 'assigning labels from sidebar' + end + + context 'on project board issue sidebar' do + let(:board) { create(:board, project: project_1) } + + before do + visit project_board_path(project_1, board) + + wait_for_requests + + find('.card').click + end + + it_behaves_like 'assigning labels from sidebar' + end + + context 'on group board issue sidebar' do + let(:board) { create(:board, group: parent) } + + before do + visit group_board_path(parent, board) + + wait_for_requests + + find('.card').click + end + + it_behaves_like 'assigning labels from sidebar' + end + end + + context 'issuable filtering' do + let!(:labeled_issue) { create(:labeled_issue, project: project_1, labels: [grandparent_group_label, parent_group_label, project_label_1]) } + let!(:issue) { create(:issue, project: project_1) } + + context 'on project issuable list' do + before do + visit project_issues_path(project_1) + end + + it_behaves_like 'filtering by ancestor labels for projects' + + it 'does not filter by descendant group labels' do + filtered_search.set("label:") + + wait_for_requests + + expect(page).not_to have_selector('.btn-link', text: child_group_label.title) + end + end + + context 'on group issuable list' do + before do + visit issues_group_path(parent) + end + + it_behaves_like 'filtering by ancestor labels for groups' + end + + context 'on project boards filter' do + let(:board) { create(:board, project: project_1) } + + before do + visit project_board_path(project_1, board) + end + + it_behaves_like 'filtering by ancestor labels for projects', true + end + + context 'on group boards filter' do + let(:board) { create(:board, group: parent) } + + before do + visit group_board_path(parent, board) + end + + it_behaves_like 'filtering by ancestor labels for groups', true + end + end + + context 'creating boards lists' do + context 'on project boards' do + let(:board) { create(:board, project: project_1) } + + before do + visit project_board_path(project_1, board) + find('.js-new-board-list').click + wait_for_requests + end + + it 'creates lists from all ancestor labels' do + [grandparent_group_label, parent_group_label, project_label_1].each do |label| + find('a', text: label.title).click + end + + wait_for_requests + + expect(page).to have_selector('.board-title-text', text: grandparent_group_label.title) + expect(page).to have_selector('.board-title-text', text: parent_group_label.title) + expect(page).to have_selector('.board-title-text', text: project_label_1.title) + end + end + + context 'on group boards' do + let(:board) { create(:board, group: parent) } + + before do + visit group_board_path(parent, board) + find('.js-new-board-list').click + wait_for_requests + end + + it 'creates lists from all ancestor group labels' do + [grandparent_group_label, parent_group_label].each do |label| + find('a', text: label.title).click + end + + wait_for_requests + + expect(page).to have_selector('.board-title-text', text: grandparent_group_label.title) + expect(page).to have_selector('.board-title-text', text: parent_group_label.title) + end + + it 'does not create lists from descendant groups' do + expect(page).not_to have_selector('a', text: child_group_label.title) + end + end + end +end diff --git a/spec/features/merge_request/user_sees_mini_pipeline_graph_spec.rb b/spec/features/merge_request/user_sees_mini_pipeline_graph_spec.rb index a43ba05c64c..fd1629746ef 100644 --- a/spec/features/merge_request/user_sees_mini_pipeline_graph_spec.rb +++ b/spec/features/merge_request/user_sees_mini_pipeline_graph_spec.rb @@ -9,6 +9,7 @@ describe 'Merge request < User sees mini pipeline graph', :js do before do build.run + build.trace.set('hello') sign_in(user) visit_merge_request end @@ -26,15 +27,15 @@ describe 'Merge request < User sees mini pipeline graph', :js do let(:artifacts_file2) { fixture_file_upload(Rails.root.join('spec/fixtures/dk.png'), 'image/png') } before do - create(:ci_build, pipeline: pipeline, legacy_artifacts_file: artifacts_file1) - create(:ci_build, pipeline: pipeline, when: 'manual') + create(:ci_build, :success, :trace_artifact, pipeline: pipeline, legacy_artifacts_file: artifacts_file1) + create(:ci_build, :manual, pipeline: pipeline, when: 'manual') end it 'avoids repeated database queries' do before = ActiveRecord::QueryRecorder.new { visit_merge_request(format: :json, serializer: 'widget') } - create(:ci_build, pipeline: pipeline, legacy_artifacts_file: artifacts_file2) - create(:ci_build, pipeline: pipeline, when: 'manual') + create(:ci_build, :success, :trace_artifact, pipeline: pipeline, legacy_artifacts_file: artifacts_file2) + create(:ci_build, :manual, pipeline: pipeline, when: 'manual') after = ActiveRecord::QueryRecorder.new { visit_merge_request(format: :json, serializer: 'widget') } diff --git a/spec/features/merge_request/user_uses_slash_commands_spec.rb b/spec/features/merge_request/user_uses_slash_commands_spec.rb index bd739e69d6c..7f261b580f7 100644 --- a/spec/features/merge_request/user_uses_slash_commands_spec.rb +++ b/spec/features/merge_request/user_uses_slash_commands_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' describe 'Merge request > User uses quick actions', :js do - include QuickActionsHelpers + include Spec::Support::Helpers::Features::NotesHelpers let(:project) { create(:project, :public, :repository) } let(:user) { project.creator } @@ -33,7 +33,7 @@ describe 'Merge request > User uses quick actions', :js do describe 'toggling the WIP prefix in the title from note' do context 'when the current user can toggle the WIP prefix' do it 'adds the WIP: prefix to the title' do - write_note("/wip") + add_note("/wip") expect(page).not_to have_content '/wip' expect(page).to have_content 'Commands applied' @@ -44,7 +44,7 @@ describe 'Merge request > User uses quick actions', :js do it 'removes the WIP: prefix from the title' do merge_request.title = merge_request.wip_title merge_request.save - write_note("/wip") + add_note("/wip") expect(page).not_to have_content '/wip' expect(page).to have_content 'Commands applied' @@ -62,7 +62,7 @@ describe 'Merge request > User uses quick actions', :js do end it 'does not change the WIP prefix' do - write_note("/wip") + add_note("/wip") expect(page).not_to have_content '/wip' expect(page).not_to have_content 'Commands applied' @@ -75,7 +75,7 @@ describe 'Merge request > User uses quick actions', :js do describe 'merging the MR from the note' do context 'when the current user can merge the MR' do it 'merges the MR' do - write_note("/merge") + add_note("/merge") expect(page).to have_content 'Commands applied' @@ -90,7 +90,7 @@ describe 'Merge request > User uses quick actions', :js do end it 'does not merge the MR' do - write_note("/merge") + add_note("/merge") expect(page).not_to have_content 'Your commands have been executed!' @@ -107,7 +107,7 @@ describe 'Merge request > User uses quick actions', :js do end it 'does not merge the MR' do - write_note("/merge") + add_note("/merge") expect(page).not_to have_content 'Your commands have been executed!' @@ -118,7 +118,7 @@ describe 'Merge request > User uses quick actions', :js do describe 'adding a due date from note' do it 'does not recognize the command nor create a note' do - write_note('/due 2016-08-28') + add_note('/due 2016-08-28') expect(page).not_to have_content '/due 2016-08-28' end @@ -162,7 +162,7 @@ describe 'Merge request > User uses quick actions', :js do describe '/target_branch command from note' do context 'when the current user can change target branch' do it 'changes target branch from a note' do - write_note("message start \n/target_branch merge-test\n message end.") + add_note("message start \n/target_branch merge-test\n message end.") wait_for_requests expect(page).not_to have_content('/target_branch') @@ -173,7 +173,7 @@ describe 'Merge request > User uses quick actions', :js do end it 'does not fail when target branch does not exists' do - write_note('/target_branch totally_not_existing_branch') + add_note('/target_branch totally_not_existing_branch') expect(page).not_to have_content('/target_branch') @@ -190,7 +190,7 @@ describe 'Merge request > User uses quick actions', :js do end it 'does not change target branch' do - write_note('/target_branch merge-test') + add_note('/target_branch merge-test') expect(page).not_to have_content '/target_branch merge-test' diff --git a/spec/features/profile_spec.rb b/spec/features/profile_spec.rb index 0848857ed1e..15dcb30cbdd 100644 --- a/spec/features/profile_spec.rb +++ b/spec/features/profile_spec.rb @@ -97,9 +97,13 @@ describe 'Profile account page', :js do end it 'changes my username' do - fill_in 'user_username', with: 'new-username' + fill_in 'username-change-input', with: 'new-username' - click_button('Update username') + page.find('[data-target="#username-change-confirmation-modal"]').click + + page.within('.modal') do + find('.js-modal-primary-action').click + end expect(page).to have_content('new-username') end diff --git a/spec/features/profiles/account_spec.rb b/spec/features/profiles/account_spec.rb index 171e061e60e..215b658eb7b 100644 --- a/spec/features/profiles/account_spec.rb +++ b/spec/features/profiles/account_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'Profile > Account' do +feature 'Profile > Account', :js do given(:user) { create(:user, username: 'foo') } before do @@ -43,14 +43,14 @@ feature 'Profile > Account' do update_username(new_username) visit new_project_path expect(current_path).to eq(new_project_path) - expect(find('.breadcrumbs-sub-title')).to have_content(project.path) + expect(find('.breadcrumbs-sub-title')).to have_content('Details') end scenario 'the old project path redirects to the new path' do update_username(new_username) visit old_project_path expect(current_path).to eq(new_project_path) - expect(find('.breadcrumbs-sub-title')).to have_content(project.path) + expect(find('.breadcrumbs-sub-title')).to have_content('Details') end end end @@ -59,6 +59,12 @@ end def update_username(new_username) allow(user.namespace).to receive(:move_dir) visit profile_account_path - fill_in 'user_username', with: new_username - click_button 'Update username' + + fill_in 'username-change-input', with: new_username + + page.find('[data-target="#username-change-confirmation-modal"]').click + + page.within('.modal') do + find('.js-modal-primary-action').click + end end diff --git a/spec/features/projects/activity/rss_spec.rb b/spec/features/projects/activity/rss_spec.rb index 2693e539268..cd1cfe07998 100644 --- a/spec/features/projects/activity/rss_spec.rb +++ b/spec/features/projects/activity/rss_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' feature 'Project Activity RSS' do - let(:user) { create(:user) } - let(:project) { create(:project, visibility_level: Gitlab::VisibilityLevel::PUBLIC) } + let(:project) { create(:project, :public) } + let(:user) { project.owner } let(:path) { activity_project_path(project) } before do @@ -11,8 +11,7 @@ feature 'Project Activity RSS' do context 'when signed in' do before do - project.add_developer(user) - sign_in(user) + sign_in(project.owner) visit path end diff --git a/spec/features/projects/activity/user_sees_activity_spec.rb b/spec/features/projects/activity/user_sees_activity_spec.rb new file mode 100644 index 00000000000..644a837dc14 --- /dev/null +++ b/spec/features/projects/activity/user_sees_activity_spec.rb @@ -0,0 +1,21 @@ +require 'spec_helper' + +feature 'Projects > Activity > User sees activity' do + let(:project) { create(:project, :repository, :public) } + let(:user) { project.creator } + + before do + event = create(:push_event, project: project, author: user) + create(:push_event_payload, + event: event, + action: :created, + commit_to: '6d394385cf567f80a8fd85055db1ab4c5295806f', + ref: 'fix', + commit_count: 1) + visit activity_project_path(project) + end + + it 'shows the last push in the activity page', :js do + expect(page).to have_content "#{user.name} pushed new branch fix" + end +end diff --git a/spec/features/projects/badges/list_spec.rb b/spec/features/projects/badges/list_spec.rb index c705e479690..0abef4bc447 100644 --- a/spec/features/projects/badges/list_spec.rb +++ b/spec/features/projects/badges/list_spec.rb @@ -6,7 +6,7 @@ feature 'list of badges' do project = create(:project, :repository) project.add_master(user) sign_in(user) - visit project_pipelines_settings_path(project) + visit project_settings_ci_cd_path(project) end scenario 'user wants to see build status badge' do diff --git a/spec/features/projects/edit_spec.rb b/spec/features/projects/edit_spec.rb deleted file mode 100644 index 1d4b4d0fdca..00000000000 --- a/spec/features/projects/edit_spec.rb +++ /dev/null @@ -1,62 +0,0 @@ -require 'rails_helper' - -feature 'Project edit', :js do - let(:admin) { create(:admin) } - let(:user) { create(:user) } - let(:project) { create(:project) } - - context 'feature visibility' do - before do - project.add_master(user) - sign_in(user) - - visit edit_project_path(project) - end - - context 'merge requests select' do - it 'hides merge requests section' do - find('.project-feature-controls[data-for="project[project_feature_attributes][merge_requests_access_level]"] .project-feature-toggle').click - - expect(page).to have_selector('.merge-requests-feature', visible: false) - end - - context 'given project with merge_requests_disabled access level' do - let(:project) { create(:project, :merge_requests_disabled) } - - it 'hides merge requests section' do - expect(page).to have_selector('.merge-requests-feature', visible: false) - end - end - end - - context 'builds select' do - it 'hides builds select section' do - find('.project-feature-controls[data-for="project[project_feature_attributes][builds_access_level]"] .project-feature-toggle').click - - expect(page).to have_selector('.builds-feature', visible: false) - end - - context 'given project with builds_disabled access level' do - let(:project) { create(:project, :builds_disabled) } - - it 'hides builds select section' do - expect(page).to have_selector('.builds-feature', visible: false) - end - end - end - end - - context 'LFS enabled setting' do - before do - sign_in(admin) - end - - it 'displays the correct elements' do - allow(Gitlab.config.lfs).to receive(:enabled).and_return(true) - visit edit_project_path(project) - - expect(page).to have_content('Git Large File Storage') - expect(page).to have_selector('input[name="project[lfs_enabled]"] + button', visible: true) - end - end -end diff --git a/spec/features/projects/files/browse_files_spec.rb b/spec/features/projects/files/browse_files_spec.rb deleted file mode 100644 index 2c38c380d9d..00000000000 --- a/spec/features/projects/files/browse_files_spec.rb +++ /dev/null @@ -1,46 +0,0 @@ -require 'spec_helper' - -feature 'user browses project', :js do - let(:project) { create(:project, :repository) } - let(:user) { create(:user) } - - before do - project.add_master(user) - sign_in(user) - visit project_tree_path(project, project.default_branch) - end - - scenario "can see blame of '.gitignore'" do - click_link ".gitignore" - click_link 'Blame' - - expect(page).to have_content "*.rb" - expect(page).to have_content "Dmitriy Zaporozhets" - expect(page).to have_content "Initial commit" - end - - scenario 'can see raw content of LFS pointer with LFS disabled' do - allow_any_instance_of(Project).to receive(:lfs_enabled?).and_return(false) - click_link 'files' - click_link 'lfs' - click_link 'lfs_object.iso' - wait_for_requests - - expect(page).not_to have_content 'Download (1.5 MB)' - expect(page).to have_content 'version https://git-lfs.github.com/spec/v1' - expect(page).to have_content 'oid sha256:91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897' - expect(page).to have_content 'size 1575078' - end - - scenario 'can see last commit for current directory' do - last_commit = project.repository.last_commit_for_path(project.default_branch, 'files') - - click_link 'files' - wait_for_requests - - page.within('.blob-commit-info') do - expect(page).to have_content last_commit.short_id - expect(page).to have_content last_commit.author_name - end - end -end diff --git a/spec/features/projects/files/creating_a_file_spec.rb b/spec/features/projects/files/creating_a_file_spec.rb deleted file mode 100644 index 8d982636525..00000000000 --- a/spec/features/projects/files/creating_a_file_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'spec_helper' - -feature 'User wants to create a file' do - let(:project) { create(:project, :repository) } - let(:user) { create(:user) } - - background do - project.add_master(user) - sign_in user - visit project_new_blob_path(project, project.default_branch) - end - - def submit_new_file(options) - file_name = find('#file_name') - file_name.set options[:file_name] || 'README.md' - - file_content = find('#file-content', visible: false) - file_content.set options[:file_content] || 'Some content' - - click_button 'Commit changes' - end - - scenario 'file name contains Chinese characters' do - submit_new_file(file_name: '测试.md') - expect(page).to have_content 'The file has been successfully created.' - end - - scenario 'directory name contains Chinese characters' do - submit_new_file(file_name: '中文/测试.md') - expect(page).to have_content 'The file has been successfully created' - end - - scenario 'file name contains directory traversal' do - submit_new_file(file_name: '../README.md') - expect(page).to have_content 'Path cannot include directory traversal' - end -end diff --git a/spec/features/projects/files/dockerfile_dropdown_spec.rb b/spec/features/projects/files/dockerfile_dropdown_spec.rb index f4a39e331fd..004585f7c9e 100644 --- a/spec/features/projects/files/dockerfile_dropdown_spec.rb +++ b/spec/features/projects/files/dockerfile_dropdown_spec.rb @@ -1,22 +1,15 @@ require 'spec_helper' -require 'fileutils' -feature 'User wants to add a Dockerfile file' do +describe 'Projects > Files > User wants to add a Dockerfile file' do before do - user = create(:user) project = create(:project, :repository) - project.add_master(user) - - sign_in user - + sign_in project.owner visit project_new_blob_path(project, 'master', file_name: 'Dockerfile') end - scenario 'user can see Dockerfile dropdown' do + it 'user can pick a Dockerfile file from the dropdown', :js do expect(page).to have_css('.dockerfile-selector') - end - scenario 'user can pick a Dockerfile file from the dropdown', :js do find('.js-dockerfile-selector').click wait_for_requests diff --git a/spec/features/projects/files/download_buttons_spec.rb b/spec/features/projects/files/download_buttons_spec.rb index 2101627f324..03cb3530e2b 100644 --- a/spec/features/projects/files/download_buttons_spec.rb +++ b/spec/features/projects/files/download_buttons_spec.rb @@ -1,42 +1,36 @@ require 'spec_helper' -feature 'Download buttons in files tree' do - given(:user) { create(:user) } - given(:role) { :developer } - given(:status) { 'success' } - given(:project) { create(:project, :repository) } +describe 'Projects > Files > Download buttons in files tree' do + let(:project) { create(:project, :repository) } + let(:user) { project.creator } - given(:pipeline) do + let(:pipeline) do create(:ci_pipeline, project: project, sha: project.commit.sha, ref: project.default_branch, - status: status) + status: 'success') end - given!(:build) do + let!(:build) do create(:ci_build, :success, :artifacts, pipeline: pipeline, status: pipeline.status, name: 'build') end - background do + before do sign_in(user) - project.add_role(user, role) - end + project.add_developer(user) - describe 'when files tree' do - context 'with artifacts' do - before do - visit project_tree_path(project, project.default_branch) - end + visit project_tree_path(project, project.default_branch) + end - scenario 'shows download artifacts button' do - href = latest_succeeded_project_artifacts_path(project, "#{project.default_branch}/download", job: 'build') + context 'with artifacts' do + it 'shows download artifacts button' do + href = latest_succeeded_project_artifacts_path(project, "#{project.default_branch}/download", job: 'build') - expect(page).to have_link "Download '#{build.name}'", href: href - end + expect(page).to have_link "Download '#{build.name}'", href: href end end end diff --git a/spec/features/projects/files/edit_file_soft_wrap_spec.rb b/spec/features/projects/files/edit_file_soft_wrap_spec.rb index 8d32ada5795..41af70d8ebc 100644 --- a/spec/features/projects/files/edit_file_soft_wrap_spec.rb +++ b/spec/features/projects/files/edit_file_soft_wrap_spec.rb @@ -1,10 +1,9 @@ require 'spec_helper' -feature 'User uses soft wrap whilst editing file', :js do +describe 'Projects > Files > User uses soft wrap whilst editing file', :js do before do - user = create(:user) project = create(:project, :repository) - project.add_master(user) + user = project.owner sign_in user visit project_new_blob_path(project, 'master', file_name: 'test_file-name') page.within('.file-editor.code') do @@ -23,7 +22,7 @@ feature 'User uses soft wrap whilst editing file', :js do let(:toggle_button) { find('.soft-wrap-toggle') } - scenario 'user clicks the "Soft wrap" button and then "No wrap" button' do + it 'user clicks the "Soft wrap" button and then "No wrap" button' do wrapped_content_width = get_content_width toggle_button.click expect(toggle_button).to have_content 'No wrap' diff --git a/spec/features/projects/files/editing_a_file_spec.rb b/spec/features/projects/files/editing_a_file_spec.rb index d874cdbff8d..4074e67e2d2 100644 --- a/spec/features/projects/files/editing_a_file_spec.rb +++ b/spec/features/projects/files/editing_a_file_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -feature 'User wants to edit a file' do +describe 'Projects > Files > User wants to edit a file' do let(:project) { create(:project, :repository) } - let(:user) { create(:user) } + let(:user) { project.owner } let(:commit_params) do { start_branch: project.default_branch, @@ -15,14 +15,13 @@ feature 'User wants to edit a file' do } end - background do - project.add_master(user) + before do sign_in user visit project_edit_blob_path(project, File.join(project.default_branch, '.gitignore')) end - scenario 'file has been updated since the user opened the edit page' do + it 'file has been updated since the user opened the edit page' do Files::UpdateService.new(project, user, commit_params).execute click_button 'Commit changes' diff --git a/spec/features/projects/files/files_sort_submodules_with_folders_spec.rb b/spec/features/projects/files/files_sort_submodules_with_folders_spec.rb index ead9f7e9168..b6dbf76bc9b 100644 --- a/spec/features/projects/files/files_sort_submodules_with_folders_spec.rb +++ b/spec/features/projects/files/files_sort_submodules_with_folders_spec.rb @@ -1,16 +1,15 @@ require 'spec_helper' -feature 'User views files page' do - let(:user) { create(:user) } +describe 'Projects > Files > User views files page' do let(:project) { create(:forked_project_with_submodules) } + let(:user) { project.owner } before do - project.add_master(user) sign_in user visit project_tree_path(project, project.repository.root_ref) end - scenario 'user sees folders and submodules sorted together, followed by files' do + it 'user sees folders and submodules sorted together, followed by files' do rows = all('td.tree-item-file-name').map(&:text) tree = project.repository.tree diff --git a/spec/features/projects/files/find_file_keyboard_spec.rb b/spec/features/projects/files/find_file_keyboard_spec.rb index e9ff06c72d8..cd0235f2b9e 100644 --- a/spec/features/projects/files/find_file_keyboard_spec.rb +++ b/spec/features/projects/files/find_file_keyboard_spec.rb @@ -1,11 +1,10 @@ require 'spec_helper' -feature 'Find file keyboard shortcuts', :js do - let(:user) { create(:user) } +describe 'Projects > Files > Find file keyboard shortcuts', :js do let(:project) { create(:project, :repository) } + let(:user) { project.owner } before do - project.add_master(user) sign_in user visit project_find_file_path(project, project.repository.root_ref) diff --git a/spec/features/projects/files/gitignore_dropdown_spec.rb b/spec/features/projects/files/gitignore_dropdown_spec.rb index 79f3fd09b48..9fa4c053a40 100644 --- a/spec/features/projects/files/gitignore_dropdown_spec.rb +++ b/spec/features/projects/files/gitignore_dropdown_spec.rb @@ -1,25 +1,24 @@ require 'spec_helper' -feature 'User wants to add a .gitignore file' do +describe 'Projects > Files > User wants to add a .gitignore file' do before do - user = create(:user) project = create(:project, :repository) - project.add_master(user) - sign_in user + sign_in project.owner visit project_new_blob_path(project, 'master', file_name: '.gitignore') end - scenario 'user can see .gitignore dropdown' do + it 'user can pick a .gitignore file from the dropdown', :js do expect(page).to have_css('.gitignore-selector') - end - scenario 'user can pick a .gitignore file from the dropdown', :js do find('.js-gitignore-selector').click + wait_for_requests + within '.gitignore-selector' do find('.dropdown-input-field').set('rails') find('.dropdown-content li', text: 'Rails').click end + wait_for_requests expect(page).to have_css('.gitignore-selector .dropdown-toggle-text', text: 'Rails') diff --git a/spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb b/spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb index db6c67b802e..53aff183562 100644 --- a/spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb +++ b/spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb @@ -1,25 +1,24 @@ require 'spec_helper' -feature 'User wants to add a .gitlab-ci.yml file' do +describe 'Projects > Files > User wants to add a .gitlab-ci.yml file' do before do - user = create(:user) project = create(:project, :repository) - project.add_master(user) - sign_in user + sign_in project.owner visit project_new_blob_path(project, 'master', file_name: '.gitlab-ci.yml') end - scenario 'user can see .gitlab-ci.yml dropdown' do + it 'user can pick a template from the dropdown', :js do expect(page).to have_css('.gitlab-ci-yml-selector') - end - scenario 'user can pick a template from the dropdown', :js do find('.js-gitlab-ci-yml-selector').click + wait_for_requests + within '.gitlab-ci-yml-selector' do find('.dropdown-input-field').set('Jekyll') find('.dropdown-content li', text: 'Jekyll').click end + wait_for_requests expect(page).to have_css('.gitlab-ci-yml-selector .dropdown-toggle-text', text: 'Jekyll') diff --git a/spec/features/projects/files/project_owner_creates_license_file_spec.rb b/spec/features/projects/files/project_owner_creates_license_file_spec.rb index 07599600876..b410199fd1f 100644 --- a/spec/features/projects/files/project_owner_creates_license_file_spec.rb +++ b/spec/features/projects/files/project_owner_creates_license_file_spec.rb @@ -1,17 +1,17 @@ require 'spec_helper' -feature 'project owner creates a license file', :js do - let(:project_master) { create(:user) } +describe 'Projects > Files > Project owner creates a license file', :js do let(:project) { create(:project, :repository) } - background do + let(:project_master) { project.owner } + + before do project.repository.delete_file(project_master, 'LICENSE', message: 'Remove LICENSE', branch_name: 'master') - project.add_master(project_master) sign_in(project_master) visit project_path(project) end - scenario 'project master creates a license file manually from a template' do + it 'project master creates a license file manually from a template' do visit project_tree_path(project, project.repository.root_ref) find('.add-to-tree').click click_link 'New file' @@ -35,7 +35,7 @@ feature 'project owner creates a license file', :js do expect(page).to have_content("Copyright (c) #{Time.now.year} #{project.namespace.human_name}") end - scenario 'project master creates a license file from the "Add license" link' do + it 'project master creates a license file from the "Add license" link' do click_link 'Add License' expect(page).to have_content('New file') diff --git a/spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb b/spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb index 7f1d1934103..53d8ace7c94 100644 --- a/spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb +++ b/spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb @@ -1,15 +1,14 @@ require 'spec_helper' -feature 'project owner sees a link to create a license file in empty project', :js do - let(:project_master) { create(:user) } +describe 'Projects > Files > Project owner sees a link to create a license file in empty project', :js do let(:project) { create(:project_empty_repo) } + let(:project_master) { project.owner } - background do - project.add_master(project_master) + before do sign_in(project_master) end - scenario 'project master creates a license file from a template' do + it 'project master creates a license file from a template' do visit project_path(project) click_on 'Add License' expect(page).to have_content('New file') diff --git a/spec/features/projects/files/template_selector_menu_spec.rb b/spec/features/projects/files/template_selector_menu_spec.rb new file mode 100644 index 00000000000..b549a69ddf3 --- /dev/null +++ b/spec/features/projects/files/template_selector_menu_spec.rb @@ -0,0 +1,66 @@ +require 'spec_helper' + +feature 'Template selector menu', :js do + let(:project) { create(:project, :repository) } + let(:user) { create(:user) } + + before do + project.add_master(user) + sign_in user + end + + context 'editing a non-matching file' do + before do + create_and_edit_file('README.md') + end + + scenario 'is not displayed' do + check_template_selector_menu_display(false) + end + + context 'user toggles preview' do + before do + click_link 'Preview' + end + + scenario 'template selector menu is not displayed' do + check_template_selector_menu_display(false) + click_link 'Write' + check_template_selector_menu_display(false) + end + end + end + + context 'editing a matching file' do + before do + visit project_edit_blob_path(project, File.join(project.default_branch, 'LICENSE')) + end + + scenario 'is displayed' do + check_template_selector_menu_display(true) + end + + context 'user toggles preview' do + before do + click_link 'Preview' + end + + scenario 'template selector menu is hidden and shown correctly' do + check_template_selector_menu_display(false) + click_link 'Write' + check_template_selector_menu_display(true) + end + end + end +end + +def check_template_selector_menu_display(is_visible) + count = is_visible ? 1 : 0 + expect(page).to have_css('.template-selectors-menu', count: count) +end + +def create_and_edit_file(file_name) + visit project_new_blob_path(project, 'master', file_name: file_name) + click_button "Commit changes" + visit project_edit_blob_path(project, File.join(project.default_branch, file_name)) +end diff --git a/spec/features/projects/files/template_type_dropdown_spec.rb b/spec/features/projects/files/template_type_dropdown_spec.rb index 97408a9c41e..342a93b328f 100644 --- a/spec/features/projects/files/template_type_dropdown_spec.rb +++ b/spec/features/projects/files/template_type_dropdown_spec.rb @@ -1,11 +1,10 @@ require 'spec_helper' -feature 'Template type dropdown selector', :js do +describe 'Projects > Files > Template type dropdown selector', :js do let(:project) { create(:project, :repository) } - let(:user) { create(:user) } + let(:user) { project.owner } before do - project.add_master(user) sign_in user end @@ -14,16 +13,16 @@ feature 'Template type dropdown selector', :js do create_and_edit_file('.random-file.js') end - scenario 'not displayed' do + it 'not displayed' do check_type_selector_display(false) end - scenario 'selects every template type correctly' do + it 'selects every template type correctly' do fill_in 'file_path', with: '.gitignore' try_selecting_all_types end - scenario 'updates toggle value when input matches' do + it 'updates toggle value when input matches' do fill_in 'file_path', with: '.gitignore' check_type_selector_toggle_text('.gitignore') end @@ -34,15 +33,15 @@ feature 'Template type dropdown selector', :js do visit project_edit_blob_path(project, File.join(project.default_branch, 'LICENSE')) end - scenario 'displayed' do + it 'displayed' do check_type_selector_display(true) end - scenario 'is displayed when input matches' do + it 'is displayed when input matches' do check_type_selector_display(true) end - scenario 'selects every template type correctly' do + it 'selects every template type correctly' do try_selecting_all_types end @@ -51,7 +50,7 @@ feature 'Template type dropdown selector', :js do click_link 'Preview changes' end - scenario 'type selector is hidden and shown correctly' do + it 'type selector is hidden and shown correctly' do check_type_selector_display(false) click_link 'Write' check_type_selector_display(true) @@ -64,15 +63,15 @@ feature 'Template type dropdown selector', :js do visit project_new_blob_path(project, 'master', file_name: '.gitignore') end - scenario 'is displayed' do + it 'is displayed' do check_type_selector_display(true) end - scenario 'toggle is set to the correct value' do + it 'toggle is set to the correct value' do check_type_selector_toggle_text('.gitignore') end - scenario 'selects every template type correctly' do + it 'selects every template type correctly' do try_selecting_all_types end end @@ -82,15 +81,15 @@ feature 'Template type dropdown selector', :js do visit project_new_blob_path(project, project.default_branch) end - scenario 'type selector is shown' do + it 'type selector is shown' do check_type_selector_display(true) end - scenario 'toggle is set to the proper value' do + it 'toggle is set to the proper value' do check_type_selector_toggle_text('Choose type') end - scenario 'selects every template type correctly' do + it 'selects every template type correctly' do try_selecting_all_types end end diff --git a/spec/features/projects/files/undo_template_spec.rb b/spec/features/projects/files/undo_template_spec.rb index fbf35fb4e1c..5de0bc009fb 100644 --- a/spec/features/projects/files/undo_template_spec.rb +++ b/spec/features/projects/files/undo_template_spec.rb @@ -1,11 +1,10 @@ require 'spec_helper' -feature 'Template Undo Button', :js do +describe 'Projects > Files > Template Undo Button', :js do let(:project) { create(:project, :repository) } - let(:user) { create(:user) } + let(:user) { project.owner } before do - project.add_master(user) sign_in user end @@ -15,7 +14,7 @@ feature 'Template Undo Button', :js do select_file_template('.js-license-selector', 'Apache License 2.0') end - scenario 'reverts template application' do + it 'reverts template application' do try_template_undo('http://www.apache.org/licenses/', 'Apply a license template') end end @@ -27,7 +26,7 @@ feature 'Template Undo Button', :js do select_file_template('.js-license-selector', 'Apache License 2.0') end - scenario 'reverts template application' do + it 'reverts template application' do try_template_undo('http://www.apache.org/licenses/', 'Apply a license template') end end diff --git a/spec/features/projects/user_browses_a_tree_with_a_folder_containing_only_a_folder.rb b/spec/features/projects/files/user_browses_a_tree_with_a_folder_containing_only_a_folder.rb index a17e65cc5b9..2d67837763c 100644 --- a/spec/features/projects/user_browses_a_tree_with_a_folder_containing_only_a_folder.rb +++ b/spec/features/projects/files/user_browses_a_tree_with_a_folder_containing_only_a_folder.rb @@ -1,9 +1,9 @@ require 'spec_helper' # This is a regression test for https://gitlab.com/gitlab-org/gitlab-ce/issues/37569 -describe 'User browses a tree with a folder containing only a folder' do +describe 'Projects > Files > User browses a tree with a folder containing only a folder' do let(:project) { create(:project, :empty_repo) } - let(:user) { project.creator } + let(:user) { project.owner } before do # We need to disable the tree.flat_path provided by Gitaly to reproduce the issue diff --git a/spec/features/projects/user_browses_files_spec.rb b/spec/features/projects/files/user_browses_files_spec.rb index 62e6419cc42..9c1f11f4c12 100644 --- a/spec/features/projects/user_browses_files_spec.rb +++ b/spec/features/projects/files/user_browses_files_spec.rb @@ -1,8 +1,6 @@ require 'spec_helper' -describe 'User browses files' do - include DropzoneHelper - +describe 'Projects > Files > User browses files' do let(:fork_message) do "You're not allowed to make changes to this project directly. "\ "A fork of this project has been created that you can make changes in, so you can submit a merge request." @@ -12,13 +10,24 @@ describe 'User browses files' do let(:project2_tree_path_root_ref) { project_tree_path(project2, project2.repository.root_ref) } let(:tree_path_ref_6d39438) { project_tree_path(project, '6d39438') } let(:tree_path_root_ref) { project_tree_path(project, project.repository.root_ref) } - let(:user) { create(:user) } + let(:user) { project.owner } before do - project.add_master(user) sign_in(user) end + it 'shows last commit for current directory' do + visit(tree_path_root_ref) + + click_link 'files' + + last_commit = project.repository.last_commit_for_path(project.default_branch, 'files') + page.within('.blob-commit-info') do + expect(page).to have_content last_commit.short_id + expect(page).to have_content last_commit.author_name + end + end + context 'when browsing the master branch' do before do visit(tree_path_root_ref) @@ -48,7 +57,7 @@ describe 'User browses files' do expect(page).not_to have_link('Browse Files') end - it 'shows the "Browse Code" link' do + it 'shows the "Browse Files" link' do click_link('History') expect(page).to have_link('Browse Files') @@ -121,6 +130,14 @@ describe 'User browses files' do wait_for_requests expect(page).to have_content('*.rbc') end + + it 'is possible to blame' do + click_link 'Blame' + + expect(page).to have_content "*.rb" + expect(page).to have_content "Dmitriy Zaporozhets" + expect(page).to have_content "Initial commit" + end end context 'when browsing a raw file' do @@ -133,57 +150,4 @@ describe 'User browses files' do expect(source).to eq('') # Body is filled in by gitlab-workhorse end end - - context 'when browsing an LFS object' do - before do - allow_any_instance_of(Project).to receive(:lfs_enabled?).and_return(true) - visit(project_tree_path(project, 'lfs')) - end - - it 'shows an LFS object' do - click_link('files') - click_link('lfs') - click_link('lfs_object.iso') - - expect(page).to have_content('Download (1.5 MB)') - expect(page).not_to have_content('version https://git-lfs.github.com/spec/v1') - expect(page).not_to have_content('oid sha256:91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897') - expect(page).not_to have_content('size 1575078') - - page.within('.content') do - expect(page).to have_content('Delete') - expect(page).to have_content('History') - expect(page).to have_content('Permalink') - expect(page).to have_content('Replace') - expect(page).not_to have_content('Annotate') - expect(page).not_to have_content('Blame') - expect(page).not_to have_content('Edit') - expect(page).to have_link('Download') - end - end - end - - context 'when previewing a file content' do - before do - visit(tree_path_root_ref) - end - - it 'shows a preview of a file content', :js do - find('.add-to-tree').click - click_link('Upload file') - drop_in_dropzone(File.join(Rails.root, 'spec', 'fixtures', 'logo_sample.svg')) - - page.within('#modal-upload-blob') do - fill_in(:commit_message, with: 'New commit message') - fill_in(:branch_name, with: 'new_branch_name', visible: true) - click_button('Upload file') - end - - wait_for_all_requests - - visit(project_blob_path(project, 'new_branch_name/logo_sample.svg')) - - expect(page).to have_css('.file-content img') - end - end end diff --git a/spec/features/projects/files/user_browses_lfs_files_spec.rb b/spec/features/projects/files/user_browses_lfs_files_spec.rb new file mode 100644 index 00000000000..c559a301ca1 --- /dev/null +++ b/spec/features/projects/files/user_browses_lfs_files_spec.rb @@ -0,0 +1,57 @@ +require 'spec_helper' + +describe 'Projects > Files > User browses LFS files' do + let(:project) { create(:project, :repository) } + let(:user) { project.owner } + + before do + sign_in(user) + end + + context 'when LFS is disabled', :js do + before do + allow_any_instance_of(Project).to receive(:lfs_enabled?).and_return(false) + visit project_tree_path(project, 'lfs') + end + + it 'is possible to see raw content of LFS pointer' do + click_link 'files' + click_link 'lfs' + click_link 'lfs_object.iso' + + expect(page).to have_content 'version https://git-lfs.github.com/spec/v1' + expect(page).to have_content 'oid sha256:91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897' + expect(page).to have_content 'size 1575078' + expect(page).not_to have_content 'Download (1.5 MB)' + end + end + + context 'when LFS is enabled' do + before do + allow_any_instance_of(Project).to receive(:lfs_enabled?).and_return(true) + visit project_tree_path(project, 'lfs') + end + + it 'shows an LFS object' do + click_link('files') + click_link('lfs') + click_link('lfs_object.iso') + + expect(page).to have_content('Download (1.5 MB)') + expect(page).not_to have_content('version https://git-lfs.github.com/spec/v1') + expect(page).not_to have_content('oid sha256:91eff75a492a3ed0dfcb544d7f31326bc4014c8551849c192fd1e48d4dd2c897') + expect(page).not_to have_content('size 1575078') + + page.within('.content') do + expect(page).to have_content('Delete') + expect(page).to have_content('History') + expect(page).to have_content('Permalink') + expect(page).to have_content('Replace') + expect(page).not_to have_content('Annotate') + expect(page).not_to have_content('Blame') + expect(page).not_to have_content('Edit') + expect(page).to have_link('Download') + end + end + end +end diff --git a/spec/features/projects/user_creates_directory_spec.rb b/spec/features/projects/files/user_creates_directory_spec.rb index 00e48f6fabd..847b5f0860f 100644 --- a/spec/features/projects/user_creates_directory_spec.rb +++ b/spec/features/projects/files/user_creates_directory_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'User creates a directory', :js do +describe 'Projects > Files > User creates a directory', :js do let(:fork_message) do "You're not allowed to make changes to this project directly. "\ "A fork of this project has been created that you can make changes in, so you can submit a merge request." diff --git a/spec/features/projects/user_creates_files_spec.rb b/spec/features/projects/files/user_creates_files_spec.rb index 8993533676b..208cc8d81f7 100644 --- a/spec/features/projects/user_creates_files_spec.rb +++ b/spec/features/projects/files/user_creates_files_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'User creates files' do +describe 'Projects > Files > User creates files' do let(:fork_message) do "You're not allowed to make changes to this project directly. "\ "A fork of this project has been created that you can make changes in, so you can submit a merge request." @@ -59,6 +59,31 @@ describe 'User creates files' do expect(page).to have_selector('.file-editor') end + def submit_new_file(options) + file_name = find('#file_name') + file_name.set options[:file_name] || 'README.md' + + file_content = find('#file-content', visible: false) + file_content.set options[:file_content] || 'Some content' + + click_button 'Commit changes' + end + + it 'allows Chinese characters in file name' do + submit_new_file(file_name: '测试.md') + expect(page).to have_content 'The file has been successfully created.' + end + + it 'allows Chinese characters in directory name' do + submit_new_file(file_name: '中文/测试.md') + expect(page).to have_content 'The file has been successfully created' + end + + it 'does not allow directory traversal in file name' do + submit_new_file(file_name: '../README.md') + expect(page).to have_content 'Path cannot include directory traversal' + end + it 'creates and commit a new file', :js do find('#editor') execute_script("ace.edit('editor').setValue('*.rbca')") diff --git a/spec/features/projects/user_deletes_files_spec.rb b/spec/features/projects/files/user_deletes_files_spec.rb index 9d55197e719..36d3e001a64 100644 --- a/spec/features/projects/user_deletes_files_spec.rb +++ b/spec/features/projects/files/user_deletes_files_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'User deletes files' do +describe 'Projects > Files > User deletes files' do let(:fork_message) do "You're not allowed to make changes to this project directly. "\ "A fork of this project has been created that you can make changes in, so you can submit a merge request." diff --git a/spec/features/projects/user_edits_files_spec.rb b/spec/features/projects/files/user_edits_files_spec.rb index 05c2be473da..523a9f3f4fe 100644 --- a/spec/features/projects/user_edits_files_spec.rb +++ b/spec/features/projects/files/user_edits_files_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'User edits files' do +describe 'Projects > Files > User edits files' do include ProjectForksHelper let(:project) { create(:project, :repository, name: 'Shop') } let(:project2) { create(:project, :repository, name: 'Another Project', path: 'another-project') } diff --git a/spec/features/projects/user_replaces_files_spec.rb b/spec/features/projects/files/user_replaces_files_spec.rb index 74872403b35..9ac3417b671 100644 --- a/spec/features/projects/user_replaces_files_spec.rb +++ b/spec/features/projects/files/user_replaces_files_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'User replaces files' do +describe 'Projects > Files > User replaces files' do include DropzoneHelper let(:fork_message) do diff --git a/spec/features/projects/files/user_searches_for_files_spec.rb b/spec/features/projects/files/user_searches_for_files_spec.rb index a105685bca7..a90e4918fb1 100644 --- a/spec/features/projects/files/user_searches_for_files_spec.rb +++ b/spec/features/projects/files/user_searches_for_files_spec.rb @@ -1,8 +1,7 @@ require 'spec_helper' -describe 'User searches for files' do - let(:user) { create(:user) } - let(:project) { create(:project, :repository) } +describe 'Projects > Files > User searches for files' do + let(:user) { project.owner } before do sign_in(user) @@ -10,11 +9,10 @@ describe 'User searches for files' do describe 'project main screen' do context 'when project is empty' do - let(:empty_project) { create(:project) } + let(:project) { create(:project) } before do - empty_project.add_developer(user) - visit project_path(empty_project) + visit project_path(project) end it 'does not show any result' do @@ -26,6 +24,8 @@ describe 'User searches for files' do end context 'when project is not empty' do + let(:project) { create(:project, :repository) } + before do project.add_developer(user) visit project_path(project) @@ -38,16 +38,16 @@ describe 'User searches for files' do end describe 'project tree screen' do + let(:project) { create(:project, :repository) } + before do project.add_developer(user) visit project_tree_path(project, project.default_branch) end - it 'shows "Find file" button' do + it 'shows found files' do expect(page).to have_selector('.tree-controls .shortcuts-find-file') - end - it 'shows found files' do fill_in('search', with: 'coffee') click_button('Go') diff --git a/spec/features/projects/user_uploads_files_spec.rb b/spec/features/projects/files/user_uploads_files_spec.rb index 75898afcda9..7a1e3a8bcce 100644 --- a/spec/features/projects/user_uploads_files_spec.rb +++ b/spec/features/projects/files/user_uploads_files_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'User uploads files' do +describe 'Projects > Files > User uploads files' do include DropzoneHelper let(:fork_message) do @@ -11,7 +11,7 @@ describe 'User uploads files' do let(:project2) { create(:project, :repository, name: 'Another Project', path: 'another-project') } let(:project_tree_path_root_ref) { project_tree_path(project, project.repository.root_ref) } let(:project2_tree_path_root_ref) { project_tree_path(project2, project2.repository.root_ref) } - let(:user) { create(:user) } + let(:user) { project.creator } before do project.add_master(user) @@ -23,7 +23,7 @@ describe 'User uploads files' do visit(project_tree_path_root_ref) end - it 'uploads and commit a new file', :js do + it 'uploads and commit a new text file', :js do find('.add-to-tree').click click_link('Upload file') drop_in_dropzone(File.join(Rails.root, 'spec', 'fixtures', 'doc_sample.txt')) @@ -46,6 +46,24 @@ describe 'User uploads files' do expect(page).to have_content('Lorem ipsum dolor sit amet') expect(page).to have_content('Sed ut perspiciatis unde omnis') end + + it 'uploads and commit a new image file', :js do + find('.add-to-tree').click + click_link('Upload file') + drop_in_dropzone(File.join(Rails.root, 'spec', 'fixtures', 'logo_sample.svg')) + + page.within('#modal-upload-blob') do + fill_in(:commit_message, with: 'New commit message') + fill_in(:branch_name, with: 'new_branch_name', visible: true) + click_button('Upload file') + end + + wait_for_all_requests + + visit(project_blob_path(project, 'new_branch_name/logo_sample.svg')) + + expect(page).to have_css('.file-content img') + end end context 'when an user does not have write access' do diff --git a/spec/features/projects/guest_navigation_menu_spec.rb b/spec/features/projects/guest_navigation_menu_spec.rb deleted file mode 100644 index 199682b943c..00000000000 --- a/spec/features/projects/guest_navigation_menu_spec.rb +++ /dev/null @@ -1,82 +0,0 @@ -require 'spec_helper' - -describe 'Guest navigation menu' do - let(:project) { create(:project, :private, public_builds: false) } - let(:guest) { create(:user) } - - before do - project.add_guest(guest) - - sign_in(guest) - end - - it 'shows allowed tabs only' do - visit project_path(project) - - within('.nav-sidebar') do - expect(page).to have_content 'Overview' - expect(page).to have_content 'Issues' - expect(page).to have_content 'Wiki' - - expect(page).not_to have_content 'Repository' - expect(page).not_to have_content 'Pipelines' - expect(page).not_to have_content 'Merge Requests' - end - end - - it 'does not show fork button' do - visit project_path(project) - - within('.count-buttons') do - expect(page).not_to have_link 'Fork' - end - end - - it 'does not show clone path' do - visit project_path(project) - - within('.project-repo-buttons') do - expect(page).not_to have_selector '.project-clone-holder' - end - end - - describe 'project landing page' do - before do - project.project_feature.update!( - issues_access_level: ProjectFeature::DISABLED, - wiki_access_level: ProjectFeature::DISABLED - ) - end - - it 'does not show the project file list landing page' do - visit project_path(project) - - expect(page).not_to have_selector '.project-stats' - expect(page).not_to have_selector '.project-last-commit' - expect(page).not_to have_selector '.project-show-files' - expect(page).to have_selector '.project-show-customize_workflow' - end - - it 'shows the customize workflow when issues and wiki are disabled' do - visit project_path(project) - - expect(page).to have_selector '.project-show-customize_workflow' - end - - it 'shows the wiki when enabled' do - project.project_feature.update!(wiki_access_level: ProjectFeature::PRIVATE) - - visit project_path(project) - - expect(page).to have_selector '.project-show-wiki' - end - - it 'shows the issues when enabled' do - project.project_feature.update!(issues_access_level: ProjectFeature::PRIVATE) - - visit project_path(project) - - expect(page).to have_selector '.issues-list' - end - end -end diff --git a/spec/features/projects/issues/user_comments_on_issue_spec.rb b/spec/features/projects/issues/user_comments_on_issue_spec.rb new file mode 100644 index 00000000000..c45fdc7642f --- /dev/null +++ b/spec/features/projects/issues/user_comments_on_issue_spec.rb @@ -0,0 +1,73 @@ +require "spec_helper" + +describe "User comments on issue", :js do + include Spec::Support::Helpers::Features::NotesHelpers + + let(:project) { create(:project_empty_repo, :public) } + let(:issue) { create(:issue, project: project) } + let(:user) { create(:user) } + + before do + project.add_guest(user) + sign_in(user) + + visit(project_issue_path(project, issue)) + end + + context "when adding comments" do + it "adds comment" do + content = "XML attached" + target_form = ".js-main-target-form" + + add_note(content) + + page.within(".note") do + expect(page).to have_content(content) + end + + page.within(target_form) do + find(".error-alert", visible: false) + end + end + + it "adds comment with code block" do + comment = "```\nCommand [1]: /usr/local/bin/git , see [text](doc/text)\n```" + + add_note(comment) + + expect(page).to have_content(comment) + end + end + + context "when editing comments" do + it "edits comment" do + add_note("# Comment with a header") + + page.within(".note-body > .note-text") do + expect(page).to have_content("Comment with a header").and have_no_css("#comment-with-a-header") + end + + page.within(".main-notes-list") do + note = find(".note") + + note.hover + note.find(".js-note-edit").click + end + + expect(page).to have_css(".current-note-edit-form textarea") + + comment = "+1 Awesome!" + + page.within(".current-note-edit-form") do + fill_in("note[note]", with: comment) + click_button("Save comment") + end + + wait_for_requests + + page.within(".note") do + expect(page).to have_content(comment) + end + end + end +end diff --git a/spec/features/projects/issues/user_creates_issue_spec.rb b/spec/features/projects/issues/user_creates_issue_spec.rb new file mode 100644 index 00000000000..e76f7c5589d --- /dev/null +++ b/spec/features/projects/issues/user_creates_issue_spec.rb @@ -0,0 +1,87 @@ +require "spec_helper" + +describe "User creates issue" do + let(:project) { create(:project_empty_repo, :public) } + let(:user) { create(:user) } + + context "when signed in as guest" do + before do + project.add_guest(user) + sign_in(user) + + visit(new_project_issue_path(project)) + end + + it "creates issue" do + page.within(".issue-form") do + expect(page).to have_no_content("Assign to") + .and have_no_content("Labels") + .and have_no_content("Milestone") + end + + issue_title = "500 error on profile" + + fill_in("Title", with: issue_title) + click_button("Submit issue") + + expect(page).to have_content(issue_title) + .and have_content(user.name) + .and have_content(project.name) + end + end + + context "when signed in as developer", :js do + before do + project.add_developer(user) + sign_in(user) + + visit(new_project_issue_path(project)) + end + + context "when previewing" do + it "previews content" do + form = first(".gfm-form") + textarea = first(".gfm-form textarea") + + page.within(form) do + click_link("Preview") + + preview = find(".js-md-preview") # this element is findable only when the "Preview" link is clicked. + + expect(preview).to have_content("Nothing to preview.") + + click_link("Write") + fill_in("Description", with: "Bug fixed :smile:") + click_link("Preview") + + expect(preview).to have_css("gl-emoji") + expect(textarea).not_to be_visible + end + end + end + + context "with labels" do + LABEL_TITLES = %w(bug feature enhancement).freeze + + before do + LABEL_TITLES.each do |title| + create(:label, project: project, title: title) + end + end + + it "creates issue" do + issue_title = "500 error on profile" + + fill_in("Title", with: issue_title) + click_button("Label") + click_link(LABEL_TITLES.first) + click_button("Submit issue") + + expect(page).to have_content(issue_title) + .and have_content(user.name) + .and have_content(project.name) + .and have_content(LABEL_TITLES.first) + end + end + end +end diff --git a/spec/features/projects/issues/user_edits_issue_spec.rb b/spec/features/projects/issues/user_edits_issue_spec.rb new file mode 100644 index 00000000000..1d9c3abc20f --- /dev/null +++ b/spec/features/projects/issues/user_edits_issue_spec.rb @@ -0,0 +1,25 @@ +require "spec_helper" + +describe "User edits issue", :js do + set(:project) { create(:project_empty_repo, :public) } + set(:user) { create(:user) } + set(:issue) { create(:issue, project: project, author: user) } + + before do + project.add_developer(user) + sign_in(user) + + visit(edit_project_issue_path(project, issue)) + end + + it "previews content" do + form = first(".gfm-form") + + page.within(form) do + fill_in("Description", with: "Bug fixed :smile:") + click_link("Preview") + end + + expect(form).to have_link("Write") + end +end diff --git a/spec/features/projects/issues/user_sorts_issues_spec.rb b/spec/features/projects/issues/user_sorts_issues_spec.rb new file mode 100644 index 00000000000..c3d63000dac --- /dev/null +++ b/spec/features/projects/issues/user_sorts_issues_spec.rb @@ -0,0 +1,39 @@ +require "spec_helper" + +describe "User sorts issues" do + set(:project) { create(:project_empty_repo, :public) } + set(:issue1) { create(:issue, project: project) } + set(:issue2) { create(:issue, project: project) } + set(:issue3) { create(:issue, project: project) } + + before do + create_list(:award_emoji, 2, :upvote, awardable: issue1) + create_list(:award_emoji, 2, :downvote, awardable: issue2) + create(:award_emoji, :downvote, awardable: issue1) + create(:award_emoji, :upvote, awardable: issue2) + + visit(project_issues_path(project)) + end + + it "sorts by popularity" do + find("button.dropdown-toggle").click + + page.within(".content ul.dropdown-menu.dropdown-menu-align-right li") do + click_link("Popularity") + end + + page.within(".issues-list") do + page.within("li.issue:nth-child(1)") do + expect(page).to have_content(issue1.title) + end + + page.within("li.issue:nth-child(2)") do + expect(page).to have_content(issue2.title) + end + + page.within("li.issue:nth-child(3)") do + expect(page).to have_content(issue3.title) + end + end + end +end diff --git a/spec/features/projects/issues/user_toggles_subscription_spec.rb b/spec/features/projects/issues/user_toggles_subscription_spec.rb new file mode 100644 index 00000000000..117a614b980 --- /dev/null +++ b/spec/features/projects/issues/user_toggles_subscription_spec.rb @@ -0,0 +1,28 @@ +require "spec_helper" + +describe "User toggles subscription", :js do + set(:project) { create(:project_empty_repo, :public) } + set(:user) { create(:user) } + set(:issue) { create(:issue, project: project, author: user) } + + before do + project.add_developer(user) + sign_in(user) + + visit(project_issue_path(project, issue)) + end + + it "unsibscribes from issue" do + subscription_button = find(".js-issuable-subscribe-button") + + # Check we're subscribed. + expect(subscription_button).to have_css("button.is-checked") + + # Toggle subscription. + find(".js-issuable-subscribe-button button").click + wait_for_requests + + # Check we're unsubscribed. + expect(subscription_button).to have_css("button:not(.is-checked)") + end +end diff --git a/spec/features/projects/issues/user_views_issue_spec.rb b/spec/features/projects/issues/user_views_issue_spec.rb new file mode 100644 index 00000000000..f7f2cde3d64 --- /dev/null +++ b/spec/features/projects/issues/user_views_issue_spec.rb @@ -0,0 +1,16 @@ +require "spec_helper" + +describe "User views issue" do + set(:project) { create(:project_empty_repo, :public) } + set(:user) { create(:user) } + set(:issue) { create(:issue, project: project, description: "# Description header", author: user) } + + before do + project.add_guest(user) + sign_in(user) + + visit(project_issue_path(project, issue)) + end + + it { expect(page).to have_header_with_correct_id_and_link(1, "Description header", "description-header") } +end diff --git a/spec/features/projects/issues/user_views_issues_spec.rb b/spec/features/projects/issues/user_views_issues_spec.rb index d35009b8974..58afb4efb86 100644 --- a/spec/features/projects/issues/user_views_issues_spec.rb +++ b/spec/features/projects/issues/user_views_issues_spec.rb @@ -1,56 +1,116 @@ -require 'spec_helper' +require "spec_helper" -describe 'User views issues' do +describe "User views issues" do + let!(:closed_issue) { create(:closed_issue, project: project) } + let!(:open_issue1) { create(:issue, project: project) } + let!(:open_issue2) { create(:issue, project: project) } set(:user) { create(:user) } - shared_examples_for 'shows issues' do - it 'shows issues' do - expect(page).to have_content(project.name) - .and have_content(issue1.title) - .and have_content(issue2.title) - .and have_no_selector('.js-new-board-list') + shared_examples "opens issue from list" do + it "opens issue" do + click_link(issue.title) + + expect(page).to have_content(issue.title) end end - context 'when project is public' do - set(:project) { create(:project_empty_repo, :public) } - set(:issue1) { create(:issue, project: project) } - set(:issue2) { create(:issue, project: project) } + shared_examples "open issues" do + context "open issues" do + let(:label) { create(:label, project: project, title: "bug") } - context 'when signed in' do before do - project.add_developer(user) - sign_in(user) + open_issue1.labels << label + + visit(project_issues_path(project, state: :opened)) + end - visit(project_issues_path(project)) + it "shows open issues" do + expect(page).to have_content(project.name) + .and have_content(open_issue1.title) + .and have_content(open_issue2.title) + .and have_no_content(closed_issue.title) + .and have_no_selector(".js-new-board-list") end - include_examples 'shows issues' + it "opens issues by label" do + page.within(".issues-list") do + click_link(label.title) + end + + expect(page).to have_content(open_issue1.title) + .and have_no_content(open_issue2.title) + .and have_no_content(closed_issue.title) + end + + include_examples "opens issue from list" do + let(:issue) { open_issue1 } + end end + end - context 'when not signed in' do + shared_examples "closed issues" do + context "closed issues" do before do - visit(project_issues_path(project)) + visit(project_issues_path(project, state: :closed)) + end + + it "shows closed issues" do + expect(page).to have_content(project.name) + .and have_content(closed_issue.title) + .and have_no_content(open_issue1.title) + .and have_no_content(open_issue2.title) + .and have_no_selector(".js-new-board-list") end - include_examples 'shows issues' + include_examples "opens issue from list" do + let(:issue) { closed_issue } + end end end - context 'when project is internal' do - set(:project) { create(:project_empty_repo, :internal) } - set(:issue1) { create(:issue, project: project) } - set(:issue2) { create(:issue, project: project) } - - context 'when signed in' do + shared_examples "all issues" do + context "all issues" do before do - project.add_developer(user) - sign_in(user) + visit(project_issues_path(project, state: :all)) + end - visit(project_issues_path(project)) + it "shows all issues" do + expect(page).to have_content(project.name) + .and have_content(closed_issue.title) + .and have_content(open_issue1.title) + .and have_content(open_issue2.title) + .and have_no_selector(".js-new-board-list") end - include_examples 'shows issues' + include_examples "opens issue from list" do + let(:issue) { closed_issue } + end + end + end + + %w[internal public].each do |visibility| + shared_examples "#{visibility} project" do + context "when project is #{visibility}" do + let(:project) { create(:project_empty_repo, :"#{visibility}") } + + include_examples "open issues" + include_examples "closed issues" + include_examples "all issues" + end end end + + context "when signed in as developer" do + before do + project.add_developer(user) + sign_in(user) + end + + include_examples "public project" + include_examples "internal project" + end + + context "when not signed in" do + include_examples "public project" + end end diff --git a/spec/features/projects/jobs/user_browses_job_spec.rb b/spec/features/projects/jobs/user_browses_job_spec.rb index 4c49cff30d4..bff5bbe99af 100644 --- a/spec/features/projects/jobs/user_browses_job_spec.rb +++ b/spec/features/projects/jobs/user_browses_job_spec.rb @@ -1,16 +1,15 @@ require 'spec_helper' describe 'User browses a job', :js do - let!(:build) { create(:ci_build, :running, :coverage, pipeline: pipeline) } - let(:pipeline) { create(:ci_empty_pipeline, project: project, sha: project.commit.sha, ref: 'master') } - let(:project) { create(:project, :repository, namespace: user.namespace) } let(:user) { create(:user) } + let(:user_access_level) { :developer } + let(:project) { create(:project, :repository, namespace: user.namespace) } + let(:pipeline) { create(:ci_empty_pipeline, project: project, sha: project.commit.sha, ref: 'master') } + let!(:build) { create(:ci_build, :success, :trace_artifact, :coverage, pipeline: pipeline) } before do project.add_master(user) project.enable_ci - build.success - build.trace.set('job trace') sign_in(user) @@ -21,7 +20,9 @@ describe 'User browses a job', :js do expect(page).to have_content("Job ##{build.id}") expect(page).to have_css('#build-trace') - accept_confirm { click_link('Erase') } + # scroll to the top of the page first + execute_script "window.scrollTo(0,0)" + accept_confirm { find('.js-erase-link').click } expect(page).to have_no_css('.artifacts') expect(build).not_to have_trace @@ -34,4 +35,26 @@ describe 'User browses a job', :js do expect(build.project.running_or_pending_build_count).to eq(build.project.builds.running_or_pending.count(:all)) end + + context 'with a failed job' do + let!(:build) { create(:ci_build, :failed, :trace_artifact, pipeline: pipeline) } + + it 'displays the failure reason' do + within('.builds-container') do + build_link = first('.build-job > a') + expect(build_link['data-title']).to eq('test - failed <br> (unknown failure)') + end + end + end + + context 'when a failed job has been retried' do + let!(:build) { create(:ci_build, :failed, :retried, :trace_artifact, pipeline: pipeline) } + + it 'displays the failure reason and retried label' do + within('.builds-container') do + build_link = first('.build-job > a') + expect(build_link['data-title']).to eq('test - failed <br> (unknown failure) (retried)') + end + end + end end diff --git a/spec/features/projects/jobs/user_browses_jobs_spec.rb b/spec/features/projects/jobs/user_browses_jobs_spec.rb index 767777f3bf9..36ebbeadd4a 100644 --- a/spec/features/projects/jobs/user_browses_jobs_spec.rb +++ b/spec/features/projects/jobs/user_browses_jobs_spec.rb @@ -29,4 +29,15 @@ describe 'User browses jobs' do expect(ci_lint_tool_link[:href]).to end_with(ci_lint_path) end end + + context 'with a failed job' do + let!(:build) { create(:ci_build, :coverage, :failed, pipeline: pipeline) } + + it 'displays a tooltip with the failure reason' do + page.within('.ci-table') do + failed_job_link = page.find('.ci-failed') + expect(failed_job_link[:title]).to eq('Failed <br> (unknown failure)') + end + end + end end diff --git a/spec/features/projects/jobs_spec.rb b/spec/features/projects/jobs_spec.rb index 5d311f2dde3..749a1b81872 100644 --- a/spec/features/projects/jobs_spec.rb +++ b/spec/features/projects/jobs_spec.rb @@ -113,7 +113,7 @@ feature 'Jobs' do describe "GET /:project/jobs/:id" do context "Job from project" do - let(:job) { create(:ci_build, :success, pipeline: pipeline) } + let(:job) { create(:ci_build, :success, :trace_live, pipeline: pipeline) } before do visit project_job_path(project, job) @@ -136,7 +136,7 @@ feature 'Jobs' do end context 'when job is not running', :js do - let(:job) { create(:ci_build, :success, pipeline: pipeline) } + let(:job) { create(:ci_build, :success, :trace_artifact, pipeline: pipeline) } before do visit project_job_path(project, job) @@ -153,7 +153,7 @@ feature 'Jobs' do end context 'if job failed' do - let(:job) { create(:ci_build, :failed, pipeline: pipeline) } + let(:job) { create(:ci_build, :failed, :trace_artifact, pipeline: pipeline) } before do visit project_job_path(project, job) @@ -339,7 +339,7 @@ feature 'Jobs' do context 'job is successfull and has deployment' do let(:deployment) { create(:deployment) } - let(:job) { create(:ci_build, :success, environment: environment.name, deployments: [deployment], pipeline: pipeline) } + let(:job) { create(:ci_build, :success, :trace_artifact, environment: environment.name, deployments: [deployment], pipeline: pipeline) } it 'shows a link for the job' do visit project_job_path(project, job) @@ -349,7 +349,7 @@ feature 'Jobs' do end context 'job is complete and not successful' do - let(:job) { create(:ci_build, :failed, environment: environment.name, pipeline: pipeline) } + let(:job) { create(:ci_build, :failed, :trace_artifact, environment: environment.name, pipeline: pipeline) } it 'shows a link for the job' do visit project_job_path(project, job) @@ -360,7 +360,7 @@ feature 'Jobs' do context 'job creates a new deployment' do let!(:deployment) { create(:deployment, environment: environment, sha: project.commit.id) } - let(:job) { create(:ci_build, :success, environment: environment.name, pipeline: pipeline) } + let(:job) { create(:ci_build, :success, :trace_artifact, environment: environment.name, pipeline: pipeline) } it 'shows a link to latest deployment' do visit project_job_path(project, job) @@ -379,6 +379,7 @@ feature 'Jobs' do end it 'shows manual action empty state' do + expect(page).to have_content(job.detailed_status(user).illustration[:title]) expect(page).to have_content('This job requires a manual action') expect(page).to have_content('This job depends on a user to trigger its process. Often they are used to deploy code to production environments') expect(page).to have_link('Trigger this manual action') @@ -402,6 +403,7 @@ feature 'Jobs' do end it 'shows empty state' do + expect(page).to have_content(job.detailed_status(user).illustration[:title]) expect(page).to have_content('This job has not been triggered yet') expect(page).to have_content('This job depends on upstream jobs that need to succeed in order for this job to be triggered') end @@ -415,10 +417,53 @@ feature 'Jobs' do end it 'shows pending empty state' do + expect(page).to have_content(job.detailed_status(user).illustration[:title]) expect(page).to have_content('This job has not started yet') expect(page).to have_content('This job is in pending state and is waiting to be picked by a runner') end end + + context 'Canceled job' do + context 'with log' do + let(:job) { create(:ci_build, :canceled, :trace_artifact, pipeline: pipeline) } + + before do + visit project_job_path(project, job) + end + + it 'renders job log' do + expect(page).to have_selector('.js-build-output') + end + end + + context 'without log' do + let(:job) { create(:ci_build, :canceled, pipeline: pipeline) } + + before do + visit project_job_path(project, job) + end + + it 'renders empty state' do + expect(page).to have_content(job.detailed_status(user).illustration[:title]) + expect(page).not_to have_selector('.js-build-output') + expect(page).to have_content('This job has been canceled') + end + end + end + + context 'Skipped job' do + let(:job) { create(:ci_build, :skipped, pipeline: pipeline) } + + before do + visit project_job_path(project, job) + end + + it 'renders empty state' do + expect(page).to have_content(job.detailed_status(user).illustration[:title]) + expect(page).not_to have_selector('.js-build-output') + expect(page).to have_content('This job has been skipped') + end + end end describe "POST /:project/jobs/:id/cancel", :js do diff --git a/spec/features/projects/labels/user_creates_labels_spec.rb b/spec/features/projects/labels/user_creates_labels_spec.rb new file mode 100644 index 00000000000..9fd7f3ee775 --- /dev/null +++ b/spec/features/projects/labels/user_creates_labels_spec.rb @@ -0,0 +1,88 @@ +require "spec_helper" + +describe "User creates labels" do + set(:project) { create(:project_empty_repo, :public) } + set(:user) { create(:user) } + + shared_examples_for "label creation" do + it "creates new label" do + title = "bug" + + create_label(title) + + page.within(".other-labels .manage-labels-list") do + expect(page).to have_content(title) + end + end + end + + context "in project" do + before do + project.add_master(user) + sign_in(user) + + visit(new_project_label_path(project)) + end + + context "when data is valid" do + include_examples "label creation" + end + + context "when data is invalid" do + context "when title is invalid" do + it "shows error message" do + create_label("") + + page.within(".label-form") do + expect(page).to have_content("Title can't be blank") + end + end + end + + context "when color is invalid" do + it "shows error message" do + create_label("feature", "#12") + + page.within(".label-form") do + expect(page).to have_content("Color must be a valid color code") + end + end + end + end + + context "when label already exists" do + let!(:label) { create(:label, project: project) } + + it "shows error message" do + create_label(label.title) + + page.within(".label-form") do + expect(page).to have_content("Title has already been taken") + end + end + end + end + + context "in another project" do + set(:another_project) { create(:project_empty_repo, :public) } + + before do + create(:label, project: project, title: "bug") # Create label for `project` (not `another_project`) project. + + another_project.add_master(user) + sign_in(user) + + visit(new_project_label_path(another_project)) + end + + include_examples "label creation" + end + + private + + def create_label(title, color = "#F95610") + fill_in("Title", with: title) + fill_in("Background color", with: color) + click_button("Create label") + end +end diff --git a/spec/features/projects/labels/user_edits_labels_spec.rb b/spec/features/projects/labels/user_edits_labels_spec.rb new file mode 100644 index 00000000000..d1041ff5c1e --- /dev/null +++ b/spec/features/projects/labels/user_edits_labels_spec.rb @@ -0,0 +1,25 @@ +require "spec_helper" + +describe "User edits labels" do + set(:project) { create(:project_empty_repo, :public) } + set(:label) { create(:label, project: project) } + set(:user) { create(:user) } + + before do + project.add_master(user) + sign_in(user) + + visit(edit_project_label_path(project, label)) + end + + it "updates label's title" do + new_title = "fix" + + fill_in("Title", with: new_title) + click_button("Save changes") + + page.within(".other-labels .manage-labels-list") do + expect(page).to have_content(new_title).and have_no_content(label.title) + end + end +end diff --git a/spec/features/projects/labels/user_removes_labels_spec.rb b/spec/features/projects/labels/user_removes_labels_spec.rb new file mode 100644 index 00000000000..f4fda6de465 --- /dev/null +++ b/spec/features/projects/labels/user_removes_labels_spec.rb @@ -0,0 +1,52 @@ +require "spec_helper" + +describe "User removes labels" do + let(:project) { create(:project_empty_repo, :public) } + let(:user) { create(:user) } + + before do + project.add_master(user) + sign_in(user) + end + + context "when one label" do + let!(:label) { create(:label, project: project) } + + before do + visit(project_labels_path(project)) + end + + it "removes label" do + page.within(".labels") do + page.first(".label-list-item") do + first(".remove-row").click + first(:link, "Delete label").click + end + end + + expect(page).to have_content("Label was removed").and have_no_content(label.title) + end + end + + context "when many labels", :js do + before do + create_list(:label, 3, project: project) + + visit(project_labels_path(project)) + end + + it "removes all labels" do + page.within(".labels") do + loop do + li = page.first(".label-list-item") + break unless li + + li.click_link("Delete") + click_link("Delete label") + end + + expect(page).to have_content("Generate a default set of labels").and have_content("New label") + end + end + end +end diff --git a/spec/features/projects/labels/user_views_labels_spec.rb b/spec/features/projects/labels/user_views_labels_spec.rb new file mode 100644 index 00000000000..0cbeca4e392 --- /dev/null +++ b/spec/features/projects/labels/user_views_labels_spec.rb @@ -0,0 +1,23 @@ +require "spec_helper" + +describe "User views labels" do + set(:project) { create(:project_empty_repo, :public) } + set(:user) { create(:user) } + + LABEL_TITLES = %w[bug enhancement feature].freeze + + before do + LABEL_TITLES.each { |title| create(:label, project: project, title: title) } + + project.add_guest(user) + sign_in(user) + + visit(project_labels_path(project)) + end + + it "shows all labels" do + page.within('.other-labels .manage-labels-list') do + LABEL_TITLES.each { |title| expect(page).to have_content(title) } + end + end +end diff --git a/spec/features/projects/milestones/milestones_sorting_spec.rb b/spec/features/projects/milestones/milestones_sorting_spec.rb index c531b81e04d..b64786d4eec 100644 --- a/spec/features/projects/milestones/milestones_sorting_spec.rb +++ b/spec/features/projects/milestones/milestones_sorting_spec.rb @@ -1,7 +1,6 @@ require 'spec_helper' feature 'Milestones sorting', :js do - include SortingHelper let(:user) { create(:user) } let(:project) { create(:project, name: 'test', namespace: user.namespace) } diff --git a/spec/features/projects/pipelines/pipeline_spec.rb b/spec/features/projects/pipelines/pipeline_spec.rb index 266ef693d0b..990e5c4d9df 100644 --- a/spec/features/projects/pipelines/pipeline_spec.rb +++ b/spec/features/projects/pipelines/pipeline_spec.rb @@ -115,6 +115,13 @@ describe 'Pipeline', :js do expect(page).not_to have_content('Retry job') end + + it 'should include the failure reason' do + page.within('#ci-badge-test') do + build_link = page.find('.js-pipeline-graph-job-link') + expect(build_link['data-original-title']).to eq('test - failed <br> (unknown failure)') + end + end end context 'when pipeline has manual jobs' do @@ -289,6 +296,15 @@ describe 'Pipeline', :js do it { expect(build_manual.reload).to be_pending } end + + context 'failed jobs' do + it 'displays a tooltip with the failure reason' do + page.within('.ci-table') do + failed_job_link = page.find('.ci-failed') + expect(failed_job_link[:title]).to eq('Failed <br> (unknown failure)') + end + end + end end describe 'GET /:project/pipelines/:id/failures' do diff --git a/spec/features/projects/pipelines/pipelines_spec.rb b/spec/features/projects/pipelines/pipelines_spec.rb index 0e81c6c629a..6e63e0f0b49 100644 --- a/spec/features/projects/pipelines/pipelines_spec.rb +++ b/spec/features/projects/pipelines/pipelines_spec.rb @@ -394,6 +394,23 @@ describe 'Pipelines', :js do expect(build.reload).to be_canceled end end + + context 'for a failed pipeline' do + let!(:build) do + create(:ci_build, :failed, pipeline: pipeline, + stage: 'build', + name: 'build') + end + + it 'should display the failure reason' do + find('.js-builds-dropdown-button').click + + within('.js-builds-dropdown-list') do + build_element = page.find('.mini-pipeline-graph-dropdown-item') + expect(build_element['data-title']).to eq('build - failed <br> (unknown failure)') + end + end + end end context 'with pagination' do diff --git a/spec/features/projects/project_settings_spec.rb b/spec/features/projects/project_settings_spec.rb deleted file mode 100644 index a3ea778d401..00000000000 --- a/spec/features/projects/project_settings_spec.rb +++ /dev/null @@ -1,205 +0,0 @@ -require 'spec_helper' - -describe 'Edit Project Settings' do - include Select2Helper - - let(:user) { create(:user) } - let(:project) { create(:project, namespace: user.namespace, path: 'gitlab', name: 'sample') } - - before do - sign_in(user) - end - - describe 'Project settings section', :js do - it 'shows errors for invalid project name' do - visit edit_project_path(project) - fill_in 'project_name_edit', with: 'foo&bar' - page.within('.general-settings') do - click_button 'Save changes' - end - expect(page).to have_field 'project_name_edit', with: 'foo&bar' - expect(page).to have_content "Name can contain only letters, digits, emojis, '_', '.', dash, space. It must start with letter, digit, emoji or '_'." - expect(page).to have_button 'Save changes' - end - - it 'shows a successful notice when the project is updated' do - visit edit_project_path(project) - fill_in 'project_name_edit', with: 'hello world' - page.within('.general-settings') do - click_button 'Save changes' - end - expect(page).to have_content "Project 'hello world' was successfully updated." - end - end - - describe 'Merge request settings section' do - it 'shows "Merge commit" strategy' do - visit edit_project_path(project) - - page.within '.merge-requests-feature' do - expect(page).to have_content 'Merge commit' - end - end - - it 'shows "Merge commit with semi-linear history " strategy' do - visit edit_project_path(project) - - page.within '.merge-requests-feature' do - expect(page).to have_content 'Merge commit with semi-linear history' - end - end - - it 'shows "Fast-forward merge" strategy' do - visit edit_project_path(project) - - page.within '.merge-requests-feature' do - expect(page).to have_content 'Fast-forward merge' - end - end - end - - describe 'Rename repository section' do - context 'with invalid characters' do - it 'shows errors for invalid project path/name' do - rename_project(project, name: 'foo&bar', path: 'foo&bar') - expect(page).to have_field 'Project name', with: 'foo&bar' - expect(page).to have_field 'Path', with: 'foo&bar' - expect(page).to have_content "Name can contain only letters, digits, emojis, '_', '.', dash, space. It must start with letter, digit, emoji or '_'." - expect(page).to have_content "Path can contain only letters, digits, '_', '-' and '.'. Cannot start with '-', end in '.git' or end in '.atom'" - end - end - - context 'when changing project name' do - it 'renames the repository' do - rename_project(project, name: 'bar') - expect(find('.breadcrumbs')).to have_content(project.name) - end - - context 'with emojis' do - it 'shows error for invalid project name' do - rename_project(project, name: '🚀 foo bar ☁️') - expect(page).to have_field 'Project name', with: '🚀 foo bar ☁️' - expect(page).not_to have_content "Name can contain only letters, digits, emojis '_', '.', dash and space. It must start with letter, digit, emoji or '_'." - end - end - end - - context 'when changing project path' do - let(:project) { create(:project, :repository, namespace: user.namespace, name: 'gitlabhq') } - - before(:context) do - TestEnv.clean_test_path - end - - after do - TestEnv.clean_test_path - end - - specify 'the project is accessible via the new path' do - rename_project(project, path: 'bar') - new_path = namespace_project_path(project.namespace, 'bar') - visit new_path - expect(current_path).to eq(new_path) - expect(find('.breadcrumbs')).to have_content(project.name) - end - - specify 'the project is accessible via a redirect from the old path' do - old_path = project_path(project) - rename_project(project, path: 'bar') - new_path = namespace_project_path(project.namespace, 'bar') - visit old_path - expect(current_path).to eq(new_path) - expect(find('.breadcrumbs')).to have_content(project.name) - end - - context 'and a new project is added with the same path' do - it 'overrides the redirect' do - old_path = project_path(project) - rename_project(project, path: 'bar') - new_project = create(:project, namespace: user.namespace, path: 'gitlabhq', name: 'quz') - visit old_path - expect(current_path).to eq(old_path) - expect(find('.breadcrumbs')).to have_content(new_project.name) - end - end - end - end - - describe 'Transfer project section', :js do - let!(:project) { create(:project, :repository, namespace: user.namespace, name: 'gitlabhq') } - let!(:group) { create(:group) } - - before(:context) do - TestEnv.clean_test_path - end - - before do - group.add_owner(user) - end - - after do - TestEnv.clean_test_path - end - - specify 'the project is accessible via the new path' do - transfer_project(project, group) - new_path = namespace_project_path(group, project) - - visit new_path - wait_for_requests - - expect(current_path).to eq(new_path) - expect(find('.breadcrumbs')).to have_content(project.name) - end - - specify 'the project is accessible via a redirect from the old path' do - old_path = project_path(project) - transfer_project(project, group) - new_path = namespace_project_path(group, project) - - visit old_path - wait_for_requests - - expect(current_path).to eq(new_path) - expect(find('.breadcrumbs')).to have_content(project.name) - end - - context 'and a new project is added with the same path' do - it 'overrides the redirect' do - old_path = project_path(project) - transfer_project(project, group) - new_project = create(:project, namespace: user.namespace, path: 'gitlabhq', name: 'quz') - visit old_path - expect(current_path).to eq(old_path) - expect(find('.breadcrumbs')).to have_content(new_project.name) - end - end - end -end - -def rename_project(project, name: nil, path: nil) - visit edit_project_path(project) - fill_in('project_name', with: name) if name - fill_in('Path', with: path) if path - click_button('Rename project') - wait_for_edit_project_page_reload - project.reload -end - -def transfer_project(project, namespace) - visit edit_project_path(project) - select2(namespace.id, from: '#new_namespace_id') - click_button('Transfer project') - confirm_transfer_modal - wait_for_edit_project_page_reload - project.reload -end - -def confirm_transfer_modal - fill_in('confirm_name_input', with: project.path) - click_button 'Confirm' -end - -def wait_for_edit_project_page_reload - expect(find('.project-edit-container')).to have_content('Rename repository') -end diff --git a/spec/features/projects/settings/forked_project_settings_spec.rb b/spec/features/projects/settings/forked_project_settings_spec.rb index 28954a4fb40..a4d1b78b83b 100644 --- a/spec/features/projects/settings/forked_project_settings_spec.rb +++ b/spec/features/projects/settings/forked_project_settings_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Settings for a forked project', :js do +describe 'Projects > Settings > For a forked project', :js do include ProjectForksHelper let(:user) { create(:user) } let(:original_project) { create(:project) } diff --git a/spec/features/projects/settings/integration_settings_spec.rb b/spec/features/projects/settings/integration_settings_spec.rb index f6a1a46df11..5178d63050e 100644 --- a/spec/features/projects/settings/integration_settings_spec.rb +++ b/spec/features/projects/settings/integration_settings_spec.rb @@ -1,20 +1,20 @@ require 'spec_helper' -feature 'Integration settings' do +describe 'Projects > Settings > Integration settings' do let(:project) { create(:project) } let(:user) { create(:user) } let(:role) { :developer } let(:integrations_path) { project_settings_integrations_path(project) } - background do + before do sign_in(user) project.add_role(user, role) end context 'for developer' do - given(:role) { :developer } + let(:role) { :developer } - scenario 'to be disallowed to view' do + it 'to be disallowed to view' do visit integrations_path expect(page.status_code).to eq(404) @@ -22,13 +22,13 @@ feature 'Integration settings' do end context 'for master' do - given(:role) { :master } + let(:role) { :master } context 'Webhooks' do let(:hook) { create(:project_hook, :all_events_enabled, enable_ssl_verification: true, project: project) } let(:url) { generate(:url) } - scenario 'show list of webhooks' do + it 'show list of webhooks' do hook visit integrations_path @@ -46,7 +46,7 @@ feature 'Integration settings' do expect(page).to have_content('Wiki page events') end - scenario 'create webhook' do + it 'create webhook' do visit integrations_path fill_in 'hook_url', with: url @@ -63,7 +63,7 @@ feature 'Integration settings' do expect(page).to have_content('Job events') end - scenario 'edit existing webhook' do + it 'edit existing webhook' do hook visit integrations_path @@ -76,7 +76,7 @@ feature 'Integration settings' do expect(page).to have_content(url) end - scenario 'test existing webhook', :js do + it 'test existing webhook', :js do WebMock.stub_request(:post, hook.url) visit integrations_path @@ -87,14 +87,14 @@ feature 'Integration settings' do end context 'remove existing webhook' do - scenario 'from webhooks list page' do + it 'from webhooks list page' do hook visit integrations_path expect { click_link 'Remove' }.to change(ProjectHook, :count).by(-1) end - scenario 'from webhook edit page' do + it 'from webhook edit page' do hook visit integrations_path click_link 'Edit' @@ -108,7 +108,7 @@ feature 'Integration settings' do let(:hook) { create(:project_hook, project: project) } let(:hook_log) { create(:web_hook_log, web_hook: hook, internal_error_message: 'some error') } - scenario 'show list of hook logs' do + it 'show list of hook logs' do hook_log visit edit_project_hook_path(project, hook) @@ -116,7 +116,7 @@ feature 'Integration settings' do expect(page).to have_content(hook_log.url) end - scenario 'show hook log details' do + it 'show hook log details' do hook_log visit edit_project_hook_path(project, hook) click_link 'View details' @@ -126,7 +126,7 @@ feature 'Integration settings' do expect(page).to have_content('Resend Request') end - scenario 'retry hook log' do + it 'retry hook log' do WebMock.stub_request(:post, hook.url) hook_log diff --git a/spec/features/projects/settings/lfs_settings_spec.rb b/spec/features/projects/settings/lfs_settings_spec.rb new file mode 100644 index 00000000000..0fd28a5681c --- /dev/null +++ b/spec/features/projects/settings/lfs_settings_spec.rb @@ -0,0 +1,21 @@ +require 'rails_helper' + +describe 'Projects > Settings > LFS settings' do + let(:admin) { create(:admin) } + let(:project) { create(:project) } + + context 'LFS enabled setting' do + before do + allow(Gitlab.config.lfs).to receive(:enabled).and_return(true) + + sign_in(admin) + end + + it 'displays the correct elements', :js do + visit edit_project_path(project) + + expect(page).to have_content('Git Large File Storage') + expect(page).to have_selector('input[name="project[lfs_enabled]"] + button', visible: true) + end + end +end diff --git a/spec/features/projects/settings/pipelines_settings_spec.rb b/spec/features/projects/settings/pipelines_settings_spec.rb index d0720855564..d9020333f28 100644 --- a/spec/features/projects/settings/pipelines_settings_spec.rb +++ b/spec/features/projects/settings/pipelines_settings_spec.rb @@ -1,19 +1,19 @@ require 'spec_helper' -feature "Pipelines settings" do +describe "Projects > Settings > Pipelines settings" do let(:project) { create(:project) } let(:user) { create(:user) } let(:role) { :developer } - background do + before do sign_in(user) project.add_role(user, role) end context 'for developer' do - given(:role) { :developer } + let(:role) { :developer } - scenario 'to be disallowed to view' do + it 'to be disallowed to view' do visit project_settings_ci_cd_path(project) expect(page.status_code).to eq(404) @@ -21,9 +21,9 @@ feature "Pipelines settings" do end context 'for master' do - given(:role) { :master } + let(:role) { :master } - scenario 'be allowed to change' do + it 'be allowed to change' do visit project_settings_ci_cd_path(project) fill_in('Test coverage parsing', with: 'coverage_regex') @@ -34,7 +34,7 @@ feature "Pipelines settings" do expect(page).to have_field('Test coverage parsing', with: 'coverage_regex') end - scenario 'updates auto_cancel_pending_pipelines' do + it 'updates auto_cancel_pending_pipelines' do visit project_settings_ci_cd_path(project) page.check('Auto-cancel redundant, pending pipelines') diff --git a/spec/features/projects/settings/project_badges_spec.rb b/spec/features/projects/settings/project_badges_spec.rb new file mode 100644 index 00000000000..cc3551a4c21 --- /dev/null +++ b/spec/features/projects/settings/project_badges_spec.rb @@ -0,0 +1,125 @@ +require 'spec_helper' + +feature 'Project Badges' do + include WaitForRequests + + let(:user) { create(:user) } + let(:group) { create(:group) } + let(:project) { create(:project, namespace: group) } + let(:badge_link_url) { 'https://gitlab.com/gitlab-org/gitlab-ee/commits/master'} + let(:badge_image_url) { 'https://gitlab.com/gitlab-org/gitlab-ee/badges/master/build.svg'} + let!(:project_badge) { create(:project_badge, project: project) } + let!(:group_badge) { create(:group_badge, group: group) } + + before do + group.add_master(user) + sign_in(user) + + visit(project_settings_badges_path(project)) + end + + it 'shows a list of badges', :js do + page.within '.badge-settings' do + wait_for_requests + + rows = all('.panel-body > div') + expect(rows.length).to eq 2 + expect(rows[0]).to have_content group_badge.link_url + expect(rows[1]).to have_content project_badge.link_url + end + end + + context 'adding a badge', :js do + it 'user can preview a badge' do + page.within '.badge-settings form' do + fill_in 'badge-link-url', with: badge_link_url + fill_in 'badge-image-url', with: badge_image_url + within '#badge-preview' do + expect(find('a')[:href]).to eq badge_link_url + expect(find('a img')[:src]).to eq badge_image_url + end + end + end + + it do + page.within '.badge-settings' do + fill_in 'badge-link-url', with: badge_link_url + fill_in 'badge-image-url', with: badge_image_url + + click_button 'Add badge' + wait_for_requests + + within '.panel-body' do + expect(find('a')[:href]).to eq badge_link_url + expect(find('a img')[:src]).to eq badge_image_url + end + end + end + end + + context 'editing a badge', :js do + it 'form is shown when clicking edit button in list' do + page.within '.badge-settings' do + wait_for_requests + rows = all('.panel-body > div') + expect(rows.length).to eq 2 + rows[1].find('[aria-label="Edit"]').click + + within 'form' do + expect(find('#badge-link-url').value).to eq project_badge.link_url + expect(find('#badge-image-url').value).to eq project_badge.image_url + end + end + end + + it 'updates a badge when submitting the edit form' do + page.within '.badge-settings' do + wait_for_requests + rows = all('.panel-body > div') + expect(rows.length).to eq 2 + rows[1].find('[aria-label="Edit"]').click + within 'form' do + fill_in 'badge-link-url', with: badge_link_url + fill_in 'badge-image-url', with: badge_image_url + + click_button 'Save changes' + wait_for_requests + end + + rows = all('.panel-body > div') + expect(rows.length).to eq 2 + expect(rows[1]).to have_content badge_link_url + end + end + end + + context 'deleting a badge', :js do + def click_delete_button(badge_row) + badge_row.find('[aria-label="Delete"]').click + end + + it 'shows a modal when deleting a badge' do + wait_for_requests + rows = all('.panel-body > div') + expect(rows.length).to eq 2 + + click_delete_button(rows[1]) + + expect(find('.modal .modal-title')).to have_content 'Delete badge?' + end + + it 'deletes a badge when confirming the modal' do + wait_for_requests + rows = all('.panel-body > div') + expect(rows.length).to eq 2 + click_delete_button(rows[1]) + + find('.modal .btn-danger').click + wait_for_requests + + rows = all('.panel-body > div') + expect(rows.length).to eq 1 + expect(rows[0]).to have_content group_badge.link_url + end + end +end diff --git a/spec/features/projects/settings/repository_settings_spec.rb b/spec/features/projects/settings/repository_settings_spec.rb index 14670e91006..e1dfe617691 100644 --- a/spec/features/projects/settings/repository_settings_spec.rb +++ b/spec/features/projects/settings/repository_settings_spec.rb @@ -1,19 +1,19 @@ require 'spec_helper' -feature 'Repository settings' do +describe 'Projects > Settings > Repository settings' do let(:project) { create(:project_empty_repo) } let(:user) { create(:user) } let(:role) { :developer } - background do + before do project.add_role(user, role) sign_in(user) end context 'for developer' do - given(:role) { :developer } + let(:role) { :developer } - scenario 'is not allowed to view' do + it 'is not allowed to view' do visit project_settings_repository_path(project) expect(page.status_code).to eq(404) @@ -21,14 +21,14 @@ feature 'Repository settings' do end context 'for master' do - given(:role) { :master } + let(:role) { :master } context 'Deploy Keys', :js do let(:private_deploy_key) { create(:deploy_key, title: 'private_deploy_key', public: false) } let(:public_deploy_key) { create(:another_deploy_key, title: 'public_deploy_key', public: true) } let(:new_ssh_key) { attributes_for(:key)[:key] } - scenario 'get list of keys' do + it 'get list of keys' do project.deploy_keys << private_deploy_key project.deploy_keys << public_deploy_key @@ -38,7 +38,7 @@ feature 'Repository settings' do expect(page).to have_content('public_deploy_key') end - scenario 'add a new deploy key' do + it 'add a new deploy key' do visit project_settings_repository_path(project) fill_in 'deploy_key_title', with: 'new_deploy_key' @@ -50,7 +50,7 @@ feature 'Repository settings' do expect(page).to have_content('Write access allowed') end - scenario 'edit an existing deploy key' do + it 'edit an existing deploy key' do project.deploy_keys << private_deploy_key visit project_settings_repository_path(project) @@ -64,7 +64,7 @@ feature 'Repository settings' do expect(page).to have_content('Write access allowed') end - scenario 'edit a deploy key from projects user has access to' do + it 'edit a deploy key from projects user has access to' do project2 = create(:project_empty_repo) project2.add_role(user, role) project2.deploy_keys << private_deploy_key @@ -79,7 +79,7 @@ feature 'Repository settings' do expect(page).to have_content('updated_deploy_key') end - scenario 'remove an existing deploy key' do + it 'remove an existing deploy key' do project.deploy_keys << private_deploy_key visit project_settings_repository_path(project) @@ -88,5 +88,32 @@ feature 'Repository settings' do expect(page).not_to have_content(private_deploy_key.title) end end + + context 'Deploy tokens' do + let!(:deploy_token) { create(:deploy_token, projects: [project]) } + + before do + stub_container_registry_config(enabled: true) + visit project_settings_repository_path(project) + end + + scenario 'view deploy tokens' do + within('.deploy-tokens') do + expect(page).to have_content(deploy_token.name) + expect(page).to have_content('read_repository') + expect(page).to have_content('read_registry') + end + end + + scenario 'add a new deploy token' do + fill_in 'deploy_token_name', with: 'new_deploy_key' + fill_in 'deploy_token_expires_at', with: (Date.today + 1.month).to_s + check 'deploy_token_read_repository' + check 'deploy_token_read_registry' + click_button 'Create deploy token' + + expect(page).to have_content('Your new project deploy token has been created') + end + end end end diff --git a/spec/features/projects/user_archives_project_spec.rb b/spec/features/projects/settings/user_archives_project_spec.rb index 72063d13c2a..38c8a8c2468 100644 --- a/spec/features/projects/user_archives_project_spec.rb +++ b/spec/features/projects/settings/user_archives_project_spec.rb @@ -1,21 +1,19 @@ require 'spec_helper' -describe 'User archives a project' do +describe 'Projects > Settings > User archives a project' do let(:user) { create(:user) } before do project.add_master(user) sign_in(user) + + visit edit_project_path(project) end context 'when a project is archived' do let(:project) { create(:project, :archived, namespace: user.namespace) } - before do - visit(edit_project_path(project)) - end - it 'unarchives a project' do expect(page).to have_content('Unarchive project') @@ -28,10 +26,6 @@ describe 'User archives a project' do context 'when a project is unarchived' do let(:project) { create(:project, :repository, namespace: user.namespace) } - before do - visit(edit_project_path(project)) - end - it 'archives a project' do expect(page).to have_content('Archive project') diff --git a/spec/features/projects/settings/user_changes_avatar_spec.rb b/spec/features/projects/settings/user_changes_avatar_spec.rb new file mode 100644 index 00000000000..2dcc79d8a12 --- /dev/null +++ b/spec/features/projects/settings/user_changes_avatar_spec.rb @@ -0,0 +1,44 @@ +require 'spec_helper' + +describe 'Projects > Settings > User changes avatar' do + let(:project) { create(:project, :repository) } + let(:user) { project.creator } + + before do + project.add_master(user) + sign_in(user) + end + + it 'saves the new avatar' do + expect(project.reload.avatar.url).to be_nil + + save_avatar(project) + + expect(project.reload.avatar.url).to eq "/uploads/-/system/project/avatar/#{project.id}/banana_sample.gif" + end + + context 'with an avatar already set' do + before do + save_avatar(project) + end + + it 'is possible to remove the avatar' do + click_link 'Remove avatar' + + expect(page).not_to have_link('Remove avatar') + + expect(project.reload.avatar.url).to be_nil + end + end + + def save_avatar(project) + visit edit_project_path(project) + attach_file( + :project_avatar, + File.join(Rails.root, 'spec', 'fixtures', 'banana_sample.gif') + ) + page.within '.general-settings' do + click_button 'Save changes' + end + end +end diff --git a/spec/features/projects/settings/user_changes_default_branch_spec.rb b/spec/features/projects/settings/user_changes_default_branch_spec.rb new file mode 100644 index 00000000000..e925539351d --- /dev/null +++ b/spec/features/projects/settings/user_changes_default_branch_spec.rb @@ -0,0 +1,20 @@ +require 'spec_helper' + +describe 'Projects > Settings > User changes default branch' do + let(:user) { create(:user) } + let(:project) { create(:project, :repository, namespace: user.namespace) } + + before do + sign_in(user) + visit edit_project_path(project) + end + + it 'allows to change the default branch' do + select 'fix', from: 'project_default_branch' + page.within '.general-settings' do + click_button 'Save changes' + end + + expect(find(:css, 'select#project_default_branch').value).to eq 'fix' + end +end diff --git a/spec/features/projects/settings/user_manages_group_links_spec.rb b/spec/features/projects/settings/user_manages_group_links_spec.rb index 91e8059865c..fdf42797091 100644 --- a/spec/features/projects/settings/user_manages_group_links_spec.rb +++ b/spec/features/projects/settings/user_manages_group_links_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'User manages group links' do +describe 'Projects > Settings > User manages group links' do include Select2Helper let(:user) { create(:user) } diff --git a/spec/features/projects/settings/merge_requests_settings_spec.rb b/spec/features/projects/settings/user_manages_merge_requests_settings_spec.rb index 015db603d33..b6e65fcbda1 100644 --- a/spec/features/projects/settings/merge_requests_settings_spec.rb +++ b/spec/features/projects/settings/user_manages_merge_requests_settings_spec.rb @@ -1,21 +1,35 @@ require 'spec_helper' -feature 'Project settings > Merge Requests', :js do - let(:project) { create(:project, :public) } +describe 'Projects > Settings > User manages merge request settings' do let(:user) { create(:user) } + let(:project) { create(:project, :public, namespace: user.namespace, path: 'gitlab', name: 'sample') } - background do - project.add_master(user) + before do sign_in(user) + visit edit_project_path(project) end - context 'when Merge Request and Pipelines are initially enabled' do - context 'when Pipelines are initially enabled' do - before do - visit edit_project_path(project) - end + it 'shows "Merge commit" strategy' do + page.within '.merge-requests-feature' do + expect(page).to have_content 'Merge commit' + end + end + + it 'shows "Merge commit with semi-linear history " strategy' do + page.within '.merge-requests-feature' do + expect(page).to have_content 'Merge commit with semi-linear history' + end + end - scenario 'shows the Merge Requests settings' do + it 'shows "Fast-forward merge" strategy' do + page.within '.merge-requests-feature' do + expect(page).to have_content 'Fast-forward merge' + end + end + + context 'when Merge Request and Pipelines are initially enabled', :js do + context 'when Pipelines are initially enabled' do + it 'shows the Merge Requests settings' do expect(page).to have_content('Only allow merge requests to be merged if the pipeline succeeds') expect(page).to have_content('Only allow merge requests to be merged if all discussions are resolved') @@ -29,13 +43,13 @@ feature 'Project settings > Merge Requests', :js do end end - context 'when Pipelines are initially disabled' do + context 'when Pipelines are initially disabled', :js do before do project.project_feature.update_attribute('builds_access_level', ProjectFeature::DISABLED) visit edit_project_path(project) end - scenario 'shows the Merge Requests settings that do not depend on Builds feature' do + it 'shows the Merge Requests settings that do not depend on Builds feature' do expect(page).not_to have_content('Only allow merge requests to be merged if the pipeline succeeds') expect(page).to have_content('Only allow merge requests to be merged if all discussions are resolved') @@ -50,13 +64,13 @@ feature 'Project settings > Merge Requests', :js do end end - context 'when Merge Request are initially disabled' do + context 'when Merge Request are initially disabled', :js do before do project.project_feature.update_attribute('merge_requests_access_level', ProjectFeature::DISABLED) visit edit_project_path(project) end - scenario 'does not show the Merge Requests settings' do + it 'does not show the Merge Requests settings' do expect(page).not_to have_content('Only allow merge requests to be merged if the pipeline succeeds') expect(page).not_to have_content('Only allow merge requests to be merged if all discussions are resolved') @@ -70,17 +84,13 @@ feature 'Project settings > Merge Requests', :js do end end - describe 'Checkbox to enable merge request link' do - before do - visit edit_project_path(project) - end - - scenario 'is initially checked' do + describe 'Checkbox to enable merge request link', :js do + it 'is initially checked' do checkbox = find_field('project_printing_merge_request_link_enabled') expect(checkbox).to be_checked end - scenario 'when unchecked sets :printing_merge_request_link_enabled to false' do + it 'when unchecked sets :printing_merge_request_link_enabled to false' do uncheck('project_printing_merge_request_link_enabled') within('.merge-request-settings-form') do click_on('Save changes') diff --git a/spec/features/projects/settings/user_manages_project_members_spec.rb b/spec/features/projects/settings/user_manages_project_members_spec.rb index 0a4f57bcd21..8af95522165 100644 --- a/spec/features/projects/settings/user_manages_project_members_spec.rb +++ b/spec/features/projects/settings/user_manages_project_members_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'User manages project members' do +describe 'Projects > Settings > User manages project members' do let(:group) { create(:group, name: 'OpenSource') } let(:project) { create(:project) } let(:project2) { create(:project) } diff --git a/spec/features/projects/settings/user_renames_a_project_spec.rb b/spec/features/projects/settings/user_renames_a_project_spec.rb new file mode 100644 index 00000000000..64c9af4b706 --- /dev/null +++ b/spec/features/projects/settings/user_renames_a_project_spec.rb @@ -0,0 +1,100 @@ +require 'spec_helper' + +describe 'Projects > Settings > User renames a project' do + let(:user) { create(:user) } + let(:project) { create(:project, namespace: user.namespace, path: 'gitlab', name: 'sample') } + + before do + sign_in(user) + visit edit_project_path(project) + end + + def rename_project(project, name: nil, path: nil) + fill_in('project_name', with: name) if name + fill_in('Path', with: path) if path + click_button('Rename project') + wait_for_edit_project_page_reload + project.reload + end + + def wait_for_edit_project_page_reload + expect(find('.project-edit-container')).to have_content('Rename repository') + end + + context 'with invalid characters' do + it 'shows errors for invalid project path/name' do + rename_project(project, name: 'foo&bar', path: 'foo&bar') + expect(page).to have_field 'Project name', with: 'foo&bar' + expect(page).to have_field 'Path', with: 'foo&bar' + expect(page).to have_content "Name can contain only letters, digits, emojis, '_', '.', dash, space. It must start with letter, digit, emoji or '_'." + expect(page).to have_content "Path can contain only letters, digits, '_', '-' and '.'. Cannot start with '-', end in '.git' or end in '.atom'" + end + end + + it 'shows a successful notice when the project is updated' do + fill_in 'project_name_edit', with: 'hello world' + page.within('.general-settings') do + click_button 'Save changes' + end + + expect(page).to have_content "Project 'hello world' was successfully updated." + end + + context 'when changing project name' do + it 'renames the repository' do + rename_project(project, name: 'bar') + expect(find('.breadcrumbs')).to have_content(project.name) + end + + context 'with emojis' do + it 'shows error for invalid project name' do + rename_project(project, name: '🚀 foo bar ☁️') + expect(page).to have_field 'Project name', with: '🚀 foo bar ☁️' + expect(page).not_to have_content "Name can contain only letters, digits, emojis '_', '.', dash and space. It must start with letter, digit, emoji or '_'." + end + end + end + + context 'when changing project path' do + let(:project) { create(:project, :repository, namespace: user.namespace, name: 'gitlabhq') } + + before(:context) do + TestEnv.clean_test_path + end + + after do + TestEnv.clean_test_path + end + + it 'the project is accessible via the new path' do + rename_project(project, path: 'bar') + new_path = namespace_project_path(project.namespace, 'bar') + visit new_path + + expect(current_path).to eq(new_path) + expect(find('.breadcrumbs')).to have_content(project.name) + end + + it 'the project is accessible via a redirect from the old path' do + old_path = project_path(project) + rename_project(project, path: 'bar') + new_path = namespace_project_path(project.namespace, 'bar') + visit old_path + + expect(current_path).to eq(new_path) + expect(find('.breadcrumbs')).to have_content(project.name) + end + + context 'and a new project is added with the same path' do + it 'overrides the redirect' do + old_path = project_path(project) + rename_project(project, path: 'bar') + new_project = create(:project, namespace: user.namespace, path: 'gitlabhq', name: 'quz') + visit old_path + + expect(current_path).to eq(old_path) + expect(find('.breadcrumbs')).to have_content(new_project.name) + end + end + end +end diff --git a/spec/features/projects/settings/user_tags_project_spec.rb b/spec/features/projects/settings/user_tags_project_spec.rb new file mode 100644 index 00000000000..57b4b1287fa --- /dev/null +++ b/spec/features/projects/settings/user_tags_project_spec.rb @@ -0,0 +1,23 @@ +require 'spec_helper' + +describe 'Projects > Settings > User tags a project' do + let(:user) { create(:user) } + let(:project) { create(:project, namespace: user.namespace) } + + before do + sign_in(user) + visit edit_project_path(project) + end + + context 'when a project is archived' do + it 'unarchives a project' do + fill_in 'Tags', with: 'tag1, tag2' + + page.within '.general-settings' do + click_button 'Save changes' + end + + expect(find_field('Tags').value).to eq 'tag1, tag2' + end + end +end diff --git a/spec/features/projects/settings/user_transfers_a_project_spec.rb b/spec/features/projects/settings/user_transfers_a_project_spec.rb new file mode 100644 index 00000000000..96b7cf1f93b --- /dev/null +++ b/spec/features/projects/settings/user_transfers_a_project_spec.rb @@ -0,0 +1,73 @@ +require 'spec_helper' + +describe 'Projects > Settings > User transfers a project', :js do + let(:user) { create(:user) } + let(:project) { create(:project, :repository, namespace: user.namespace) } + let(:group) { create(:group) } + + before do + group.add_owner(user) + sign_in(user) + end + + def transfer_project(project, group) + visit edit_project_path(project) + + page.within('.js-project-transfer-form') do + page.find('.select2-container').click + end + + page.find("div[role='option']", text: group.full_name).click + + click_button('Transfer project') + + fill_in 'confirm_name_input', with: project.name + + click_button 'Confirm' + + wait_for_requests + end + + it 'allows transferring a project to a group' do + old_path = project_path(project) + transfer_project(project, group) + new_path = namespace_project_path(group, project) + + expect(project.reload.namespace).to eq(group) + + visit new_path + wait_for_requests + + expect(current_path).to eq(new_path) + expect(find('.breadcrumbs')).to have_content(project.name) + + visit old_path + wait_for_requests + + expect(current_path).to eq(new_path) + expect(find('.breadcrumbs')).to have_content(project.name) + end + + context 'and a new project is added with the same path' do + it 'overrides the redirect' do + old_path = project_path(project) + project_path = project.path + transfer_project(project, group) + new_project = create(:project, namespace: user.namespace, path: project_path) + visit old_path + + expect(current_path).to eq(old_path) + expect(find('.breadcrumbs')).to have_content(new_project.name) + end + end + + context 'when nested groups are available', :nested_groups do + it 'allows transferring a project to a subgroup' do + subgroup = create(:group, parent: group) + + transfer_project(project, subgroup) + + expect(project.reload.namespace).to eq(subgroup) + end + end +end diff --git a/spec/features/projects/settings/visibility_settings_spec.rb b/spec/features/projects/settings/visibility_settings_spec.rb index 06f6702670b..2ec6990313f 100644 --- a/spec/features/projects/settings/visibility_settings_spec.rb +++ b/spec/features/projects/settings/visibility_settings_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Visibility settings', :js do +describe 'Projects > Settings > Visibility settings', :js do let(:user) { create(:user) } let(:project) { create(:project, namespace: user.namespace, visibility_level: 20) } @@ -10,14 +10,14 @@ feature 'Visibility settings', :js do visit edit_project_path(project) end - scenario 'project visibility select is available' do + it 'project visibility select is available' do visibility_select_container = find('.project-visibility-setting') expect(visibility_select_container.find('select').value).to eq project.visibility_level.to_s expect(visibility_select_container).to have_content 'The project can be accessed by anyone, regardless of authentication.' end - scenario 'project visibility description updates on change' do + it 'project visibility description updates on change' do visibility_select_container = find('.project-visibility-setting') visibility_select = visibility_select_container.find('select') visibility_select.select('Private') @@ -25,6 +25,38 @@ feature 'Visibility settings', :js do expect(visibility_select.value).to eq '0' expect(visibility_select_container).to have_content 'Access must be granted explicitly to each user.' end + + context 'merge requests select' do + it 'hides merge requests section' do + find('.project-feature-controls[data-for="project[project_feature_attributes][merge_requests_access_level]"] .project-feature-toggle').click + + expect(page).to have_selector('.merge-requests-feature', visible: false) + end + + context 'given project with merge_requests_disabled access level' do + let(:project) { create(:project, :merge_requests_disabled, namespace: user.namespace) } + + it 'hides merge requests section' do + expect(page).to have_selector('.merge-requests-feature', visible: false) + end + end + end + + context 'builds select' do + it 'hides builds select section' do + find('.project-feature-controls[data-for="project[project_feature_attributes][builds_access_level]"] .project-feature-toggle').click + + expect(page).to have_selector('.builds-feature', visible: false) + end + + context 'given project with builds_disabled access level' do + let(:project) { create(:project, :builds_disabled, namespace: user.namespace) } + + it 'hides builds select section' do + expect(page).to have_selector('.builds-feature', visible: false) + end + end + end end context 'as master' do @@ -36,7 +68,7 @@ feature 'Visibility settings', :js do visit edit_project_path(project) end - scenario 'project visibility is locked' do + it 'project visibility is locked' do visibility_select_container = find('.project-visibility-setting') expect(visibility_select_container).to have_selector 'select[name="project[visibility_level]"]:disabled' diff --git a/spec/features/projects/developer_views_empty_project_instructions_spec.rb b/spec/features/projects/show/developer_views_empty_project_instructions_spec.rb index bf55917bf4c..8803b5222be 100644 --- a/spec/features/projects/developer_views_empty_project_instructions_spec.rb +++ b/spec/features/projects/show/developer_views_empty_project_instructions_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'Developer views empty project instructions' do +feature 'Projects > Show > Developer views empty project instructions' do let(:project) { create(:project, :empty_repo) } let(:developer) { create(:user) } diff --git a/spec/features/projects/main/download_buttons_spec.rb b/spec/features/projects/show/download_buttons_spec.rb index 81f08e44cf3..254affd4a94 100644 --- a/spec/features/projects/main/download_buttons_spec.rb +++ b/spec/features/projects/show/download_buttons_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Download buttons in project main page' do +feature 'Projects > Show > Download buttons' do given(:user) { create(:user) } given(:role) { :developer } given(:status) { 'success' } diff --git a/spec/features/projects/no_password_spec.rb b/spec/features/projects/show/no_password_spec.rb index b3b3212556c..b3b3212556c 100644 --- a/spec/features/projects/no_password_spec.rb +++ b/spec/features/projects/show/no_password_spec.rb diff --git a/spec/features/projects/redirects_spec.rb b/spec/features/projects/show/redirects_spec.rb index d1d8ca07035..8d41c547d77 100644 --- a/spec/features/projects/redirects_spec.rb +++ b/spec/features/projects/show/redirects_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'Project redirects' do +describe 'Projects > Show > Redirects' do let(:user) { create :user } let(:public_project) { create :project, :public } let(:private_project) { create :project, :private } diff --git a/spec/features/projects/main/rss_spec.rb b/spec/features/projects/show/rss_spec.rb index 3c98c11b490..d02eaf34533 100644 --- a/spec/features/projects/main/rss_spec.rb +++ b/spec/features/projects/show/rss_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Project RSS' do +feature 'Projects > Show > RSS' do let(:user) { create(:user) } let(:project) { create(:project, :repository, visibility_level: Gitlab::VisibilityLevel::PUBLIC) } let(:path) { project_path(project) } diff --git a/spec/features/projects/user_interacts_with_stars_spec.rb b/spec/features/projects/show/user_interacts_with_stars_spec.rb index d9d2e0ab171..ba28c0e1b8a 100644 --- a/spec/features/projects/user_interacts_with_stars_spec.rb +++ b/spec/features/projects/show/user_interacts_with_stars_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'User interacts with project stars' do +describe 'Projects > Show > User interacts with project stars' do let(:project) { create(:project, :public, :repository) } context 'when user is signed in', :js do diff --git a/spec/features/projects/show/user_manages_notifications_spec.rb b/spec/features/projects/show/user_manages_notifications_spec.rb new file mode 100644 index 00000000000..31b105229be --- /dev/null +++ b/spec/features/projects/show/user_manages_notifications_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper' + +describe 'Projects > Show > User manages notifications', :js do + let(:project) { create(:project, :public, :repository) } + + before do + sign_in(project.owner) + visit project_path(project) + end + + it 'changes the notification setting' do + first('.notifications-btn').click + click_link 'On mention' + + page.within '#notifications-button' do + expect(page).to have_content 'On mention' + end + end +end diff --git a/spec/features/projects/show/user_sees_deletion_failure_message_spec.rb b/spec/features/projects/show/user_sees_deletion_failure_message_spec.rb new file mode 100644 index 00000000000..aa23bef6fd8 --- /dev/null +++ b/spec/features/projects/show/user_sees_deletion_failure_message_spec.rb @@ -0,0 +1,18 @@ +require 'spec_helper' + +describe 'Projects > Show > User sees a deletion failure message' do + let(:project) { create(:project, :empty_repo, pending_delete: true) } + + before do + sign_in(project.owner) + end + + it 'shows error message if deletion for project fails' do + project.update_attributes(delete_error: "Something went wrong", pending_delete: false) + + visit project_path(project) + + expect(page).to have_selector('.project-deletion-failed-message') + expect(page).to have_content("This project was scheduled for deletion, but failed with the following message: #{project.delete_error}") + end +end diff --git a/spec/features/projects/user_views_details_spec.rb b/spec/features/projects/show/user_sees_git_instructions_spec.rb index ffc063654cd..9a82fee1b5d 100644 --- a/spec/features/projects/user_views_details_spec.rb +++ b/spec/features/projects/show/user_sees_git_instructions_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'User views details' do +describe 'Projects > Show > User sees Git instructions' do set(:user) { create(:user) } shared_examples_for 'redirects to the sign in page' do @@ -9,6 +9,16 @@ describe 'User views details' do end end + shared_examples_for 'shows details of empty project with no repo' do + it 'shows Git command line instructions' do + click_link 'Create empty repository' + + page.within '.empty_wrapper' do + expect(page).to have_content('Command line instructions') + end + end + end + shared_examples_for 'shows details of empty project' do let(:user_has_ssh_key) { false } @@ -36,6 +46,17 @@ describe 'User views details' do end context 'when project is public' do + context 'when project has no repo' do + set(:project) { create(:project, :public) } + + before do + sign_in(project.owner) + visit project_path(project) + end + + include_examples 'shows details of empty project with no repo' + end + context 'when project is empty' do set(:project) { create(:project_empty_repo, :public) } diff --git a/spec/features/projects/show/user_sees_last_commit_ci_status_spec.rb b/spec/features/projects/show/user_sees_last_commit_ci_status_spec.rb new file mode 100644 index 00000000000..e277bfb8011 --- /dev/null +++ b/spec/features/projects/show/user_sees_last_commit_ci_status_spec.rb @@ -0,0 +1,18 @@ +require 'spec_helper' + +describe 'Projects > Show > User sees last commit CI status' do + set(:project) { create(:project, :repository, :public) } + + it 'shows the project README', :js do + project.enable_ci + pipeline = create(:ci_pipeline, project: project, sha: project.commit.sha, ref: 'master') + pipeline.skip + + visit project_path(project) + + page.within '.blob-commit-info' do + expect(page).to have_content(project.commit.sha[0..6]) + expect(page).to have_link('Commit: skipped') + end + end +end diff --git a/spec/features/projects/show/user_sees_readme_spec.rb b/spec/features/projects/show/user_sees_readme_spec.rb new file mode 100644 index 00000000000..d80606c1c23 --- /dev/null +++ b/spec/features/projects/show/user_sees_readme_spec.rb @@ -0,0 +1,16 @@ +require 'spec_helper' + +describe 'Projects > Show > User sees README' do + set(:user) { create(:user) } + + set(:project) { create(:project, :repository, :public) } + + it 'shows the project README', :js do + visit project_path(project) + wait_for_requests + + page.within('.readme-holder') do + expect(page).to have_content 'testme' + end + end +end diff --git a/spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb b/spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb new file mode 100644 index 00000000000..a906fa20233 --- /dev/null +++ b/spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb @@ -0,0 +1,318 @@ +require 'spec_helper' + +describe 'Projects > Show > User sees setup shortcut buttons' do + # For "New file", "Add License" functionality, + # see spec/features/projects/files/project_owner_creates_license_file_spec.rb + # see spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb + + let(:user) { create(:user) } + + describe 'empty project' do + let(:project) { create(:project, :public, :empty_repo) } + let(:presenter) { project.present(current_user: user) } + + describe 'as a normal user' do + before do + sign_in(user) + + visit project_path(project) + end + + it 'no Auto DevOps button if can not manage pipelines' do + page.within('.project-stats') do + expect(page).not_to have_link('Enable Auto DevOps') + expect(page).not_to have_link('Auto DevOps enabled') + end + end + + it '"Auto DevOps enabled" button not linked' do + project.create_auto_devops!(enabled: true) + + visit project_path(project) + + page.within('.project-stats') do + expect(page).to have_text('Auto DevOps enabled') + end + end + end + + describe 'as a master' do + before do + project.add_master(user) + sign_in(user) + + visit project_path(project) + end + + it '"New file" button linked to new file page' do + page.within('.project-stats') do + expect(page).to have_link('New file', href: project_new_blob_path(project, project.default_branch || 'master')) + end + end + + it '"Add Readme" button linked to new file populated for a readme' do + page.within('.project-stats') do + expect(page).to have_link('Add Readme', href: presenter.add_readme_path) + end + end + + it '"Add License" button linked to new file populated for a license' do + page.within('.project-stats') do + expect(page).to have_link('Add License', href: presenter.add_license_path) + end + end + + describe 'Auto DevOps button' do + it '"Enable Auto DevOps" button linked to settings page' do + page.within('.project-stats') do + expect(page).to have_link('Enable Auto DevOps', href: project_settings_ci_cd_path(project, anchor: 'js-general-pipeline-settings')) + end + end + + it '"Auto DevOps enabled" anchor linked to settings page' do + project.create_auto_devops!(enabled: true) + + visit project_path(project) + + page.within('.project-stats') do + expect(page).to have_link('Auto DevOps enabled', href: project_settings_ci_cd_path(project, anchor: 'js-general-pipeline-settings')) + end + end + end + + describe 'Kubernetes cluster button' do + it '"Add Kubernetes cluster" button linked to clusters page' do + page.within('.project-stats') do + expect(page).to have_link('Add Kubernetes cluster', href: new_project_cluster_path(project)) + end + end + + it '"Kubernetes cluster" anchor linked to cluster page' do + cluster = create(:cluster, :provided_by_gcp, projects: [project]) + + visit project_path(project) + + page.within('.project-stats') do + expect(page).to have_link('Kubernetes configured', href: project_cluster_path(project, cluster)) + end + end + end + end + end + + describe 'populated project' do + let(:project) { create(:project, :public, :repository) } + let(:presenter) { project.present(current_user: user) } + + describe 'as a normal user' do + before do + sign_in(user) + + visit project_path(project) + end + + it 'no Auto DevOps button if can not manage pipelines' do + page.within('.project-stats') do + expect(page).not_to have_link('Enable Auto DevOps') + expect(page).not_to have_link('Auto DevOps enabled') + end + end + + it '"Auto DevOps enabled" button not linked' do + project.create_auto_devops!(enabled: true) + + visit project_path(project) + + page.within('.project-stats') do + expect(page).to have_text('Auto DevOps enabled') + end + end + + it 'no Kubernetes cluster button if can not manage clusters' do + page.within('.project-stats') do + expect(page).not_to have_link('Add Kubernetes cluster') + expect(page).not_to have_link('Kubernetes configured') + end + end + end + + describe 'as a master' do + before do + allow_any_instance_of(AutoDevopsHelper).to receive(:show_auto_devops_callout?).and_return(false) + project.add_master(user) + sign_in(user) + + visit project_path(project) + end + + it 'no "Add Changelog" button if the project already has a changelog' do + expect(project.repository.changelog).not_to be_nil + + page.within('.project-stats') do + expect(page).not_to have_link('Add Changelog') + end + end + + it 'no "Add License" button if the project already has a license' do + expect(project.repository.license_blob).not_to be_nil + + page.within('.project-stats') do + expect(page).not_to have_link('Add License') + end + end + + it 'no "Add Contribution guide" button if the project already has a contribution guide' do + expect(project.repository.contribution_guide).not_to be_nil + + page.within('.project-stats') do + expect(page).not_to have_link('Add Contribution guide') + end + end + + describe 'GitLab CI configuration button' do + it '"Set up CI/CD" button linked to new file populated for a .gitlab-ci.yml' do + expect(project.repository.gitlab_ci_yml).to be_nil + + page.within('.project-stats') do + expect(page).to have_link('Set up CI/CD', href: presenter.add_ci_yml_path) + end + end + + it 'no "Set up CI/CD" button if the project already has a .gitlab-ci.yml' do + Files::CreateService.new( + project, + project.creator, + start_branch: 'master', + branch_name: 'master', + commit_message: "Add .gitlab-ci.yml", + file_path: '.gitlab-ci.yml', + file_content: File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')) + ).execute + + expect(project.repository.gitlab_ci_yml).not_to be_nil + + visit project_path(project) + + page.within('.project-stats') do + expect(page).not_to have_link('Set up CI/CD') + end + end + + it 'no "Set up CI/CD" button if the project has Auto DevOps enabled' do + project.create_auto_devops!(enabled: true) + + visit project_path(project) + + page.within('.project-stats') do + expect(page).not_to have_link('Set up CI/CD') + end + end + end + + describe 'Auto DevOps button' do + it '"Enable Auto DevOps" button linked to settings page' do + page.within('.project-stats') do + expect(page).to have_link('Enable Auto DevOps', href: project_settings_ci_cd_path(project, anchor: 'js-general-pipeline-settings')) + end + end + + it '"Enable Auto DevOps" button linked to settings page' do + project.create_auto_devops!(enabled: true) + + visit project_path(project) + + page.within('.project-stats') do + expect(page).to have_link('Auto DevOps enabled', href: project_settings_ci_cd_path(project, anchor: 'js-general-pipeline-settings')) + end + end + + it 'no Auto DevOps button if Auto DevOps callout is shown' do + allow_any_instance_of(AutoDevopsHelper).to receive(:show_auto_devops_callout?).and_return(true) + + visit project_path(project) + + expect(page).to have_selector('.js-autodevops-banner') + + page.within('.project-stats') do + expect(page).not_to have_link('Enable Auto DevOps') + expect(page).not_to have_link('Auto DevOps enabled') + end + end + + it 'no "Enable Auto DevOps" button when .gitlab-ci.yml already exists' do + Files::CreateService.new( + project, + project.creator, + start_branch: 'master', + branch_name: 'master', + commit_message: "Add .gitlab-ci.yml", + file_path: '.gitlab-ci.yml', + file_content: File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')) + ).execute + + expect(project.repository.gitlab_ci_yml).not_to be_nil + + visit project_path(project) + + page.within('.project-stats') do + expect(page).not_to have_link('Enable Auto DevOps') + expect(page).not_to have_link('Auto DevOps enabled') + end + end + end + + describe 'Kubernetes cluster button' do + it '"Add Kubernetes cluster" button linked to clusters page' do + page.within('.project-stats') do + expect(page).to have_link('Add Kubernetes cluster', href: new_project_cluster_path(project)) + end + end + + it '"Kubernetes cluster" button linked to cluster page' do + cluster = create(:cluster, :provided_by_gcp, projects: [project]) + + visit project_path(project) + + page.within('.project-stats') do + expect(page).to have_link('Kubernetes configured', href: project_cluster_path(project, cluster)) + end + end + end + + describe '"Set up Koding" button' do + it 'no "Set up Koding" button if Koding disabled' do + stub_application_setting(koding_enabled?: false) + + visit project_path(project) + + page.within('.project-stats') do + expect(page).not_to have_link('Set up Koding') + end + end + + it 'no "Set up Koding" button if the project already has a .koding.yml' do + stub_application_setting(koding_enabled?: true) + allow(Gitlab::CurrentSettings.current_application_settings).to receive(:koding_url).and_return('http://koding.example.com') + expect(project.repository.changelog).not_to be_nil + allow_any_instance_of(Repository).to receive(:koding_yml).and_return(project.repository.changelog) + + visit project_path(project) + + page.within('.project-stats') do + expect(page).not_to have_link('Set up Koding') + end + end + + it '"Set up Koding" button linked to new file populated for a .koding.yml' do + stub_application_setting(koding_enabled?: true) + + visit project_path(project) + + page.within('.project-stats') do + expect(page).to have_link('Set up Koding', href: presenter.add_koding_stack_path) + end + end + end + end + end +end diff --git a/spec/features/projects/show_project_spec.rb b/spec/features/projects/show_project_spec.rb deleted file mode 100644 index e4f13e6cab7..00000000000 --- a/spec/features/projects/show_project_spec.rb +++ /dev/null @@ -1,359 +0,0 @@ -require 'spec_helper' - -describe 'Project show page', :feature do - include DropzoneHelper - - context 'when project pending delete' do - let(:project) { create(:project, :empty_repo, pending_delete: true) } - - before do - sign_in(project.owner) - end - - it 'shows error message if deletion for project fails' do - project.update_attributes(delete_error: "Something went wrong", pending_delete: false) - - visit project_path(project) - - expect(page).to have_selector('.project-deletion-failed-message') - expect(page).to have_content("This project was scheduled for deletion, but failed with the following message: #{project.delete_error}") - end - end - - describe 'stat button existence' do - # For "New file", "Add License" functionality, - # see spec/features/projects/files/project_owner_creates_license_file_spec.rb - # see spec/features/projects/files/project_owner_sees_link_to_create_license_file_in_empty_project_spec.rb - - let(:user) { create(:user) } - - describe 'empty project' do - let(:project) { create(:project, :public, :empty_repo) } - let(:presenter) { project.present(current_user: user) } - - describe 'as a normal user' do - before do - sign_in(user) - - visit project_path(project) - end - - it 'no Auto DevOps button if can not manage pipelines' do - page.within('.project-stats') do - expect(page).not_to have_link('Enable Auto DevOps') - expect(page).not_to have_link('Auto DevOps enabled') - end - end - - it '"Auto DevOps enabled" button not linked' do - project.create_auto_devops!(enabled: true) - - visit project_path(project) - - page.within('.project-stats') do - expect(page).to have_text('Auto DevOps enabled') - end - end - end - - describe 'as a master' do - before do - project.add_master(user) - sign_in(user) - - visit project_path(project) - end - - it '"New file" button linked to new file page' do - page.within('.project-stats') do - expect(page).to have_link('New file', href: project_new_blob_path(project, project.default_branch || 'master')) - end - end - - it '"Add Readme" button linked to new file populated for a readme' do - page.within('.project-stats') do - expect(page).to have_link('Add Readme', href: presenter.add_readme_path) - end - end - - it '"Add License" button linked to new file populated for a license' do - page.within('.project-stats') do - expect(page).to have_link('Add License', href: presenter.add_license_path) - end - end - - describe 'Auto DevOps button' do - it '"Enable Auto DevOps" button linked to settings page' do - page.within('.project-stats') do - expect(page).to have_link('Enable Auto DevOps', href: project_settings_ci_cd_path(project, anchor: 'js-general-pipeline-settings')) - end - end - - it '"Auto DevOps enabled" anchor linked to settings page' do - project.create_auto_devops!(enabled: true) - - visit project_path(project) - - page.within('.project-stats') do - expect(page).to have_link('Auto DevOps enabled', href: project_settings_ci_cd_path(project, anchor: 'js-general-pipeline-settings')) - end - end - end - - describe 'Kubernetes cluster button' do - it '"Add Kubernetes cluster" button linked to clusters page' do - page.within('.project-stats') do - expect(page).to have_link('Add Kubernetes cluster', href: new_project_cluster_path(project)) - end - end - - it '"Kubernetes cluster" anchor linked to cluster page' do - cluster = create(:cluster, :provided_by_gcp, projects: [project]) - - visit project_path(project) - - page.within('.project-stats') do - expect(page).to have_link('Kubernetes configured', href: project_cluster_path(project, cluster)) - end - end - end - end - end - - describe 'populated project' do - let(:project) { create(:project, :public, :repository) } - let(:presenter) { project.present(current_user: user) } - - describe 'as a normal user' do - before do - sign_in(user) - - visit project_path(project) - end - - it 'no Auto DevOps button if can not manage pipelines' do - page.within('.project-stats') do - expect(page).not_to have_link('Enable Auto DevOps') - expect(page).not_to have_link('Auto DevOps enabled') - end - end - - it '"Auto DevOps enabled" button not linked' do - project.create_auto_devops!(enabled: true) - - visit project_path(project) - - page.within('.project-stats') do - expect(page).to have_text('Auto DevOps enabled') - end - end - - it 'no Kubernetes cluster button if can not manage clusters' do - page.within('.project-stats') do - expect(page).not_to have_link('Add Kubernetes cluster') - expect(page).not_to have_link('Kubernetes configured') - end - end - end - - describe 'as a master' do - before do - allow_any_instance_of(AutoDevopsHelper).to receive(:show_auto_devops_callout?).and_return(false) - project.add_master(user) - sign_in(user) - - visit project_path(project) - end - - it 'no "Add Changelog" button if the project already has a changelog' do - expect(project.repository.changelog).not_to be_nil - - page.within('.project-stats') do - expect(page).not_to have_link('Add Changelog') - end - end - - it 'no "Add License" button if the project already has a license' do - expect(project.repository.license_blob).not_to be_nil - - page.within('.project-stats') do - expect(page).not_to have_link('Add License') - end - end - - it 'no "Add Contribution guide" button if the project already has a contribution guide' do - expect(project.repository.contribution_guide).not_to be_nil - - page.within('.project-stats') do - expect(page).not_to have_link('Add Contribution guide') - end - end - - describe 'GitLab CI configuration button' do - it '"Set up CI/CD" button linked to new file populated for a .gitlab-ci.yml' do - expect(project.repository.gitlab_ci_yml).to be_nil - - page.within('.project-stats') do - expect(page).to have_link('Set up CI/CD', href: presenter.add_ci_yml_path) - end - end - - it 'no "Set up CI/CD" button if the project already has a .gitlab-ci.yml' do - Files::CreateService.new( - project, - project.creator, - start_branch: 'master', - branch_name: 'master', - commit_message: "Add .gitlab-ci.yml", - file_path: '.gitlab-ci.yml', - file_content: File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')) - ).execute - - expect(project.repository.gitlab_ci_yml).not_to be_nil - - visit project_path(project) - - page.within('.project-stats') do - expect(page).not_to have_link('Set up CI/CD') - end - end - - it 'no "Set up CI/CD" button if the project has Auto DevOps enabled' do - project.create_auto_devops!(enabled: true) - - visit project_path(project) - - page.within('.project-stats') do - expect(page).not_to have_link('Set up CI/CD') - end - end - end - - describe 'Auto DevOps button' do - it '"Enable Auto DevOps" button linked to settings page' do - page.within('.project-stats') do - expect(page).to have_link('Enable Auto DevOps', href: project_settings_ci_cd_path(project, anchor: 'js-general-pipeline-settings')) - end - end - - it '"Enable Auto DevOps" button linked to settings page' do - project.create_auto_devops!(enabled: true) - - visit project_path(project) - - page.within('.project-stats') do - expect(page).to have_link('Auto DevOps enabled', href: project_settings_ci_cd_path(project, anchor: 'js-general-pipeline-settings')) - end - end - - it 'no Auto DevOps button if Auto DevOps callout is shown' do - allow_any_instance_of(AutoDevopsHelper).to receive(:show_auto_devops_callout?).and_return(true) - - visit project_path(project) - - expect(page).to have_selector('.js-autodevops-banner') - - page.within('.project-stats') do - expect(page).not_to have_link('Enable Auto DevOps') - expect(page).not_to have_link('Auto DevOps enabled') - end - end - - it 'no "Enable Auto DevOps" button when .gitlab-ci.yml already exists' do - Files::CreateService.new( - project, - project.creator, - start_branch: 'master', - branch_name: 'master', - commit_message: "Add .gitlab-ci.yml", - file_path: '.gitlab-ci.yml', - file_content: File.read(Rails.root.join('spec/support/gitlab_stubs/gitlab_ci.yml')) - ).execute - - expect(project.repository.gitlab_ci_yml).not_to be_nil - - visit project_path(project) - - page.within('.project-stats') do - expect(page).not_to have_link('Enable Auto DevOps') - expect(page).not_to have_link('Auto DevOps enabled') - end - end - end - - describe 'Kubernetes cluster button' do - it '"Add Kubernetes cluster" button linked to clusters page' do - page.within('.project-stats') do - expect(page).to have_link('Add Kubernetes cluster', href: new_project_cluster_path(project)) - end - end - - it '"Kubernetes cluster" button linked to cluster page' do - cluster = create(:cluster, :provided_by_gcp, projects: [project]) - - visit project_path(project) - - page.within('.project-stats') do - expect(page).to have_link('Kubernetes configured', href: project_cluster_path(project, cluster)) - end - end - end - - describe '"Set up Koding" button' do - it 'no "Set up Koding" button if Koding disabled' do - stub_application_setting(koding_enabled?: false) - - visit project_path(project) - - page.within('.project-stats') do - expect(page).not_to have_link('Set up Koding') - end - end - - it 'no "Set up Koding" button if the project already has a .koding.yml' do - stub_application_setting(koding_enabled?: true) - allow(Gitlab::CurrentSettings.current_application_settings).to receive(:koding_url).and_return('http://koding.example.com') - expect(project.repository.changelog).not_to be_nil - allow_any_instance_of(Repository).to receive(:koding_yml).and_return(project.repository.changelog) - - visit project_path(project) - - page.within('.project-stats') do - expect(page).not_to have_link('Set up Koding') - end - end - - it '"Set up Koding" button linked to new file populated for a .koding.yml' do - stub_application_setting(koding_enabled?: true) - - visit project_path(project) - - page.within('.project-stats') do - expect(page).to have_link('Set up Koding', href: presenter.add_koding_stack_path) - end - end - end - end - end - end - - describe 'dropzone', :js do - let(:project) { create(:project, :repository) } - let(:user) { create(:user) } - - before do - project.add_master(user) - sign_in(user) - - visit project_path(project) - end - - it 'can upload files' do - find('.add-to-tree').click - click_link 'Upload file' - drop_in_dropzone(File.join(Rails.root, 'spec', 'fixtures', 'doc_sample.txt')) - - expect(find('.dz-filename')).to have_content('doc_sample.txt') - end - end -end diff --git a/spec/features/projects/snippets/create_snippet_spec.rb b/spec/features/projects/snippets/create_snippet_spec.rb index 3466a3dfb77..2388feeb980 100644 --- a/spec/features/projects/snippets/create_snippet_spec.rb +++ b/spec/features/projects/snippets/create_snippet_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -feature 'Create Snippet', :js do +describe 'Projects > Snippets > Create Snippet', :js do include DropzoneHelper let(:user) { create(:user) } diff --git a/spec/features/projects/snippets/show_spec.rb b/spec/features/projects/snippets/show_spec.rb index 216f2af7c88..004ac55b656 100644 --- a/spec/features/projects/snippets/show_spec.rb +++ b/spec/features/projects/snippets/show_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Project snippet', :js do +describe 'Projects > Snippets > Project snippet', :js do let(:user) { create(:user) } let(:project) { create(:project, :repository) } let(:snippet) { create(:project_snippet, project: project, file_name: file_name, content: content) } diff --git a/spec/features/projects/snippets/user_comments_on_snippet_spec.rb b/spec/features/projects/snippets/user_comments_on_snippet_spec.rb index 1bd2098af6d..01cf9740d1f 100644 --- a/spec/features/projects/snippets/user_comments_on_snippet_spec.rb +++ b/spec/features/projects/snippets/user_comments_on_snippet_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'User comments on a snippet', :js do +describe 'Projects > Snippets > User comments on a snippet', :js do let(:project) { create(:project) } let!(:snippet) { create(:project_snippet, project: project, author: user) } let(:user) { create(:user) } @@ -22,4 +22,16 @@ describe 'User comments on a snippet', :js do expect(page).to have_content('Good snippet!') end + + it 'should have autocomplete' do + find('#note_note').native.send_keys('') + fill_in 'note[note]', with: '@' + + expect(page).to have_selector('.atwho-view') + end + + it 'should have zen mode' do + find('.js-zen-enter').click() + expect(page).to have_selector('.fullscreen') + end end diff --git a/spec/features/projects/snippets/user_deletes_snippet_spec.rb b/spec/features/projects/snippets/user_deletes_snippet_spec.rb index ca5f7981c33..e64837ad59e 100644 --- a/spec/features/projects/snippets/user_deletes_snippet_spec.rb +++ b/spec/features/projects/snippets/user_deletes_snippet_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'User deletes a snippet' do +describe 'Projects > Snippets > User deletes a snippet' do let(:project) { create(:project) } let!(:snippet) { create(:project_snippet, project: project, author: user) } let(:user) { create(:user) } diff --git a/spec/features/projects/snippets/user_updates_snippet_spec.rb b/spec/features/projects/snippets/user_updates_snippet_spec.rb index 09a390443cf..eaedbbf32b6 100644 --- a/spec/features/projects/snippets/user_updates_snippet_spec.rb +++ b/spec/features/projects/snippets/user_updates_snippet_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'User updates a snippet' do +describe 'Projects > Snippets > User updates a snippet' do let(:project) { create(:project) } let!(:snippet) { create(:project_snippet, project: project, author: user) } let(:user) { create(:user) } diff --git a/spec/features/projects/snippets/user_views_snippets_spec.rb b/spec/features/projects/snippets/user_views_snippets_spec.rb index e9992e00ca8..376b76e0001 100644 --- a/spec/features/projects/snippets/user_views_snippets_spec.rb +++ b/spec/features/projects/snippets/user_views_snippets_spec.rb @@ -1,9 +1,10 @@ require 'spec_helper' -describe 'User views snippets' do +describe 'Projects > Snippets > User views snippets' do let(:project) { create(:project) } let!(:project_snippet) { create(:project_snippet, project: project, author: user) } let!(:snippet) { create(:snippet, author: user) } + let(:snippets) { [project_snippet, snippet] } # Used by the shared examples let(:user) { create(:user) } before do @@ -13,6 +14,17 @@ describe 'User views snippets' do visit(project_snippets_path(project)) end + context 'pagination' do + before do + create(:project_snippet, project: project, author: user) + allow(Snippet).to receive(:default_per_page).and_return(1) + + visit project_snippets_path(project) + end + + it_behaves_like 'paginated snippets' + end + it 'shows snippets' do expect(page).to have_content(project_snippet.title) expect(page).not_to have_content(snippet.title) diff --git a/spec/features/projects/snippets_spec.rb b/spec/features/projects/snippets_spec.rb deleted file mode 100644 index 0fa7ca9afd4..00000000000 --- a/spec/features/projects/snippets_spec.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'spec_helper' - -describe 'Project snippets', :js do - context 'when the project has snippets' do - let(:project) { create(:project, :public) } - let!(:snippets) { create_list(:project_snippet, 2, :public, author: project.owner, project: project) } - let!(:other_snippet) { create(:project_snippet) } - - context 'pagination' do - before do - allow(Snippet).to receive(:default_per_page).and_return(1) - - visit project_snippets_path(project) - end - - it_behaves_like 'paginated snippets' - end - - context 'list content' do - it 'contains all project snippets' do - visit project_snippets_path(project) - - expect(page).to have_selector('.snippet-row', count: 2) - - expect(page).to have_content(snippets[0].title) - expect(page).to have_content(snippets[1].title) - end - end - - context 'when submitting a note' do - before do - sign_in(create(:admin)) - visit project_snippet_path(project, snippets[0]) - end - - it 'should have autocomplete' do - find('#note_note').native.send_keys('') - fill_in 'note[note]', with: '@' - - expect(page).to have_selector('.atwho-view') - end - - it 'should have zen mode' do - find('.js-zen-enter').click() - expect(page).to have_selector('.fullscreen') - end - end - end -end diff --git a/spec/features/projects/user_sees_sidebar_spec.rb b/spec/features/projects/user_sees_sidebar_spec.rb new file mode 100644 index 00000000000..cf80517b934 --- /dev/null +++ b/spec/features/projects/user_sees_sidebar_spec.rb @@ -0,0 +1,106 @@ +require 'spec_helper' + +describe 'Projects > User sees sidebar' do + let(:user) { create(:user) } + let(:project) { create(:project, :private, public_builds: false, namespace: user.namespace) } + + context 'as owner' do + before do + sign_in(user) + end + + context 'when snippets are disabled' do + before do + project.project_feature.update_attribute('snippets_access_level', ProjectFeature::DISABLED) + end + + it 'does not display a "Snippets" link' do + visit project_path(project) + + within('.nav-sidebar') do + expect(page).not_to have_content 'Snippets' + end + end + end + end + + context 'as guest' do + let(:guest) { create(:user) } + + before do + project.add_guest(guest) + + sign_in(guest) + end + + it 'shows allowed tabs only' do + visit project_path(project) + + within('.nav-sidebar') do + expect(page).to have_content 'Overview' + expect(page).to have_content 'Issues' + expect(page).to have_content 'Wiki' + + expect(page).not_to have_content 'Repository' + expect(page).not_to have_content 'CI / CD' + expect(page).not_to have_content 'Merge Requests' + end + end + + it 'does not show fork button' do + visit project_path(project) + + within('.count-buttons') do + expect(page).not_to have_link 'Fork' + end + end + + it 'does not show clone path' do + visit project_path(project) + + within('.project-repo-buttons') do + expect(page).not_to have_selector '.project-clone-holder' + end + end + + describe 'project landing page' do + before do + project.project_feature.update!( + issues_access_level: ProjectFeature::DISABLED, + wiki_access_level: ProjectFeature::DISABLED + ) + end + + it 'does not show the project file list landing page' do + visit project_path(project) + + expect(page).not_to have_selector '.project-stats' + expect(page).not_to have_selector '.project-last-commit' + expect(page).not_to have_selector '.project-show-files' + expect(page).to have_selector '.project-show-customize_workflow' + end + + it 'shows the customize workflow when issues and wiki are disabled' do + visit project_path(project) + + expect(page).to have_selector '.project-show-customize_workflow' + end + + it 'shows the wiki when enabled' do + project.project_feature.update!(wiki_access_level: ProjectFeature::PRIVATE) + + visit project_path(project) + + expect(page).to have_selector '.project-show-wiki' + end + + it 'shows the issues when enabled' do + project.project_feature.update!(issues_access_level: ProjectFeature::PRIVATE) + + visit project_path(project) + + expect(page).to have_selector '.issues-list' + end + end + end +end diff --git a/spec/features/projects/user_transfers_a_project_spec.rb b/spec/features/projects/user_transfers_a_project_spec.rb deleted file mode 100644 index 78f72b644ff..00000000000 --- a/spec/features/projects/user_transfers_a_project_spec.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'spec_helper' - -feature 'User transfers a project', :js do - let(:user) { create(:user) } - let(:project) { create(:project, :repository, namespace: user.namespace) } - - before do - sign_in user - end - - def transfer_project(project, group) - visit edit_project_path(project) - - page.within('.js-project-transfer-form') do - page.find('.select2-container').click - end - - page.find("div[role='option']", text: group.full_name).click - - click_button('Transfer project') - - fill_in 'confirm_name_input', with: project.name - - click_button 'Confirm' - - wait_for_requests - end - - it 'allows transferring a project to a subgroup of a namespace' do - group = create(:group) - group.add_owner(user) - - transfer_project(project, group) - - expect(project.reload.namespace).to eq(group) - end - - context 'when nested groups are available', :nested_groups do - it 'allows transferring a project to a subgroup' do - parent = create(:group) - parent.add_owner(user) - subgroup = create(:group, parent: parent) - - transfer_project(project, subgroup) - - expect(project.reload.namespace).to eq(subgroup) - end - end -end diff --git a/spec/features/protected_branches_spec.rb b/spec/features/protected_branches_spec.rb index a4084818284..43cabd3b9f2 100644 --- a/spec/features/protected_branches_spec.rb +++ b/spec/features/protected_branches_spec.rb @@ -142,7 +142,10 @@ feature 'Protected Branches', :js do set_protected_branch_name('*-stable') click_on "Protect" - within(".protected-branches-list") { expect(page).to have_content("2 matching branches") } + within(".protected-branches-list") do + expect(page).to have_content("Protected branch (2)") + expect(page).to have_content("2 matching branches") + end end it "displays all the branches matching the wildcard" do diff --git a/spec/features/protected_tags_spec.rb b/spec/features/protected_tags_spec.rb index 8cc6f17b8d9..efccaeaff6c 100644 --- a/spec/features/protected_tags_spec.rb +++ b/spec/features/protected_tags_spec.rb @@ -65,7 +65,10 @@ feature 'Protected Tags', :js do set_protected_tag_name('*-stable') click_on "Protect" - within(".protected-tags-list") { expect(page).to have_content("2 matching tags") } + within(".protected-tags-list") do + expect(page).to have_content("Protected tag (2)") + expect(page).to have_content("2 matching tags") + end end it "displays all the tags matching the wildcard" do diff --git a/spec/features/search/user_uses_header_search_field_spec.rb b/spec/features/search/user_uses_header_search_field_spec.rb index 5ddea36add5..a9128104b87 100644 --- a/spec/features/search/user_uses_header_search_field_spec.rb +++ b/spec/features/search/user_uses_header_search_field_spec.rb @@ -9,49 +9,25 @@ describe 'User uses header search field' do before do project.add_reporter(user) sign_in(user) - - visit(project_path(project)) - end - - it 'starts searching by pressing the enter key', :js do - fill_in('search', with: 'gitlab') - find('#search').native.send_keys(:enter) - - page.within('.breadcrumbs-sub-title') do - expect(page).to have_content('Search') - end end - it 'contains location badge' do - expect(page).to have_selector('.has-location-badge') - end - - context 'when clicking the search field', :js do + context 'when user is in a global scope', :js do before do + visit(root_path) page.find('#search').click end - it 'shows category search dropdown' do - expect(page).to have_selector('.dropdown-header', text: /#{project.name}/i) - end - context 'when clicking issues' do - let!(:issue) { create(:issue, project: project, author: user, assignees: [user]) } - it 'shows assigned issues' do - find('.dropdown-menu').click_link('Issues assigned to me') + find('.search-input-container .dropdown-menu').click_link('Issues assigned to me') - expect(page).to have_selector('.filtered-search') - expect_tokens([assignee_token(user.name)]) - expect_filtered_search_input_empty + expect(find('.js-assignee-search')).to have_content(user.name) end it 'shows created issues' do - find('.dropdown-menu').click_link("Issues I've created") + find('.search-input-container .dropdown-menu').click_link("Issues I've created") - expect(page).to have_selector('.filtered-search') - expect_tokens([author_token(user.name)]) - expect_filtered_search_input_empty + expect(find('.js-author-search')).to have_content(user.name) end end @@ -59,32 +35,97 @@ describe 'User uses header search field' do let!(:merge_request) { create(:merge_request, source_project: project, author: user, assignee: user) } it 'shows assigned merge requests' do - find('.dropdown-menu').click_link('Merge requests assigned to me') + find('.search-input-container .dropdown-menu').click_link('Merge requests assigned to me') - expect(page).to have_selector('.merge-requests-holder') - expect_tokens([assignee_token(user.name)]) - expect_filtered_search_input_empty + expect(find('.js-assignee-search')).to have_content(user.name) end it 'shows created merge requests' do - find('.dropdown-menu').click_link("Merge requests I've created") + find('.search-input-container .dropdown-menu').click_link("Merge requests I've created") - expect(page).to have_selector('.merge-requests-holder') - expect_tokens([author_token(user.name)]) - expect_filtered_search_input_empty + expect(find('.js-author-search')).to have_content(user.name) end end end - context 'when entering text into the search field', :js do + context 'when user is in a project scope' do before do - page.within('.search-input-wrap') do - fill_in('search', with: project.name[0..3]) + visit(project_path(project)) + end + + it 'starts searching by pressing the enter key', :js do + fill_in('search', with: 'gitlab') + find('#search').native.send_keys(:enter) + + page.within('.breadcrumbs-sub-title') do + expect(page).to have_content('Search') end end - it 'does not display the category search dropdown' do - expect(page).not_to have_selector('.dropdown-header', text: /#{project.name}/i) + it 'contains location badge' do + expect(page).to have_selector('.has-location-badge') + end + + context 'when clicking the search field', :js do + before do + page.find('#search').click + end + + it 'shows category search dropdown' do + expect(page).to have_selector('.dropdown-header', text: /#{project.name}/i) + end + + context 'when clicking issues' do + let!(:issue) { create(:issue, project: project, author: user, assignees: [user]) } + + it 'shows assigned issues' do + find('.dropdown-menu').click_link('Issues assigned to me') + + expect(page).to have_selector('.filtered-search') + expect_tokens([assignee_token(user.name)]) + expect_filtered_search_input_empty + end + + it 'shows created issues' do + find('.dropdown-menu').click_link("Issues I've created") + + expect(page).to have_selector('.filtered-search') + expect_tokens([author_token(user.name)]) + expect_filtered_search_input_empty + end + end + + context 'when clicking merge requests' do + let!(:merge_request) { create(:merge_request, source_project: project, author: user, assignee: user) } + + it 'shows assigned merge requests' do + find('.dropdown-menu').click_link('Merge requests assigned to me') + + expect(page).to have_selector('.merge-requests-holder') + expect_tokens([assignee_token(user.name)]) + expect_filtered_search_input_empty + end + + it 'shows created merge requests' do + find('.dropdown-menu').click_link("Merge requests I've created") + + expect(page).to have_selector('.merge-requests-holder') + expect_tokens([author_token(user.name)]) + expect_filtered_search_input_empty + end + end + end + + context 'when entering text into the search field', :js do + before do + page.within('.search-input-wrap') do + fill_in('search', with: project.name[0..3]) + end + end + + it 'does not display the category search dropdown' do + expect(page).not_to have_selector('.dropdown-header', text: /#{project.name}/i) + end end end end diff --git a/spec/features/user_sorts_things_spec.rb b/spec/features/user_sorts_things_spec.rb new file mode 100644 index 00000000000..69ebdddaeec --- /dev/null +++ b/spec/features/user_sorts_things_spec.rb @@ -0,0 +1,57 @@ +require "spec_helper" + +# The main goal of this spec is not to check whether the sorting UI works, but +# to check if the sorting option set by user is being kept persisted while going through pages. +# The `it`s are named here by convention `starting point -> some pages -> final point`. +# All those specs are moved out to this spec intentionally to keep them all in one place. +describe "User sorts things" do + include Spec::Support::Helpers::Features::SortingHelpers + include Helpers::DashboardHelper + + set(:project) { create(:project_empty_repo, :public) } + set(:current_user) { create(:user) } # Using `current_user` instead of just `user` because of the hardoced call in `assigned_mrs_dashboard_path` which is used below. + set(:issue) { create(:issue, project: project, author: current_user) } + set(:merge_request) { create(:merge_request, target_project: project, source_project: project, author: current_user) } + + before do + project.add_developer(current_user) + sign_in(current_user) + end + + it "issues -> project home page -> issues" do + sort_option = "Last updated" + + visit(project_issues_path(project)) + + sort_by(sort_option) + + visit(project_path(project)) + visit(project_issues_path(project)) + + expect(find(".issues-filters")).to have_content(sort_option) + end + + it "issues -> merge requests" do + sort_option = "Last updated" + + visit(project_issues_path(project)) + + sort_by(sort_option) + + visit(project_merge_requests_path(project)) + + expect(find(".issues-filters")).to have_content(sort_option) + end + + it "merge requests -> dashboard merge requests" do + sort_option = "Last updated" + + visit(project_merge_requests_path(project)) + + sort_by(sort_option) + + visit(assigned_mrs_dashboard_path) + + expect(find(".issues-filters")).to have_content(sort_option) + end +end diff --git a/spec/finders/labels_finder_spec.rb b/spec/finders/labels_finder_spec.rb index d434c501110..899d0d22819 100644 --- a/spec/finders/labels_finder_spec.rb +++ b/spec/finders/labels_finder_spec.rb @@ -71,6 +71,24 @@ describe LabelsFinder do end end + context 'when group has no projects' do + let(:empty_group) { create(:group) } + let!(:empty_group_label_1) { create(:group_label, group: empty_group, title: 'Label 1 (empty group)') } + let!(:empty_group_label_2) { create(:group_label, group: empty_group, title: 'Label 2 (empty group)') } + + before do + empty_group.add_developer(user) + end + + context 'when only group labels is false' do + it 'returns group labels' do + finder = described_class.new(user, group_id: empty_group.id) + + expect(finder.execute).to eq [empty_group_label_1, empty_group_label_2] + end + end + end + context 'when including labels from group ancestors', :nested_groups do it 'returns labels from group and its ancestors' do private_group_1.add_developer(user) @@ -110,7 +128,21 @@ describe LabelsFinder do end end - context 'filtering by project_id' do + context 'filtering by project_id', :nested_groups do + context 'when include_ancestor_groups is true' do + let!(:sub_project) { create(:project, namespace: private_subgroup_1 ) } + let!(:project_label) { create(:label, project: sub_project, title: 'Label 5') } + let(:finder) { described_class.new(user, project_id: sub_project.id, include_ancestor_groups: true) } + + before do + private_group_1.add_developer(user) + end + + it 'returns all ancestor labels' do + expect(finder.execute).to match_array([private_subgroup_label_1, private_group_label_1, project_label]) + end + end + it 'returns labels available for the project' do finder = described_class.new(user, project_id: project_1.id) diff --git a/spec/fixtures/api/schemas/issue.json b/spec/fixtures/api/schemas/issue.json index b579e32c9aa..8833825e3fb 100644 --- a/spec/fixtures/api/schemas/issue.json +++ b/spec/fixtures/api/schemas/issue.json @@ -15,6 +15,8 @@ "relative_position": { "type": "integer" }, "issue_sidebar_endpoint": { "type": "string" }, "toggle_subscription_endpoint": { "type": "string" }, + "reference_path": { "type": "string" }, + "real_path": { "type": "string" }, "project": { "id": { "type": "integer" }, "path": { "type": "string" } diff --git a/spec/fixtures/api/schemas/public_api/v4/project/export_status.json b/spec/fixtures/api/schemas/public_api/v4/project/export_status.json index d24a6f93f4b..81c8815caf6 100644 --- a/spec/fixtures/api/schemas/public_api/v4/project/export_status.json +++ b/spec/fixtures/api/schemas/public_api/v4/project/export_status.json @@ -1,7 +1,9 @@ { "type": "object", "allOf": [ - { "$ref": "identity.json" }, + { + "$ref": "identity.json" + }, { "required": [ "export_status" @@ -9,7 +11,12 @@ "properties": { "export_status": { "type": "string", - "enum": ["none", "started", "finished"] + "enum": [ + "none", + "started", + "finished", + "after_export_action" + ] } } } diff --git a/spec/fixtures/api/schemas/public_api/v4/tag.json b/spec/fixtures/api/schemas/public_api/v4/tag.json index 52cfe86aeeb..10d4edb7ffb 100644 --- a/spec/fixtures/api/schemas/public_api/v4/tag.json +++ b/spec/fixtures/api/schemas/public_api/v4/tag.json @@ -10,6 +10,7 @@ "name": { "type": "string" }, "message": { "type": ["string", "null"] }, "commit": { "$ref": "commit/basic.json" }, + "target": { "type": "string" }, "release": { "oneOf": [ { "type": "null" }, diff --git a/spec/fixtures/exported-project.gz b/spec/fixtures/exported-project.gz Binary files differnew file mode 100644 index 00000000000..352384f16c8 --- /dev/null +++ b/spec/fixtures/exported-project.gz diff --git a/spec/helpers/diff_helper_spec.rb b/spec/helpers/diff_helper_spec.rb index 15cbe36ae76..53c010fa0db 100644 --- a/spec/helpers/diff_helper_spec.rb +++ b/spec/helpers/diff_helper_spec.rb @@ -135,11 +135,37 @@ describe DiffHelper do it "returns strings with marked inline diffs" do marked_old_line, marked_new_line = mark_inline_diffs(old_line, new_line) - expect(marked_old_line).to eq(%q{abc <span class="idiff left right deletion">'def'</span>}) + expect(marked_old_line).to eq(%q{abc <span class="idiff left right deletion">'def'</span>}) expect(marked_old_line).to be_html_safe - expect(marked_new_line).to eq(%q{abc <span class="idiff left right addition">"def"</span>}) + expect(marked_new_line).to eq(%q{abc <span class="idiff left right addition">"def"</span>}) expect(marked_new_line).to be_html_safe end + + context 'when given HTML' do + it 'sanitizes it' do + old_line = %{test.txt} + new_line = %{<img src=x onerror=alert(document.domain)>} + + marked_old_line, marked_new_line = mark_inline_diffs(old_line, new_line) + + expect(marked_old_line).to eq(%q{<span class="idiff left right deletion">test.txt</span>}) + expect(marked_old_line).to be_html_safe + expect(marked_new_line).to eq(%q{<span class="idiff left right addition"><img src=x onerror=alert(document.domain)></span>}) + expect(marked_new_line).to be_html_safe + end + + it 'sanitizes the entire line, not just the changes' do + old_line = %{<img src=x onerror=alert(document.domain)>} + new_line = %{<img src=y onerror=alert(document.domain)>} + + marked_old_line, marked_new_line = mark_inline_diffs(old_line, new_line) + + expect(marked_old_line).to eq(%q{<img src=<span class="idiff left right deletion">x</span> onerror=alert(document.domain)>}) + expect(marked_old_line).to be_html_safe + expect(marked_new_line).to eq(%q{<img src=<span class="idiff left right addition">y</span> onerror=alert(document.domain)>}) + expect(marked_new_line).to be_html_safe + end + end end describe '#parallel_diff_discussions' do diff --git a/spec/helpers/issuables_helper_spec.rb b/spec/helpers/issuables_helper_spec.rb index 2fecd1a3d27..4224cea4652 100644 --- a/spec/helpers/issuables_helper_spec.rb +++ b/spec/helpers/issuables_helper_spec.rb @@ -40,22 +40,22 @@ describe IssuablesHelper do end it 'returns "Open" when state is :opened' do - expect(helper.issuables_state_counter_text(:issues, :opened)) + expect(helper.issuables_state_counter_text(:issues, :opened, true)) .to eq('<span>Open</span> <span class="badge">42</span>') end it 'returns "Closed" when state is :closed' do - expect(helper.issuables_state_counter_text(:issues, :closed)) + expect(helper.issuables_state_counter_text(:issues, :closed, true)) .to eq('<span>Closed</span> <span class="badge">42</span>') end it 'returns "Merged" when state is :merged' do - expect(helper.issuables_state_counter_text(:merge_requests, :merged)) + expect(helper.issuables_state_counter_text(:merge_requests, :merged, true)) .to eq('<span>Merged</span> <span class="badge">42</span>') end it 'returns "All" when state is :all' do - expect(helper.issuables_state_counter_text(:merge_requests, :all)) + expect(helper.issuables_state_counter_text(:merge_requests, :all, true)) .to eq('<span>All</span> <span class="badge">42</span>') end end @@ -101,27 +101,6 @@ describe IssuablesHelper do end end - describe '#issuable_filter_present?' do - it 'returns true when any key is present' do - allow(helper).to receive(:params).and_return( - ActionController::Parameters.new(milestone_title: 'Velit consectetur asperiores natus delectus.', - project_id: 'gitlabhq', - scope: 'all') - ) - - expect(helper.issuable_filter_present?).to be_truthy - end - - it 'returns false when no key is present' do - allow(helper).to receive(:params).and_return( - ActionController::Parameters.new(project_id: 'gitlabhq', - scope: 'all') - ) - - expect(helper.issuable_filter_present?).to be_falsey - end - end - describe '#updated_at_by' do let(:user) { create(:user) } let(:unedited_issuable) { create(:issue) } diff --git a/spec/helpers/tree_helper_spec.rb b/spec/helpers/tree_helper_spec.rb index ccac6e29447..ffdf6561a53 100644 --- a/spec/helpers/tree_helper_spec.rb +++ b/spec/helpers/tree_helper_spec.rb @@ -8,6 +8,7 @@ describe TreeHelper do describe '.render_tree' do before do @id = sha + @path = "" @project = project @lfs_blob_ids = [] end @@ -61,6 +62,15 @@ describe TreeHelper do end end end + + context 'when the root path contains a plus character' do + let(:root_path) { 'gtk/C++' } + let(:tree_item) { double(flat_path: 'gtk/C++/glade') } + + it 'returns the flattened path' do + expect(subject).to eq('glade') + end + end end describe '#commit_in_single_accessible_branch' do diff --git a/spec/initializers/artifacts_direct_upload_support_spec.rb b/spec/initializers/artifacts_direct_upload_support_spec.rb new file mode 100644 index 00000000000..bfb71da3388 --- /dev/null +++ b/spec/initializers/artifacts_direct_upload_support_spec.rb @@ -0,0 +1,71 @@ +require 'spec_helper' + +describe 'Artifacts direct upload support' do + subject do + load Rails.root.join('config/initializers/artifacts_direct_upload_support.rb') + end + + let(:connection) do + { provider: provider } + end + + before do + stub_artifacts_setting( + object_store: { + enabled: enabled, + direct_upload: direct_upload, + connection: connection + }) + end + + context 'when object storage is enabled' do + let(:enabled) { true } + + context 'when direct upload is enabled' do + let(:direct_upload) { true } + + context 'when provider is Google' do + let(:provider) { 'Google' } + + it 'succeeds' do + expect { subject }.not_to raise_error + end + end + + context 'when connection is empty' do + let(:connection) { nil } + + it 'raises an error' do + expect { subject }.to raise_error /object storage provider when 'direct_upload' of artifacts is used/ + end + end + + context 'when other provider is used' do + let(:provider) { 'AWS' } + + it 'raises an error' do + expect { subject }.to raise_error /object storage provider when 'direct_upload' of artifacts is used/ + end + end + end + + context 'when direct upload is disabled' do + let(:direct_upload) { false } + let(:provider) { 'AWS' } + + it 'succeeds' do + expect { subject }.not_to raise_error + end + end + end + + context 'when object storage is disabled' do + let(:enabled) { false } + let(:direct_upload) { false } + let(:provider) { 'AWS' } + + it 'succeeds' do + expect { subject }.not_to raise_error + end + end +end diff --git a/spec/javascripts/api_spec.js b/spec/javascripts/api_spec.js index 5477581c1b9..3d7ccf432be 100644 --- a/spec/javascripts/api_spec.js +++ b/spec/javascripts/api_spec.js @@ -35,14 +35,14 @@ describe('Api', () => { }); describe('group', () => { - it('fetches a group', (done) => { + it('fetches a group', done => { const groupId = '123456'; const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/groups/${groupId}`; mock.onGet(expectedUrl).reply(200, { name: 'test', }); - Api.group(groupId, (response) => { + Api.group(groupId, response => { expect(response.name).toBe('test'); done(); }); @@ -50,15 +50,17 @@ describe('Api', () => { }); describe('groups', () => { - it('fetches groups', (done) => { + it('fetches groups', done => { const query = 'dummy query'; const options = { unused: 'option' }; const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/groups.json`; - mock.onGet(expectedUrl).reply(200, [{ - name: 'test', - }]); + mock.onGet(expectedUrl).reply(200, [ + { + name: 'test', + }, + ]); - Api.groups(query, options, (response) => { + Api.groups(query, options, response => { expect(response.length).toBe(1); expect(response[0].name).toBe('test'); done(); @@ -67,14 +69,16 @@ describe('Api', () => { }); describe('namespaces', () => { - it('fetches namespaces', (done) => { + it('fetches namespaces', done => { const query = 'dummy query'; const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/namespaces.json`; - mock.onGet(expectedUrl).reply(200, [{ - name: 'test', - }]); + mock.onGet(expectedUrl).reply(200, [ + { + name: 'test', + }, + ]); - Api.namespaces(query, (response) => { + Api.namespaces(query, response => { expect(response.length).toBe(1); expect(response[0].name).toBe('test'); done(); @@ -83,31 +87,35 @@ describe('Api', () => { }); describe('projects', () => { - it('fetches projects with membership when logged in', (done) => { + it('fetches projects with membership when logged in', done => { const query = 'dummy query'; const options = { unused: 'option' }; const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/projects.json`; window.gon.current_user_id = 1; - mock.onGet(expectedUrl).reply(200, [{ - name: 'test', - }]); + mock.onGet(expectedUrl).reply(200, [ + { + name: 'test', + }, + ]); - Api.projects(query, options, (response) => { + Api.projects(query, options, response => { expect(response.length).toBe(1); expect(response[0].name).toBe('test'); done(); }); }); - it('fetches projects without membership when not logged in', (done) => { + it('fetches projects without membership when not logged in', done => { const query = 'dummy query'; const options = { unused: 'option' }; const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/projects.json`; - mock.onGet(expectedUrl).reply(200, [{ - name: 'test', - }]); + mock.onGet(expectedUrl).reply(200, [ + { + name: 'test', + }, + ]); - Api.projects(query, options, (response) => { + Api.projects(query, options, response => { expect(response.length).toBe(1); expect(response[0].name).toBe('test'); done(); @@ -115,8 +123,65 @@ describe('Api', () => { }); }); + describe('mergerequest', () => { + it('fetches a merge request', done => { + const projectPath = 'abc'; + const mergeRequestId = '123456'; + const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/projects/${projectPath}/merge_requests/${mergeRequestId}`; + mock.onGet(expectedUrl).reply(200, { + title: 'test', + }); + + Api.mergeRequest(projectPath, mergeRequestId) + .then(({ data }) => { + expect(data.title).toBe('test'); + }) + .then(done) + .catch(done.fail); + }); + }); + + describe('mergerequest changes', () => { + it('fetches the changes of a merge request', done => { + const projectPath = 'abc'; + const mergeRequestId = '123456'; + const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/projects/${projectPath}/merge_requests/${mergeRequestId}/changes`; + mock.onGet(expectedUrl).reply(200, { + title: 'test', + }); + + Api.mergeRequestChanges(projectPath, mergeRequestId) + .then(({ data }) => { + expect(data.title).toBe('test'); + }) + .then(done) + .catch(done.fail); + }); + }); + + describe('mergerequest versions', () => { + it('fetches the versions of a merge request', done => { + const projectPath = 'abc'; + const mergeRequestId = '123456'; + const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/projects/${projectPath}/merge_requests/${mergeRequestId}/versions`; + mock.onGet(expectedUrl).reply(200, [ + { + id: 123, + }, + ]); + + Api.mergeRequestVersions(projectPath, mergeRequestId) + .then(({ data }) => { + expect(data.length).toBe(1); + expect(data[0].id).toBe(123); + }) + .then(done) + .catch(done.fail); + }); + }); + describe('newLabel', () => { - it('creates a new label', (done) => { + it('creates a new label', done => { const namespace = 'some namespace'; const project = 'some project'; const labelData = { some: 'data' }; @@ -124,36 +189,42 @@ describe('Api', () => { const expectedData = { label: labelData, }; - mock.onPost(expectedUrl).reply((config) => { + mock.onPost(expectedUrl).reply(config => { expect(config.data).toBe(JSON.stringify(expectedData)); - return [200, { - name: 'test', - }]; + return [ + 200, + { + name: 'test', + }, + ]; }); - Api.newLabel(namespace, project, labelData, (response) => { + Api.newLabel(namespace, project, labelData, response => { expect(response.name).toBe('test'); done(); }); }); - it('creates a group label', (done) => { + it('creates a group label', done => { const namespace = 'group/subgroup'; const labelData = { some: 'data' }; const expectedUrl = `${dummyUrlRoot}/groups/${namespace}/-/labels`; const expectedData = { label: labelData, }; - mock.onPost(expectedUrl).reply((config) => { + mock.onPost(expectedUrl).reply(config => { expect(config.data).toBe(JSON.stringify(expectedData)); - return [200, { - name: 'test', - }]; + return [ + 200, + { + name: 'test', + }, + ]; }); - Api.newLabel(namespace, undefined, labelData, (response) => { + Api.newLabel(namespace, undefined, labelData, response => { expect(response.name).toBe('test'); done(); }); @@ -161,15 +232,17 @@ describe('Api', () => { }); describe('groupProjects', () => { - it('fetches group projects', (done) => { + it('fetches group projects', done => { const groupId = '123456'; const query = 'dummy query'; const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/groups/${groupId}/projects.json`; - mock.onGet(expectedUrl).reply(200, [{ - name: 'test', - }]); + mock.onGet(expectedUrl).reply(200, [ + { + name: 'test', + }, + ]); - Api.groupProjects(groupId, query, (response) => { + Api.groupProjects(groupId, query, response => { expect(response.length).toBe(1); expect(response[0].name).toBe('test'); done(); @@ -178,13 +251,13 @@ describe('Api', () => { }); describe('licenseText', () => { - it('fetches a license text', (done) => { + it('fetches a license text', done => { const licenseKey = "driver's license"; const data = { unused: 'option' }; const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/templates/licenses/${licenseKey}`; mock.onGet(expectedUrl).reply(200, 'test'); - Api.licenseText(licenseKey, data, (response) => { + Api.licenseText(licenseKey, data, response => { expect(response).toBe('test'); done(); }); @@ -192,12 +265,12 @@ describe('Api', () => { }); describe('gitignoreText', () => { - it('fetches a gitignore text', (done) => { + it('fetches a gitignore text', done => { const gitignoreKey = 'ignore git'; const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/templates/gitignores/${gitignoreKey}`; mock.onGet(expectedUrl).reply(200, 'test'); - Api.gitignoreText(gitignoreKey, (response) => { + Api.gitignoreText(gitignoreKey, response => { expect(response).toBe('test'); done(); }); @@ -205,12 +278,12 @@ describe('Api', () => { }); describe('gitlabCiYml', () => { - it('fetches a .gitlab-ci.yml', (done) => { + it('fetches a .gitlab-ci.yml', done => { const gitlabCiYmlKey = 'Y CI ML'; const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/templates/gitlab_ci_ymls/${gitlabCiYmlKey}`; mock.onGet(expectedUrl).reply(200, 'test'); - Api.gitlabCiYml(gitlabCiYmlKey, (response) => { + Api.gitlabCiYml(gitlabCiYmlKey, response => { expect(response).toBe('test'); done(); }); @@ -218,12 +291,12 @@ describe('Api', () => { }); describe('dockerfileYml', () => { - it('fetches a Dockerfile', (done) => { + it('fetches a Dockerfile', done => { const dockerfileYmlKey = 'a giant whale'; const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/templates/dockerfiles/${dockerfileYmlKey}`; mock.onGet(expectedUrl).reply(200, 'test'); - Api.dockerfileYml(dockerfileYmlKey, (response) => { + Api.dockerfileYml(dockerfileYmlKey, response => { expect(response).toBe('test'); done(); }); @@ -231,12 +304,14 @@ describe('Api', () => { }); describe('issueTemplate', () => { - it('fetches an issue template', (done) => { + it('fetches an issue template', done => { const namespace = 'some namespace'; const project = 'some project'; const templateKey = ' template #%?.key '; const templateType = 'template type'; - const expectedUrl = `${dummyUrlRoot}/${namespace}/${project}/templates/${templateType}/${encodeURIComponent(templateKey)}`; + const expectedUrl = `${dummyUrlRoot}/${namespace}/${project}/templates/${templateType}/${encodeURIComponent( + templateKey, + )}`; mock.onGet(expectedUrl).reply(200, 'test'); Api.issueTemplate(namespace, project, templateKey, templateType, (error, response) => { @@ -247,13 +322,15 @@ describe('Api', () => { }); describe('users', () => { - it('fetches users', (done) => { + it('fetches users', done => { const query = 'dummy query'; const options = { unused: 'option' }; const expectedUrl = `${dummyUrlRoot}/api/${dummyApiVersion}/users.json`; - mock.onGet(expectedUrl).reply(200, [{ - name: 'test', - }]); + mock.onGet(expectedUrl).reply(200, [ + { + name: 'test', + }, + ]); Api.users(query, options) .then(({ data }) => { diff --git a/spec/javascripts/badges/components/badge_form_spec.js b/spec/javascripts/badges/components/badge_form_spec.js new file mode 100644 index 00000000000..dd21ec279cb --- /dev/null +++ b/spec/javascripts/badges/components/badge_form_spec.js @@ -0,0 +1,171 @@ +import Vue from 'vue'; +import store from '~/badges/store'; +import BadgeForm from '~/badges/components/badge_form.vue'; +import { mountComponentWithStore } from 'spec/helpers/vue_mount_component_helper'; +import { createDummyBadge } from '../dummy_badge'; + +describe('BadgeForm component', () => { + const Component = Vue.extend(BadgeForm); + let vm; + + beforeEach(() => { + setFixtures(` + <div id="dummy-element"></div> + `); + }); + + afterEach(() => { + vm.$destroy(); + }); + + describe('methods', () => { + beforeEach(() => { + vm = mountComponentWithStore(Component, { + el: '#dummy-element', + store, + props: { + isEditing: false, + }, + }); + }); + + describe('onCancel', () => { + it('calls stopEditing', () => { + spyOn(vm, 'stopEditing'); + + vm.onCancel(); + + expect(vm.stopEditing).toHaveBeenCalled(); + }); + }); + + describe('onSubmit', () => { + describe('if isEditing is true', () => { + beforeEach(() => { + spyOn(vm, 'saveBadge').and.returnValue(Promise.resolve()); + store.replaceState({ + ...store.state, + isSaving: false, + badgeInEditForm: createDummyBadge(), + }); + vm.isEditing = true; + }); + + it('returns immediately if imageUrl is empty', () => { + store.state.badgeInEditForm.imageUrl = ''; + + vm.onSubmit(); + + expect(vm.saveBadge).not.toHaveBeenCalled(); + }); + + it('returns immediately if linkUrl is empty', () => { + store.state.badgeInEditForm.linkUrl = ''; + + vm.onSubmit(); + + expect(vm.saveBadge).not.toHaveBeenCalled(); + }); + + it('returns immediately if isSaving is true', () => { + store.state.isSaving = true; + + vm.onSubmit(); + + expect(vm.saveBadge).not.toHaveBeenCalled(); + }); + + it('calls saveBadge', () => { + vm.onSubmit(); + + expect(vm.saveBadge).toHaveBeenCalled(); + }); + }); + + describe('if isEditing is false', () => { + beforeEach(() => { + spyOn(vm, 'addBadge').and.returnValue(Promise.resolve()); + store.replaceState({ + ...store.state, + isSaving: false, + badgeInAddForm: createDummyBadge(), + }); + vm.isEditing = false; + }); + + it('returns immediately if imageUrl is empty', () => { + store.state.badgeInAddForm.imageUrl = ''; + + vm.onSubmit(); + + expect(vm.addBadge).not.toHaveBeenCalled(); + }); + + it('returns immediately if linkUrl is empty', () => { + store.state.badgeInAddForm.linkUrl = ''; + + vm.onSubmit(); + + expect(vm.addBadge).not.toHaveBeenCalled(); + }); + + it('returns immediately if isSaving is true', () => { + store.state.isSaving = true; + + vm.onSubmit(); + + expect(vm.addBadge).not.toHaveBeenCalled(); + }); + + it('calls addBadge', () => { + vm.onSubmit(); + + expect(vm.addBadge).toHaveBeenCalled(); + }); + }); + }); + }); + + describe('if isEditing is false', () => { + beforeEach(() => { + vm = mountComponentWithStore(Component, { + el: '#dummy-element', + store, + props: { + isEditing: false, + }, + }); + }); + + it('renders one button', () => { + const buttons = vm.$el.querySelectorAll('.row-content-block button'); + expect(buttons.length).toBe(1); + const buttonAddElement = buttons[0]; + expect(buttonAddElement).toBeVisible(); + expect(buttonAddElement).toHaveText('Add badge'); + }); + }); + + describe('if isEditing is true', () => { + beforeEach(() => { + vm = mountComponentWithStore(Component, { + el: '#dummy-element', + store, + props: { + isEditing: true, + }, + }); + }); + + it('renders two buttons', () => { + const buttons = vm.$el.querySelectorAll('.row-content-block button'); + expect(buttons.length).toBe(2); + const buttonSaveElement = buttons[0]; + expect(buttonSaveElement).toBeVisible(); + expect(buttonSaveElement).toHaveText('Save changes'); + const buttonCancelElement = buttons[1]; + expect(buttonCancelElement).toBeVisible(); + expect(buttonCancelElement).toHaveText('Cancel'); + }); + }); +}); diff --git a/spec/javascripts/badges/components/badge_list_row_spec.js b/spec/javascripts/badges/components/badge_list_row_spec.js new file mode 100644 index 00000000000..21bd00d82f0 --- /dev/null +++ b/spec/javascripts/badges/components/badge_list_row_spec.js @@ -0,0 +1,97 @@ +import $ from 'jquery'; +import Vue from 'vue'; +import { GROUP_BADGE, PROJECT_BADGE } from '~/badges/constants'; +import store from '~/badges/store'; +import BadgeListRow from '~/badges/components/badge_list_row.vue'; +import { mountComponentWithStore } from 'spec/helpers/vue_mount_component_helper'; +import { createDummyBadge } from '../dummy_badge'; + +describe('BadgeListRow component', () => { + const Component = Vue.extend(BadgeListRow); + let badge; + let vm; + + beforeEach(() => { + setFixtures(` + <div id="delete-badge-modal" class="modal"></div> + <div id="dummy-element"></div> + `); + store.replaceState({ + ...store.state, + kind: PROJECT_BADGE, + }); + badge = createDummyBadge(); + vm = mountComponentWithStore(Component, { + el: '#dummy-element', + store, + props: { badge }, + }); + }); + + afterEach(() => { + vm.$destroy(); + }); + + it('renders the badge', () => { + const badgeElement = vm.$el.querySelector('.project-badge'); + expect(badgeElement).not.toBeNull(); + expect(badgeElement.getAttribute('src')).toBe(badge.renderedImageUrl); + }); + + it('renders the badge link', () => { + expect(vm.$el).toContainText(badge.linkUrl); + }); + + it('renders the badge kind', () => { + expect(vm.$el).toContainText('Project Badge'); + }); + + it('shows edit and delete buttons', () => { + const buttons = vm.$el.querySelectorAll('.table-button-footer button'); + expect(buttons).toHaveLength(2); + const buttonEditElement = buttons[0]; + expect(buttonEditElement).toBeVisible(); + expect(buttonEditElement).toHaveSpriteIcon('pencil'); + const buttonDeleteElement = buttons[1]; + expect(buttonDeleteElement).toBeVisible(); + expect(buttonDeleteElement).toHaveSpriteIcon('remove'); + }); + + it('calls editBadge when clicking then edit button', () => { + spyOn(vm, 'editBadge'); + + const editButton = vm.$el.querySelector('.table-button-footer button:first-of-type'); + editButton.click(); + + expect(vm.editBadge).toHaveBeenCalled(); + }); + + it('calls updateBadgeInModal and shows modal when clicking then delete button', done => { + spyOn(vm, 'updateBadgeInModal'); + $('#delete-badge-modal').on('shown.bs.modal', () => done()); + + const deleteButton = vm.$el.querySelector('.table-button-footer button:last-of-type'); + deleteButton.click(); + + expect(vm.updateBadgeInModal).toHaveBeenCalled(); + }); + + describe('for a group badge', () => { + beforeEach(done => { + badge.kind = GROUP_BADGE; + + Vue.nextTick() + .then(done) + .catch(done.fail); + }); + + it('renders the badge kind', () => { + expect(vm.$el).toContainText('Group Badge'); + }); + + it('hides edit and delete buttons', () => { + const buttons = vm.$el.querySelectorAll('.table-button-footer button'); + expect(buttons).toHaveLength(0); + }); + }); +}); diff --git a/spec/javascripts/badges/components/badge_list_spec.js b/spec/javascripts/badges/components/badge_list_spec.js new file mode 100644 index 00000000000..9439c578973 --- /dev/null +++ b/spec/javascripts/badges/components/badge_list_spec.js @@ -0,0 +1,88 @@ +import Vue from 'vue'; +import { GROUP_BADGE, PROJECT_BADGE } from '~/badges/constants'; +import store from '~/badges/store'; +import BadgeList from '~/badges/components/badge_list.vue'; +import { mountComponentWithStore } from 'spec/helpers/vue_mount_component_helper'; +import { createDummyBadge } from '../dummy_badge'; + +describe('BadgeList component', () => { + const Component = Vue.extend(BadgeList); + const numberOfDummyBadges = 3; + let vm; + + beforeEach(() => { + setFixtures('<div id="dummy-element"></div>'); + const badges = []; + for (let id = 0; id < numberOfDummyBadges; id += 1) { + badges.push({ id, ...createDummyBadge() }); + } + store.replaceState({ + ...store.state, + badges, + kind: PROJECT_BADGE, + isLoading: false, + }); + vm = mountComponentWithStore(Component, { + el: '#dummy-element', + store, + }); + }); + + afterEach(() => { + vm.$destroy(); + }); + + it('renders a header with the badge count', () => { + const header = vm.$el.querySelector('.panel-heading'); + expect(header).toHaveText(new RegExp(`Your badges\\s+${numberOfDummyBadges}`)); + }); + + it('renders a row for each badge', () => { + const rows = vm.$el.querySelectorAll('.gl-responsive-table-row'); + expect(rows).toHaveLength(numberOfDummyBadges); + }); + + it('renders a message if no badges exist', done => { + store.state.badges = []; + + Vue.nextTick() + .then(() => { + expect(vm.$el).toContainText('This project has no badges'); + }) + .then(done) + .catch(done.fail); + }); + + it('shows a loading icon when loading', done => { + store.state.isLoading = true; + + Vue.nextTick() + .then(() => { + const loadingIcon = vm.$el.querySelector('.fa-spinner'); + expect(loadingIcon).toBeVisible(); + }) + .then(done) + .catch(done.fail); + }); + + describe('for group badges', () => { + beforeEach(done => { + store.state.kind = GROUP_BADGE; + + Vue.nextTick() + .then(done) + .catch(done.fail); + }); + + it('renders a message if no badges exist', done => { + store.state.badges = []; + + Vue.nextTick() + .then(() => { + expect(vm.$el).toContainText('This group has no badges'); + }) + .then(done) + .catch(done.fail); + }); + }); +}); diff --git a/spec/javascripts/badges/components/badge_settings_spec.js b/spec/javascripts/badges/components/badge_settings_spec.js new file mode 100644 index 00000000000..3db02982ad4 --- /dev/null +++ b/spec/javascripts/badges/components/badge_settings_spec.js @@ -0,0 +1,109 @@ +import $ from 'jquery'; +import Vue from 'vue'; +import store from '~/badges/store'; +import BadgeSettings from '~/badges/components/badge_settings.vue'; +import { mountComponentWithStore } from 'spec/helpers/vue_mount_component_helper'; +import { createDummyBadge } from '../dummy_badge'; + +describe('BadgeSettings component', () => { + const Component = Vue.extend(BadgeSettings); + let vm; + + beforeEach(() => { + setFixtures(` + <div id="dummy-element"></div> + <button + id="dummy-modal-button" + type="button" + data-toggle="modal" + data-target="#delete-badge-modal" + >Show modal</button> + `); + vm = mountComponentWithStore(Component, { + el: '#dummy-element', + store, + }); + }); + + afterEach(() => { + vm.$destroy(); + }); + + it('displays modal if button is clicked', done => { + const badge = createDummyBadge(); + store.state.badgeInModal = badge; + const modal = vm.$el.querySelector('#delete-badge-modal'); + const button = document.getElementById('dummy-modal-button'); + + $(modal).on('shown.bs.modal', () => { + expect(modal).toContainText('Delete badge?'); + const badgeElement = modal.querySelector('img.project-badge'); + expect(badgeElement).not.toBe(null); + expect(badgeElement.getAttribute('src')).toBe(badge.renderedImageUrl); + + done(); + }); + + Vue.nextTick() + .then(() => { + button.click(); + }) + .catch(done.fail); + }); + + it('displays a form to add a badge', () => { + const form = vm.$el.querySelector('form:nth-of-type(2)'); + expect(form).not.toBe(null); + const button = form.querySelector('.btn-success'); + expect(button).not.toBe(null); + expect(button).toHaveText(/Add badge/); + }); + + it('displays badge list', () => { + const badgeListElement = vm.$el.querySelector('.panel'); + expect(badgeListElement).not.toBe(null); + expect(badgeListElement).toBeVisible(); + expect(badgeListElement).toContainText('Your badges'); + }); + + describe('when editing', () => { + beforeEach(done => { + store.state.isEditing = true; + + Vue.nextTick() + .then(done) + .catch(done.fail); + }); + + it('displays a form to edit a badge', () => { + const form = vm.$el.querySelector('form:nth-of-type(1)'); + expect(form).not.toBe(null); + const submitButton = form.querySelector('.btn-success'); + expect(submitButton).not.toBe(null); + expect(submitButton).toHaveText(/Save changes/); + const cancelButton = form.querySelector('.btn-cancel'); + expect(cancelButton).not.toBe(null); + expect(cancelButton).toHaveText(/Cancel/); + }); + + it('displays no badge list', () => { + const badgeListElement = vm.$el.querySelector('.panel'); + expect(badgeListElement).toBeHidden(); + }); + }); + + describe('methods', () => { + describe('onSubmitModal', () => { + it('triggers ', () => { + spyOn(vm, 'deleteBadge').and.callFake(() => Promise.resolve()); + const modal = vm.$el.querySelector('#delete-badge-modal'); + const deleteButton = modal.querySelector('.btn-danger'); + + deleteButton.click(); + + const badge = store.state.badgeInModal; + expect(vm.deleteBadge).toHaveBeenCalledWith(badge); + }); + }); + }); +}); diff --git a/spec/javascripts/badges/components/badge_spec.js b/spec/javascripts/badges/components/badge_spec.js new file mode 100644 index 00000000000..fd1ecc9cdd8 --- /dev/null +++ b/spec/javascripts/badges/components/badge_spec.js @@ -0,0 +1,147 @@ +import Vue from 'vue'; +import Badge from '~/badges/components/badge.vue'; +import mountComponent from 'spec/helpers/vue_mount_component_helper'; +import { DUMMY_IMAGE_URL, TEST_HOST } from 'spec/test_constants'; + +describe('Badge component', () => { + const Component = Vue.extend(Badge); + const dummyProps = { + imageUrl: DUMMY_IMAGE_URL, + linkUrl: `${TEST_HOST}/badge/link/url`, + }; + let vm; + + const findElements = () => { + const buttons = vm.$el.querySelectorAll('button'); + return { + badgeImage: vm.$el.querySelector('img.project-badge'), + loadingIcon: vm.$el.querySelector('.fa-spinner'), + reloadButton: buttons[buttons.length - 1], + }; + }; + + const createComponent = (props, el = null) => { + vm = mountComponent(Component, props, el); + const { badgeImage } = findElements(); + return new Promise(resolve => badgeImage.addEventListener('load', resolve)).then(() => + Vue.nextTick(), + ); + }; + + afterEach(() => { + vm.$destroy(); + }); + + describe('watchers', () => { + describe('imageUrl', () => { + it('sets isLoading and resets numRetries and hasError', done => { + const props = { ...dummyProps }; + createComponent(props) + .then(() => { + expect(vm.isLoading).toBe(false); + vm.hasError = true; + vm.numRetries = 42; + + vm.imageUrl = `${props.imageUrl}#something/else`; + + return Vue.nextTick(); + }) + .then(() => { + expect(vm.isLoading).toBe(true); + expect(vm.numRetries).toBe(0); + expect(vm.hasError).toBe(false); + }) + .then(done) + .catch(done.fail); + }); + }); + }); + + describe('methods', () => { + beforeEach(done => { + createComponent({ ...dummyProps }) + .then(done) + .catch(done.fail); + }); + + it('onError resets isLoading and sets hasError', () => { + vm.hasError = false; + vm.isLoading = true; + + vm.onError(); + + expect(vm.hasError).toBe(true); + expect(vm.isLoading).toBe(false); + }); + + it('onLoad sets isLoading', () => { + vm.isLoading = true; + + vm.onLoad(); + + expect(vm.isLoading).toBe(false); + }); + + it('reloadImage resets isLoading and hasError and increases numRetries', () => { + vm.hasError = true; + vm.isLoading = false; + vm.numRetries = 0; + + vm.reloadImage(); + + expect(vm.hasError).toBe(false); + expect(vm.isLoading).toBe(true); + expect(vm.numRetries).toBe(1); + }); + }); + + describe('behavior', () => { + beforeEach(done => { + setFixtures('<div id="dummy-element"></div>'); + createComponent({ ...dummyProps }, '#dummy-element') + .then(done) + .catch(done.fail); + }); + + it('shows a badge image after loading', () => { + expect(vm.isLoading).toBe(false); + expect(vm.hasError).toBe(false); + const { badgeImage, loadingIcon, reloadButton } = findElements(); + expect(badgeImage).toBeVisible(); + expect(loadingIcon).toBeHidden(); + expect(reloadButton).toBeHidden(); + expect(vm.$el.innerText).toBe(''); + }); + + it('shows a loading icon when loading', done => { + vm.isLoading = true; + + Vue.nextTick() + .then(() => { + const { badgeImage, loadingIcon, reloadButton } = findElements(); + expect(badgeImage).toBeHidden(); + expect(loadingIcon).toBeVisible(); + expect(reloadButton).toBeHidden(); + expect(vm.$el.innerText).toBe(''); + }) + .then(done) + .catch(done.fail); + }); + + it('shows an error and reload button if loading failed', done => { + vm.hasError = true; + + Vue.nextTick() + .then(() => { + const { badgeImage, loadingIcon, reloadButton } = findElements(); + expect(badgeImage).toBeHidden(); + expect(loadingIcon).toBeHidden(); + expect(reloadButton).toBeVisible(); + expect(reloadButton).toHaveSpriteIcon('retry'); + expect(vm.$el.innerText.trim()).toBe('No badge image'); + }) + .then(done) + .catch(done.fail); + }); + }); +}); diff --git a/spec/javascripts/badges/dummy_badge.js b/spec/javascripts/badges/dummy_badge.js new file mode 100644 index 00000000000..6aaff21c503 --- /dev/null +++ b/spec/javascripts/badges/dummy_badge.js @@ -0,0 +1,23 @@ +import { PROJECT_BADGE } from '~/badges/constants'; +import { DUMMY_IMAGE_URL, TEST_HOST } from 'spec/test_constants'; + +export const createDummyBadge = () => { + const id = Math.floor(1000 * Math.random()); + return { + id, + imageUrl: `${TEST_HOST}/badges/${id}/image/url`, + isDeleting: false, + linkUrl: `${TEST_HOST}/badges/${id}/link/url`, + kind: PROJECT_BADGE, + renderedImageUrl: `${DUMMY_IMAGE_URL}?id=${id}`, + renderedLinkUrl: `${TEST_HOST}/badges/${id}/rendered/link/url`, + }; +}; + +export const createDummyBadgeResponse = () => ({ + image_url: `${TEST_HOST}/badge/image/url`, + link_url: `${TEST_HOST}/badge/link/url`, + kind: PROJECT_BADGE, + rendered_image_url: DUMMY_IMAGE_URL, + rendered_link_url: `${TEST_HOST}/rendered/badge/link/url`, +}); diff --git a/spec/javascripts/badges/store/actions_spec.js b/spec/javascripts/badges/store/actions_spec.js new file mode 100644 index 00000000000..bb6263c6de4 --- /dev/null +++ b/spec/javascripts/badges/store/actions_spec.js @@ -0,0 +1,607 @@ +import axios from '~/lib/utils/axios_utils'; +import MockAdapter from 'axios-mock-adapter'; +import actions, { transformBackendBadge } from '~/badges/store/actions'; +import mutationTypes from '~/badges/store/mutation_types'; +import createState from '~/badges/store/state'; +import { TEST_HOST } from 'spec/test_constants'; +import testAction from 'spec/helpers/vuex_action_helper'; +import { createDummyBadge, createDummyBadgeResponse } from '../dummy_badge'; + +describe('Badges store actions', () => { + const dummyEndpointUrl = `${TEST_HOST}/badges/endpoint`; + const dummyBadges = [{ ...createDummyBadge(), id: 5 }, { ...createDummyBadge(), id: 6 }]; + + let axiosMock; + let badgeId; + let state; + + beforeEach(() => { + axiosMock = new MockAdapter(axios); + state = { + ...createState(), + apiEndpointUrl: dummyEndpointUrl, + badges: dummyBadges, + }; + badgeId = state.badges[0].id; + }); + + afterEach(() => { + axiosMock.restore(); + }); + + describe('requestNewBadge', () => { + it('commits REQUEST_NEW_BADGE', done => { + testAction( + actions.requestNewBadge, + null, + state, + [{ type: mutationTypes.REQUEST_NEW_BADGE }], + [], + done, + ); + }); + }); + + describe('receiveNewBadge', () => { + it('commits RECEIVE_NEW_BADGE', done => { + const newBadge = createDummyBadge(); + testAction( + actions.receiveNewBadge, + newBadge, + state, + [{ type: mutationTypes.RECEIVE_NEW_BADGE, payload: newBadge }], + [], + done, + ); + }); + }); + + describe('receiveNewBadgeError', () => { + it('commits RECEIVE_NEW_BADGE_ERROR', done => { + testAction( + actions.receiveNewBadgeError, + null, + state, + [{ type: mutationTypes.RECEIVE_NEW_BADGE_ERROR }], + [], + done, + ); + }); + }); + + describe('addBadge', () => { + let badgeInAddForm; + let dispatch; + let endpointMock; + + beforeEach(() => { + endpointMock = axiosMock.onPost(dummyEndpointUrl); + dispatch = jasmine.createSpy('dispatch'); + badgeInAddForm = createDummyBadge(); + state = { + ...state, + badgeInAddForm, + }; + }); + + it('dispatches requestNewBadge and receiveNewBadge for successful response', done => { + const dummyResponse = createDummyBadgeResponse(); + + endpointMock.replyOnce(req => { + expect(req.data).toBe( + JSON.stringify({ + image_url: badgeInAddForm.imageUrl, + link_url: badgeInAddForm.linkUrl, + }), + ); + expect(dispatch.calls.allArgs()).toEqual([['requestNewBadge']]); + dispatch.calls.reset(); + return [200, dummyResponse]; + }); + + const dummyBadge = transformBackendBadge(dummyResponse); + actions + .addBadge({ state, dispatch }) + .then(() => { + expect(dispatch.calls.allArgs()).toEqual([['receiveNewBadge', dummyBadge]]); + }) + .then(done) + .catch(done.fail); + }); + + it('dispatches requestNewBadge and receiveNewBadgeError for error response', done => { + endpointMock.replyOnce(req => { + expect(req.data).toBe( + JSON.stringify({ + image_url: badgeInAddForm.imageUrl, + link_url: badgeInAddForm.linkUrl, + }), + ); + expect(dispatch.calls.allArgs()).toEqual([['requestNewBadge']]); + dispatch.calls.reset(); + return [500, '']; + }); + + actions + .addBadge({ state, dispatch }) + .then(() => done.fail('Expected Ajax call to fail!')) + .catch(() => { + expect(dispatch.calls.allArgs()).toEqual([['receiveNewBadgeError']]); + }) + .then(done) + .catch(done.fail); + }); + }); + + describe('requestDeleteBadge', () => { + it('commits REQUEST_DELETE_BADGE', done => { + testAction( + actions.requestDeleteBadge, + badgeId, + state, + [{ type: mutationTypes.REQUEST_DELETE_BADGE, payload: badgeId }], + [], + done, + ); + }); + }); + + describe('receiveDeleteBadge', () => { + it('commits RECEIVE_DELETE_BADGE', done => { + testAction( + actions.receiveDeleteBadge, + badgeId, + state, + [{ type: mutationTypes.RECEIVE_DELETE_BADGE, payload: badgeId }], + [], + done, + ); + }); + }); + + describe('receiveDeleteBadgeError', () => { + it('commits RECEIVE_DELETE_BADGE_ERROR', done => { + testAction( + actions.receiveDeleteBadgeError, + badgeId, + state, + [{ type: mutationTypes.RECEIVE_DELETE_BADGE_ERROR, payload: badgeId }], + [], + done, + ); + }); + }); + + describe('deleteBadge', () => { + let dispatch; + let endpointMock; + + beforeEach(() => { + endpointMock = axiosMock.onDelete(`${dummyEndpointUrl}/${badgeId}`); + dispatch = jasmine.createSpy('dispatch'); + }); + + it('dispatches requestDeleteBadge and receiveDeleteBadge for successful response', done => { + endpointMock.replyOnce(() => { + expect(dispatch.calls.allArgs()).toEqual([['requestDeleteBadge', badgeId]]); + dispatch.calls.reset(); + return [200, '']; + }); + + actions + .deleteBadge({ state, dispatch }, { id: badgeId }) + .then(() => { + expect(dispatch.calls.allArgs()).toEqual([['receiveDeleteBadge', badgeId]]); + }) + .then(done) + .catch(done.fail); + }); + + it('dispatches requestDeleteBadge and receiveDeleteBadgeError for error response', done => { + endpointMock.replyOnce(() => { + expect(dispatch.calls.allArgs()).toEqual([['requestDeleteBadge', badgeId]]); + dispatch.calls.reset(); + return [500, '']; + }); + + actions + .deleteBadge({ state, dispatch }, { id: badgeId }) + .then(() => done.fail('Expected Ajax call to fail!')) + .catch(() => { + expect(dispatch.calls.allArgs()).toEqual([['receiveDeleteBadgeError', badgeId]]); + }) + .then(done) + .catch(done.fail); + }); + }); + + describe('editBadge', () => { + it('commits START_EDITING', done => { + const dummyBadge = createDummyBadge(); + testAction( + actions.editBadge, + dummyBadge, + state, + [{ type: mutationTypes.START_EDITING, payload: dummyBadge }], + [], + done, + ); + }); + }); + + describe('requestLoadBadges', () => { + it('commits REQUEST_LOAD_BADGES', done => { + const dummyData = 'this is not real data'; + testAction( + actions.requestLoadBadges, + dummyData, + state, + [{ type: mutationTypes.REQUEST_LOAD_BADGES, payload: dummyData }], + [], + done, + ); + }); + }); + + describe('receiveLoadBadges', () => { + it('commits RECEIVE_LOAD_BADGES', done => { + const badges = dummyBadges; + testAction( + actions.receiveLoadBadges, + badges, + state, + [{ type: mutationTypes.RECEIVE_LOAD_BADGES, payload: badges }], + [], + done, + ); + }); + }); + + describe('receiveLoadBadgesError', () => { + it('commits RECEIVE_LOAD_BADGES_ERROR', done => { + testAction( + actions.receiveLoadBadgesError, + null, + state, + [{ type: mutationTypes.RECEIVE_LOAD_BADGES_ERROR }], + [], + done, + ); + }); + }); + + describe('loadBadges', () => { + let dispatch; + let endpointMock; + + beforeEach(() => { + endpointMock = axiosMock.onGet(dummyEndpointUrl); + dispatch = jasmine.createSpy('dispatch'); + }); + + it('dispatches requestLoadBadges and receiveLoadBadges for successful response', done => { + const dummyData = 'this is just some data'; + const dummyReponse = [ + createDummyBadgeResponse(), + createDummyBadgeResponse(), + createDummyBadgeResponse(), + ]; + endpointMock.replyOnce(() => { + expect(dispatch.calls.allArgs()).toEqual([['requestLoadBadges', dummyData]]); + dispatch.calls.reset(); + return [200, dummyReponse]; + }); + + actions + .loadBadges({ state, dispatch }, dummyData) + .then(() => { + const badges = dummyReponse.map(transformBackendBadge); + expect(dispatch.calls.allArgs()).toEqual([['receiveLoadBadges', badges]]); + }) + .then(done) + .catch(done.fail); + }); + + it('dispatches requestLoadBadges and receiveLoadBadgesError for error response', done => { + const dummyData = 'this is just some data'; + endpointMock.replyOnce(() => { + expect(dispatch.calls.allArgs()).toEqual([['requestLoadBadges', dummyData]]); + dispatch.calls.reset(); + return [500, '']; + }); + + actions + .loadBadges({ state, dispatch }, dummyData) + .then(() => done.fail('Expected Ajax call to fail!')) + .catch(() => { + expect(dispatch.calls.allArgs()).toEqual([['receiveLoadBadgesError']]); + }) + .then(done) + .catch(done.fail); + }); + }); + + describe('requestRenderedBadge', () => { + it('commits REQUEST_RENDERED_BADGE', done => { + testAction( + actions.requestRenderedBadge, + null, + state, + [{ type: mutationTypes.REQUEST_RENDERED_BADGE }], + [], + done, + ); + }); + }); + + describe('receiveRenderedBadge', () => { + it('commits RECEIVE_RENDERED_BADGE', done => { + const dummyBadge = createDummyBadge(); + testAction( + actions.receiveRenderedBadge, + dummyBadge, + state, + [{ type: mutationTypes.RECEIVE_RENDERED_BADGE, payload: dummyBadge }], + [], + done, + ); + }); + }); + + describe('receiveRenderedBadgeError', () => { + it('commits RECEIVE_RENDERED_BADGE_ERROR', done => { + testAction( + actions.receiveRenderedBadgeError, + null, + state, + [{ type: mutationTypes.RECEIVE_RENDERED_BADGE_ERROR }], + [], + done, + ); + }); + }); + + describe('renderBadge', () => { + let dispatch; + let endpointMock; + let badgeInForm; + + beforeEach(() => { + badgeInForm = createDummyBadge(); + state = { + ...state, + badgeInAddForm: badgeInForm, + }; + const urlParameters = [ + `link_url=${encodeURIComponent(badgeInForm.linkUrl)}`, + `image_url=${encodeURIComponent(badgeInForm.imageUrl)}`, + ].join('&'); + endpointMock = axiosMock.onGet(`${dummyEndpointUrl}/render?${urlParameters}`); + dispatch = jasmine.createSpy('dispatch'); + }); + + it('returns immediately if imageUrl is empty', done => { + spyOn(axios, 'get'); + badgeInForm.imageUrl = ''; + + actions + .renderBadge({ state, dispatch }) + .then(() => { + expect(axios.get).not.toHaveBeenCalled(); + }) + .then(done) + .catch(done.fail); + }); + + it('returns immediately if linkUrl is empty', done => { + spyOn(axios, 'get'); + badgeInForm.linkUrl = ''; + + actions + .renderBadge({ state, dispatch }) + .then(() => { + expect(axios.get).not.toHaveBeenCalled(); + }) + .then(done) + .catch(done.fail); + }); + + it('escapes user input', done => { + spyOn(axios, 'get').and.callFake(() => Promise.resolve({ data: createDummyBadgeResponse() })); + badgeInForm.imageUrl = '&make-sandwhich=true'; + badgeInForm.linkUrl = '<script>I am dangerous!</script>'; + + actions + .renderBadge({ state, dispatch }) + .then(() => { + expect(axios.get.calls.count()).toBe(1); + const url = axios.get.calls.argsFor(0)[0]; + expect(url).toMatch(`^${dummyEndpointUrl}/render?`); + expect(url).toMatch('\\?link_url=%3Cscript%3EI%20am%20dangerous!%3C%2Fscript%3E&'); + expect(url).toMatch('&image_url=%26make-sandwhich%3Dtrue$'); + }) + .then(done) + .catch(done.fail); + }); + + it('dispatches requestRenderedBadge and receiveRenderedBadge for successful response', done => { + const dummyReponse = createDummyBadgeResponse(); + endpointMock.replyOnce(() => { + expect(dispatch.calls.allArgs()).toEqual([['requestRenderedBadge']]); + dispatch.calls.reset(); + return [200, dummyReponse]; + }); + + actions + .renderBadge({ state, dispatch }) + .then(() => { + const renderedBadge = transformBackendBadge(dummyReponse); + expect(dispatch.calls.allArgs()).toEqual([['receiveRenderedBadge', renderedBadge]]); + }) + .then(done) + .catch(done.fail); + }); + + it('dispatches requestRenderedBadge and receiveRenderedBadgeError for error response', done => { + endpointMock.replyOnce(() => { + expect(dispatch.calls.allArgs()).toEqual([['requestRenderedBadge']]); + dispatch.calls.reset(); + return [500, '']; + }); + + actions + .renderBadge({ state, dispatch }) + .then(() => done.fail('Expected Ajax call to fail!')) + .catch(() => { + expect(dispatch.calls.allArgs()).toEqual([['receiveRenderedBadgeError']]); + }) + .then(done) + .catch(done.fail); + }); + }); + + describe('requestUpdatedBadge', () => { + it('commits REQUEST_UPDATED_BADGE', done => { + testAction( + actions.requestUpdatedBadge, + null, + state, + [{ type: mutationTypes.REQUEST_UPDATED_BADGE }], + [], + done, + ); + }); + }); + + describe('receiveUpdatedBadge', () => { + it('commits RECEIVE_UPDATED_BADGE', done => { + const updatedBadge = createDummyBadge(); + testAction( + actions.receiveUpdatedBadge, + updatedBadge, + state, + [{ type: mutationTypes.RECEIVE_UPDATED_BADGE, payload: updatedBadge }], + [], + done, + ); + }); + }); + + describe('receiveUpdatedBadgeError', () => { + it('commits RECEIVE_UPDATED_BADGE_ERROR', done => { + testAction( + actions.receiveUpdatedBadgeError, + null, + state, + [{ type: mutationTypes.RECEIVE_UPDATED_BADGE_ERROR }], + [], + done, + ); + }); + }); + + describe('saveBadge', () => { + let badgeInEditForm; + let dispatch; + let endpointMock; + + beforeEach(() => { + badgeInEditForm = createDummyBadge(); + state = { + ...state, + badgeInEditForm, + }; + endpointMock = axiosMock.onPut(`${dummyEndpointUrl}/${badgeInEditForm.id}`); + dispatch = jasmine.createSpy('dispatch'); + }); + + it('dispatches requestUpdatedBadge and receiveUpdatedBadge for successful response', done => { + const dummyResponse = createDummyBadgeResponse(); + + endpointMock.replyOnce(req => { + expect(req.data).toBe( + JSON.stringify({ + image_url: badgeInEditForm.imageUrl, + link_url: badgeInEditForm.linkUrl, + }), + ); + expect(dispatch.calls.allArgs()).toEqual([['requestUpdatedBadge']]); + dispatch.calls.reset(); + return [200, dummyResponse]; + }); + + const updatedBadge = transformBackendBadge(dummyResponse); + actions + .saveBadge({ state, dispatch }) + .then(() => { + expect(dispatch.calls.allArgs()).toEqual([['receiveUpdatedBadge', updatedBadge]]); + }) + .then(done) + .catch(done.fail); + }); + + it('dispatches requestUpdatedBadge and receiveUpdatedBadgeError for error response', done => { + endpointMock.replyOnce(req => { + expect(req.data).toBe( + JSON.stringify({ + image_url: badgeInEditForm.imageUrl, + link_url: badgeInEditForm.linkUrl, + }), + ); + expect(dispatch.calls.allArgs()).toEqual([['requestUpdatedBadge']]); + dispatch.calls.reset(); + return [500, '']; + }); + + actions + .saveBadge({ state, dispatch }) + .then(() => done.fail('Expected Ajax call to fail!')) + .catch(() => { + expect(dispatch.calls.allArgs()).toEqual([['receiveUpdatedBadgeError']]); + }) + .then(done) + .catch(done.fail); + }); + }); + + describe('stopEditing', () => { + it('commits STOP_EDITING', done => { + testAction( + actions.stopEditing, + null, + state, + [{ type: mutationTypes.STOP_EDITING }], + [], + done, + ); + }); + }); + + describe('updateBadgeInForm', () => { + it('commits UPDATE_BADGE_IN_FORM', done => { + const dummyBadge = createDummyBadge(); + testAction( + actions.updateBadgeInForm, + dummyBadge, + state, + [{ type: mutationTypes.UPDATE_BADGE_IN_FORM, payload: dummyBadge }], + [], + done, + ); + }); + + describe('updateBadgeInModal', () => { + it('commits UPDATE_BADGE_IN_MODAL', done => { + const dummyBadge = createDummyBadge(); + testAction( + actions.updateBadgeInModal, + dummyBadge, + state, + [{ type: mutationTypes.UPDATE_BADGE_IN_MODAL, payload: dummyBadge }], + [], + done, + ); + }); + }); + }); +}); diff --git a/spec/javascripts/badges/store/mutations_spec.js b/spec/javascripts/badges/store/mutations_spec.js new file mode 100644 index 00000000000..8d26f83339d --- /dev/null +++ b/spec/javascripts/badges/store/mutations_spec.js @@ -0,0 +1,418 @@ +import { GROUP_BADGE, PROJECT_BADGE } from '~/badges/constants'; +import store from '~/badges/store'; +import types from '~/badges/store/mutation_types'; +import createState from '~/badges/store/state'; +import { createDummyBadge } from '../dummy_badge'; + +describe('Badges store mutations', () => { + let dummyBadge; + + beforeEach(() => { + dummyBadge = createDummyBadge(); + store.replaceState(createState()); + }); + + describe('RECEIVE_DELETE_BADGE', () => { + beforeEach(() => { + const badges = [ + { ...dummyBadge, id: dummyBadge.id - 1 }, + dummyBadge, + { ...dummyBadge, id: dummyBadge.id + 1 }, + ]; + + store.replaceState({ + ...store.state, + badges, + }); + }); + + it('removes deleted badge', () => { + const badgeCount = store.state.badges.length; + + store.commit(types.RECEIVE_DELETE_BADGE, dummyBadge.id); + + expect(store.state.badges.length).toBe(badgeCount - 1); + expect(store.state.badges.indexOf(dummyBadge)).toBe(-1); + }); + }); + + describe('RECEIVE_DELETE_BADGE_ERROR', () => { + beforeEach(() => { + const badges = [ + { ...dummyBadge, id: dummyBadge.id - 1, isDeleting: false }, + { ...dummyBadge, isDeleting: true }, + { ...dummyBadge, id: dummyBadge.id + 1, isDeleting: true }, + ]; + + store.replaceState({ + ...store.state, + badges, + }); + }); + + it('sets isDeleting to false', () => { + const badgeCount = store.state.badges.length; + + store.commit(types.RECEIVE_DELETE_BADGE_ERROR, dummyBadge.id); + + expect(store.state.badges.length).toBe(badgeCount); + expect(store.state.badges[0].isDeleting).toBe(false); + expect(store.state.badges[1].isDeleting).toBe(false); + expect(store.state.badges[2].isDeleting).toBe(true); + }); + }); + + describe('RECEIVE_LOAD_BADGES', () => { + beforeEach(() => { + store.replaceState({ + ...store.state, + isLoading: 'not false', + }); + }); + + it('sets badges and isLoading to false', () => { + const badges = [createDummyBadge()]; + store.commit(types.RECEIVE_LOAD_BADGES, badges); + + expect(store.state.isLoading).toBe(false); + expect(store.state.badges).toBe(badges); + }); + }); + + describe('RECEIVE_LOAD_BADGES_ERROR', () => { + beforeEach(() => { + store.replaceState({ + ...store.state, + isLoading: 'not false', + }); + }); + + it('sets isLoading to false', () => { + store.commit(types.RECEIVE_LOAD_BADGES_ERROR); + + expect(store.state.isLoading).toBe(false); + }); + }); + + describe('RECEIVE_NEW_BADGE', () => { + beforeEach(() => { + const badges = [ + { ...dummyBadge, id: dummyBadge.id - 1, kind: GROUP_BADGE }, + { ...dummyBadge, id: dummyBadge.id + 1, kind: GROUP_BADGE }, + { ...dummyBadge, id: dummyBadge.id - 1, kind: PROJECT_BADGE }, + { ...dummyBadge, id: dummyBadge.id + 1, kind: PROJECT_BADGE }, + ]; + store.replaceState({ + ...store.state, + badgeInAddForm: createDummyBadge(), + badges, + isSaving: 'dummy value', + renderedBadge: createDummyBadge(), + }); + }); + + it('resets the add form', () => { + store.commit(types.RECEIVE_NEW_BADGE, dummyBadge); + + expect(store.state.badgeInAddForm).toBe(null); + expect(store.state.isSaving).toBe(false); + expect(store.state.renderedBadge).toBe(null); + }); + + it('inserts group badge at correct position', () => { + const badgeCount = store.state.badges.length; + dummyBadge = { ...dummyBadge, kind: GROUP_BADGE }; + + store.commit(types.RECEIVE_NEW_BADGE, dummyBadge); + + expect(store.state.badges.length).toBe(badgeCount + 1); + expect(store.state.badges.indexOf(dummyBadge)).toBe(1); + }); + + it('inserts project badge at correct position', () => { + const badgeCount = store.state.badges.length; + dummyBadge = { ...dummyBadge, kind: PROJECT_BADGE }; + + store.commit(types.RECEIVE_NEW_BADGE, dummyBadge); + + expect(store.state.badges.length).toBe(badgeCount + 1); + expect(store.state.badges.indexOf(dummyBadge)).toBe(3); + }); + }); + + describe('RECEIVE_NEW_BADGE_ERROR', () => { + beforeEach(() => { + store.replaceState({ + ...store.state, + isSaving: 'dummy value', + }); + }); + + it('sets isSaving to false', () => { + store.commit(types.RECEIVE_NEW_BADGE_ERROR); + + expect(store.state.isSaving).toBe(false); + }); + }); + + describe('RECEIVE_RENDERED_BADGE', () => { + beforeEach(() => { + store.replaceState({ + ...store.state, + isRendering: 'dummy value', + renderedBadge: 'dummy value', + }); + }); + + it('sets renderedBadge', () => { + store.commit(types.RECEIVE_RENDERED_BADGE, dummyBadge); + + expect(store.state.isRendering).toBe(false); + expect(store.state.renderedBadge).toBe(dummyBadge); + }); + }); + + describe('RECEIVE_RENDERED_BADGE_ERROR', () => { + beforeEach(() => { + store.replaceState({ + ...store.state, + isRendering: 'dummy value', + }); + }); + + it('sets isRendering to false', () => { + store.commit(types.RECEIVE_RENDERED_BADGE_ERROR); + + expect(store.state.isRendering).toBe(false); + }); + }); + + describe('RECEIVE_UPDATED_BADGE', () => { + beforeEach(() => { + const badges = [ + { ...dummyBadge, id: dummyBadge.id - 1 }, + dummyBadge, + { ...dummyBadge, id: dummyBadge.id + 1 }, + ]; + store.replaceState({ + ...store.state, + badgeInEditForm: createDummyBadge(), + badges, + isEditing: 'dummy value', + isSaving: 'dummy value', + renderedBadge: createDummyBadge(), + }); + }); + + it('resets the edit form', () => { + store.commit(types.RECEIVE_UPDATED_BADGE, dummyBadge); + + expect(store.state.badgeInAddForm).toBe(null); + expect(store.state.isSaving).toBe(false); + expect(store.state.renderedBadge).toBe(null); + }); + + it('replaces the updated badge', () => { + const badgeCount = store.state.badges.length; + const badgeIndex = store.state.badges.indexOf(dummyBadge); + const newBadge = { id: dummyBadge.id, dummy: 'value' }; + + store.commit(types.RECEIVE_UPDATED_BADGE, newBadge); + + expect(store.state.badges.length).toBe(badgeCount); + expect(store.state.badges[badgeIndex]).toBe(newBadge); + }); + }); + + describe('RECEIVE_UPDATED_BADGE_ERROR', () => { + beforeEach(() => { + store.replaceState({ + ...store.state, + isSaving: 'dummy value', + }); + }); + + it('sets isSaving to false', () => { + store.commit(types.RECEIVE_NEW_BADGE_ERROR); + + expect(store.state.isSaving).toBe(false); + }); + }); + + describe('REQUEST_DELETE_BADGE', () => { + beforeEach(() => { + const badges = [ + { ...dummyBadge, id: dummyBadge.id - 1, isDeleting: false }, + { ...dummyBadge, isDeleting: false }, + { ...dummyBadge, id: dummyBadge.id + 1, isDeleting: true }, + ]; + + store.replaceState({ + ...store.state, + badges, + }); + }); + + it('sets isDeleting to true', () => { + const badgeCount = store.state.badges.length; + + store.commit(types.REQUEST_DELETE_BADGE, dummyBadge.id); + + expect(store.state.badges.length).toBe(badgeCount); + expect(store.state.badges[0].isDeleting).toBe(false); + expect(store.state.badges[1].isDeleting).toBe(true); + expect(store.state.badges[2].isDeleting).toBe(true); + }); + }); + + describe('REQUEST_LOAD_BADGES', () => { + beforeEach(() => { + store.replaceState({ + ...store.state, + apiEndpointUrl: 'some endpoint', + docsUrl: 'some url', + isLoading: 'dummy value', + kind: 'some kind', + }); + }); + + it('sets isLoading to true and initializes the store', () => { + const dummyData = { + apiEndpointUrl: 'dummy endpoint', + docsUrl: 'dummy url', + kind: 'dummy kind', + }; + + store.commit(types.REQUEST_LOAD_BADGES, dummyData); + + expect(store.state.isLoading).toBe(true); + expect(store.state.apiEndpointUrl).toBe(dummyData.apiEndpointUrl); + expect(store.state.docsUrl).toBe(dummyData.docsUrl); + expect(store.state.kind).toBe(dummyData.kind); + }); + }); + + describe('REQUEST_NEW_BADGE', () => { + beforeEach(() => { + store.replaceState({ + ...store.state, + isSaving: 'dummy value', + }); + }); + + it('sets isSaving to true', () => { + store.commit(types.REQUEST_NEW_BADGE); + + expect(store.state.isSaving).toBe(true); + }); + }); + + describe('REQUEST_RENDERED_BADGE', () => { + beforeEach(() => { + store.replaceState({ + ...store.state, + isRendering: 'dummy value', + }); + }); + + it('sets isRendering to true', () => { + store.commit(types.REQUEST_RENDERED_BADGE); + + expect(store.state.isRendering).toBe(true); + }); + }); + + describe('REQUEST_UPDATED_BADGE', () => { + beforeEach(() => { + store.replaceState({ + ...store.state, + isSaving: 'dummy value', + }); + }); + + it('sets isSaving to true', () => { + store.commit(types.REQUEST_NEW_BADGE); + + expect(store.state.isSaving).toBe(true); + }); + }); + + describe('START_EDITING', () => { + beforeEach(() => { + store.replaceState({ + ...store.state, + badgeInEditForm: 'dummy value', + isEditing: 'dummy value', + renderedBadge: 'dummy value', + }); + }); + + it('initializes the edit form', () => { + store.commit(types.START_EDITING, dummyBadge); + + expect(store.state.isEditing).toBe(true); + expect(store.state.badgeInEditForm).toEqual(dummyBadge); + expect(store.state.renderedBadge).toEqual(dummyBadge); + }); + }); + + describe('STOP_EDITING', () => { + beforeEach(() => { + store.replaceState({ + ...store.state, + badgeInEditForm: 'dummy value', + isEditing: 'dummy value', + renderedBadge: 'dummy value', + }); + }); + + it('resets the edit form', () => { + store.commit(types.STOP_EDITING); + + expect(store.state.isEditing).toBe(false); + expect(store.state.badgeInEditForm).toBe(null); + expect(store.state.renderedBadge).toBe(null); + }); + }); + + describe('UPDATE_BADGE_IN_FORM', () => { + beforeEach(() => { + store.replaceState({ + ...store.state, + badgeInAddForm: 'dummy value', + badgeInEditForm: 'dummy value', + }); + }); + + it('sets badgeInEditForm if isEditing is true', () => { + store.state.isEditing = true; + + store.commit(types.UPDATE_BADGE_IN_FORM, dummyBadge); + + expect(store.state.badgeInEditForm).toBe(dummyBadge); + }); + + it('sets badgeInAddForm if isEditing is false', () => { + store.state.isEditing = false; + + store.commit(types.UPDATE_BADGE_IN_FORM, dummyBadge); + + expect(store.state.badgeInAddForm).toBe(dummyBadge); + }); + }); + + describe('UPDATE_BADGE_IN_MODAL', () => { + beforeEach(() => { + store.replaceState({ + ...store.state, + badgeInModal: 'dummy value', + }); + }); + + it('sets badgeInModal', () => { + store.commit(types.UPDATE_BADGE_IN_MODAL, dummyBadge); + + expect(store.state.badgeInModal).toBe(dummyBadge); + }); + }); +}); diff --git a/spec/javascripts/boards/board_blank_state_spec.js b/spec/javascripts/boards/board_blank_state_spec.js index f757dadfada..664ea202e93 100644 --- a/spec/javascripts/boards/board_blank_state_spec.js +++ b/spec/javascripts/boards/board_blank_state_spec.js @@ -1,7 +1,7 @@ /* global BoardService */ import Vue from 'vue'; import '~/boards/stores/boards_store'; -import boardBlankState from '~/boards/components/board_blank_state'; +import BoardBlankState from '~/boards/components/board_blank_state.vue'; import { mockBoardService } from './mock_data'; describe('Boards blank state', () => { @@ -9,7 +9,7 @@ describe('Boards blank state', () => { let fail = false; beforeEach((done) => { - const Comp = Vue.extend(boardBlankState); + const Comp = Vue.extend(BoardBlankState); gl.issueBoards.BoardsStore.create(); gl.boardService = mockBoardService(); diff --git a/spec/javascripts/boards/issue_card_spec.js b/spec/javascripts/boards/issue_card_spec.js index 37088a6421c..be1ea0b57b4 100644 --- a/spec/javascripts/boards/issue_card_spec.js +++ b/spec/javascripts/boards/issue_card_spec.js @@ -41,6 +41,8 @@ describe('Issue card component', () => { confidential: false, labels: [list.label], assignees: [], + reference_path: '#1', + real_path: '/test/1', }); component = new Vue({ diff --git a/spec/javascripts/boards/mock_data.js b/spec/javascripts/boards/mock_data.js index 0671facb285..81f1a97112f 100644 --- a/spec/javascripts/boards/mock_data.js +++ b/spec/javascripts/boards/mock_data.js @@ -1,7 +1,4 @@ /* global BoardService */ -/* eslint-disable comma-dangle, no-unused-vars, quote-props */ -import _ from 'underscore'; - export const listObj = { id: 300, position: 0, @@ -11,8 +8,8 @@ export const listObj = { id: 5000, title: 'Testing', color: 'red', - description: 'testing;' - } + description: 'testing;', + }, }; export const listObjDuplicate = { @@ -24,35 +21,37 @@ export const listObjDuplicate = { id: listObj.label.id, title: 'Testing', color: 'red', - description: 'testing;' - } + description: 'testing;', + }, }; export const BoardsMockData = { - 'GET': { + GET: { '/test/-/boards/1/lists/300/issues?id=300&page=1&=': { - issues: [{ - title: 'Testing', - id: 1, - iid: 1, - confidential: false, - labels: [], - assignees: [], - }], - } + issues: [ + { + title: 'Testing', + id: 1, + iid: 1, + confidential: false, + labels: [], + assignees: [], + }, + ], + }, + }, + POST: { + '/test/-/boards/1/lists': listObj, }, - 'POST': { - '/test/-/boards/1/lists': listObj + PUT: { + '/test/issue-boards/board/1/lists{/id}': {}, }, - 'PUT': { - '/test/issue-boards/board/1/lists{/id}': {} + DELETE: { + '/test/issue-boards/board/1/lists{/id}': {}, }, - 'DELETE': { - '/test/issue-boards/board/1/lists{/id}': {} - } }; -export const boardsMockInterceptor = (config) => { +export const boardsMockInterceptor = config => { const body = BoardsMockData[config.method.toUpperCase()][config.url]; return [200, body]; }; diff --git a/spec/javascripts/boards/modal_store_spec.js b/spec/javascripts/boards/modal_store_spec.js index e9d77f035e3..797693a21aa 100644 --- a/spec/javascripts/boards/modal_store_spec.js +++ b/spec/javascripts/boards/modal_store_spec.js @@ -4,12 +4,11 @@ import '~/vue_shared/models/label'; import '~/boards/models/issue'; import '~/boards/models/list'; import '~/boards/models/assignee'; -import '~/boards/stores/modal_store'; +import Store from '~/boards/stores/modal_store'; describe('Modal store', () => { let issue; let issue2; - const Store = gl.issueBoards.ModalStore; beforeEach(() => { // Setup default state diff --git a/spec/javascripts/commit/pipelines/pipelines_spec.js b/spec/javascripts/commit/pipelines/pipelines_spec.js index 0afe09d87bc..53820770f3f 100644 --- a/spec/javascripts/commit/pipelines/pipelines_spec.js +++ b/spec/javascripts/commit/pipelines/pipelines_spec.js @@ -1,113 +1,82 @@ -import _ from 'underscore'; import Vue from 'vue'; +import MockAdapter from 'axios-mock-adapter'; +import axios from '~/lib/utils/axios_utils'; import pipelinesTable from '~/commit/pipelines/pipelines_table.vue'; +import mountComponent from 'spec/helpers/vue_mount_component_helper'; describe('Pipelines table in Commits and Merge requests', () => { const jsonFixtureName = 'pipelines/pipelines.json'; let pipeline; let PipelinesTable; + let mock; + let vm; preloadFixtures(jsonFixtureName); beforeEach(() => { + mock = new MockAdapter(axios); + const pipelines = getJSONFixture(jsonFixtureName).pipelines; PipelinesTable = Vue.extend(pipelinesTable); pipeline = pipelines.find(p => p.user !== null && p.commit !== null); }); + afterEach(() => { + vm.$destroy(); + mock.restore(); + }); + describe('successful request', () => { describe('without pipelines', () => { - const pipelinesEmptyResponse = (request, next) => { - next(request.respondWith(JSON.stringify([]), { - status: 200, - })); - }; - beforeEach(function () { - Vue.http.interceptors.push(pipelinesEmptyResponse); - - this.component = new PipelinesTable({ - propsData: { - endpoint: 'endpoint', - helpPagePath: 'foo', - emptyStateSvgPath: 'foo', - errorStateSvgPath: 'foo', - autoDevopsHelpPath: 'foo', - }, - }).$mount(); - }); + mock.onGet('endpoint.json').reply(200, []); - afterEach(function () { - Vue.http.interceptors = _.without( - Vue.http.interceptors, pipelinesEmptyResponse, - ); - this.component.$destroy(); + vm = mountComponent(PipelinesTable, { + endpoint: 'endpoint.json', + helpPagePath: 'foo', + emptyStateSvgPath: 'foo', + errorStateSvgPath: 'foo', + autoDevopsHelpPath: 'foo', + }); }); it('should render the empty state', function (done) { setTimeout(() => { - expect(this.component.$el.querySelector('.empty-state')).toBeDefined(); - expect(this.component.$el.querySelector('.realtime-loading')).toBe(null); - expect(this.component.$el.querySelector('.js-pipelines-error-state')).toBe(null); + expect(vm.$el.querySelector('.empty-state')).toBeDefined(); + expect(vm.$el.querySelector('.realtime-loading')).toBe(null); + expect(vm.$el.querySelector('.js-pipelines-error-state')).toBe(null); done(); - }, 1); + }, 0); }); }); describe('with pipelines', () => { - const pipelinesResponse = (request, next) => { - next(request.respondWith(JSON.stringify([pipeline]), { - status: 200, - })); - }; - beforeEach(() => { - Vue.http.interceptors.push(pipelinesResponse); - - this.component = new PipelinesTable({ - propsData: { - endpoint: 'endpoint', - helpPagePath: 'foo', - emptyStateSvgPath: 'foo', - errorStateSvgPath: 'foo', - autoDevopsHelpPath: 'foo', - }, - }).$mount(); - }); - - afterEach(() => { - Vue.http.interceptors = _.without( - Vue.http.interceptors, pipelinesResponse, - ); - this.component.$destroy(); + mock.onGet('endpoint.json').reply(200, [pipeline]); + vm = mountComponent(PipelinesTable, { + endpoint: 'endpoint.json', + helpPagePath: 'foo', + emptyStateSvgPath: 'foo', + errorStateSvgPath: 'foo', + autoDevopsHelpPath: 'foo', + }); }); it('should render a table with the received pipelines', (done) => { setTimeout(() => { - expect(this.component.$el.querySelectorAll('.ci-table .commit').length).toEqual(1); - expect(this.component.$el.querySelector('.realtime-loading')).toBe(null); - expect(this.component.$el.querySelector('.empty-state')).toBe(null); - expect(this.component.$el.querySelector('.js-pipelines-error-state')).toBe(null); + expect(vm.$el.querySelectorAll('.ci-table .commit').length).toEqual(1); + expect(vm.$el.querySelector('.realtime-loading')).toBe(null); + expect(vm.$el.querySelector('.empty-state')).toBe(null); + expect(vm.$el.querySelector('.js-pipelines-error-state')).toBe(null); done(); }, 0); }); }); describe('pipeline badge counts', () => { - const pipelinesResponse = (request, next) => { - next(request.respondWith(JSON.stringify([pipeline]), { - status: 200, - })); - }; - beforeEach(() => { - Vue.http.interceptors.push(pipelinesResponse); - }); - - afterEach(() => { - Vue.http.interceptors = _.without(Vue.http.interceptors, pipelinesResponse); - this.component.$destroy(); + mock.onGet('endpoint.json').reply(200, [pipeline]); }); it('should receive update-pipelines-count event', (done) => { @@ -119,54 +88,38 @@ describe('Pipelines table in Commits and Merge requests', () => { done(); }); - this.component = new PipelinesTable({ - propsData: { - endpoint: 'endpoint', - helpPagePath: 'foo', - emptyStateSvgPath: 'foo', - errorStateSvgPath: 'foo', - autoDevopsHelpPath: 'foo', - }, - }).$mount(); - element.appendChild(this.component.$el); - }); - }); - }); - - describe('unsuccessfull request', () => { - const pipelinesErrorResponse = (request, next) => { - next(request.respondWith(JSON.stringify([]), { - status: 500, - })); - }; - - beforeEach(function () { - Vue.http.interceptors.push(pipelinesErrorResponse); - - this.component = new PipelinesTable({ - propsData: { - endpoint: 'endpoint', + vm = mountComponent(PipelinesTable, { + endpoint: 'endpoint.json', helpPagePath: 'foo', emptyStateSvgPath: 'foo', errorStateSvgPath: 'foo', autoDevopsHelpPath: 'foo', - }, - }).$mount(); + }); + + element.appendChild(vm.$el); + }); }); + }); - afterEach(function () { - Vue.http.interceptors = _.without( - Vue.http.interceptors, pipelinesErrorResponse, - ); - this.component.$destroy(); + describe('unsuccessfull request', () => { + beforeEach(() => { + mock.onGet('endpoint.json').reply(500, []); + + vm = mountComponent(PipelinesTable, { + endpoint: 'endpoint.json', + helpPagePath: 'foo', + emptyStateSvgPath: 'foo', + errorStateSvgPath: 'foo', + autoDevopsHelpPath: 'foo', + }); }); it('should render error state', function (done) { setTimeout(() => { - expect(this.component.$el.querySelector('.js-pipelines-error-state')).toBeDefined(); - expect(this.component.$el.querySelector('.realtime-loading')).toBe(null); - expect(this.component.$el.querySelector('.js-empty-state')).toBe(null); - expect(this.component.$el.querySelector('.ci-table')).toBe(null); + expect(vm.$el.querySelector('.js-pipelines-error-state')).toBeDefined(); + expect(vm.$el.querySelector('.realtime-loading')).toBe(null); + expect(vm.$el.querySelector('.js-empty-state')).toBe(null); + expect(vm.$el.querySelector('.ci-table')).toBe(null); done(); }, 0); }); diff --git a/spec/javascripts/droplab/constants_spec.js b/spec/javascripts/droplab/constants_spec.js index b9d28db74cc..23b69defec6 100644 --- a/spec/javascripts/droplab/constants_spec.js +++ b/spec/javascripts/droplab/constants_spec.js @@ -1,39 +1,37 @@ -/* eslint-disable */ - import * as constants from '~/droplab/constants'; -describe('constants', function () { - describe('DATA_TRIGGER', function () { +describe('constants', function() { + describe('DATA_TRIGGER', function() { it('should be `data-dropdown-trigger`', function() { expect(constants.DATA_TRIGGER).toBe('data-dropdown-trigger'); }); }); - describe('DATA_DROPDOWN', function () { + describe('DATA_DROPDOWN', function() { it('should be `data-dropdown`', function() { expect(constants.DATA_DROPDOWN).toBe('data-dropdown'); }); }); - describe('SELECTED_CLASS', function () { + describe('SELECTED_CLASS', function() { it('should be `droplab-item-selected`', function() { expect(constants.SELECTED_CLASS).toBe('droplab-item-selected'); }); }); - describe('ACTIVE_CLASS', function () { + describe('ACTIVE_CLASS', function() { it('should be `droplab-item-active`', function() { expect(constants.ACTIVE_CLASS).toBe('droplab-item-active'); }); }); - describe('TEMPLATE_REGEX', function () { + describe('TEMPLATE_REGEX', function() { it('should be a handlebars templating syntax regex', function() { expect(constants.TEMPLATE_REGEX).toEqual(/\{\{(.+?)\}\}/g); }); }); - describe('IGNORE_CLASS', function () { + describe('IGNORE_CLASS', function() { it('should be `droplab-item-ignore`', function() { expect(constants.IGNORE_CLASS).toBe('droplab-item-ignore'); }); diff --git a/spec/javascripts/fixtures/one_white_pixel.png b/spec/javascripts/fixtures/one_white_pixel.png Binary files differnew file mode 100644 index 00000000000..073fcf40a18 --- /dev/null +++ b/spec/javascripts/fixtures/one_white_pixel.png diff --git a/spec/javascripts/helpers/vue_mount_component_helper.js b/spec/javascripts/helpers/vue_mount_component_helper.js index 34acdfbfba9..effacbcff4e 100644 --- a/spec/javascripts/helpers/vue_mount_component_helper.js +++ b/spec/javascripts/helpers/vue_mount_component_helper.js @@ -3,6 +3,12 @@ export const createComponentWithStore = (Component, store, propsData = {}) => ne propsData, }); +export const mountComponentWithStore = (Component, { el, props, store }) => + new Component({ + store, + propsData: props || { }, + }).$mount(el); + export default (Component, props = {}, el = null) => new Component({ propsData: props, }).$mount(el); diff --git a/spec/javascripts/ide/components/changed_file_icon_spec.js b/spec/javascripts/ide/components/changed_file_icon_spec.js index 987aea7befc..541864e912e 100644 --- a/spec/javascripts/ide/components/changed_file_icon_spec.js +++ b/spec/javascripts/ide/components/changed_file_icon_spec.js @@ -11,6 +11,7 @@ describe('IDE changed file icon', () => { vm = createComponent(component, { file: { tempFile: false, + changed: true, }, }); }); @@ -20,7 +21,7 @@ describe('IDE changed file icon', () => { }); describe('changedIcon', () => { - it('equals file-modified when not a temp file', () => { + it('equals file-modified when not a temp file and has changes', () => { expect(vm.changedIcon).toBe('file-modified'); }); diff --git a/spec/javascripts/ide/components/commit_sidebar/list_item_spec.js b/spec/javascripts/ide/components/commit_sidebar/list_item_spec.js index 15b66952d99..509434e4300 100644 --- a/spec/javascripts/ide/components/commit_sidebar/list_item_spec.js +++ b/spec/javascripts/ide/components/commit_sidebar/list_item_spec.js @@ -1,8 +1,9 @@ import Vue from 'vue'; import listItem from '~/ide/components/commit_sidebar/list_item.vue'; import router from '~/ide/ide_router'; -import mountComponent from 'spec/helpers/vue_mount_component_helper'; -import { file } from '../../helpers'; +import store from '~/ide/stores'; +import { createComponentWithStore } from 'spec/helpers/vue_mount_component_helper'; +import { file, resetStore } from '../../helpers'; describe('Multi-file editor commit sidebar list item', () => { let vm; @@ -13,19 +14,21 @@ describe('Multi-file editor commit sidebar list item', () => { f = file('test-file'); - vm = mountComponent(Component, { + store.state.entries[f.path] = f; + + vm = createComponentWithStore(Component, store, { file: f, - }); + }).$mount(); }); afterEach(() => { vm.$destroy(); + + resetStore(store); }); it('renders file path', () => { - expect( - vm.$el.querySelector('.multi-file-commit-list-path').textContent.trim(), - ).toBe(f.path); + expect(vm.$el.querySelector('.multi-file-commit-list-path').textContent.trim()).toBe(f.path); }); it('calls discardFileChanges when clicking discard button', () => { @@ -36,25 +39,32 @@ describe('Multi-file editor commit sidebar list item', () => { expect(vm.discardFileChanges).toHaveBeenCalled(); }); - it('opens a closed file in the editor when clicking the file path', () => { + it('opens a closed file in the editor when clicking the file path', done => { spyOn(vm, 'openFileInEditor').and.callThrough(); - spyOn(vm, 'updateViewer'); spyOn(router, 'push'); vm.$el.querySelector('.multi-file-commit-list-path').click(); - expect(vm.openFileInEditor).toHaveBeenCalled(); - expect(router.push).toHaveBeenCalled(); + setTimeout(() => { + expect(vm.openFileInEditor).toHaveBeenCalled(); + expect(router.push).toHaveBeenCalled(); + + done(); + }); }); - it('calls updateViewer with diff when clicking file', () => { + it('calls updateViewer with diff when clicking file', done => { spyOn(vm, 'openFileInEditor').and.callThrough(); - spyOn(vm, 'updateViewer'); + spyOn(vm, 'updateViewer').and.callThrough(); spyOn(router, 'push'); vm.$el.querySelector('.multi-file-commit-list-path').click(); - expect(vm.updateViewer).toHaveBeenCalledWith('diff'); + setTimeout(() => { + expect(vm.updateViewer).toHaveBeenCalledWith('diff'); + + done(); + }); }); describe('computed', () => { diff --git a/spec/javascripts/ide/components/repo_file_buttons_spec.js b/spec/javascripts/ide/components/ide_file_buttons_spec.js index c86bdb132b4..8ac8d1b2acf 100644 --- a/spec/javascripts/ide/components/repo_file_buttons_spec.js +++ b/spec/javascripts/ide/components/ide_file_buttons_spec.js @@ -1,5 +1,5 @@ import Vue from 'vue'; -import repoFileButtons from '~/ide/components/repo_file_buttons.vue'; +import repoFileButtons from '~/ide/components/ide_file_buttons.vue'; import createVueComponent from '../../helpers/vue_mount_component_helper'; import { file } from '../helpers'; @@ -23,7 +23,7 @@ describe('RepoFileButtons', () => { vm.$destroy(); }); - it('renders Raw, Blame, History, Permalink and Preview toggle', done => { + it('renders Raw, Blame, History and Permalink', done => { vm = createComponent(); vm.$nextTick(() => { @@ -32,16 +32,30 @@ describe('RepoFileButtons', () => { const history = vm.$el.querySelector('.history'); expect(raw.href).toMatch(`/${activeFile.rawPath}`); - expect(raw.textContent.trim()).toEqual('Raw'); + expect(raw.getAttribute('data-original-title')).toEqual('Raw'); expect(blame.href).toMatch(`/${activeFile.blamePath}`); - expect(blame.textContent.trim()).toEqual('Blame'); + expect(blame.getAttribute('data-original-title')).toEqual('Blame'); expect(history.href).toMatch(`/${activeFile.commitsPath}`); - expect(history.textContent.trim()).toEqual('History'); - expect(vm.$el.querySelector('.permalink').textContent.trim()).toEqual( + expect(history.getAttribute('data-original-title')).toEqual('History'); + expect(vm.$el.querySelector('.permalink').getAttribute('data-original-title')).toEqual( 'Permalink', ); done(); }); }); + + it('renders Download', done => { + activeFile.binary = true; + vm = createComponent(); + + vm.$nextTick(() => { + const raw = vm.$el.querySelector('.raw'); + + expect(raw.href).toMatch(`/${activeFile.rawPath}`); + expect(raw.getAttribute('data-original-title')).toEqual('Download'); + + done(); + }); + }); }); diff --git a/spec/javascripts/ide/components/repo_editor_spec.js b/spec/javascripts/ide/components/repo_editor_spec.js index ae657e8c881..63a3d2c6cd5 100644 --- a/spec/javascripts/ide/components/repo_editor_spec.js +++ b/spec/javascripts/ide/components/repo_editor_spec.js @@ -19,7 +19,6 @@ describe('RepoEditor', () => { f.active = true; f.tempFile = true; - f.html = 'testing'; vm.$store.state.openFiles.push(f); vm.$store.state.entries[f.path] = f; vm.monaco = true; @@ -47,6 +46,61 @@ describe('RepoEditor', () => { }); }); + it('renders only an edit tab', done => { + Vue.nextTick(() => { + const tabs = vm.$el.querySelectorAll('.ide-mode-tabs .nav-links li'); + expect(tabs.length).toBe(1); + expect(tabs[0].textContent.trim()).toBe('Edit'); + + done(); + }); + }); + + describe('when file is markdown', () => { + beforeEach(done => { + vm.file.previewMode = { + id: 'markdown', + previewTitle: 'Preview Markdown', + }; + + vm.$nextTick(done); + }); + + it('renders an Edit and a Preview Tab', done => { + Vue.nextTick(() => { + const tabs = vm.$el.querySelectorAll('.ide-mode-tabs .nav-links li'); + expect(tabs.length).toBe(2); + expect(tabs[0].textContent.trim()).toBe('Edit'); + expect(tabs[1].textContent.trim()).toBe('Preview Markdown'); + + done(); + }); + }); + }); + + describe('when file is markdown and viewer mode is review', () => { + beforeEach(done => { + vm.file.previewMode = { + id: 'markdown', + previewTitle: 'Preview Markdown', + }; + vm.$store.state.viewer = 'diff'; + + vm.$nextTick(done); + }); + + it('renders an Edit and a Preview Tab', done => { + Vue.nextTick(() => { + const tabs = vm.$el.querySelectorAll('.ide-mode-tabs .nav-links li'); + expect(tabs.length).toBe(2); + expect(tabs[0].textContent.trim()).toBe('Review'); + expect(tabs[1].textContent.trim()).toBe('Preview Markdown'); + + done(); + }); + }); + }); + describe('when open file is binary and not raw', () => { beforeEach(done => { vm.file.binary = true; @@ -57,10 +111,6 @@ describe('RepoEditor', () => { it('does not render the IDE', () => { expect(vm.shouldHideEditor).toBeTruthy(); }); - - it('shows activeFile html', () => { - expect(vm.$el.textContent).toContain('testing'); - }); }); describe('createEditorInstance', () => { @@ -89,6 +139,20 @@ describe('RepoEditor', () => { done(); }); }); + + it('calls createDiffInstance when viewer is a merge request diff', done => { + vm.$store.state.viewer = 'mrdiff'; + + spyOn(vm.editor, 'createDiffInstance'); + + vm.createEditorInstance(); + + vm.$nextTick(() => { + expect(vm.editor.createDiffInstance).toHaveBeenCalled(); + + done(); + }); + }); }); describe('setupEditor', () => { @@ -134,4 +198,50 @@ describe('RepoEditor', () => { }); }); }); + + describe('editor updateDimensions', () => { + beforeEach(() => { + spyOn(vm.editor, 'updateDimensions').and.callThrough(); + spyOn(vm.editor, 'updateDiffView'); + }); + + it('calls updateDimensions when rightPanelCollapsed is changed', done => { + vm.$store.state.rightPanelCollapsed = true; + + vm.$nextTick(() => { + expect(vm.editor.updateDimensions).toHaveBeenCalled(); + expect(vm.editor.updateDiffView).toHaveBeenCalled(); + + done(); + }); + }); + + it('calls updateDimensions when panelResizing is false', done => { + vm.$store.state.panelResizing = true; + + vm + .$nextTick() + .then(() => { + vm.$store.state.panelResizing = false; + }) + .then(vm.$nextTick) + .then(() => { + expect(vm.editor.updateDimensions).toHaveBeenCalled(); + expect(vm.editor.updateDiffView).toHaveBeenCalled(); + }) + .then(done) + .catch(done.fail); + }); + + it('does not call updateDimensions when panelResizing is true', done => { + vm.$store.state.panelResizing = true; + + vm.$nextTick(() => { + expect(vm.editor.updateDimensions).not.toHaveBeenCalled(); + expect(vm.editor.updateDiffView).not.toHaveBeenCalled(); + + done(); + }); + }); + }); }); diff --git a/spec/javascripts/ide/components/repo_tab_spec.js b/spec/javascripts/ide/components/repo_tab_spec.js index ddb5204e3a7..8cabc6e8935 100644 --- a/spec/javascripts/ide/components/repo_tab_spec.js +++ b/spec/javascripts/ide/components/repo_tab_spec.js @@ -59,7 +59,7 @@ describe('RepoTab', () => { vm.$el.querySelector('.multi-file-tab-close').click(); - expect(vm.closeFile).toHaveBeenCalledWith(vm.tab.path); + expect(vm.closeFile).toHaveBeenCalledWith(vm.tab); }); it('changes icon on hover', done => { diff --git a/spec/javascripts/ide/components/repo_tabs_spec.js b/spec/javascripts/ide/components/repo_tabs_spec.js index ceb0416aff8..cb785ba2cd3 100644 --- a/spec/javascripts/ide/components/repo_tabs_spec.js +++ b/spec/javascripts/ide/components/repo_tabs_spec.js @@ -17,6 +17,8 @@ describe('RepoTabs', () => { files: openedFiles, viewer: 'editor', hasChanges: false, + activeFile: file('activeFile'), + hasMergeRequest: false, }); openedFiles[0].active = true; @@ -56,6 +58,8 @@ describe('RepoTabs', () => { files: [], viewer: 'editor', hasChanges: false, + activeFile: file('activeFile'), + hasMergeRequest: false, }, '#test-app', ); diff --git a/spec/javascripts/ide/lib/common/model_manager_spec.js b/spec/javascripts/ide/lib/common/model_manager_spec.js index 4381f6fcfd0..c00d590c580 100644 --- a/spec/javascripts/ide/lib/common/model_manager_spec.js +++ b/spec/javascripts/ide/lib/common/model_manager_spec.js @@ -27,9 +27,10 @@ describe('Multi-file editor library model manager', () => { }); it('caches model by file path', () => { - instance.addModel(file('path-name')); + const f = file('path-name'); + instance.addModel(f); - expect(instance.models.keys().next().value).toBe('path-name'); + expect(instance.models.keys().next().value).toBe(f.key); }); it('adds model into disposable', () => { @@ -56,7 +57,7 @@ describe('Multi-file editor library model manager', () => { instance.addModel(f); expect(eventHub.$on).toHaveBeenCalledWith( - `editor.update.model.dispose.${f.path}`, + `editor.update.model.dispose.${f.key}`, jasmine.anything(), ); }); @@ -68,9 +69,11 @@ describe('Multi-file editor library model manager', () => { }); it('returns true when model exists', () => { - instance.addModel(file('path-name')); + const f = file('path-name'); + + instance.addModel(f); - expect(instance.hasCachedModel('path-name')).toBeTruthy(); + expect(instance.hasCachedModel(f.key)).toBeTruthy(); }); }); @@ -103,7 +106,7 @@ describe('Multi-file editor library model manager', () => { instance.removeCachedModel(f); expect(eventHub.$off).toHaveBeenCalledWith( - `editor.update.model.dispose.${f.path}`, + `editor.update.model.dispose.${f.key}`, jasmine.anything(), ); }); diff --git a/spec/javascripts/ide/lib/common/model_spec.js b/spec/javascripts/ide/lib/common/model_spec.js index adc6a93c06b..8fc2fccb64c 100644 --- a/spec/javascripts/ide/lib/common/model_spec.js +++ b/spec/javascripts/ide/lib/common/model_spec.js @@ -11,7 +11,10 @@ describe('Multi-file editor library model', () => { spyOn(eventHub, '$on').and.callThrough(); monacoLoader(['vs/editor/editor.main'], () => { - model = new Model(monaco, file('path')); + const f = file('path'); + f.mrChange = { diff: 'ABC' }; + f.baseRaw = 'test'; + model = new Model(monaco, f); done(); }); @@ -21,21 +24,22 @@ describe('Multi-file editor library model', () => { model.dispose(); }); - it('creates original model & new model', () => { + it('creates original model & base model & new model', () => { expect(model.originalModel).not.toBeNull(); expect(model.model).not.toBeNull(); + expect(model.baseModel).not.toBeNull(); }); it('adds eventHub listener', () => { expect(eventHub.$on).toHaveBeenCalledWith( - `editor.update.model.dispose.${model.file.path}`, + `editor.update.model.dispose.${model.file.key}`, jasmine.anything(), ); }); describe('path', () => { it('returns file path', () => { - expect(model.path).toBe('path'); + expect(model.path).toBe(model.file.key); }); }); @@ -51,6 +55,12 @@ describe('Multi-file editor library model', () => { }); }); + describe('getBaseModel', () => { + it('returns base model', () => { + expect(model.getBaseModel()).toBe(model.baseModel); + }); + }); + describe('setValue', () => { it('updates models value', () => { model.setValue('testing 123'); @@ -64,7 +74,7 @@ describe('Multi-file editor library model', () => { model.onChange(() => {}); expect(model.events.size).toBe(1); - expect(model.events.keys().next().value).toBe('path'); + expect(model.events.keys().next().value).toBe(model.file.key); }); it('calls callback on change', done => { @@ -105,7 +115,7 @@ describe('Multi-file editor library model', () => { model.dispose(); expect(eventHub.$off).toHaveBeenCalledWith( - `editor.update.model.dispose.${model.file.path}`, + `editor.update.model.dispose.${model.file.key}`, jasmine.anything(), ); }); diff --git a/spec/javascripts/ide/lib/decorations/controller_spec.js b/spec/javascripts/ide/lib/decorations/controller_spec.js index 092170d086a..aec325e26a9 100644 --- a/spec/javascripts/ide/lib/decorations/controller_spec.js +++ b/spec/javascripts/ide/lib/decorations/controller_spec.js @@ -36,9 +36,7 @@ describe('Multi-file editor library decorations controller', () => { }); it('returns decorations by model URL', () => { - controller.addDecorations(model, 'key', [ - { decoration: 'decorationValue' }, - ]); + controller.addDecorations(model, 'key', [{ decoration: 'decorationValue' }]); const decorations = controller.getAllDecorationsForModel(model); @@ -48,39 +46,29 @@ describe('Multi-file editor library decorations controller', () => { describe('addDecorations', () => { it('caches decorations in a new map', () => { - controller.addDecorations(model, 'key', [ - { decoration: 'decorationValue' }, - ]); + controller.addDecorations(model, 'key', [{ decoration: 'decorationValue' }]); expect(controller.decorations.size).toBe(1); }); it('does not create new cache model', () => { - controller.addDecorations(model, 'key', [ - { decoration: 'decorationValue' }, - ]); - controller.addDecorations(model, 'key', [ - { decoration: 'decorationValue2' }, - ]); + controller.addDecorations(model, 'key', [{ decoration: 'decorationValue' }]); + controller.addDecorations(model, 'key', [{ decoration: 'decorationValue2' }]); expect(controller.decorations.size).toBe(1); }); it('caches decorations by model URL', () => { - controller.addDecorations(model, 'key', [ - { decoration: 'decorationValue' }, - ]); + controller.addDecorations(model, 'key', [{ decoration: 'decorationValue' }]); expect(controller.decorations.size).toBe(1); - expect(controller.decorations.keys().next().value).toBe('path'); + expect(controller.decorations.keys().next().value).toBe('path--path'); }); it('calls decorate method', () => { spyOn(controller, 'decorate'); - controller.addDecorations(model, 'key', [ - { decoration: 'decorationValue' }, - ]); + controller.addDecorations(model, 'key', [{ decoration: 'decorationValue' }]); expect(controller.decorate).toHaveBeenCalled(); }); @@ -92,10 +80,7 @@ describe('Multi-file editor library decorations controller', () => { controller.decorate(model); - expect(controller.editor.instance.deltaDecorations).toHaveBeenCalledWith( - [], - [], - ); + expect(controller.editor.instance.deltaDecorations).toHaveBeenCalledWith([], []); }); it('caches decorations', () => { @@ -111,15 +96,13 @@ describe('Multi-file editor library decorations controller', () => { controller.decorate(model); - expect(controller.editorDecorations.keys().next().value).toBe('path'); + expect(controller.editorDecorations.keys().next().value).toBe('path--path'); }); }); describe('dispose', () => { it('clears cached decorations', () => { - controller.addDecorations(model, 'key', [ - { decoration: 'decorationValue' }, - ]); + controller.addDecorations(model, 'key', [{ decoration: 'decorationValue' }]); controller.dispose(); @@ -127,9 +110,7 @@ describe('Multi-file editor library decorations controller', () => { }); it('clears cached editorDecorations', () => { - controller.addDecorations(model, 'key', [ - { decoration: 'decorationValue' }, - ]); + controller.addDecorations(model, 'key', [{ decoration: 'decorationValue' }]); controller.dispose(); diff --git a/spec/javascripts/ide/lib/diff/controller_spec.js b/spec/javascripts/ide/lib/diff/controller_spec.js index c8f3e9f4830..ff73240734e 100644 --- a/spec/javascripts/ide/lib/diff/controller_spec.js +++ b/spec/javascripts/ide/lib/diff/controller_spec.js @@ -131,7 +131,7 @@ describe('Multi-file editor library dirty diff controller', () => { it('adds decorations into decorations controller', () => { spyOn(controller.decorationsController, 'addDecorations'); - controller.decorate({ data: { changes: [], path: 'path' } }); + controller.decorate({ data: { changes: [], path: model.path } }); expect( controller.decorationsController.addDecorations, @@ -145,7 +145,7 @@ describe('Multi-file editor library dirty diff controller', () => { ); controller.decorate({ - data: { changes: computeDiff('123', '1234'), path: 'path' }, + data: { changes: computeDiff('123', '1234'), path: model.path }, }); expect(spy).toHaveBeenCalledWith( diff --git a/spec/javascripts/ide/lib/editor_spec.js b/spec/javascripts/ide/lib/editor_spec.js index 2ccd87de1a7..75e6f0f54ec 100644 --- a/spec/javascripts/ide/lib/editor_spec.js +++ b/spec/javascripts/ide/lib/editor_spec.js @@ -76,7 +76,8 @@ describe('Multi-file editor library', () => { occurrencesHighlight: false, renderLineHighlight: 'none', hideCursorInOverviewRuler: true, - wordWrap: 'bounded', + wordWrap: 'on', + renderSideBySide: true, }); }); }); @@ -143,6 +144,31 @@ describe('Multi-file editor library', () => { }); }); + describe('attachMergeRequestModel', () => { + let model; + + beforeEach(() => { + instance.createDiffInstance(document.createElement('div')); + + const f = file(); + f.mrChanges = { diff: 'ABC' }; + f.baseRaw = 'testing'; + + model = instance.createModel(f); + }); + + it('sets original & modified', () => { + spyOn(instance.instance, 'setModel'); + + instance.attachMergeRequestModel(model); + + expect(instance.instance.setModel).toHaveBeenCalledWith({ + original: model.getBaseModel(), + modified: model.getModel(), + }); + }); + }); + describe('clearEditor', () => { it('resets the editor model', () => { instance.createInstance(document.createElement('div')); @@ -190,4 +216,56 @@ describe('Multi-file editor library', () => { expect(instance.decorationsController.dispose).not.toHaveBeenCalled(); }); }); + + describe('updateDiffView', () => { + describe('edit mode', () => { + it('does not update options', () => { + instance.createInstance(holder); + + spyOn(instance.instance, 'updateOptions'); + + instance.updateDiffView(); + + expect(instance.instance.updateOptions).not.toHaveBeenCalled(); + }); + }); + + describe('diff mode', () => { + beforeEach(() => { + instance.createDiffInstance(holder); + + spyOn(instance.instance, 'updateOptions').and.callThrough(); + }); + + it('sets renderSideBySide to false if el is less than 700 pixels', () => { + spyOnProperty(instance.instance.getDomNode(), 'offsetWidth').and.returnValue(600); + + expect(instance.instance.updateOptions).not.toHaveBeenCalledWith({ + renderSideBySide: false, + }); + }); + + it('sets renderSideBySide to false if el is more than 700 pixels', () => { + spyOnProperty(instance.instance.getDomNode(), 'offsetWidth').and.returnValue(800); + + expect(instance.instance.updateOptions).not.toHaveBeenCalledWith({ + renderSideBySide: true, + }); + }); + }); + }); + + describe('isDiffEditorType', () => { + it('returns true when diff editor', () => { + instance.createDiffInstance(holder); + + expect(instance.isDiffEditorType).toBe(true); + }); + + it('returns false when not diff editor', () => { + instance.createInstance(holder); + + expect(instance.isDiffEditorType).toBe(false); + }); + }); }); diff --git a/spec/javascripts/ide/stores/actions/file_spec.js b/spec/javascripts/ide/stores/actions/file_spec.js index 5b7c8365641..479ed7ce49e 100644 --- a/spec/javascripts/ide/stores/actions/file_spec.js +++ b/spec/javascripts/ide/stores/actions/file_spec.js @@ -5,7 +5,7 @@ import router from '~/ide/ide_router'; import eventHub from '~/ide/eventhub'; import { file, resetStore } from '../../helpers'; -describe('Multi-file store file actions', () => { +describe('IDE store file actions', () => { beforeEach(() => { spyOn(router, 'push'); }); @@ -29,7 +29,7 @@ describe('Multi-file store file actions', () => { it('closes open files', done => { store - .dispatch('closeFile', localFile.path) + .dispatch('closeFile', localFile) .then(() => { expect(localFile.opened).toBeFalsy(); expect(localFile.active).toBeFalsy(); @@ -44,7 +44,7 @@ describe('Multi-file store file actions', () => { store.state.changedFiles.push(localFile); store - .dispatch('closeFile', localFile.path) + .dispatch('closeFile', localFile) .then(Vue.nextTick) .then(() => { expect(store.state.openFiles.length).toBe(0); @@ -65,7 +65,7 @@ describe('Multi-file store file actions', () => { store.state.entries[f.path] = f; store - .dispatch('closeFile', localFile.path) + .dispatch('closeFile', localFile) .then(Vue.nextTick) .then(() => { expect(router.push).toHaveBeenCalledWith(`/project${f.url}`); @@ -74,6 +74,22 @@ describe('Multi-file store file actions', () => { }) .catch(done.fail); }); + + it('removes file if it pending', done => { + store.state.openFiles.push({ + ...localFile, + pending: true, + }); + + store + .dispatch('closeFile', localFile) + .then(() => { + expect(store.state.openFiles.length).toBe(0); + + done(); + }) + .catch(done.fail); + }); }); describe('setFileActive', () => { @@ -189,7 +205,7 @@ describe('Multi-file store file actions', () => { it('calls the service', done => { store - .dispatch('getFileData', localFile) + .dispatch('getFileData', { path: localFile.path }) .then(() => { expect(service.getFileData).toHaveBeenCalledWith('getFileDataURL'); @@ -200,7 +216,7 @@ describe('Multi-file store file actions', () => { it('sets the file data', done => { store - .dispatch('getFileData', localFile) + .dispatch('getFileData', { path: localFile.path }) .then(() => { expect(localFile.blamePath).toBe('blame_path'); @@ -211,7 +227,7 @@ describe('Multi-file store file actions', () => { it('sets document title', done => { store - .dispatch('getFileData', localFile) + .dispatch('getFileData', { path: localFile.path }) .then(() => { expect(document.title).toBe('testing getFileData'); @@ -222,7 +238,7 @@ describe('Multi-file store file actions', () => { it('sets the file as active', done => { store - .dispatch('getFileData', localFile) + .dispatch('getFileData', { path: localFile.path }) .then(() => { expect(localFile.active).toBeTruthy(); @@ -231,9 +247,20 @@ describe('Multi-file store file actions', () => { .catch(done.fail); }); + it('sets the file not as active if we pass makeFileActive false', done => { + store + .dispatch('getFileData', { path: localFile.path, makeFileActive: false }) + .then(() => { + expect(localFile.active).toBeFalsy(); + + done(); + }) + .catch(done.fail); + }); + it('adds the file to open files', done => { store - .dispatch('getFileData', localFile) + .dispatch('getFileData', { path: localFile.path }) .then(() => { expect(store.state.openFiles.length).toBe(1); expect(store.state.openFiles[0].name).toBe(localFile.name); @@ -256,7 +283,7 @@ describe('Multi-file store file actions', () => { it('calls getRawFileData service method', done => { store - .dispatch('getRawFileData', tmpFile) + .dispatch('getRawFileData', { path: tmpFile.path }) .then(() => { expect(service.getRawFileData).toHaveBeenCalledWith(tmpFile); @@ -267,7 +294,7 @@ describe('Multi-file store file actions', () => { it('updates file raw data', done => { store - .dispatch('getRawFileData', tmpFile) + .dispatch('getRawFileData', { path: tmpFile.path }) .then(() => { expect(tmpFile.raw).toBe('raw'); @@ -275,6 +302,22 @@ describe('Multi-file store file actions', () => { }) .catch(done.fail); }); + + it('calls also getBaseRawFileData service method', done => { + spyOn(service, 'getBaseRawFileData').and.returnValue(Promise.resolve('baseraw')); + + tmpFile.mrChange = { new_file: false }; + + store + .dispatch('getRawFileData', { path: tmpFile.path, baseSha: 'SHA' }) + .then(() => { + expect(service.getBaseRawFileData).toHaveBeenCalledWith(tmpFile, 'SHA'); + expect(tmpFile.baseRaw).toBe('baseraw'); + + done(); + }) + .catch(done.fail); + }); }); describe('changeFileContent', () => { @@ -418,4 +461,113 @@ describe('Multi-file store file actions', () => { .catch(done.fail); }); }); + + describe('openPendingTab', () => { + let f; + + beforeEach(() => { + f = { + ...file(), + projectId: '123', + }; + + store.state.entries[f.path] = f; + }); + + it('makes file pending in openFiles', done => { + store + .dispatch('openPendingTab', f) + .then(() => { + expect(store.state.openFiles[0].pending).toBe(true); + }) + .then(done) + .catch(done.fail); + }); + + it('returns true when opened', done => { + store + .dispatch('openPendingTab', f) + .then(added => { + expect(added).toBe(true); + }) + .then(done) + .catch(done.fail); + }); + + it('pushes router URL when added', done => { + store.state.currentBranchId = 'master'; + + store + .dispatch('openPendingTab', f) + .then(() => { + expect(router.push).toHaveBeenCalledWith('/project/123/tree/master/'); + }) + .then(done) + .catch(done.fail); + }); + + it('calls scrollToTab', done => { + const scrollToTabSpy = jasmine.createSpy('scrollToTab'); + const oldScrollToTab = store._actions.scrollToTab; // eslint-disable-line + store._actions.scrollToTab = [scrollToTabSpy]; // eslint-disable-line + + store + .dispatch('openPendingTab', f) + .then(() => { + expect(scrollToTabSpy).toHaveBeenCalled(); + store._actions.scrollToTab = oldScrollToTab; // eslint-disable-line + }) + .then(done) + .catch(done.fail); + }); + + it('returns false when passed in file is active & viewer is diff', done => { + f.active = true; + store.state.openFiles.push(f); + store.state.viewer = 'diff'; + + store + .dispatch('openPendingTab', f) + .then(added => { + expect(added).toBe(false); + }) + .then(done) + .catch(done.fail); + }); + }); + + describe('removePendingTab', () => { + let f; + + beforeEach(() => { + spyOn(eventHub, '$emit'); + + f = { + ...file('pendingFile'), + pending: true, + }; + }); + + it('removes pending file from open files', done => { + store.state.openFiles.push(f); + + store + .dispatch('removePendingTab', f) + .then(() => { + expect(store.state.openFiles.length).toBe(0); + }) + .then(done) + .catch(done.fail); + }); + + it('emits event to dispose model', done => { + store + .dispatch('removePendingTab', f) + .then(() => { + expect(eventHub.$emit).toHaveBeenCalledWith(`editor.update.model.dispose.${f.key}`); + }) + .then(done) + .catch(done.fail); + }); + }); }); diff --git a/spec/javascripts/ide/stores/actions/merge_request_spec.js b/spec/javascripts/ide/stores/actions/merge_request_spec.js new file mode 100644 index 00000000000..b4ec4a0b173 --- /dev/null +++ b/spec/javascripts/ide/stores/actions/merge_request_spec.js @@ -0,0 +1,110 @@ +import store from '~/ide/stores'; +import service from '~/ide/services'; +import { resetStore } from '../../helpers'; + +describe('IDE store merge request actions', () => { + beforeEach(() => { + store.state.projects.abcproject = { + mergeRequests: {}, + }; + }); + + afterEach(() => { + resetStore(store); + }); + + describe('getMergeRequestData', () => { + beforeEach(() => { + spyOn(service, 'getProjectMergeRequestData').and.returnValue( + Promise.resolve({ data: { title: 'mergerequest' } }), + ); + }); + + it('calls getProjectMergeRequestData service method', done => { + store + .dispatch('getMergeRequestData', { projectId: 'abcproject', mergeRequestId: 1 }) + .then(() => { + expect(service.getProjectMergeRequestData).toHaveBeenCalledWith('abcproject', 1); + + done(); + }) + .catch(done.fail); + }); + + it('sets the Merge Request Object', done => { + store + .dispatch('getMergeRequestData', { projectId: 'abcproject', mergeRequestId: 1 }) + .then(() => { + expect(store.state.projects.abcproject.mergeRequests['1'].title).toBe('mergerequest'); + expect(store.state.currentMergeRequestId).toBe(1); + + done(); + }) + .catch(done.fail); + }); + }); + + describe('getMergeRequestChanges', () => { + beforeEach(() => { + spyOn(service, 'getProjectMergeRequestChanges').and.returnValue( + Promise.resolve({ data: { title: 'mergerequest' } }), + ); + + store.state.projects.abcproject.mergeRequests['1'] = { changes: [] }; + }); + + it('calls getProjectMergeRequestChanges service method', done => { + store + .dispatch('getMergeRequestChanges', { projectId: 'abcproject', mergeRequestId: 1 }) + .then(() => { + expect(service.getProjectMergeRequestChanges).toHaveBeenCalledWith('abcproject', 1); + + done(); + }) + .catch(done.fail); + }); + + it('sets the Merge Request Changes Object', done => { + store + .dispatch('getMergeRequestChanges', { projectId: 'abcproject', mergeRequestId: 1 }) + .then(() => { + expect(store.state.projects.abcproject.mergeRequests['1'].changes.title).toBe( + 'mergerequest', + ); + done(); + }) + .catch(done.fail); + }); + }); + + describe('getMergeRequestVersions', () => { + beforeEach(() => { + spyOn(service, 'getProjectMergeRequestVersions').and.returnValue( + Promise.resolve({ data: [{ id: 789 }] }), + ); + + store.state.projects.abcproject.mergeRequests['1'] = { versions: [] }; + }); + + it('calls getProjectMergeRequestVersions service method', done => { + store + .dispatch('getMergeRequestVersions', { projectId: 'abcproject', mergeRequestId: 1 }) + .then(() => { + expect(service.getProjectMergeRequestVersions).toHaveBeenCalledWith('abcproject', 1); + + done(); + }) + .catch(done.fail); + }); + + it('sets the Merge Request Versions Object', done => { + store + .dispatch('getMergeRequestVersions', { projectId: 'abcproject', mergeRequestId: 1 }) + .then(() => { + expect(store.state.projects.abcproject.mergeRequests['1'].versions.length).toBe(1); + done(); + }) + .catch(done.fail); + }); + }); +}); diff --git a/spec/javascripts/ide/stores/actions/tree_spec.js b/spec/javascripts/ide/stores/actions/tree_spec.js index 381f038067b..e0ef57a3966 100644 --- a/spec/javascripts/ide/stores/actions/tree_spec.js +++ b/spec/javascripts/ide/stores/actions/tree_spec.js @@ -68,9 +68,7 @@ describe('Multi-file store tree actions', () => { expect(projectTree.tree[0].tree[1].name).toBe('fileinfolder.js'); expect(projectTree.tree[1].type).toBe('blob'); expect(projectTree.tree[0].tree[0].tree[0].type).toBe('blob'); - expect(projectTree.tree[0].tree[0].tree[0].name).toBe( - 'fileinsubfolder.js', - ); + expect(projectTree.tree[0].tree[0].tree[0].name).toBe('fileinsubfolder.js'); done(); }) @@ -132,9 +130,7 @@ describe('Multi-file store tree actions', () => { store .dispatch('getLastCommitData', projectTree) .then(() => { - expect(service.getTreeLastCommit).toHaveBeenCalledWith( - 'lastcommitpath', - ); + expect(service.getTreeLastCommit).toHaveBeenCalledWith('lastcommitpath'); done(); }) @@ -160,9 +156,7 @@ describe('Multi-file store tree actions', () => { .dispatch('getLastCommitData', projectTree) .then(Vue.nextTick) .then(() => { - expect(projectTree.tree[0].lastCommit.message).not.toBe( - 'commit message', - ); + expect(projectTree.tree[0].lastCommit.message).not.toBe('commit message'); done(); }) diff --git a/spec/javascripts/ide/stores/getters_spec.js b/spec/javascripts/ide/stores/getters_spec.js index a613f3a21cc..33733b97dff 100644 --- a/spec/javascripts/ide/stores/getters_spec.js +++ b/spec/javascripts/ide/stores/getters_spec.js @@ -2,7 +2,7 @@ import * as getters from '~/ide/stores/getters'; import state from '~/ide/stores/state'; import { file } from '../helpers'; -describe('Multi-file store getters', () => { +describe('IDE store getters', () => { let localState; beforeEach(() => { @@ -52,4 +52,24 @@ describe('Multi-file store getters', () => { expect(modifiedFiles[0].name).toBe('added'); }); }); + + describe('currentMergeRequest', () => { + it('returns Current Merge Request', () => { + localState.currentProjectId = 'abcproject'; + localState.currentMergeRequestId = 1; + localState.projects.abcproject = { + mergeRequests: { + 1: { mergeId: 1 }, + }, + }; + + expect(getters.currentMergeRequest(localState).mergeId).toBe(1); + }); + + it('returns null if no active Merge Request was found', () => { + localState.currentProjectId = 'otherproject'; + + expect(getters.currentMergeRequest(localState)).toBeNull(); + }); + }); }); diff --git a/spec/javascripts/ide/stores/mutations/file_spec.js b/spec/javascripts/ide/stores/mutations/file_spec.js index 131380248e8..bf9d5166d0a 100644 --- a/spec/javascripts/ide/stores/mutations/file_spec.js +++ b/spec/javascripts/ide/stores/mutations/file_spec.js @@ -2,7 +2,7 @@ import mutations from '~/ide/stores/mutations/file'; import state from '~/ide/stores/state'; import { file } from '../../helpers'; -describe('Multi-file store file mutations', () => { +describe('IDE store file mutations', () => { let localState; let localFile; @@ -22,6 +22,21 @@ describe('Multi-file store file mutations', () => { expect(localFile.active).toBeTruthy(); }); + + it('sets pending tab as not active', () => { + localState.openFiles.push({ + ...localFile, + pending: true, + active: true, + }); + + mutations.SET_FILE_ACTIVE(localState, { + path: localFile.path, + active: true, + }); + + expect(localState.openFiles[0].active).toBe(false); + }); }); describe('TOGGLE_FILE_OPEN', () => { @@ -62,6 +77,8 @@ describe('Multi-file store file mutations', () => { expect(localFile.rawPath).toBe('raw'); expect(localFile.binary).toBeTruthy(); expect(localFile.renderError).toBe('render_error'); + expect(localFile.raw).toBeNull(); + expect(localFile.baseRaw).toBeNull(); }); }); @@ -76,6 +93,17 @@ describe('Multi-file store file mutations', () => { }); }); + describe('SET_FILE_BASE_RAW_DATA', () => { + it('sets raw data from base branch', () => { + mutations.SET_FILE_BASE_RAW_DATA(localState, { + file: localFile, + baseRaw: 'testing', + }); + + expect(localFile.baseRaw).toBe('testing'); + }); + }); + describe('UPDATE_FILE_CONTENT', () => { beforeEach(() => { localFile.raw = 'test'; @@ -112,6 +140,17 @@ describe('Multi-file store file mutations', () => { }); }); + describe('SET_FILE_MERGE_REQUEST_CHANGE', () => { + it('sets file mr change', () => { + mutations.SET_FILE_MERGE_REQUEST_CHANGE(localState, { + file: localFile, + mrChange: { diff: 'ABC' }, + }); + + expect(localFile.mrChange.diff).toBe('ABC'); + }); + }); + describe('DISCARD_FILE_CHANGES', () => { beforeEach(() => { localFile.content = 'test'; @@ -154,4 +193,80 @@ describe('Multi-file store file mutations', () => { expect(localFile.changed).toBeTruthy(); }); }); + + describe('SET_FILE_VIEWMODE', () => { + it('updates file view mode', () => { + mutations.SET_FILE_VIEWMODE(localState, { + file: localFile, + viewMode: 'preview', + }); + + expect(localFile.viewMode).toBe('preview'); + }); + }); + + describe('ADD_PENDING_TAB', () => { + beforeEach(() => { + const f = { + ...file('openFile'), + path: 'openFile', + active: true, + opened: true, + }; + + localState.entries[f.path] = f; + localState.openFiles.push(f); + }); + + it('adds file into openFiles as pending', () => { + mutations.ADD_PENDING_TAB(localState, { file: localFile }); + + expect(localState.openFiles.length).toBe(2); + expect(localState.openFiles[1].pending).toBe(true); + expect(localState.openFiles[1].key).toBe(`pending-${localFile.key}`); + }); + + it('updates open file to pending', () => { + mutations.ADD_PENDING_TAB(localState, { file: localState.openFiles[0] }); + + expect(localState.openFiles.length).toBe(1); + }); + + it('updates pending open file to active', () => { + localState.openFiles.push({ + ...localFile, + pending: true, + }); + + mutations.ADD_PENDING_TAB(localState, { file: localFile }); + + expect(localState.openFiles[1].pending).toBe(true); + expect(localState.openFiles[1].active).toBe(true); + }); + + it('sets all openFiles to not active', () => { + mutations.ADD_PENDING_TAB(localState, { file: localFile }); + + expect(localState.openFiles.length).toBe(2); + + localState.openFiles.forEach(f => { + if (f.pending) { + expect(f.active).toBe(true); + } else { + expect(f.active).toBe(false); + } + }); + }); + }); + + describe('REMOVE_PENDING_TAB', () => { + it('removes pending tab from openFiles', () => { + localFile.key = 'testing'; + localState.openFiles.push(localFile); + + mutations.REMOVE_PENDING_TAB(localState, localFile); + + expect(localState.openFiles.length).toBe(0); + }); + }); }); diff --git a/spec/javascripts/ide/stores/mutations/merge_request_spec.js b/spec/javascripts/ide/stores/mutations/merge_request_spec.js new file mode 100644 index 00000000000..f724bf464f5 --- /dev/null +++ b/spec/javascripts/ide/stores/mutations/merge_request_spec.js @@ -0,0 +1,65 @@ +import mutations from '~/ide/stores/mutations/merge_request'; +import state from '~/ide/stores/state'; + +describe('IDE store merge request mutations', () => { + let localState; + + beforeEach(() => { + localState = state(); + localState.projects = { abcproject: { mergeRequests: {} } }; + + mutations.SET_MERGE_REQUEST(localState, { + projectPath: 'abcproject', + mergeRequestId: 1, + mergeRequest: { + title: 'mr', + }, + }); + }); + + describe('SET_CURRENT_MERGE_REQUEST', () => { + it('sets current merge request', () => { + mutations.SET_CURRENT_MERGE_REQUEST(localState, 2); + + expect(localState.currentMergeRequestId).toBe(2); + }); + }); + + describe('SET_MERGE_REQUEST', () => { + it('setsmerge request data', () => { + const newMr = localState.projects.abcproject.mergeRequests[1]; + + expect(newMr.title).toBe('mr'); + expect(newMr.active).toBeTruthy(); + }); + }); + + describe('SET_MERGE_REQUEST_CHANGES', () => { + it('sets merge request changes', () => { + mutations.SET_MERGE_REQUEST_CHANGES(localState, { + projectPath: 'abcproject', + mergeRequestId: 1, + changes: { + diff: 'abc', + }, + }); + + const newMr = localState.projects.abcproject.mergeRequests[1]; + expect(newMr.changes.diff).toBe('abc'); + }); + }); + + describe('SET_MERGE_REQUEST_VERSIONS', () => { + it('sets merge request versions', () => { + mutations.SET_MERGE_REQUEST_VERSIONS(localState, { + projectPath: 'abcproject', + mergeRequestId: 1, + versions: [{ id: 123 }], + }); + + const newMr = localState.projects.abcproject.mergeRequests[1]; + expect(newMr.versions.length).toBe(1); + expect(newMr.versions[0].id).toBe(123); + }); + }); +}); diff --git a/spec/javascripts/lib/utils/text_utility_spec.js b/spec/javascripts/lib/utils/text_utility_spec.js index e57a55fa71a..ae00fb76714 100644 --- a/spec/javascripts/lib/utils/text_utility_spec.js +++ b/spec/javascripts/lib/utils/text_utility_spec.js @@ -65,11 +65,15 @@ describe('text_utility', () => { describe('stripHtml', () => { it('replaces html tag with the default replacement', () => { - expect(textUtils.stripHtml('This is a text with <p>html</p>.')).toEqual('This is a text with html.'); + expect(textUtils.stripHtml('This is a text with <p>html</p>.')).toEqual( + 'This is a text with html.', + ); }); it('replaces html tags with the provided replacement', () => { - expect(textUtils.stripHtml('This is a text with <p>html</p>.', ' ')).toEqual('This is a text with html .'); + expect(textUtils.stripHtml('This is a text with <p>html</p>.', ' ')).toEqual( + 'This is a text with html .', + ); }); }); @@ -78,4 +82,10 @@ describe('text_utility', () => { expect(textUtils.convertToCamelCase('snake_case')).toBe('snakeCase'); }); }); + + describe('convertToSentenceCase', () => { + it('converts Sentence Case to Sentence case', () => { + expect(textUtils.convertToSentenceCase('Hello World')).toBe('Hello world'); + }); + }); }); diff --git a/spec/javascripts/matchers.js b/spec/javascripts/matchers.js new file mode 100644 index 00000000000..7cc5e753c22 --- /dev/null +++ b/spec/javascripts/matchers.js @@ -0,0 +1,35 @@ +export default { + toHaveSpriteIcon: () => ({ + compare(element, iconName) { + if (!iconName) { + throw new Error('toHaveSpriteIcon is missing iconName argument!'); + } + + if (!(element instanceof HTMLElement)) { + throw new Error(`${element} is not a DOM element!`); + } + + const iconReferences = [].slice.apply(element.querySelectorAll('svg use')); + const matchingIcon = iconReferences.find(reference => reference.getAttribute('xlink:href').endsWith(`#${iconName}`)); + const result = { + pass: !!matchingIcon, + }; + + if (result.pass) { + result.message = `${element.outerHTML} contains the sprite icon "${iconName}"!`; + } else { + result.message = `${element.outerHTML} does not contain the sprite icon "${iconName}"!`; + + const existingIcons = iconReferences.map((reference) => { + const iconUrl = reference.getAttribute('xlink:href'); + return `"${iconUrl.replace(/^.+#/, '')}"`; + }); + if (existingIcons.length > 0) { + result.message += ` (only found ${existingIcons.join(',')})`; + } + } + + return result; + }, + }), +}; diff --git a/spec/javascripts/monitoring/graph/axis_spec.js b/spec/javascripts/monitoring/graph/axis_spec.js new file mode 100644 index 00000000000..c7adba00637 --- /dev/null +++ b/spec/javascripts/monitoring/graph/axis_spec.js @@ -0,0 +1,65 @@ +import Vue from 'vue'; +import GraphAxis from '~/monitoring/components/graph/axis.vue'; +import measurements from '~/monitoring/utils/measurements'; + +const createComponent = propsData => { + const Component = Vue.extend(GraphAxis); + + return new Component({ + propsData, + }).$mount(); +}; + +const defaultValuesComponent = { + graphWidth: 500, + graphHeight: 300, + graphHeightOffset: 120, + margin: measurements.large.margin, + measurements: measurements.large, + yAxisLabel: 'Values', + unitOfDisplay: 'MB', +}; + +function getTextFromNode(component, selector) { + return component.$el.querySelector(selector).firstChild.nodeValue.trim(); +} + +describe('Axis', () => { + describe('Computed props', () => { + it('textTransform', () => { + const component = createComponent(defaultValuesComponent); + + expect(component.textTransform).toContain('translate(15, 120) rotate(-90)'); + }); + + it('xPosition', () => { + const component = createComponent(defaultValuesComponent); + + expect(component.xPosition).toEqual(180); + }); + + it('yPosition', () => { + const component = createComponent(defaultValuesComponent); + + expect(component.yPosition).toEqual(240); + }); + + it('rectTransform', () => { + const component = createComponent(defaultValuesComponent); + + expect(component.rectTransform).toContain('translate(0, 120) rotate(-90)'); + }); + }); + + it('has 2 rect-axis-text rect svg elements', () => { + const component = createComponent(defaultValuesComponent); + + expect(component.$el.querySelectorAll('.rect-axis-text').length).toEqual(2); + }); + + it('contains text to signal the usage, title and time with multiple time series', () => { + const component = createComponent(defaultValuesComponent); + + expect(getTextFromNode(component, '.y-label-text')).toEqual('Values (MB)'); + }); +}); diff --git a/spec/javascripts/monitoring/graph/legend_spec.js b/spec/javascripts/monitoring/graph/legend_spec.js index 145c8db28d5..abcc51aa077 100644 --- a/spec/javascripts/monitoring/graph/legend_spec.js +++ b/spec/javascripts/monitoring/graph/legend_spec.js @@ -1,106 +1,44 @@ import Vue from 'vue'; import GraphLegend from '~/monitoring/components/graph/legend.vue'; -import measurements from '~/monitoring/utils/measurements'; import createTimeSeries from '~/monitoring/utils/multiple_time_series'; +import mountComponent from 'spec/helpers/vue_mount_component_helper'; import { singleRowMetricsMultipleSeries, convertDatesMultipleSeries } from '../mock_data'; -const createComponent = (propsData) => { - const Component = Vue.extend(GraphLegend); - - return new Component({ - propsData, - }).$mount(); -}; - const convertedMetrics = convertDatesMultipleSeries(singleRowMetricsMultipleSeries); -const defaultValuesComponent = { - graphWidth: 500, - graphHeight: 300, - graphHeightOffset: 120, - margin: measurements.large.margin, - measurements: measurements.large, - areaColorRgb: '#f0f0f0', - legendTitle: 'Title', - yAxisLabel: 'Values', - metricUsage: 'Value', - unitOfDisplay: 'Req/Sec', - currentDataIndex: 0, -}; +const defaultValuesComponent = {}; -const timeSeries = createTimeSeries(convertedMetrics[0].queries, - defaultValuesComponent.graphWidth, defaultValuesComponent.graphHeight, - defaultValuesComponent.graphHeightOffset); +const timeSeries = createTimeSeries(convertedMetrics[0].queries, 500, 300, 120); defaultValuesComponent.timeSeries = timeSeries; -function getTextFromNode(component, selector) { - return component.$el.querySelector(selector).firstChild.nodeValue.trim(); -} - -describe('GraphLegend', () => { - describe('Computed props', () => { - it('textTransform', () => { - const component = createComponent(defaultValuesComponent); - - expect(component.textTransform).toContain('translate(15, 120) rotate(-90)'); - }); - - it('xPosition', () => { - const component = createComponent(defaultValuesComponent); - - expect(component.xPosition).toEqual(180); - }); - - it('yPosition', () => { - const component = createComponent(defaultValuesComponent); - - expect(component.yPosition).toEqual(240); - }); - - it('rectTransform', () => { - const component = createComponent(defaultValuesComponent); +describe('Legend Component', () => { + let vm; + let Legend; - expect(component.rectTransform).toContain('translate(0, 120) rotate(-90)'); - }); + beforeEach(() => { + Legend = Vue.extend(GraphLegend); }); - describe('methods', () => { - it('translateLegendGroup should only change Y direction', () => { - const component = createComponent(defaultValuesComponent); - - const translatedCoordinate = component.translateLegendGroup(1); - expect(translatedCoordinate.indexOf('translate(0, ')).not.toEqual(-1); + describe('View', () => { + beforeEach(() => { + vm = mountComponent(Legend, { + legendTitle: 'legend', + timeSeries, + currentDataIndex: 0, + unitOfDisplay: 'Req/Sec', + }); }); - it('formatMetricUsage should contain the unit of display and the current value selected via "currentDataIndex"', () => { - const component = createComponent(defaultValuesComponent); + it('should render the usage, title and time with multiple time series', () => { + const titles = vm.$el.querySelectorAll('.legend-metric-title'); - const formattedMetricUsage = component.formatMetricUsage(timeSeries[0]); - const valueFromSeries = timeSeries[0].values[component.currentDataIndex].value; - expect(formattedMetricUsage.indexOf(component.unitOfDisplay)).not.toEqual(-1); - expect(formattedMetricUsage.indexOf(valueFromSeries)).not.toEqual(-1); + expect(titles[0].textContent.indexOf('1xx')).not.toEqual(-1); + expect(titles[1].textContent.indexOf('2xx')).not.toEqual(-1); }); - }); - - it('has 2 rect-axis-text rect svg elements', () => { - const component = createComponent(defaultValuesComponent); - - expect(component.$el.querySelectorAll('.rect-axis-text').length).toEqual(2); - }); - it('contains text to signal the usage, title and time with multiple time series', () => { - const component = createComponent(defaultValuesComponent); - const titles = component.$el.querySelectorAll('.legend-metric-title'); - - expect(titles[0].textContent.indexOf('1xx')).not.toEqual(-1); - expect(titles[1].textContent.indexOf('2xx')).not.toEqual(-1); - expect(getTextFromNode(component, '.y-label-text')).toEqual(component.yAxisLabel); - }); - - it('should contain the same number of legend groups as the timeSeries length', () => { - const component = createComponent(defaultValuesComponent); - - expect(component.$el.querySelectorAll('.legend-group').length).toEqual(component.timeSeries.length); + it('should container the same number of rows in the table as time series', () => { + expect(vm.$el.querySelectorAll('.prometheus-table tr').length).toEqual(vm.timeSeries.length); + }); }); }); diff --git a/spec/javascripts/monitoring/graph/track_info_spec.js b/spec/javascripts/monitoring/graph/track_info_spec.js new file mode 100644 index 00000000000..d3121d553f9 --- /dev/null +++ b/spec/javascripts/monitoring/graph/track_info_spec.js @@ -0,0 +1,44 @@ +import Vue from 'vue'; +import TrackInfo from '~/monitoring/components/graph/track_info.vue'; +import mountComponent from 'spec/helpers/vue_mount_component_helper'; +import createTimeSeries from '~/monitoring/utils/multiple_time_series'; +import { singleRowMetricsMultipleSeries, convertDatesMultipleSeries } from '../mock_data'; + +const convertedMetrics = convertDatesMultipleSeries(singleRowMetricsMultipleSeries); +const timeSeries = createTimeSeries(convertedMetrics[0].queries, 500, 300, 120); + +describe('TrackInfo component', () => { + let vm; + let Component; + + beforeEach(() => { + Component = Vue.extend(TrackInfo); + }); + + afterEach(() => { + vm.$destroy(); + }); + + describe('Computed props', () => { + beforeEach(() => { + vm = mountComponent(Component, { track: timeSeries[0] }); + }); + + it('summaryMetrics', () => { + expect(vm.summaryMetrics).toEqual('Avg: 0.000 · Max: 0.000'); + }); + }); + + describe('Rendered output', () => { + beforeEach(() => { + vm = mountComponent(Component, { track: timeSeries[0] }); + }); + + it('contains metric tag and the summary metrics', () => { + const metricTag = vm.$el.querySelector('strong'); + + expect(metricTag.textContent.trim()).toEqual(vm.track.metricTag); + expect(vm.$el.textContent).toContain('Avg: 0.000 · Max: 0.000'); + }); + }); +}); diff --git a/spec/javascripts/monitoring/graph/track_line_spec.js b/spec/javascripts/monitoring/graph/track_line_spec.js new file mode 100644 index 00000000000..45106830a67 --- /dev/null +++ b/spec/javascripts/monitoring/graph/track_line_spec.js @@ -0,0 +1,52 @@ +import Vue from 'vue'; +import TrackLine from '~/monitoring/components/graph/track_line.vue'; +import mountComponent from 'spec/helpers/vue_mount_component_helper'; +import createTimeSeries from '~/monitoring/utils/multiple_time_series'; +import { singleRowMetricsMultipleSeries, convertDatesMultipleSeries } from '../mock_data'; + +const convertedMetrics = convertDatesMultipleSeries(singleRowMetricsMultipleSeries); +const timeSeries = createTimeSeries(convertedMetrics[0].queries, 500, 300, 120); + +describe('TrackLine component', () => { + let vm; + let Component; + + beforeEach(() => { + Component = Vue.extend(TrackLine); + }); + + afterEach(() => { + vm.$destroy(); + }); + + describe('Computed props', () => { + it('stylizedLine for dashed lineStyles', () => { + vm = mountComponent(Component, { track: { ...timeSeries[0], lineStyle: 'dashed' } }); + + expect(vm.stylizedLine).toEqual('6, 3'); + }); + + it('stylizedLine for dotted lineStyles', () => { + vm = mountComponent(Component, { track: { ...timeSeries[0], lineStyle: 'dotted' } }); + + expect(vm.stylizedLine).toEqual('3, 3'); + }); + }); + + describe('Rendered output', () => { + it('has an svg with a line', () => { + vm = mountComponent(Component, { track: { ...timeSeries[0] } }); + const svgEl = vm.$el.querySelector('svg'); + const lineEl = vm.$el.querySelector('svg line'); + + expect(svgEl.getAttribute('width')).toEqual('15'); + expect(svgEl.getAttribute('height')).toEqual('6'); + + expect(lineEl.getAttribute('stroke-width')).toEqual('4'); + expect(lineEl.getAttribute('x1')).toEqual('0'); + expect(lineEl.getAttribute('x2')).toEqual('15'); + expect(lineEl.getAttribute('y1')).toEqual('2'); + expect(lineEl.getAttribute('y2')).toEqual('2'); + }); + }); +}); diff --git a/spec/javascripts/monitoring/graph_spec.js b/spec/javascripts/monitoring/graph_spec.js index b1d69752bad..1213c80ba3a 100644 --- a/spec/javascripts/monitoring/graph_spec.js +++ b/spec/javascripts/monitoring/graph_spec.js @@ -2,11 +2,15 @@ import Vue from 'vue'; import Graph from '~/monitoring/components/graph.vue'; import MonitoringMixins from '~/monitoring/mixins/monitoring_mixins'; import eventHub from '~/monitoring/event_hub'; -import { deploymentData, convertDatesMultipleSeries, singleRowMetricsMultipleSeries } from './mock_data'; +import { + deploymentData, + convertDatesMultipleSeries, + singleRowMetricsMultipleSeries, +} from './mock_data'; const tagsPath = 'http://test.host/frontend-fixtures/environments-project/tags'; const projectPath = 'http://test.host/frontend-fixtures/environments-project'; -const createComponent = (propsData) => { +const createComponent = propsData => { const Component = Vue.extend(Graph); return new Component({ @@ -14,7 +18,9 @@ const createComponent = (propsData) => { }).$mount(); }; -const convertedMetrics = convertDatesMultipleSeries(singleRowMetricsMultipleSeries); +const convertedMetrics = convertDatesMultipleSeries( + singleRowMetricsMultipleSeries, +); describe('Graph', () => { beforeEach(() => { @@ -31,7 +37,9 @@ describe('Graph', () => { projectPath, }); - expect(component.$el.querySelector('.text-center').innerText.trim()).toBe(component.graphData.title); + expect(component.$el.querySelector('.text-center').innerText.trim()).toBe( + component.graphData.title, + ); }); describe('Computed props', () => { @@ -46,8 +54,9 @@ describe('Graph', () => { }); const transformedHeight = `${component.graphHeight - 100}`; - expect(component.axisTransform.indexOf(transformedHeight)) - .not.toEqual(-1); + expect(component.axisTransform.indexOf(transformedHeight)).not.toEqual( + -1, + ); }); it('outerViewBox gets a width and height property based on the DOM size of the element', () => { @@ -63,11 +72,11 @@ describe('Graph', () => { const viewBoxArray = component.outerViewBox.split(' '); expect(typeof component.outerViewBox).toEqual('string'); expect(viewBoxArray[2]).toEqual(component.graphWidth.toString()); - expect(viewBoxArray[3]).toEqual(component.graphHeight.toString()); + expect(viewBoxArray[3]).toEqual((component.graphHeight - 50).toString()); }); }); - it('sends an event to the eventhub when it has finished resizing', (done) => { + it('sends an event to the eventhub when it has finished resizing', done => { const component = createComponent({ graphData: convertedMetrics[1], classType: 'col-md-6', diff --git a/spec/javascripts/monitoring/mock_data.js b/spec/javascripts/monitoring/mock_data.js index f30208b27b6..50da6da2e07 100644 --- a/spec/javascripts/monitoring/mock_data.js +++ b/spec/javascripts/monitoring/mock_data.js @@ -3,2426 +3,645 @@ export const mockApiEndpoint = `${gl.TEST_HOST}/monitoring/mock`; export const metricsGroupsAPIResponse = { - 'success': true, - 'data': [ + success: true, + data: [ { - 'group': 'Kubernetes', - 'priority': 1, - 'metrics': [ - { - 'title': 'Memory usage', - 'weight': 1, - 'queries': [ + group: 'Kubernetes', + priority: 1, + metrics: [ + { + title: 'Memory usage', + weight: 1, + queries: [ + { + query_range: 'avg(container_memory_usage_bytes{%{environment_filter}}) / 2^20', + y_label: 'Memory', + unit: 'MiB', + result: [ { - 'query_range': 'avg(container_memory_usage_bytes{%{environment_filter}}) / 2^20', - 'y_label': 'Memory', - 'unit': 'MiB', - 'result': [ - { - 'metric': {}, - 'values': [ - [ - 1495700554.925, - '8.0390625' - ], - [ - 1495700614.925, - '8.0390625' - ], - [ - 1495700674.925, - '8.0390625' - ], - [ - 1495700734.925, - '8.0390625' - ], - [ - 1495700794.925, - '8.0390625' - ], - [ - 1495700854.925, - '8.0390625' - ], - [ - 1495700914.925, - '8.0390625' - ], - [ - 1495700974.925, - '8.0390625' - ], - [ - 1495701034.925, - '8.0390625' - ], - [ - 1495701094.925, - '8.0390625' - ], - [ - 1495701154.925, - '8.0390625' - ], - [ - 1495701214.925, - '8.0390625' - ], - [ - 1495701274.925, - '8.0390625' - ], - [ - 1495701334.925, - '8.0390625' - ], - [ - 1495701394.925, - '8.0390625' - ], - [ - 1495701454.925, - '8.0390625' - ], - [ - 1495701514.925, - '8.0390625' - ], - [ - 1495701574.925, - '8.0390625' - ], - [ - 1495701634.925, - '8.0390625' - ], - [ - 1495701694.925, - '8.0390625' - ], - [ - 1495701754.925, - '8.0390625' - ], - [ - 1495701814.925, - '8.0390625' - ], - [ - 1495701874.925, - '8.0390625' - ], - [ - 1495701934.925, - '8.0390625' - ], - [ - 1495701994.925, - '8.0390625' - ], - [ - 1495702054.925, - '8.0390625' - ], - [ - 1495702114.925, - '8.0390625' - ], - [ - 1495702174.925, - '8.0390625' - ], - [ - 1495702234.925, - '8.0390625' - ], - [ - 1495702294.925, - '8.0390625' - ], - [ - 1495702354.925, - '8.0390625' - ], - [ - 1495702414.925, - '8.0390625' - ], - [ - 1495702474.925, - '8.0390625' - ], - [ - 1495702534.925, - '8.0390625' - ], - [ - 1495702594.925, - '8.0390625' - ], - [ - 1495702654.925, - '8.0390625' - ], - [ - 1495702714.925, - '8.0390625' - ], - [ - 1495702774.925, - '8.0390625' - ], - [ - 1495702834.925, - '8.0390625' - ], - [ - 1495702894.925, - '8.0390625' - ], - [ - 1495702954.925, - '8.0390625' - ], - [ - 1495703014.925, - '8.0390625' - ], - [ - 1495703074.925, - '8.0390625' - ], - [ - 1495703134.925, - '8.0390625' - ], - [ - 1495703194.925, - '8.0390625' - ], - [ - 1495703254.925, - '8.03515625' - ], - [ - 1495703314.925, - '8.03515625' - ], - [ - 1495703374.925, - '8.03515625' - ], - [ - 1495703434.925, - '8.03515625' - ], - [ - 1495703494.925, - '8.03515625' - ], - [ - 1495703554.925, - '8.03515625' - ], - [ - 1495703614.925, - '8.03515625' - ], - [ - 1495703674.925, - '8.03515625' - ], - [ - 1495703734.925, - '8.03515625' - ], - [ - 1495703794.925, - '8.03515625' - ], - [ - 1495703854.925, - '8.03515625' - ], - [ - 1495703914.925, - '8.03515625' - ], - [ - 1495703974.925, - '8.03515625' - ], - [ - 1495704034.925, - '8.03515625' - ], - [ - 1495704094.925, - '8.03515625' - ], - [ - 1495704154.925, - '8.03515625' - ], - [ - 1495704214.925, - '7.9296875' - ], - [ - 1495704274.925, - '7.9296875' - ], - [ - 1495704334.925, - '7.9296875' - ], - [ - 1495704394.925, - '7.9296875' - ], - [ - 1495704454.925, - '7.9296875' - ], - [ - 1495704514.925, - '7.9296875' - ], - [ - 1495704574.925, - '7.9296875' - ], - [ - 1495704634.925, - '7.9296875' - ], - [ - 1495704694.925, - '7.9296875' - ], - [ - 1495704754.925, - '7.9296875' - ], - [ - 1495704814.925, - '7.9296875' - ], - [ - 1495704874.925, - '7.9296875' - ], - [ - 1495704934.925, - '7.9296875' - ], - [ - 1495704994.925, - '7.9296875' - ], - [ - 1495705054.925, - '7.9296875' - ], - [ - 1495705114.925, - '7.9296875' - ], - [ - 1495705174.925, - '7.9296875' - ], - [ - 1495705234.925, - '7.9296875' - ], - [ - 1495705294.925, - '7.9296875' - ], - [ - 1495705354.925, - '7.9296875' - ], - [ - 1495705414.925, - '7.9296875' - ], - [ - 1495705474.925, - '7.9296875' - ], - [ - 1495705534.925, - '7.9296875' - ], - [ - 1495705594.925, - '7.9296875' - ], - [ - 1495705654.925, - '7.9296875' - ], - [ - 1495705714.925, - '7.9296875' - ], - [ - 1495705774.925, - '7.9296875' - ], - [ - 1495705834.925, - '7.9296875' - ], - [ - 1495705894.925, - '7.9296875' - ], - [ - 1495705954.925, - '7.9296875' - ], - [ - 1495706014.925, - '7.9296875' - ], - [ - 1495706074.925, - '7.9296875' - ], - [ - 1495706134.925, - '7.9296875' - ], - [ - 1495706194.925, - '7.9296875' - ], - [ - 1495706254.925, - '7.9296875' - ], - [ - 1495706314.925, - '7.9296875' - ], - [ - 1495706374.925, - '7.9296875' - ], - [ - 1495706434.925, - '7.9296875' - ], - [ - 1495706494.925, - '7.9296875' - ], - [ - 1495706554.925, - '7.9296875' - ], - [ - 1495706614.925, - '7.9296875' - ], - [ - 1495706674.925, - '7.9296875' - ], - [ - 1495706734.925, - '7.9296875' - ], - [ - 1495706794.925, - '7.9296875' - ], - [ - 1495706854.925, - '7.9296875' - ], - [ - 1495706914.925, - '7.9296875' - ], - [ - 1495706974.925, - '7.9296875' - ], - [ - 1495707034.925, - '7.9296875' - ], - [ - 1495707094.925, - '7.9296875' - ], - [ - 1495707154.925, - '7.9296875' - ], - [ - 1495707214.925, - '7.9296875' - ], - [ - 1495707274.925, - '7.9296875' - ], - [ - 1495707334.925, - '7.9296875' - ], - [ - 1495707394.925, - '7.9296875' - ], - [ - 1495707454.925, - '7.9296875' - ], - [ - 1495707514.925, - '7.9296875' - ], - [ - 1495707574.925, - '7.9296875' - ], - [ - 1495707634.925, - '7.9296875' - ], - [ - 1495707694.925, - '7.9296875' - ], - [ - 1495707754.925, - '7.9296875' - ], - [ - 1495707814.925, - '7.9296875' - ], - [ - 1495707874.925, - '7.9296875' - ], - [ - 1495707934.925, - '7.9296875' - ], - [ - 1495707994.925, - '7.9296875' - ], - [ - 1495708054.925, - '7.9296875' - ], - [ - 1495708114.925, - '7.9296875' - ], - [ - 1495708174.925, - '7.9296875' - ], - [ - 1495708234.925, - '7.9296875' - ], - [ - 1495708294.925, - '7.9296875' - ], - [ - 1495708354.925, - '7.9296875' - ], - [ - 1495708414.925, - '7.9296875' - ], - [ - 1495708474.925, - '7.9296875' - ], - [ - 1495708534.925, - '7.9296875' - ], - [ - 1495708594.925, - '7.9296875' - ], - [ - 1495708654.925, - '7.9296875' - ], - [ - 1495708714.925, - '7.9296875' - ], - [ - 1495708774.925, - '7.9296875' - ], - [ - 1495708834.925, - '7.9296875' - ], - [ - 1495708894.925, - '7.9296875' - ], - [ - 1495708954.925, - '7.8984375' - ], - [ - 1495709014.925, - '7.8984375' - ], - [ - 1495709074.925, - '7.8984375' - ], - [ - 1495709134.925, - '7.8984375' - ], - [ - 1495709194.925, - '7.8984375' - ], - [ - 1495709254.925, - '7.89453125' - ], - [ - 1495709314.925, - '7.89453125' - ], - [ - 1495709374.925, - '7.89453125' - ], - [ - 1495709434.925, - '7.89453125' - ], - [ - 1495709494.925, - '7.89453125' - ], - [ - 1495709554.925, - '7.89453125' - ], - [ - 1495709614.925, - '7.89453125' - ], - [ - 1495709674.925, - '7.89453125' - ], - [ - 1495709734.925, - '7.89453125' - ], - [ - 1495709794.925, - '7.89453125' - ], - [ - 1495709854.925, - '7.89453125' - ], - [ - 1495709914.925, - '7.89453125' - ], - [ - 1495709974.925, - '7.89453125' - ], - [ - 1495710034.925, - '7.89453125' - ], - [ - 1495710094.925, - '7.89453125' - ], - [ - 1495710154.925, - '7.89453125' - ], - [ - 1495710214.925, - '7.89453125' - ], - [ - 1495710274.925, - '7.89453125' - ], - [ - 1495710334.925, - '7.89453125' - ], - [ - 1495710394.925, - '7.89453125' - ], - [ - 1495710454.925, - '7.89453125' - ], - [ - 1495710514.925, - '7.89453125' - ], - [ - 1495710574.925, - '7.89453125' - ], - [ - 1495710634.925, - '7.89453125' - ], - [ - 1495710694.925, - '7.89453125' - ], - [ - 1495710754.925, - '7.89453125' - ], - [ - 1495710814.925, - '7.89453125' - ], - [ - 1495710874.925, - '7.89453125' - ], - [ - 1495710934.925, - '7.89453125' - ], - [ - 1495710994.925, - '7.89453125' - ], - [ - 1495711054.925, - '7.89453125' - ], - [ - 1495711114.925, - '7.89453125' - ], - [ - 1495711174.925, - '7.8515625' - ], - [ - 1495711234.925, - '7.8515625' - ], - [ - 1495711294.925, - '7.8515625' - ], - [ - 1495711354.925, - '7.8515625' - ], - [ - 1495711414.925, - '7.8515625' - ], - [ - 1495711474.925, - '7.8515625' - ], - [ - 1495711534.925, - '7.8515625' - ], - [ - 1495711594.925, - '7.8515625' - ], - [ - 1495711654.925, - '7.8515625' - ], - [ - 1495711714.925, - '7.8515625' - ], - [ - 1495711774.925, - '7.8515625' - ], - [ - 1495711834.925, - '7.8515625' - ], - [ - 1495711894.925, - '7.8515625' - ], - [ - 1495711954.925, - '7.8515625' - ], - [ - 1495712014.925, - '7.8515625' - ], - [ - 1495712074.925, - '7.8515625' - ], - [ - 1495712134.925, - '7.8515625' - ], - [ - 1495712194.925, - '7.8515625' - ], - [ - 1495712254.925, - '7.8515625' - ], - [ - 1495712314.925, - '7.8515625' - ], - [ - 1495712374.925, - '7.8515625' - ], - [ - 1495712434.925, - '7.83203125' - ], - [ - 1495712494.925, - '7.83203125' - ], - [ - 1495712554.925, - '7.83203125' - ], - [ - 1495712614.925, - '7.83203125' - ], - [ - 1495712674.925, - '7.83203125' - ], - [ - 1495712734.925, - '7.83203125' - ], - [ - 1495712794.925, - '7.83203125' - ], - [ - 1495712854.925, - '7.83203125' - ], - [ - 1495712914.925, - '7.83203125' - ], - [ - 1495712974.925, - '7.83203125' - ], - [ - 1495713034.925, - '7.83203125' - ], - [ - 1495713094.925, - '7.83203125' - ], - [ - 1495713154.925, - '7.83203125' - ], - [ - 1495713214.925, - '7.83203125' - ], - [ - 1495713274.925, - '7.83203125' - ], - [ - 1495713334.925, - '7.83203125' - ], - [ - 1495713394.925, - '7.8125' - ], - [ - 1495713454.925, - '7.8125' - ], - [ - 1495713514.925, - '7.8125' - ], - [ - 1495713574.925, - '7.8125' - ], - [ - 1495713634.925, - '7.8125' - ], - [ - 1495713694.925, - '7.8125' - ], - [ - 1495713754.925, - '7.8125' - ], - [ - 1495713814.925, - '7.8125' - ], - [ - 1495713874.925, - '7.8125' - ], - [ - 1495713934.925, - '7.8125' - ], - [ - 1495713994.925, - '7.8125' - ], - [ - 1495714054.925, - '7.8125' - ], - [ - 1495714114.925, - '7.8125' - ], - [ - 1495714174.925, - '7.8125' - ], - [ - 1495714234.925, - '7.8125' - ], - [ - 1495714294.925, - '7.8125' - ], - [ - 1495714354.925, - '7.80859375' - ], - [ - 1495714414.925, - '7.80859375' - ], - [ - 1495714474.925, - '7.80859375' - ], - [ - 1495714534.925, - '7.80859375' - ], - [ - 1495714594.925, - '7.80859375' - ], - [ - 1495714654.925, - '7.80859375' - ], - [ - 1495714714.925, - '7.80859375' - ], - [ - 1495714774.925, - '7.80859375' - ], - [ - 1495714834.925, - '7.80859375' - ], - [ - 1495714894.925, - '7.80859375' - ], - [ - 1495714954.925, - '7.80859375' - ], - [ - 1495715014.925, - '7.80859375' - ], - [ - 1495715074.925, - '7.80859375' - ], - [ - 1495715134.925, - '7.80859375' - ], - [ - 1495715194.925, - '7.80859375' - ], - [ - 1495715254.925, - '7.80859375' - ], - [ - 1495715314.925, - '7.80859375' - ], - [ - 1495715374.925, - '7.80859375' - ], - [ - 1495715434.925, - '7.80859375' - ], - [ - 1495715494.925, - '7.80859375' - ], - [ - 1495715554.925, - '7.80859375' - ], - [ - 1495715614.925, - '7.80859375' - ], - [ - 1495715674.925, - '7.80859375' - ], - [ - 1495715734.925, - '7.80859375' - ], - [ - 1495715794.925, - '7.80859375' - ], - [ - 1495715854.925, - '7.80859375' - ], - [ - 1495715914.925, - '7.80078125' - ], - [ - 1495715974.925, - '7.80078125' - ], - [ - 1495716034.925, - '7.80078125' - ], - [ - 1495716094.925, - '7.80078125' - ], - [ - 1495716154.925, - '7.80078125' - ], - [ - 1495716214.925, - '7.796875' - ], - [ - 1495716274.925, - '7.796875' - ], - [ - 1495716334.925, - '7.796875' - ], - [ - 1495716394.925, - '7.796875' - ], - [ - 1495716454.925, - '7.796875' - ], - [ - 1495716514.925, - '7.796875' - ], - [ - 1495716574.925, - '7.796875' - ], - [ - 1495716634.925, - '7.796875' - ], - [ - 1495716694.925, - '7.796875' - ], - [ - 1495716754.925, - '7.796875' - ], - [ - 1495716814.925, - '7.796875' - ], - [ - 1495716874.925, - '7.79296875' - ], - [ - 1495716934.925, - '7.79296875' - ], - [ - 1495716994.925, - '7.79296875' - ], - [ - 1495717054.925, - '7.79296875' - ], - [ - 1495717114.925, - '7.79296875' - ], - [ - 1495717174.925, - '7.7890625' - ], - [ - 1495717234.925, - '7.7890625' - ], - [ - 1495717294.925, - '7.7890625' - ], - [ - 1495717354.925, - '7.7890625' - ], - [ - 1495717414.925, - '7.7890625' - ], - [ - 1495717474.925, - '7.7890625' - ], - [ - 1495717534.925, - '7.7890625' - ], - [ - 1495717594.925, - '7.7890625' - ], - [ - 1495717654.925, - '7.7890625' - ], - [ - 1495717714.925, - '7.7890625' - ], - [ - 1495717774.925, - '7.7890625' - ], - [ - 1495717834.925, - '7.77734375' - ], - [ - 1495717894.925, - '7.77734375' - ], - [ - 1495717954.925, - '7.77734375' - ], - [ - 1495718014.925, - '7.77734375' - ], - [ - 1495718074.925, - '7.77734375' - ], - [ - 1495718134.925, - '7.7421875' - ], - [ - 1495718194.925, - '7.7421875' - ], - [ - 1495718254.925, - '7.7421875' - ], - [ - 1495718314.925, - '7.7421875' - ] - ] - } - ] - } - ] + metric: {}, + values: [ + [1495700554.925, '8.0390625'], + [1495700614.925, '8.0390625'], + [1495700674.925, '8.0390625'], + [1495700734.925, '8.0390625'], + [1495700794.925, '8.0390625'], + [1495700854.925, '8.0390625'], + [1495700914.925, '8.0390625'], + [1495700974.925, '8.0390625'], + [1495701034.925, '8.0390625'], + [1495701094.925, '8.0390625'], + [1495701154.925, '8.0390625'], + [1495701214.925, '8.0390625'], + [1495701274.925, '8.0390625'], + [1495701334.925, '8.0390625'], + [1495701394.925, '8.0390625'], + [1495701454.925, '8.0390625'], + [1495701514.925, '8.0390625'], + [1495701574.925, '8.0390625'], + [1495701634.925, '8.0390625'], + [1495701694.925, '8.0390625'], + [1495701754.925, '8.0390625'], + [1495701814.925, '8.0390625'], + [1495701874.925, '8.0390625'], + [1495701934.925, '8.0390625'], + [1495701994.925, '8.0390625'], + [1495702054.925, '8.0390625'], + [1495702114.925, '8.0390625'], + [1495702174.925, '8.0390625'], + [1495702234.925, '8.0390625'], + [1495702294.925, '8.0390625'], + [1495702354.925, '8.0390625'], + [1495702414.925, '8.0390625'], + [1495702474.925, '8.0390625'], + [1495702534.925, '8.0390625'], + [1495702594.925, '8.0390625'], + [1495702654.925, '8.0390625'], + [1495702714.925, '8.0390625'], + [1495702774.925, '8.0390625'], + [1495702834.925, '8.0390625'], + [1495702894.925, '8.0390625'], + [1495702954.925, '8.0390625'], + [1495703014.925, '8.0390625'], + [1495703074.925, '8.0390625'], + [1495703134.925, '8.0390625'], + [1495703194.925, '8.0390625'], + [1495703254.925, '8.03515625'], + [1495703314.925, '8.03515625'], + [1495703374.925, '8.03515625'], + [1495703434.925, '8.03515625'], + [1495703494.925, '8.03515625'], + [1495703554.925, '8.03515625'], + [1495703614.925, '8.03515625'], + [1495703674.925, '8.03515625'], + [1495703734.925, '8.03515625'], + [1495703794.925, '8.03515625'], + [1495703854.925, '8.03515625'], + [1495703914.925, '8.03515625'], + [1495703974.925, '8.03515625'], + [1495704034.925, '8.03515625'], + [1495704094.925, '8.03515625'], + [1495704154.925, '8.03515625'], + [1495704214.925, '7.9296875'], + [1495704274.925, '7.9296875'], + [1495704334.925, '7.9296875'], + [1495704394.925, '7.9296875'], + [1495704454.925, '7.9296875'], + [1495704514.925, '7.9296875'], + [1495704574.925, '7.9296875'], + [1495704634.925, '7.9296875'], + [1495704694.925, '7.9296875'], + [1495704754.925, '7.9296875'], + [1495704814.925, '7.9296875'], + [1495704874.925, '7.9296875'], + [1495704934.925, '7.9296875'], + [1495704994.925, '7.9296875'], + [1495705054.925, '7.9296875'], + [1495705114.925, '7.9296875'], + [1495705174.925, '7.9296875'], + [1495705234.925, '7.9296875'], + [1495705294.925, '7.9296875'], + [1495705354.925, '7.9296875'], + [1495705414.925, '7.9296875'], + [1495705474.925, '7.9296875'], + [1495705534.925, '7.9296875'], + [1495705594.925, '7.9296875'], + [1495705654.925, '7.9296875'], + [1495705714.925, '7.9296875'], + [1495705774.925, '7.9296875'], + [1495705834.925, '7.9296875'], + [1495705894.925, '7.9296875'], + [1495705954.925, '7.9296875'], + [1495706014.925, '7.9296875'], + [1495706074.925, '7.9296875'], + [1495706134.925, '7.9296875'], + [1495706194.925, '7.9296875'], + [1495706254.925, '7.9296875'], + [1495706314.925, '7.9296875'], + [1495706374.925, '7.9296875'], + [1495706434.925, '7.9296875'], + [1495706494.925, '7.9296875'], + [1495706554.925, '7.9296875'], + [1495706614.925, '7.9296875'], + [1495706674.925, '7.9296875'], + [1495706734.925, '7.9296875'], + [1495706794.925, '7.9296875'], + [1495706854.925, '7.9296875'], + [1495706914.925, '7.9296875'], + [1495706974.925, '7.9296875'], + [1495707034.925, '7.9296875'], + [1495707094.925, '7.9296875'], + [1495707154.925, '7.9296875'], + [1495707214.925, '7.9296875'], + [1495707274.925, '7.9296875'], + [1495707334.925, '7.9296875'], + [1495707394.925, '7.9296875'], + [1495707454.925, '7.9296875'], + [1495707514.925, '7.9296875'], + [1495707574.925, '7.9296875'], + [1495707634.925, '7.9296875'], + [1495707694.925, '7.9296875'], + [1495707754.925, '7.9296875'], + [1495707814.925, '7.9296875'], + [1495707874.925, '7.9296875'], + [1495707934.925, '7.9296875'], + [1495707994.925, '7.9296875'], + [1495708054.925, '7.9296875'], + [1495708114.925, '7.9296875'], + [1495708174.925, '7.9296875'], + [1495708234.925, '7.9296875'], + [1495708294.925, '7.9296875'], + [1495708354.925, '7.9296875'], + [1495708414.925, '7.9296875'], + [1495708474.925, '7.9296875'], + [1495708534.925, '7.9296875'], + [1495708594.925, '7.9296875'], + [1495708654.925, '7.9296875'], + [1495708714.925, '7.9296875'], + [1495708774.925, '7.9296875'], + [1495708834.925, '7.9296875'], + [1495708894.925, '7.9296875'], + [1495708954.925, '7.8984375'], + [1495709014.925, '7.8984375'], + [1495709074.925, '7.8984375'], + [1495709134.925, '7.8984375'], + [1495709194.925, '7.8984375'], + [1495709254.925, '7.89453125'], + [1495709314.925, '7.89453125'], + [1495709374.925, '7.89453125'], + [1495709434.925, '7.89453125'], + [1495709494.925, '7.89453125'], + [1495709554.925, '7.89453125'], + [1495709614.925, '7.89453125'], + [1495709674.925, '7.89453125'], + [1495709734.925, '7.89453125'], + [1495709794.925, '7.89453125'], + [1495709854.925, '7.89453125'], + [1495709914.925, '7.89453125'], + [1495709974.925, '7.89453125'], + [1495710034.925, '7.89453125'], + [1495710094.925, '7.89453125'], + [1495710154.925, '7.89453125'], + [1495710214.925, '7.89453125'], + [1495710274.925, '7.89453125'], + [1495710334.925, '7.89453125'], + [1495710394.925, '7.89453125'], + [1495710454.925, '7.89453125'], + [1495710514.925, '7.89453125'], + [1495710574.925, '7.89453125'], + [1495710634.925, '7.89453125'], + [1495710694.925, '7.89453125'], + [1495710754.925, '7.89453125'], + [1495710814.925, '7.89453125'], + [1495710874.925, '7.89453125'], + [1495710934.925, '7.89453125'], + [1495710994.925, '7.89453125'], + [1495711054.925, '7.89453125'], + [1495711114.925, '7.89453125'], + [1495711174.925, '7.8515625'], + [1495711234.925, '7.8515625'], + [1495711294.925, '7.8515625'], + [1495711354.925, '7.8515625'], + [1495711414.925, '7.8515625'], + [1495711474.925, '7.8515625'], + [1495711534.925, '7.8515625'], + [1495711594.925, '7.8515625'], + [1495711654.925, '7.8515625'], + [1495711714.925, '7.8515625'], + [1495711774.925, '7.8515625'], + [1495711834.925, '7.8515625'], + [1495711894.925, '7.8515625'], + [1495711954.925, '7.8515625'], + [1495712014.925, '7.8515625'], + [1495712074.925, '7.8515625'], + [1495712134.925, '7.8515625'], + [1495712194.925, '7.8515625'], + [1495712254.925, '7.8515625'], + [1495712314.925, '7.8515625'], + [1495712374.925, '7.8515625'], + [1495712434.925, '7.83203125'], + [1495712494.925, '7.83203125'], + [1495712554.925, '7.83203125'], + [1495712614.925, '7.83203125'], + [1495712674.925, '7.83203125'], + [1495712734.925, '7.83203125'], + [1495712794.925, '7.83203125'], + [1495712854.925, '7.83203125'], + [1495712914.925, '7.83203125'], + [1495712974.925, '7.83203125'], + [1495713034.925, '7.83203125'], + [1495713094.925, '7.83203125'], + [1495713154.925, '7.83203125'], + [1495713214.925, '7.83203125'], + [1495713274.925, '7.83203125'], + [1495713334.925, '7.83203125'], + [1495713394.925, '7.8125'], + [1495713454.925, '7.8125'], + [1495713514.925, '7.8125'], + [1495713574.925, '7.8125'], + [1495713634.925, '7.8125'], + [1495713694.925, '7.8125'], + [1495713754.925, '7.8125'], + [1495713814.925, '7.8125'], + [1495713874.925, '7.8125'], + [1495713934.925, '7.8125'], + [1495713994.925, '7.8125'], + [1495714054.925, '7.8125'], + [1495714114.925, '7.8125'], + [1495714174.925, '7.8125'], + [1495714234.925, '7.8125'], + [1495714294.925, '7.8125'], + [1495714354.925, '7.80859375'], + [1495714414.925, '7.80859375'], + [1495714474.925, '7.80859375'], + [1495714534.925, '7.80859375'], + [1495714594.925, '7.80859375'], + [1495714654.925, '7.80859375'], + [1495714714.925, '7.80859375'], + [1495714774.925, '7.80859375'], + [1495714834.925, '7.80859375'], + [1495714894.925, '7.80859375'], + [1495714954.925, '7.80859375'], + [1495715014.925, '7.80859375'], + [1495715074.925, '7.80859375'], + [1495715134.925, '7.80859375'], + [1495715194.925, '7.80859375'], + [1495715254.925, '7.80859375'], + [1495715314.925, '7.80859375'], + [1495715374.925, '7.80859375'], + [1495715434.925, '7.80859375'], + [1495715494.925, '7.80859375'], + [1495715554.925, '7.80859375'], + [1495715614.925, '7.80859375'], + [1495715674.925, '7.80859375'], + [1495715734.925, '7.80859375'], + [1495715794.925, '7.80859375'], + [1495715854.925, '7.80859375'], + [1495715914.925, '7.80078125'], + [1495715974.925, '7.80078125'], + [1495716034.925, '7.80078125'], + [1495716094.925, '7.80078125'], + [1495716154.925, '7.80078125'], + [1495716214.925, '7.796875'], + [1495716274.925, '7.796875'], + [1495716334.925, '7.796875'], + [1495716394.925, '7.796875'], + [1495716454.925, '7.796875'], + [1495716514.925, '7.796875'], + [1495716574.925, '7.796875'], + [1495716634.925, '7.796875'], + [1495716694.925, '7.796875'], + [1495716754.925, '7.796875'], + [1495716814.925, '7.796875'], + [1495716874.925, '7.79296875'], + [1495716934.925, '7.79296875'], + [1495716994.925, '7.79296875'], + [1495717054.925, '7.79296875'], + [1495717114.925, '7.79296875'], + [1495717174.925, '7.7890625'], + [1495717234.925, '7.7890625'], + [1495717294.925, '7.7890625'], + [1495717354.925, '7.7890625'], + [1495717414.925, '7.7890625'], + [1495717474.925, '7.7890625'], + [1495717534.925, '7.7890625'], + [1495717594.925, '7.7890625'], + [1495717654.925, '7.7890625'], + [1495717714.925, '7.7890625'], + [1495717774.925, '7.7890625'], + [1495717834.925, '7.77734375'], + [1495717894.925, '7.77734375'], + [1495717954.925, '7.77734375'], + [1495718014.925, '7.77734375'], + [1495718074.925, '7.77734375'], + [1495718134.925, '7.7421875'], + [1495718194.925, '7.7421875'], + [1495718254.925, '7.7421875'], + [1495718314.925, '7.7421875'], + ], + }, + ], + }, + ], }, { - 'title': 'CPU usage', - 'weight': 1, - 'queries': [ + title: 'CPU usage', + weight: 1, + queries: [ + { + query_range: + 'avg(rate(container_cpu_usage_seconds_total{%{environment_filter}}[2m])) * 100', + result: [ { - 'query_range': 'avg(rate(container_cpu_usage_seconds_total{%{environment_filter}}[2m])) * 100', - 'result': [ - { - 'metric': {}, - 'values': [ - [ - 1495700554.925, - '0.0010794445585559514' - ], - [ - 1495700614.925, - '0.003927214935433527' - ], - [ - 1495700674.925, - '0.0053045219047619975' - ], - [ - 1495700734.925, - '0.0048892095238097155' - ], - [ - 1495700794.925, - '0.005827140952381137' - ], - [ - 1495700854.925, - '0.00569846906219937' - ], - [ - 1495700914.925, - '0.004972616802849382' - ], - [ - 1495700974.925, - '0.005117509523809902' - ], - [ - 1495701034.925, - '0.00512389061919564' - ], - [ - 1495701094.925, - '0.005199100501890691' - ], - [ - 1495701154.925, - '0.005415746394885837' - ], - [ - 1495701214.925, - '0.005607682788146286' - ], - [ - 1495701274.925, - '0.005641300000000118' - ], - [ - 1495701334.925, - '0.0071166279368766495' - ], - [ - 1495701394.925, - '0.0063242138095234044' - ], - [ - 1495701454.925, - '0.005793314698235304' - ], - [ - 1495701514.925, - '0.00703934942237556' - ], - [ - 1495701574.925, - '0.006357007076123191' - ], - [ - 1495701634.925, - '0.003753167300126738' - ], - [ - 1495701694.925, - '0.005018469678430698' - ], - [ - 1495701754.925, - '0.0045217153371887' - ], - [ - 1495701814.925, - '0.006140104285714119' - ], - [ - 1495701874.925, - '0.004818684285714102' - ], - [ - 1495701934.925, - '0.005079509718955242' - ], - [ - 1495701994.925, - '0.005059981142498263' - ], - [ - 1495702054.925, - '0.005269098389538773' - ], - [ - 1495702114.925, - '0.005269954285714175' - ], - [ - 1495702174.925, - '0.014199241435795856' - ], - [ - 1495702234.925, - '0.01511936843111017' - ], - [ - 1495702294.925, - '0.0060933692920682875' - ], - [ - 1495702354.925, - '0.004945682380952493' - ], - [ - 1495702414.925, - '0.005641266666666565' - ], - [ - 1495702474.925, - '0.005223752857142996' - ], - [ - 1495702534.925, - '0.005743098505699831' - ], - [ - 1495702594.925, - '0.00538493380952391' - ], - [ - 1495702654.925, - '0.005507793883751339' - ], - [ - 1495702714.925, - '0.005666705714285466' - ], - [ - 1495702774.925, - '0.006231530000000112' - ], - [ - 1495702834.925, - '0.006570768635394899' - ], - [ - 1495702894.925, - '0.005551146666666895' - ], - [ - 1495702954.925, - '0.005602604737098058' - ], - [ - 1495703014.925, - '0.00613993580402159' - ], - [ - 1495703074.925, - '0.004770258764368832' - ], - [ - 1495703134.925, - '0.005512376671364914' - ], - [ - 1495703194.925, - '0.005254436666666674' - ], - [ - 1495703254.925, - '0.0050109839141320505' - ], - [ - 1495703314.925, - '0.0049478019256960016' - ], - [ - 1495703374.925, - '0.0037666860965123463' - ], - [ - 1495703434.925, - '0.004813526061656314' - ], - [ - 1495703494.925, - '0.005047748095238278' - ], - [ - 1495703554.925, - '0.00386494081008772' - ], - [ - 1495703614.925, - '0.004304037408111405' - ], - [ - 1495703674.925, - '0.004999466661587168' - ], - [ - 1495703734.925, - '0.004689140476190834' - ], - [ - 1495703794.925, - '0.004746126153582475' - ], - [ - 1495703854.925, - '0.004482706382572302' - ], - [ - 1495703914.925, - '0.004032808931864524' - ], - [ - 1495703974.925, - '0.005728319047618988' - ], - [ - 1495704034.925, - '0.004436139179627006' - ], - [ - 1495704094.925, - '0.004553455714285617' - ], - [ - 1495704154.925, - '0.003455244285714341' - ], - [ - 1495704214.925, - '0.004742244761904621' - ], - [ - 1495704274.925, - '0.005366978571428422' - ], - [ - 1495704334.925, - '0.004257954837665058' - ], - [ - 1495704394.925, - '0.005431603259831257' - ], - [ - 1495704454.925, - '0.0052009214498621986' - ], - [ - 1495704514.925, - '0.004317201904761618' - ], - [ - 1495704574.925, - '0.004307384285714157' - ], - [ - 1495704634.925, - '0.004789801146644822' - ], - [ - 1495704694.925, - '0.0051429795906706485' - ], - [ - 1495704754.925, - '0.005322495714285479' - ], - [ - 1495704814.925, - '0.004512809333244233' - ], - [ - 1495704874.925, - '0.004953843582568726' - ], - [ - 1495704934.925, - '0.005812690120858119' - ], - [ - 1495704994.925, - '0.004997024285714838' - ], - [ - 1495705054.925, - '0.005246216154439592' - ], - [ - 1495705114.925, - '0.0063494966618726795' - ], - [ - 1495705174.925, - '0.005306004342898225' - ], - [ - 1495705234.925, - '0.005081412857142978' - ], - [ - 1495705294.925, - '0.00511409523809522' - ], - [ - 1495705354.925, - '0.0047861001481192' - ], - [ - 1495705414.925, - '0.005107688228042962' - ], - [ - 1495705474.925, - '0.005271929582294012' - ], - [ - 1495705534.925, - '0.004453254502681249' - ], - [ - 1495705594.925, - '0.005799134293959226' - ], - [ - 1495705654.925, - '0.005340865929502478' - ], - [ - 1495705714.925, - '0.004911654761904942' - ], - [ - 1495705774.925, - '0.005888234873953261' - ], - [ - 1495705834.925, - '0.005565283333332954' - ], - [ - 1495705894.925, - '0.005522869047618869' - ], - [ - 1495705954.925, - '0.005177549737621646' - ], - [ - 1495706014.925, - '0.0053145810232096465' - ], - [ - 1495706074.925, - '0.004751095238095275' - ], - [ - 1495706134.925, - '0.006242077142856976' - ], - [ - 1495706194.925, - '0.00621034406957871' - ], - [ - 1495706254.925, - '0.006887592738978596' - ], - [ - 1495706314.925, - '0.006328128779726213' - ], - [ - 1495706374.925, - '0.007488363809523927' - ], - [ - 1495706434.925, - '0.006193758571428157' - ], - [ - 1495706494.925, - '0.0068798371839706935' - ], - [ - 1495706554.925, - '0.005757034340423128' - ], - [ - 1495706614.925, - '0.004571388497294698' - ], - [ - 1495706674.925, - '0.00620283044923395' - ], - [ - 1495706734.925, - '0.005607562380952455' - ], - [ - 1495706794.925, - '0.005506969933620308' - ], - [ - 1495706854.925, - '0.005621118095238131' - ], - [ - 1495706914.925, - '0.004876606098698849' - ], - [ - 1495706974.925, - '0.0047871205988517206' - ], - [ - 1495707034.925, - '0.00526405939458784' - ], - [ - 1495707094.925, - '0.005716323800605852' - ], - [ - 1495707154.925, - '0.005301459523809575' - ], - [ - 1495707214.925, - '0.0051613042857144905' - ], - [ - 1495707274.925, - '0.005384792857142714' - ], - [ - 1495707334.925, - '0.005259719047619222' - ], - [ - 1495707394.925, - '0.00584101142857182' - ], - [ - 1495707454.925, - '0.0060066121920326326' - ], - [ - 1495707514.925, - '0.006359978571428453' - ], - [ - 1495707574.925, - '0.006315876322151109' - ], - [ - 1495707634.925, - '0.005590012517198831' - ], - [ - 1495707694.925, - '0.005517419877137072' - ], - [ - 1495707754.925, - '0.006089813430348506' - ], - [ - 1495707814.925, - '0.00466754476190479' - ], - [ - 1495707874.925, - '0.006059954380517721' - ], - [ - 1495707934.925, - '0.005085657142856972' - ], - [ - 1495707994.925, - '0.005897665238095296' - ], - [ - 1495708054.925, - '0.0062282023199555885' - ], - [ - 1495708114.925, - '0.00526214553236979' - ], - [ - 1495708174.925, - '0.0044803300000000644' - ], - [ - 1495708234.925, - '0.005421443333333592' - ], - [ - 1495708294.925, - '0.005694326244512144' - ], - [ - 1495708354.925, - '0.005527721904761457' - ], - [ - 1495708414.925, - '0.005988819523809819' - ], - [ - 1495708474.925, - '0.005484704285714448' - ], - [ - 1495708534.925, - '0.005041123649230085' - ], - [ - 1495708594.925, - '0.005717767639612059' - ], - [ - 1495708654.925, - '0.005412954417342863' - ], - [ - 1495708714.925, - '0.005833343333333254' - ], - [ - 1495708774.925, - '0.005448135238094969' - ], - [ - 1495708834.925, - '0.005117341428571432' - ], - [ - 1495708894.925, - '0.005888345825277833' - ], - [ - 1495708954.925, - '0.005398543809524135' - ], - [ - 1495709014.925, - '0.005325611428571416' - ], - [ - 1495709074.925, - '0.005848668571428527' - ], - [ - 1495709134.925, - '0.005135003105145044' - ], - [ - 1495709194.925, - '0.0054551400000003' - ], - [ - 1495709254.925, - '0.005319472937322171' - ], - [ - 1495709314.925, - '0.00585677857142792' - ], - [ - 1495709374.925, - '0.0062146261904759215' - ], - [ - 1495709434.925, - '0.0067105060904182265' - ], - [ - 1495709494.925, - '0.005829691904762108' - ], - [ - 1495709554.925, - '0.005719280952381261' - ], - [ - 1495709614.925, - '0.005682603793416407' - ], - [ - 1495709674.925, - '0.0055272846277326934' - ], - [ - 1495709734.925, - '0.0057123680952386735' - ], - [ - 1495709794.925, - '0.00520597958075818' - ], - [ - 1495709854.925, - '0.005584358957263837' - ], - [ - 1495709914.925, - '0.005601104275197466' - ], - [ - 1495709974.925, - '0.005991657142857066' - ], - [ - 1495710034.925, - '0.00553722238095218' - ], - [ - 1495710094.925, - '0.005127883122696293' - ], - [ - 1495710154.925, - '0.005498111927534584' - ], - [ - 1495710214.925, - '0.005609934069084202' - ], - [ - 1495710274.925, - '0.00459206285714307' - ], - [ - 1495710334.925, - '0.0047910828571428084' - ], - [ - 1495710394.925, - '0.0056014671288845685' - ], - [ - 1495710454.925, - '0.005686936791078528' - ], - [ - 1495710514.925, - '0.00444480476190448' - ], - [ - 1495710574.925, - '0.005780394696738921' - ], - [ - 1495710634.925, - '0.0053107227550210365' - ], - [ - 1495710694.925, - '0.005096031495761817' - ], - [ - 1495710754.925, - '0.005451377979091524' - ], - [ - 1495710814.925, - '0.005328136666667083' - ], - [ - 1495710874.925, - '0.006020612857143043' - ], - [ - 1495710934.925, - '0.0061063585714285365' - ], - [ - 1495710994.925, - '0.006018346015752312' - ], - [ - 1495711054.925, - '0.005069130952381193' - ], - [ - 1495711114.925, - '0.005458406190476052' - ], - [ - 1495711174.925, - '0.00577219190476179' - ], - [ - 1495711234.925, - '0.005760814645658314' - ], - [ - 1495711294.925, - '0.005371875716579101' - ], - [ - 1495711354.925, - '0.0064232666666665834' - ], - [ - 1495711414.925, - '0.009369806836906667' - ], - [ - 1495711474.925, - '0.008956864761904692' - ], - [ - 1495711534.925, - '0.005266849368559271' - ], - [ - 1495711594.925, - '0.005335111364934262' - ], - [ - 1495711654.925, - '0.006461778319586945' - ], - [ - 1495711714.925, - '0.004687939890762393' - ], - [ - 1495711774.925, - '0.004438831245760684' - ], - [ - 1495711834.925, - '0.005142786666666613' - ], - [ - 1495711894.925, - '0.007257734212054963' - ], - [ - 1495711954.925, - '0.005621991904761494' - ], - [ - 1495712014.925, - '0.007868689999999862' - ], - [ - 1495712074.925, - '0.00910970215275738' - ], - [ - 1495712134.925, - '0.006151004285714278' - ], - [ - 1495712194.925, - '0.005447120924961522' - ], - [ - 1495712254.925, - '0.005150705153929503' - ], - [ - 1495712314.925, - '0.006358108714969314' - ], - [ - 1495712374.925, - '0.0057725354795696475' - ], - [ - 1495712434.925, - '0.005232139047619015' - ], - [ - 1495712494.925, - '0.004932809617949037' - ], - [ - 1495712554.925, - '0.004511607508499662' - ], - [ - 1495712614.925, - '0.00440487701522666' - ], - [ - 1495712674.925, - '0.005479113333333174' - ], - [ - 1495712734.925, - '0.004726317619047547' - ], - [ - 1495712794.925, - '0.005582041102958029' - ], - [ - 1495712854.925, - '0.006381481216082099' - ], - [ - 1495712914.925, - '0.005474260014095208' - ], - [ - 1495712974.925, - '0.00567597142857188' - ], - [ - 1495713034.925, - '0.0064741233333332985' - ], - [ - 1495713094.925, - '0.005467475714285271' - ], - [ - 1495713154.925, - '0.004868648393824457' - ], - [ - 1495713214.925, - '0.005254923286444893' - ], - [ - 1495713274.925, - '0.005599217150312865' - ], - [ - 1495713334.925, - '0.005105413720618919' - ], - [ - 1495713394.925, - '0.007246073333333279' - ], - [ - 1495713454.925, - '0.005990312380952272' - ], - [ - 1495713514.925, - '0.005594601853351101' - ], - [ - 1495713574.925, - '0.004739258673727054' - ], - [ - 1495713634.925, - '0.003932121428571783' - ], - [ - 1495713694.925, - '0.005018188268459395' - ], - [ - 1495713754.925, - '0.004538238095237985' - ], - [ - 1495713814.925, - '0.00561816643265435' - ], - [ - 1495713874.925, - '0.0063132584495033586' - ], - [ - 1495713934.925, - '0.00442385238095213' - ], - [ - 1495713994.925, - '0.004181795887658453' - ], - [ - 1495714054.925, - '0.004437759047619037' - ], - [ - 1495714114.925, - '0.006421748157178241' - ], - [ - 1495714174.925, - '0.006525143809523842' - ], - [ - 1495714234.925, - '0.004715904935144247' - ], - [ - 1495714294.925, - '0.005966040152763461' - ], - [ - 1495714354.925, - '0.005614535466921674' - ], - [ - 1495714414.925, - '0.004934375119415906' - ], - [ - 1495714474.925, - '0.0054122933333327385' - ], - [ - 1495714534.925, - '0.004926540699612279' - ], - [ - 1495714594.925, - '0.006124649517134237' - ], - [ - 1495714654.925, - '0.004629427092013995' - ], - [ - 1495714714.925, - '0.005117951257607005' - ], - [ - 1495714774.925, - '0.004868774512685422' - ], - [ - 1495714834.925, - '0.005310093333333399' - ], - [ - 1495714894.925, - '0.0054907752286127345' - ], - [ - 1495714954.925, - '0.004597678117351089' - ], - [ - 1495715014.925, - '0.0059622552380952' - ], - [ - 1495715074.925, - '0.005352457072655368' - ], - [ - 1495715134.925, - '0.005491630952381143' - ], - [ - 1495715194.925, - '0.006391770078379791' - ], - [ - 1495715254.925, - '0.005933472857142518' - ], - [ - 1495715314.925, - '0.005301314285714163' - ], - [ - 1495715374.925, - '0.0058352959724814165' - ], - [ - 1495715434.925, - '0.006154755147867044' - ], - [ - 1495715494.925, - '0.009391935637482038' - ], - [ - 1495715554.925, - '0.007846462857142592' - ], - [ - 1495715614.925, - '0.00477608215316353' - ], - [ - 1495715674.925, - '0.006132865238094998' - ], - [ - 1495715734.925, - '0.006159762457649516' - ], - [ - 1495715794.925, - '0.005957307073265968' - ], - [ - 1495715854.925, - '0.006652319091792501' - ], - [ - 1495715914.925, - '0.005493557402895287' - ], - [ - 1495715974.925, - '0.0058652434829145166' - ], - [ - 1495716034.925, - '0.005627400430468021' - ], - [ - 1495716094.925, - '0.006240656190475609' - ], - [ - 1495716154.925, - '0.006305997676168624' - ], - [ - 1495716214.925, - '0.005388057732783248' - ], - [ - 1495716274.925, - '0.0052814916048421244' - ], - [ - 1495716334.925, - '0.00699498614272497' - ], - [ - 1495716394.925, - '0.00627768693035141' - ], - [ - 1495716454.925, - '0.0042411487048161145' - ], - [ - 1495716514.925, - '0.005348647473627653' - ], - [ - 1495716574.925, - '0.0047176657142853975' - ], - [ - 1495716634.925, - '0.004437898571428686' - ], - [ - 1495716694.925, - '0.004923527366927261' - ], - [ - 1495716754.925, - '0.005131935066048421' - ], - [ - 1495716814.925, - '0.005046949523809611' - ], - [ - 1495716874.925, - '0.00547184095238092' - ], - [ - 1495716934.925, - '0.005224140016380444' - ], - [ - 1495716994.925, - '0.005297991171665292' - ], - [ - 1495717054.925, - '0.005492965995623498' - ], - [ - 1495717114.925, - '0.005754660000000403' - ], - [ - 1495717174.925, - '0.005949557138639285' - ], - [ - 1495717234.925, - '0.006091816112534666' - ], - [ - 1495717294.925, - '0.005554210080192063' - ], - [ - 1495717354.925, - '0.006411504395279871' - ], - [ - 1495717414.925, - '0.006319643996609606' - ], - [ - 1495717474.925, - '0.005539174405717675' - ], - [ - 1495717534.925, - '0.0053157078842772255' - ], - [ - 1495717594.925, - '0.005247480952381066' - ], - [ - 1495717654.925, - '0.004820141620396252' - ], - [ - 1495717714.925, - '0.005906173868322844' - ], - [ - 1495717774.925, - '0.006173117219570961' - ], - [ - 1495717834.925, - '0.005963340952380661' - ], - [ - 1495717894.925, - '0.005698976627681527' - ], - [ - 1495717954.925, - '0.004751279096346378' - ], - [ - 1495718014.925, - '0.005733142379359711' - ], - [ - 1495718074.925, - '0.004831689010348035' - ], - [ - 1495718134.925, - '0.005188370476191092' - ], - [ - 1495718194.925, - '0.004793227554547938' - ], - [ - 1495718254.925, - '0.003997442857142731' - ], - [ - 1495718314.925, - '0.004386040132951264' - ] - ] - } - ] - } - ] - } - ] - } + metric: {}, + values: [ + [1495700554.925, '0.0010794445585559514'], + [1495700614.925, '0.003927214935433527'], + [1495700674.925, '0.0053045219047619975'], + [1495700734.925, '0.0048892095238097155'], + [1495700794.925, '0.005827140952381137'], + [1495700854.925, '0.00569846906219937'], + [1495700914.925, '0.004972616802849382'], + [1495700974.925, '0.005117509523809902'], + [1495701034.925, '0.00512389061919564'], + [1495701094.925, '0.005199100501890691'], + [1495701154.925, '0.005415746394885837'], + [1495701214.925, '0.005607682788146286'], + [1495701274.925, '0.005641300000000118'], + [1495701334.925, '0.0071166279368766495'], + [1495701394.925, '0.0063242138095234044'], + [1495701454.925, '0.005793314698235304'], + [1495701514.925, '0.00703934942237556'], + [1495701574.925, '0.006357007076123191'], + [1495701634.925, '0.003753167300126738'], + [1495701694.925, '0.005018469678430698'], + [1495701754.925, '0.0045217153371887'], + [1495701814.925, '0.006140104285714119'], + [1495701874.925, '0.004818684285714102'], + [1495701934.925, '0.005079509718955242'], + [1495701994.925, '0.005059981142498263'], + [1495702054.925, '0.005269098389538773'], + [1495702114.925, '0.005269954285714175'], + [1495702174.925, '0.014199241435795856'], + [1495702234.925, '0.01511936843111017'], + [1495702294.925, '0.0060933692920682875'], + [1495702354.925, '0.004945682380952493'], + [1495702414.925, '0.005641266666666565'], + [1495702474.925, '0.005223752857142996'], + [1495702534.925, '0.005743098505699831'], + [1495702594.925, '0.00538493380952391'], + [1495702654.925, '0.005507793883751339'], + [1495702714.925, '0.005666705714285466'], + [1495702774.925, '0.006231530000000112'], + [1495702834.925, '0.006570768635394899'], + [1495702894.925, '0.005551146666666895'], + [1495702954.925, '0.005602604737098058'], + [1495703014.925, '0.00613993580402159'], + [1495703074.925, '0.004770258764368832'], + [1495703134.925, '0.005512376671364914'], + [1495703194.925, '0.005254436666666674'], + [1495703254.925, '0.0050109839141320505'], + [1495703314.925, '0.0049478019256960016'], + [1495703374.925, '0.0037666860965123463'], + [1495703434.925, '0.004813526061656314'], + [1495703494.925, '0.005047748095238278'], + [1495703554.925, '0.00386494081008772'], + [1495703614.925, '0.004304037408111405'], + [1495703674.925, '0.004999466661587168'], + [1495703734.925, '0.004689140476190834'], + [1495703794.925, '0.004746126153582475'], + [1495703854.925, '0.004482706382572302'], + [1495703914.925, '0.004032808931864524'], + [1495703974.925, '0.005728319047618988'], + [1495704034.925, '0.004436139179627006'], + [1495704094.925, '0.004553455714285617'], + [1495704154.925, '0.003455244285714341'], + [1495704214.925, '0.004742244761904621'], + [1495704274.925, '0.005366978571428422'], + [1495704334.925, '0.004257954837665058'], + [1495704394.925, '0.005431603259831257'], + [1495704454.925, '0.0052009214498621986'], + [1495704514.925, '0.004317201904761618'], + [1495704574.925, '0.004307384285714157'], + [1495704634.925, '0.004789801146644822'], + [1495704694.925, '0.0051429795906706485'], + [1495704754.925, '0.005322495714285479'], + [1495704814.925, '0.004512809333244233'], + [1495704874.925, '0.004953843582568726'], + [1495704934.925, '0.005812690120858119'], + [1495704994.925, '0.004997024285714838'], + [1495705054.925, '0.005246216154439592'], + [1495705114.925, '0.0063494966618726795'], + [1495705174.925, '0.005306004342898225'], + [1495705234.925, '0.005081412857142978'], + [1495705294.925, '0.00511409523809522'], + [1495705354.925, '0.0047861001481192'], + [1495705414.925, '0.005107688228042962'], + [1495705474.925, '0.005271929582294012'], + [1495705534.925, '0.004453254502681249'], + [1495705594.925, '0.005799134293959226'], + [1495705654.925, '0.005340865929502478'], + [1495705714.925, '0.004911654761904942'], + [1495705774.925, '0.005888234873953261'], + [1495705834.925, '0.005565283333332954'], + [1495705894.925, '0.005522869047618869'], + [1495705954.925, '0.005177549737621646'], + [1495706014.925, '0.0053145810232096465'], + [1495706074.925, '0.004751095238095275'], + [1495706134.925, '0.006242077142856976'], + [1495706194.925, '0.00621034406957871'], + [1495706254.925, '0.006887592738978596'], + [1495706314.925, '0.006328128779726213'], + [1495706374.925, '0.007488363809523927'], + [1495706434.925, '0.006193758571428157'], + [1495706494.925, '0.0068798371839706935'], + [1495706554.925, '0.005757034340423128'], + [1495706614.925, '0.004571388497294698'], + [1495706674.925, '0.00620283044923395'], + [1495706734.925, '0.005607562380952455'], + [1495706794.925, '0.005506969933620308'], + [1495706854.925, '0.005621118095238131'], + [1495706914.925, '0.004876606098698849'], + [1495706974.925, '0.0047871205988517206'], + [1495707034.925, '0.00526405939458784'], + [1495707094.925, '0.005716323800605852'], + [1495707154.925, '0.005301459523809575'], + [1495707214.925, '0.0051613042857144905'], + [1495707274.925, '0.005384792857142714'], + [1495707334.925, '0.005259719047619222'], + [1495707394.925, '0.00584101142857182'], + [1495707454.925, '0.0060066121920326326'], + [1495707514.925, '0.006359978571428453'], + [1495707574.925, '0.006315876322151109'], + [1495707634.925, '0.005590012517198831'], + [1495707694.925, '0.005517419877137072'], + [1495707754.925, '0.006089813430348506'], + [1495707814.925, '0.00466754476190479'], + [1495707874.925, '0.006059954380517721'], + [1495707934.925, '0.005085657142856972'], + [1495707994.925, '0.005897665238095296'], + [1495708054.925, '0.0062282023199555885'], + [1495708114.925, '0.00526214553236979'], + [1495708174.925, '0.0044803300000000644'], + [1495708234.925, '0.005421443333333592'], + [1495708294.925, '0.005694326244512144'], + [1495708354.925, '0.005527721904761457'], + [1495708414.925, '0.005988819523809819'], + [1495708474.925, '0.005484704285714448'], + [1495708534.925, '0.005041123649230085'], + [1495708594.925, '0.005717767639612059'], + [1495708654.925, '0.005412954417342863'], + [1495708714.925, '0.005833343333333254'], + [1495708774.925, '0.005448135238094969'], + [1495708834.925, '0.005117341428571432'], + [1495708894.925, '0.005888345825277833'], + [1495708954.925, '0.005398543809524135'], + [1495709014.925, '0.005325611428571416'], + [1495709074.925, '0.005848668571428527'], + [1495709134.925, '0.005135003105145044'], + [1495709194.925, '0.0054551400000003'], + [1495709254.925, '0.005319472937322171'], + [1495709314.925, '0.00585677857142792'], + [1495709374.925, '0.0062146261904759215'], + [1495709434.925, '0.0067105060904182265'], + [1495709494.925, '0.005829691904762108'], + [1495709554.925, '0.005719280952381261'], + [1495709614.925, '0.005682603793416407'], + [1495709674.925, '0.0055272846277326934'], + [1495709734.925, '0.0057123680952386735'], + [1495709794.925, '0.00520597958075818'], + [1495709854.925, '0.005584358957263837'], + [1495709914.925, '0.005601104275197466'], + [1495709974.925, '0.005991657142857066'], + [1495710034.925, '0.00553722238095218'], + [1495710094.925, '0.005127883122696293'], + [1495710154.925, '0.005498111927534584'], + [1495710214.925, '0.005609934069084202'], + [1495710274.925, '0.00459206285714307'], + [1495710334.925, '0.0047910828571428084'], + [1495710394.925, '0.0056014671288845685'], + [1495710454.925, '0.005686936791078528'], + [1495710514.925, '0.00444480476190448'], + [1495710574.925, '0.005780394696738921'], + [1495710634.925, '0.0053107227550210365'], + [1495710694.925, '0.005096031495761817'], + [1495710754.925, '0.005451377979091524'], + [1495710814.925, '0.005328136666667083'], + [1495710874.925, '0.006020612857143043'], + [1495710934.925, '0.0061063585714285365'], + [1495710994.925, '0.006018346015752312'], + [1495711054.925, '0.005069130952381193'], + [1495711114.925, '0.005458406190476052'], + [1495711174.925, '0.00577219190476179'], + [1495711234.925, '0.005760814645658314'], + [1495711294.925, '0.005371875716579101'], + [1495711354.925, '0.0064232666666665834'], + [1495711414.925, '0.009369806836906667'], + [1495711474.925, '0.008956864761904692'], + [1495711534.925, '0.005266849368559271'], + [1495711594.925, '0.005335111364934262'], + [1495711654.925, '0.006461778319586945'], + [1495711714.925, '0.004687939890762393'], + [1495711774.925, '0.004438831245760684'], + [1495711834.925, '0.005142786666666613'], + [1495711894.925, '0.007257734212054963'], + [1495711954.925, '0.005621991904761494'], + [1495712014.925, '0.007868689999999862'], + [1495712074.925, '0.00910970215275738'], + [1495712134.925, '0.006151004285714278'], + [1495712194.925, '0.005447120924961522'], + [1495712254.925, '0.005150705153929503'], + [1495712314.925, '0.006358108714969314'], + [1495712374.925, '0.0057725354795696475'], + [1495712434.925, '0.005232139047619015'], + [1495712494.925, '0.004932809617949037'], + [1495712554.925, '0.004511607508499662'], + [1495712614.925, '0.00440487701522666'], + [1495712674.925, '0.005479113333333174'], + [1495712734.925, '0.004726317619047547'], + [1495712794.925, '0.005582041102958029'], + [1495712854.925, '0.006381481216082099'], + [1495712914.925, '0.005474260014095208'], + [1495712974.925, '0.00567597142857188'], + [1495713034.925, '0.0064741233333332985'], + [1495713094.925, '0.005467475714285271'], + [1495713154.925, '0.004868648393824457'], + [1495713214.925, '0.005254923286444893'], + [1495713274.925, '0.005599217150312865'], + [1495713334.925, '0.005105413720618919'], + [1495713394.925, '0.007246073333333279'], + [1495713454.925, '0.005990312380952272'], + [1495713514.925, '0.005594601853351101'], + [1495713574.925, '0.004739258673727054'], + [1495713634.925, '0.003932121428571783'], + [1495713694.925, '0.005018188268459395'], + [1495713754.925, '0.004538238095237985'], + [1495713814.925, '0.00561816643265435'], + [1495713874.925, '0.0063132584495033586'], + [1495713934.925, '0.00442385238095213'], + [1495713994.925, '0.004181795887658453'], + [1495714054.925, '0.004437759047619037'], + [1495714114.925, '0.006421748157178241'], + [1495714174.925, '0.006525143809523842'], + [1495714234.925, '0.004715904935144247'], + [1495714294.925, '0.005966040152763461'], + [1495714354.925, '0.005614535466921674'], + [1495714414.925, '0.004934375119415906'], + [1495714474.925, '0.0054122933333327385'], + [1495714534.925, '0.004926540699612279'], + [1495714594.925, '0.006124649517134237'], + [1495714654.925, '0.004629427092013995'], + [1495714714.925, '0.005117951257607005'], + [1495714774.925, '0.004868774512685422'], + [1495714834.925, '0.005310093333333399'], + [1495714894.925, '0.0054907752286127345'], + [1495714954.925, '0.004597678117351089'], + [1495715014.925, '0.0059622552380952'], + [1495715074.925, '0.005352457072655368'], + [1495715134.925, '0.005491630952381143'], + [1495715194.925, '0.006391770078379791'], + [1495715254.925, '0.005933472857142518'], + [1495715314.925, '0.005301314285714163'], + [1495715374.925, '0.0058352959724814165'], + [1495715434.925, '0.006154755147867044'], + [1495715494.925, '0.009391935637482038'], + [1495715554.925, '0.007846462857142592'], + [1495715614.925, '0.00477608215316353'], + [1495715674.925, '0.006132865238094998'], + [1495715734.925, '0.006159762457649516'], + [1495715794.925, '0.005957307073265968'], + [1495715854.925, '0.006652319091792501'], + [1495715914.925, '0.005493557402895287'], + [1495715974.925, '0.0058652434829145166'], + [1495716034.925, '0.005627400430468021'], + [1495716094.925, '0.006240656190475609'], + [1495716154.925, '0.006305997676168624'], + [1495716214.925, '0.005388057732783248'], + [1495716274.925, '0.0052814916048421244'], + [1495716334.925, '0.00699498614272497'], + [1495716394.925, '0.00627768693035141'], + [1495716454.925, '0.0042411487048161145'], + [1495716514.925, '0.005348647473627653'], + [1495716574.925, '0.0047176657142853975'], + [1495716634.925, '0.004437898571428686'], + [1495716694.925, '0.004923527366927261'], + [1495716754.925, '0.005131935066048421'], + [1495716814.925, '0.005046949523809611'], + [1495716874.925, '0.00547184095238092'], + [1495716934.925, '0.005224140016380444'], + [1495716994.925, '0.005297991171665292'], + [1495717054.925, '0.005492965995623498'], + [1495717114.925, '0.005754660000000403'], + [1495717174.925, '0.005949557138639285'], + [1495717234.925, '0.006091816112534666'], + [1495717294.925, '0.005554210080192063'], + [1495717354.925, '0.006411504395279871'], + [1495717414.925, '0.006319643996609606'], + [1495717474.925, '0.005539174405717675'], + [1495717534.925, '0.0053157078842772255'], + [1495717594.925, '0.005247480952381066'], + [1495717654.925, '0.004820141620396252'], + [1495717714.925, '0.005906173868322844'], + [1495717774.925, '0.006173117219570961'], + [1495717834.925, '0.005963340952380661'], + [1495717894.925, '0.005698976627681527'], + [1495717954.925, '0.004751279096346378'], + [1495718014.925, '0.005733142379359711'], + [1495718074.925, '0.004831689010348035'], + [1495718134.925, '0.005188370476191092'], + [1495718194.925, '0.004793227554547938'], + [1495718254.925, '0.003997442857142731'], + [1495718314.925, '0.004386040132951264'], + ], + }, + ], + }, + ], + }, + ], + }, ], - 'last_update': '2017-05-25T13:18:34.949Z' + last_update: '2017-05-25T13:18:34.949Z', }; export default metricsGroupsAPIResponse; @@ -2432,41 +651,44 @@ export const deploymentData = [ id: 111, iid: 3, sha: 'f5bcd1d9dac6fa4137e2510b9ccd134ef2e84187', - commitUrl: 'http://test.host/frontend-fixtures/environments-project/commit/f5bcd1d9dac6fa4137e2510b9ccd134ef2e84187', + commitUrl: + 'http://test.host/frontend-fixtures/environments-project/commit/f5bcd1d9dac6fa4137e2510b9ccd134ef2e84187', ref: { - name: 'master' + name: 'master', }, created_at: '2017-05-31T21:23:37.881Z', tag: false, tagUrl: 'http://test.host/frontend-fixtures/environments-project/tags/false', - 'last?': true + 'last?': true, }, { id: 110, iid: 2, sha: 'f5bcd1d9dac6fa4137e2510b9ccd134ef2e84187', - commitUrl: 'http://test.host/frontend-fixtures/environments-project/commit/f5bcd1d9dac6fa4137e2510b9ccd134ef2e84187', + commitUrl: + 'http://test.host/frontend-fixtures/environments-project/commit/f5bcd1d9dac6fa4137e2510b9ccd134ef2e84187', ref: { - name: 'master' + name: 'master', }, created_at: '2017-05-30T20:08:04.629Z', tag: false, - tagUrl: 'http://test.host/frontend-fixtures/environments-project/tags/false', - 'last?': false + tagUrl: 'http://test.host/frontend-fixtures/environments-project/tags/false', + 'last?': false, }, { id: 109, iid: 1, sha: '6511e58faafaa7ad2228990ec57f19d66f7db7c2', - commitUrl: 'http://test.host/frontend-fixtures/environments-project/commit/6511e58faafaa7ad2228990ec57f19d66f7db7c2', + commitUrl: + 'http://test.host/frontend-fixtures/environments-project/commit/6511e58faafaa7ad2228990ec57f19d66f7db7c2', ref: { - name: 'update2-readme' + name: 'update2-readme', }, created_at: '2017-05-30T17:42:38.409Z', tag: false, tagUrl: 'http://test.host/frontend-fixtures/environments-project/tags/false', - 'last?': false - } + 'last?': false, + }, ]; export const statePaths = { @@ -2476,5844 +698,5844 @@ export const statePaths = { }; export const singleRowMetricsMultipleSeries = [ - { - 'title': 'Multiple Time Series', - 'weight': 1, - 'y_label': 'Request Rates', - 'queries': [ - { - 'query_range': 'sum(rate(nginx_responses_total{environment="production"}[2m])) by (status_code)', - 'label': 'Requests', - 'unit': 'Req/sec', - 'result': [ - { - 'metric': { - 'status_code': '1xx' - }, - 'values': [ - { - 'time': '2017-08-27T11:01:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:02:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:03:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:04:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:05:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:06:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:07:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:08:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:09:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:10:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:11:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:12:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:13:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:14:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:15:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:16:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:17:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:18:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:19:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:20:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:21:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:22:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:23:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:24:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:25:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:26:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:27:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:28:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:29:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:30:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:31:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:32:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:33:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:34:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:35:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:36:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:37:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:38:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:39:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:40:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:41:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:42:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:43:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:44:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:45:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:46:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:47:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:48:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:49:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:50:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:51:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:52:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:53:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:54:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:55:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:56:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:57:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:58:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T11:59:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:00:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:01:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:02:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:03:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:04:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:05:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:06:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:07:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:08:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:09:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:10:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:11:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:12:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:13:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:14:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:15:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:16:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:17:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:18:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:19:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:20:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:21:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:22:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:23:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:24:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:25:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:26:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:27:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:28:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:29:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:30:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:31:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:32:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:33:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:34:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:35:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:36:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:37:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:38:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:39:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:40:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:41:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:42:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:43:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:44:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:45:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:46:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:47:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:48:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:49:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:50:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:51:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:52:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:53:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:54:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:55:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:56:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:57:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:58:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T12:59:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:00:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:01:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:02:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:03:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:04:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:05:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:06:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:07:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:08:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:09:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:10:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:11:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:12:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:13:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:14:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:15:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:16:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:17:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:18:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:19:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:20:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:21:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:22:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:23:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:24:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:25:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:26:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:27:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:28:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:29:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:30:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:31:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:32:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:33:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:34:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:35:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:36:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:37:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:38:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:39:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:40:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:41:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:42:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:43:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:44:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:45:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:46:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:47:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:48:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:49:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:50:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:51:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:52:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:53:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:54:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:55:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:56:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:57:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:58:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T13:59:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:00:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:01:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:02:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:03:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:04:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:05:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:06:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:07:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:08:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:09:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:10:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:11:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:12:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:13:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:14:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:15:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:16:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:17:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:18:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:19:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:20:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:21:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:22:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:23:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:24:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:25:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:26:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:27:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:28:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:29:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:30:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:31:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:32:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:33:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:34:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:35:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:36:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:37:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:38:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:39:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:40:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:41:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:42:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:43:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:44:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:45:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:46:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:47:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:48:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:49:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:50:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:51:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:52:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:53:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:54:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:55:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:56:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:57:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:58:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T14:59:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:00:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:01:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:02:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:03:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:04:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:05:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:06:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:07:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:08:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:09:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:10:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:11:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:12:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:13:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:14:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:15:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:16:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:17:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:18:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:19:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:20:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:21:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:22:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:23:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:24:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:25:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:26:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:27:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:28:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:29:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:30:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:31:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:32:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:33:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:34:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:35:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:36:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:37:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:38:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:39:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:40:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:41:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:42:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:43:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:44:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:45:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:46:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:47:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:48:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:49:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:50:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:51:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:52:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:53:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:54:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:55:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:56:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:57:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:58:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T15:59:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:00:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:01:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:02:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:03:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:04:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:05:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:06:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:07:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:08:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:09:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:10:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:11:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:12:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:13:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:14:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:15:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:16:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:17:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:18:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:19:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:20:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:21:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:22:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:23:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:24:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:25:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:26:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:27:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:28:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:29:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:30:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:31:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:32:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:33:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:34:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:35:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:36:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:37:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:38:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:39:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:40:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:41:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:42:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:43:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:44:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:45:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:46:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:47:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:48:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:49:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:50:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:51:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:52:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:53:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:54:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:55:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:56:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:57:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:58:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T16:59:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:00:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:01:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:02:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:03:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:04:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:05:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:06:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:07:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:08:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:09:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:10:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:11:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:12:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:13:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:14:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:15:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:16:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:17:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:18:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:19:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:20:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:21:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:22:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:23:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:24:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:25:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:26:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:27:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:28:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:29:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:30:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:31:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:32:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:33:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:34:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:35:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:36:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:37:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:38:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:39:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:40:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:41:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:42:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:43:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:44:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:45:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:46:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:47:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:48:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:49:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:50:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:51:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:52:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:53:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:54:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:55:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:56:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:57:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:58:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T17:59:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:00:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:01:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:02:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:03:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:04:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:05:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:06:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:07:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:08:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:09:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:10:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:11:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:12:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:13:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:14:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:15:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:16:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:17:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:18:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:19:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:20:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:21:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:22:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:23:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:24:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:25:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:26:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:27:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:28:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:29:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:30:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:31:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:32:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:33:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:34:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:35:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:36:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:37:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:38:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:39:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:40:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:41:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:42:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:43:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:44:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:45:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:46:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:47:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:48:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:49:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:50:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:51:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:52:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:53:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:54:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:55:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:56:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:57:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:58:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T18:59:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T19:00:51.462Z', - 'value': '0' - }, - { - 'time': '2017-08-27T19:01:51.462Z', - 'value': '0' - } - ] - }, - { - 'metric': { - 'status_code': '2xx' - }, - 'values': [ - { - 'time': '2017-08-27T11:01:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T11:02:51.462Z', - 'value': '1.2571428571428571' - }, - { - 'time': '2017-08-27T11:03:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T11:04:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T11:05:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T11:06:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T11:07:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T11:08:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T11:09:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T11:10:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T11:11:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T11:12:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T11:13:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T11:14:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T11:15:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T11:16:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T11:17:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T11:18:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T11:19:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T11:20:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T11:21:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T11:22:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T11:23:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T11:24:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T11:25:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T11:26:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T11:27:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T11:28:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T11:29:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T11:30:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T11:31:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T11:32:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T11:33:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T11:34:51.462Z', - 'value': '1.333320635041571' - }, - { - 'time': '2017-08-27T11:35:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T11:36:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T11:37:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T11:38:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T11:39:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T11:40:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T11:41:51.462Z', - 'value': '1.3333587306424883' - }, - { - 'time': '2017-08-27T11:42:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T11:43:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T11:44:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T11:45:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T11:46:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T11:47:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T11:48:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T11:49:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T11:50:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T11:51:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T11:52:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T11:53:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T11:54:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T11:55:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T11:56:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T11:57:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T11:58:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T11:59:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T12:00:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T12:01:51.462Z', - 'value': '1.3333460318669703' - }, - { - 'time': '2017-08-27T12:02:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T12:03:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T12:04:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T12:05:51.462Z', - 'value': '1.31427319739812' - }, - { - 'time': '2017-08-27T12:06:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T12:07:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T12:08:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T12:09:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T12:10:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T12:11:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T12:12:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T12:13:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T12:14:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T12:15:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T12:16:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T12:17:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T12:18:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T12:19:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T12:20:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T12:21:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T12:22:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T12:23:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T12:24:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T12:25:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T12:26:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T12:27:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T12:28:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T12:29:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T12:30:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T12:31:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T12:32:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T12:33:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T12:34:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T12:35:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T12:36:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T12:37:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T12:38:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T12:39:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T12:40:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T12:41:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T12:42:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T12:43:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T12:44:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T12:45:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T12:46:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T12:47:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T12:48:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T12:49:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T12:50:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T12:51:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T12:52:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T12:53:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T12:54:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T12:55:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T12:56:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T12:57:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T12:58:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T12:59:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T13:00:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T13:01:51.462Z', - 'value': '1.295225759754669' - }, - { - 'time': '2017-08-27T13:02:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T13:03:51.462Z', - 'value': '1.2952627669098458' - }, - { - 'time': '2017-08-27T13:04:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T13:05:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T13:06:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T13:07:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T13:08:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T13:09:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T13:10:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T13:11:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T13:12:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T13:13:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T13:14:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T13:15:51.462Z', - 'value': '1.2571428571428571' - }, - { - 'time': '2017-08-27T13:16:51.462Z', - 'value': '1.3333587306424883' - }, - { - 'time': '2017-08-27T13:17:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T13:18:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T13:19:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T13:20:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T13:21:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T13:22:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T13:23:51.462Z', - 'value': '1.276190476190476' - }, - { - 'time': '2017-08-27T13:24:51.462Z', - 'value': '1.2571428571428571' - }, - { - 'time': '2017-08-27T13:25:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T13:26:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T13:27:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T13:28:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T13:29:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T13:30:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T13:31:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T13:32:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T13:33:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T13:34:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T13:35:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T13:36:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T13:37:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T13:38:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T13:39:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T13:40:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T13:41:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T13:42:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T13:43:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T13:44:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T13:45:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T13:46:51.462Z', - 'value': '1.2571428571428571' - }, - { - 'time': '2017-08-27T13:47:51.462Z', - 'value': '1.276190476190476' - }, - { - 'time': '2017-08-27T13:48:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T13:49:51.462Z', - 'value': '1.295225759754669' - }, - { - 'time': '2017-08-27T13:50:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T13:51:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T13:52:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T13:53:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T13:54:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T13:55:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T13:56:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T13:57:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T13:58:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T13:59:51.462Z', - 'value': '1.295225759754669' - }, - { - 'time': '2017-08-27T14:00:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T14:01:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T14:02:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T14:03:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T14:04:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T14:05:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T14:06:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T14:07:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T14:08:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T14:09:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T14:10:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T14:11:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T14:12:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T14:13:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T14:14:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T14:15:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T14:16:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T14:17:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T14:18:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T14:19:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T14:20:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T14:21:51.462Z', - 'value': '1.3333079369916765' - }, - { - 'time': '2017-08-27T14:22:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T14:23:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T14:24:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T14:25:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T14:26:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T14:27:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T14:28:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T14:29:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T14:30:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T14:31:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T14:32:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T14:33:51.462Z', - 'value': '1.2571428571428571' - }, - { - 'time': '2017-08-27T14:34:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T14:35:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T14:36:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T14:37:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T14:38:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T14:39:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T14:40:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T14:41:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T14:42:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T14:43:51.462Z', - 'value': '1.276190476190476' - }, - { - 'time': '2017-08-27T14:44:51.462Z', - 'value': '1.2571428571428571' - }, - { - 'time': '2017-08-27T14:45:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T14:46:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T14:47:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T14:48:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T14:49:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T14:50:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T14:51:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T14:52:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T14:53:51.462Z', - 'value': '1.333320635041571' - }, - { - 'time': '2017-08-27T14:54:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T14:55:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T14:56:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T14:57:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T14:58:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T14:59:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T15:00:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T15:01:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T15:02:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T15:03:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T15:04:51.462Z', - 'value': '1.2571428571428571' - }, - { - 'time': '2017-08-27T15:05:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T15:06:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T15:07:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T15:08:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T15:09:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T15:10:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T15:11:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T15:12:51.462Z', - 'value': '1.31427319739812' - }, - { - 'time': '2017-08-27T15:13:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T15:14:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T15:15:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T15:16:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T15:17:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T15:18:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T15:19:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T15:20:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T15:21:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T15:22:51.462Z', - 'value': '1.3333460318669703' - }, - { - 'time': '2017-08-27T15:23:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T15:24:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T15:25:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T15:26:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T15:27:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T15:28:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T15:29:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T15:30:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T15:31:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T15:32:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T15:33:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T15:34:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T15:35:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T15:36:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T15:37:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T15:38:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T15:39:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T15:40:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T15:41:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T15:42:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T15:43:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T15:44:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T15:45:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T15:46:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T15:47:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T15:48:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T15:49:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T15:50:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T15:51:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T15:52:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T15:53:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T15:54:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T15:55:51.462Z', - 'value': '1.3333587306424883' - }, - { - 'time': '2017-08-27T15:56:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T15:57:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T15:58:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T15:59:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T16:00:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T16:01:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T16:02:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T16:03:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T16:04:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T16:05:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T16:06:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T16:07:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T16:08:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T16:09:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T16:10:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T16:11:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T16:12:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T16:13:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T16:14:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T16:15:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T16:16:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T16:17:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T16:18:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T16:19:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T16:20:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T16:21:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T16:22:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T16:23:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T16:24:51.462Z', - 'value': '1.295225759754669' - }, - { - 'time': '2017-08-27T16:25:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T16:26:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T16:27:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T16:28:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T16:29:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T16:30:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T16:31:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T16:32:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T16:33:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T16:34:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T16:35:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T16:36:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T16:37:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T16:38:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T16:39:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T16:40:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T16:41:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T16:42:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T16:43:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T16:44:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T16:45:51.462Z', - 'value': '1.3142982314117277' - }, - { - 'time': '2017-08-27T16:46:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T16:47:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T16:48:51.462Z', - 'value': '1.333320635041571' - }, - { - 'time': '2017-08-27T16:49:51.462Z', - 'value': '1.31427319739812' - }, - { - 'time': '2017-08-27T16:50:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T16:51:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T16:52:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T16:53:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T16:54:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T16:55:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T16:56:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T16:57:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T16:58:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T16:59:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T17:00:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T17:01:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T17:02:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T17:03:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T17:04:51.462Z', - 'value': '1.2952504309564854' - }, - { - 'time': '2017-08-27T17:05:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T17:06:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T17:07:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T17:08:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T17:09:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T17:10:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T17:11:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T17:12:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T17:13:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T17:14:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T17:15:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T17:16:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T17:17:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T17:18:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T17:19:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T17:20:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T17:21:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T17:22:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T17:23:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T17:24:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T17:25:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T17:26:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T17:27:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T17:28:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T17:29:51.462Z', - 'value': '1.295225759754669' - }, - { - 'time': '2017-08-27T17:30:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T17:31:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T17:32:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T17:33:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T17:34:51.462Z', - 'value': '1.295225759754669' - }, - { - 'time': '2017-08-27T17:35:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T17:36:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T17:37:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T17:38:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T17:39:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T17:40:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T17:41:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T17:42:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T17:43:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T17:44:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T17:45:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T17:46:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T17:47:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T17:48:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T17:49:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T17:50:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T17:51:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T17:52:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T17:53:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T17:54:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T17:55:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T17:56:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T17:57:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T17:58:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T17:59:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T18:00:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T18:01:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T18:02:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T18:03:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T18:04:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T18:05:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T18:06:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T18:07:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T18:08:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T18:09:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T18:10:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T18:11:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T18:12:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T18:13:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T18:14:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T18:15:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T18:16:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T18:17:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T18:18:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T18:19:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T18:20:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T18:21:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T18:22:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T18:23:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T18:24:51.462Z', - 'value': '1.2571428571428571' - }, - { - 'time': '2017-08-27T18:25:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T18:26:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T18:27:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T18:28:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T18:29:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T18:30:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T18:31:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T18:32:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T18:33:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T18:34:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T18:35:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T18:36:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T18:37:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T18:38:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T18:39:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T18:40:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T18:41:51.462Z', - 'value': '1.580952380952381' - }, - { - 'time': '2017-08-27T18:42:51.462Z', - 'value': '1.7333333333333334' - }, - { - 'time': '2017-08-27T18:43:51.462Z', - 'value': '2.057142857142857' - }, - { - 'time': '2017-08-27T18:44:51.462Z', - 'value': '2.1904761904761902' - }, - { - 'time': '2017-08-27T18:45:51.462Z', - 'value': '1.8285714285714287' - }, - { - 'time': '2017-08-27T18:46:51.462Z', - 'value': '2.1142857142857143' - }, - { - 'time': '2017-08-27T18:47:51.462Z', - 'value': '1.619047619047619' - }, - { - 'time': '2017-08-27T18:48:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T18:49:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T18:50:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T18:51:51.462Z', - 'value': '1.2952504309564854' - }, - { - 'time': '2017-08-27T18:52:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T18:53:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T18:54:51.462Z', - 'value': '1.3333333333333333' - }, - { - 'time': '2017-08-27T18:55:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T18:56:51.462Z', - 'value': '1.314285714285714' - }, - { - 'time': '2017-08-27T18:57:51.462Z', - 'value': '1.295238095238095' - }, - { - 'time': '2017-08-27T18:58:51.462Z', - 'value': '1.7142857142857142' - }, - { - 'time': '2017-08-27T18:59:51.462Z', - 'value': '1.7333333333333334' - }, - { - 'time': '2017-08-27T19:00:51.462Z', - 'value': '1.3904761904761904' - }, - { - 'time': '2017-08-27T19:01:51.462Z', - 'value': '1.5047619047619047' - } - ] - }, - ], - 'when': [ - { - 'value': 'hundred(s)', - 'color': 'green', - }, - ], - } - ] - }, - { - 'title': 'Throughput', - 'weight': 1, - 'y_label': 'Requests / Sec', - 'queries': [ - { - 'query_range': 'sum(rate(nginx_requests_total{server_zone!=\'*\', server_zone!=\'_\', container_name!=\'POD\',environment=\'production\'}[2m]))', - 'label': 'Total', - 'unit': 'req / sec', - 'result': [ - { - 'metric': { - - }, - 'values': [ - { - 'time': '2017-08-27T11:01:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T11:02:51.462Z', - 'value': '0.45714285714285713' - }, - { - 'time': '2017-08-27T11:03:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T11:04:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T11:05:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T11:06:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T11:07:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T11:08:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T11:09:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T11:10:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T11:11:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T11:12:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T11:13:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T11:14:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T11:15:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T11:16:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T11:17:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T11:18:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T11:19:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T11:20:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T11:21:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T11:22:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T11:23:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T11:24:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T11:25:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T11:26:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T11:27:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T11:28:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T11:29:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T11:30:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T11:31:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T11:32:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T11:33:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T11:34:51.462Z', - 'value': '0.4952333787297264' - }, - { - 'time': '2017-08-27T11:35:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T11:36:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T11:37:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T11:38:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T11:39:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T11:40:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T11:41:51.462Z', - 'value': '0.49524752852435283' - }, - { - 'time': '2017-08-27T11:42:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T11:43:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T11:44:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T11:45:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T11:46:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T11:47:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T11:48:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T11:49:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T11:50:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T11:51:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T11:52:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T11:53:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T11:54:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T11:55:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T11:56:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T11:57:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T11:58:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T11:59:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T12:00:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T12:01:51.462Z', - 'value': '0.49524281183630325' - }, - { - 'time': '2017-08-27T12:02:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T12:03:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T12:04:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T12:05:51.462Z', - 'value': '0.4857096599080009' - }, - { - 'time': '2017-08-27T12:06:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T12:07:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T12:08:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T12:09:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T12:10:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T12:11:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T12:12:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T12:13:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T12:14:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T12:15:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T12:16:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T12:17:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T12:18:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T12:19:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T12:20:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T12:21:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T12:22:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T12:23:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T12:24:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T12:25:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T12:26:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T12:27:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T12:28:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T12:29:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T12:30:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T12:31:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T12:32:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T12:33:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T12:34:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T12:35:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T12:36:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T12:37:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T12:38:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T12:39:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T12:40:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T12:41:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T12:42:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T12:43:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T12:44:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T12:45:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T12:46:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T12:47:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T12:48:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T12:49:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T12:50:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T12:51:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T12:52:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T12:53:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T12:54:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T12:55:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T12:56:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T12:57:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T12:58:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T12:59:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T13:00:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T13:01:51.462Z', - 'value': '0.4761859410862754' - }, - { - 'time': '2017-08-27T13:02:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T13:03:51.462Z', - 'value': '0.4761995466580315' - }, - { - 'time': '2017-08-27T13:04:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T13:05:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T13:06:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T13:07:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T13:08:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T13:09:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T13:10:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T13:11:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T13:12:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T13:13:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T13:14:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T13:15:51.462Z', - 'value': '0.45714285714285713' - }, - { - 'time': '2017-08-27T13:16:51.462Z', - 'value': '0.49524752852435283' - }, - { - 'time': '2017-08-27T13:17:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T13:18:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T13:19:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T13:20:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T13:21:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T13:22:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T13:23:51.462Z', - 'value': '0.4666666666666667' - }, - { - 'time': '2017-08-27T13:24:51.462Z', - 'value': '0.45714285714285713' - }, - { - 'time': '2017-08-27T13:25:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T13:26:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T13:27:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T13:28:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T13:29:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T13:30:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T13:31:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T13:32:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T13:33:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T13:34:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T13:35:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T13:36:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T13:37:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T13:38:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T13:39:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T13:40:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T13:41:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T13:42:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T13:43:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T13:44:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T13:45:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T13:46:51.462Z', - 'value': '0.45714285714285713' - }, - { - 'time': '2017-08-27T13:47:51.462Z', - 'value': '0.4666666666666667' - }, - { - 'time': '2017-08-27T13:48:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T13:49:51.462Z', - 'value': '0.4761859410862754' - }, - { - 'time': '2017-08-27T13:50:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T13:51:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T13:52:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T13:53:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T13:54:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T13:55:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T13:56:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T13:57:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T13:58:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T13:59:51.462Z', - 'value': '0.4761859410862754' - }, - { - 'time': '2017-08-27T14:00:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T14:01:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T14:02:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T14:03:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T14:04:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T14:05:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T14:06:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T14:07:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T14:08:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T14:09:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T14:10:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T14:11:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T14:12:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T14:13:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T14:14:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T14:15:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T14:16:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T14:17:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T14:18:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T14:19:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T14:20:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T14:21:51.462Z', - 'value': '0.4952286623111941' - }, - { - 'time': '2017-08-27T14:22:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T14:23:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T14:24:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T14:25:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T14:26:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T14:27:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T14:28:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T14:29:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T14:30:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T14:31:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T14:32:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T14:33:51.462Z', - 'value': '0.45714285714285713' - }, - { - 'time': '2017-08-27T14:34:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T14:35:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T14:36:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T14:37:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T14:38:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T14:39:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T14:40:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T14:41:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T14:42:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T14:43:51.462Z', - 'value': '0.4666666666666667' - }, - { - 'time': '2017-08-27T14:44:51.462Z', - 'value': '0.45714285714285713' - }, - { - 'time': '2017-08-27T14:45:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T14:46:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T14:47:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T14:48:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T14:49:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T14:50:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T14:51:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T14:52:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T14:53:51.462Z', - 'value': '0.4952333787297264' - }, - { - 'time': '2017-08-27T14:54:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T14:55:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T14:56:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T14:57:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T14:58:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T14:59:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T15:00:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T15:01:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T15:02:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T15:03:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T15:04:51.462Z', - 'value': '0.45714285714285713' - }, - { - 'time': '2017-08-27T15:05:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T15:06:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T15:07:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T15:08:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T15:09:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T15:10:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T15:11:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T15:12:51.462Z', - 'value': '0.4857096599080009' - }, - { - 'time': '2017-08-27T15:13:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T15:14:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T15:15:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T15:16:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T15:17:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T15:18:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T15:19:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T15:20:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T15:21:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T15:22:51.462Z', - 'value': '0.49524281183630325' - }, - { - 'time': '2017-08-27T15:23:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T15:24:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T15:25:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T15:26:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T15:27:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T15:28:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T15:29:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T15:30:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T15:31:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T15:32:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T15:33:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T15:34:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T15:35:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T15:36:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T15:37:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T15:38:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T15:39:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T15:40:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T15:41:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T15:42:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T15:43:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T15:44:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T15:45:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T15:46:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T15:47:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T15:48:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T15:49:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T15:50:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T15:51:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T15:52:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T15:53:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T15:54:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T15:55:51.462Z', - 'value': '0.49524752852435283' - }, - { - 'time': '2017-08-27T15:56:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T15:57:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T15:58:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T15:59:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T16:00:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T16:01:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T16:02:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T16:03:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T16:04:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T16:05:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T16:06:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T16:07:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T16:08:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T16:09:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T16:10:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T16:11:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T16:12:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T16:13:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T16:14:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T16:15:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T16:16:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T16:17:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T16:18:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T16:19:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T16:20:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T16:21:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T16:22:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T16:23:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T16:24:51.462Z', - 'value': '0.4761859410862754' - }, - { - 'time': '2017-08-27T16:25:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T16:26:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T16:27:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T16:28:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T16:29:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T16:30:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T16:31:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T16:32:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T16:33:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T16:34:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T16:35:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T16:36:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T16:37:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T16:38:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T16:39:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T16:40:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T16:41:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T16:42:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T16:43:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T16:44:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T16:45:51.462Z', - 'value': '0.485718911608682' - }, - { - 'time': '2017-08-27T16:46:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T16:47:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T16:48:51.462Z', - 'value': '0.4952333787297264' - }, - { - 'time': '2017-08-27T16:49:51.462Z', - 'value': '0.4857096599080009' - }, - { - 'time': '2017-08-27T16:50:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T16:51:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T16:52:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T16:53:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T16:54:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T16:55:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T16:56:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T16:57:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T16:58:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T16:59:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T17:00:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T17:01:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T17:02:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T17:03:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T17:04:51.462Z', - 'value': '0.47619501138106085' - }, - { - 'time': '2017-08-27T17:05:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T17:06:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T17:07:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T17:08:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T17:09:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T17:10:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T17:11:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T17:12:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T17:13:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T17:14:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T17:15:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T17:16:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T17:17:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T17:18:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T17:19:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T17:20:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T17:21:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T17:22:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T17:23:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T17:24:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T17:25:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T17:26:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T17:27:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T17:28:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T17:29:51.462Z', - 'value': '0.4761859410862754' - }, - { - 'time': '2017-08-27T17:30:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T17:31:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T17:32:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T17:33:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T17:34:51.462Z', - 'value': '0.4761859410862754' - }, - { - 'time': '2017-08-27T17:35:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T17:36:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T17:37:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T17:38:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T17:39:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T17:40:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T17:41:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T17:42:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T17:43:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T17:44:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T17:45:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T17:46:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T17:47:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T17:48:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T17:49:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T17:50:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T17:51:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T17:52:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T17:53:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T17:54:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T17:55:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T17:56:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T17:57:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T17:58:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T17:59:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T18:00:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T18:01:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T18:02:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T18:03:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T18:04:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T18:05:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T18:06:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T18:07:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T18:08:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T18:09:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T18:10:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T18:11:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T18:12:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T18:13:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T18:14:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T18:15:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T18:16:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T18:17:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T18:18:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T18:19:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T18:20:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T18:21:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T18:22:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T18:23:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T18:24:51.462Z', - 'value': '0.45714285714285713' - }, - { - 'time': '2017-08-27T18:25:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T18:26:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T18:27:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T18:28:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T18:29:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T18:30:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T18:31:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T18:32:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T18:33:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T18:34:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T18:35:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T18:36:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T18:37:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T18:38:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T18:39:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T18:40:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T18:41:51.462Z', - 'value': '0.6190476190476191' - }, - { - 'time': '2017-08-27T18:42:51.462Z', - 'value': '0.6952380952380952' - }, - { - 'time': '2017-08-27T18:43:51.462Z', - 'value': '0.857142857142857' - }, - { - 'time': '2017-08-27T18:44:51.462Z', - 'value': '0.9238095238095239' - }, - { - 'time': '2017-08-27T18:45:51.462Z', - 'value': '0.7428571428571429' - }, - { - 'time': '2017-08-27T18:46:51.462Z', - 'value': '0.8857142857142857' - }, - { - 'time': '2017-08-27T18:47:51.462Z', - 'value': '0.638095238095238' - }, - { - 'time': '2017-08-27T18:48:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T18:49:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T18:50:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T18:51:51.462Z', - 'value': '0.47619501138106085' - }, - { - 'time': '2017-08-27T18:52:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T18:53:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T18:54:51.462Z', - 'value': '0.4952380952380952' - }, - { - 'time': '2017-08-27T18:55:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T18:56:51.462Z', - 'value': '0.4857142857142857' - }, - { - 'time': '2017-08-27T18:57:51.462Z', - 'value': '0.47619047619047616' - }, - { - 'time': '2017-08-27T18:58:51.462Z', - 'value': '0.6857142857142856' - }, - { - 'time': '2017-08-27T18:59:51.462Z', - 'value': '0.6952380952380952' - }, - { - 'time': '2017-08-27T19:00:51.462Z', - 'value': '0.5238095238095237' - }, - { - 'time': '2017-08-27T19:01:51.462Z', - 'value': '0.5904761904761905' - } - ] - } - ] - } - ] - } + { + title: 'Multiple Time Series', + weight: 1, + y_label: 'Request Rates', + queries: [ + { + query_range: + 'sum(rate(nginx_responses_total{environment="production"}[2m])) by (status_code)', + label: 'Requests', + unit: 'Req/sec', + result: [ + { + metric: { + status_code: '1xx', + }, + values: [ + { + time: '2017-08-27T11:01:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:02:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:03:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:04:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:05:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:06:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:07:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:08:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:09:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:10:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:11:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:12:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:13:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:14:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:15:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:16:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:17:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:18:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:19:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:20:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:21:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:22:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:23:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:24:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:25:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:26:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:27:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:28:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:29:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:30:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:31:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:32:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:33:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:34:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:35:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:36:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:37:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:38:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:39:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:40:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:41:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:42:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:43:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:44:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:45:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:46:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:47:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:48:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:49:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:50:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:51:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:52:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:53:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:54:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:55:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:56:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:57:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:58:51.462Z', + value: '0', + }, + { + time: '2017-08-27T11:59:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:00:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:01:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:02:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:03:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:04:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:05:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:06:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:07:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:08:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:09:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:10:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:11:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:12:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:13:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:14:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:15:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:16:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:17:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:18:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:19:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:20:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:21:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:22:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:23:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:24:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:25:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:26:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:27:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:28:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:29:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:30:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:31:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:32:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:33:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:34:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:35:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:36:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:37:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:38:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:39:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:40:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:41:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:42:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:43:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:44:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:45:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:46:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:47:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:48:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:49:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:50:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:51:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:52:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:53:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:54:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:55:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:56:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:57:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:58:51.462Z', + value: '0', + }, + { + time: '2017-08-27T12:59:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:00:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:01:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:02:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:03:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:04:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:05:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:06:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:07:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:08:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:09:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:10:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:11:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:12:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:13:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:14:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:15:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:16:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:17:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:18:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:19:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:20:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:21:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:22:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:23:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:24:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:25:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:26:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:27:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:28:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:29:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:30:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:31:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:32:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:33:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:34:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:35:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:36:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:37:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:38:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:39:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:40:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:41:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:42:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:43:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:44:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:45:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:46:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:47:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:48:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:49:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:50:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:51:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:52:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:53:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:54:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:55:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:56:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:57:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:58:51.462Z', + value: '0', + }, + { + time: '2017-08-27T13:59:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:00:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:01:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:02:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:03:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:04:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:05:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:06:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:07:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:08:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:09:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:10:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:11:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:12:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:13:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:14:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:15:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:16:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:17:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:18:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:19:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:20:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:21:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:22:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:23:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:24:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:25:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:26:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:27:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:28:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:29:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:30:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:31:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:32:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:33:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:34:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:35:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:36:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:37:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:38:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:39:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:40:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:41:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:42:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:43:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:44:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:45:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:46:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:47:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:48:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:49:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:50:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:51:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:52:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:53:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:54:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:55:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:56:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:57:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:58:51.462Z', + value: '0', + }, + { + time: '2017-08-27T14:59:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:00:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:01:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:02:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:03:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:04:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:05:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:06:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:07:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:08:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:09:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:10:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:11:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:12:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:13:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:14:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:15:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:16:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:17:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:18:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:19:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:20:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:21:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:22:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:23:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:24:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:25:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:26:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:27:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:28:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:29:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:30:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:31:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:32:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:33:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:34:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:35:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:36:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:37:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:38:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:39:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:40:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:41:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:42:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:43:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:44:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:45:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:46:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:47:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:48:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:49:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:50:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:51:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:52:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:53:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:54:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:55:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:56:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:57:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:58:51.462Z', + value: '0', + }, + { + time: '2017-08-27T15:59:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:00:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:01:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:02:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:03:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:04:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:05:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:06:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:07:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:08:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:09:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:10:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:11:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:12:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:13:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:14:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:15:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:16:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:17:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:18:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:19:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:20:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:21:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:22:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:23:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:24:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:25:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:26:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:27:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:28:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:29:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:30:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:31:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:32:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:33:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:34:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:35:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:36:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:37:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:38:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:39:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:40:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:41:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:42:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:43:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:44:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:45:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:46:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:47:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:48:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:49:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:50:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:51:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:52:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:53:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:54:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:55:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:56:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:57:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:58:51.462Z', + value: '0', + }, + { + time: '2017-08-27T16:59:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:00:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:01:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:02:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:03:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:04:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:05:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:06:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:07:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:08:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:09:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:10:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:11:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:12:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:13:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:14:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:15:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:16:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:17:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:18:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:19:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:20:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:21:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:22:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:23:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:24:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:25:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:26:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:27:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:28:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:29:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:30:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:31:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:32:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:33:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:34:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:35:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:36:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:37:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:38:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:39:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:40:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:41:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:42:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:43:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:44:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:45:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:46:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:47:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:48:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:49:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:50:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:51:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:52:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:53:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:54:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:55:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:56:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:57:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:58:51.462Z', + value: '0', + }, + { + time: '2017-08-27T17:59:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:00:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:01:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:02:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:03:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:04:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:05:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:06:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:07:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:08:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:09:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:10:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:11:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:12:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:13:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:14:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:15:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:16:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:17:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:18:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:19:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:20:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:21:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:22:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:23:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:24:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:25:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:26:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:27:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:28:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:29:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:30:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:31:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:32:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:33:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:34:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:35:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:36:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:37:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:38:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:39:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:40:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:41:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:42:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:43:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:44:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:45:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:46:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:47:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:48:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:49:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:50:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:51:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:52:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:53:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:54:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:55:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:56:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:57:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:58:51.462Z', + value: '0', + }, + { + time: '2017-08-27T18:59:51.462Z', + value: '0', + }, + { + time: '2017-08-27T19:00:51.462Z', + value: '0', + }, + { + time: '2017-08-27T19:01:51.462Z', + value: '0', + }, + ], + }, + { + metric: { + status_code: '2xx', + }, + values: [ + { + time: '2017-08-27T11:01:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T11:02:51.462Z', + value: '1.2571428571428571', + }, + { + time: '2017-08-27T11:03:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T11:04:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T11:05:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T11:06:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T11:07:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T11:08:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T11:09:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T11:10:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T11:11:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T11:12:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T11:13:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T11:14:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T11:15:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T11:16:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T11:17:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T11:18:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T11:19:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T11:20:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T11:21:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T11:22:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T11:23:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T11:24:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T11:25:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T11:26:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T11:27:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T11:28:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T11:29:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T11:30:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T11:31:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T11:32:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T11:33:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T11:34:51.462Z', + value: '1.333320635041571', + }, + { + time: '2017-08-27T11:35:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T11:36:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T11:37:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T11:38:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T11:39:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T11:40:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T11:41:51.462Z', + value: '1.3333587306424883', + }, + { + time: '2017-08-27T11:42:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T11:43:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T11:44:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T11:45:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T11:46:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T11:47:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T11:48:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T11:49:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T11:50:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T11:51:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T11:52:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T11:53:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T11:54:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T11:55:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T11:56:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T11:57:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T11:58:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T11:59:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T12:00:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T12:01:51.462Z', + value: '1.3333460318669703', + }, + { + time: '2017-08-27T12:02:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T12:03:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T12:04:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T12:05:51.462Z', + value: '1.31427319739812', + }, + { + time: '2017-08-27T12:06:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T12:07:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T12:08:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T12:09:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T12:10:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T12:11:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T12:12:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T12:13:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T12:14:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T12:15:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T12:16:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T12:17:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T12:18:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T12:19:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T12:20:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T12:21:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T12:22:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T12:23:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T12:24:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T12:25:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T12:26:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T12:27:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T12:28:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T12:29:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T12:30:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T12:31:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T12:32:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T12:33:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T12:34:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T12:35:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T12:36:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T12:37:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T12:38:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T12:39:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T12:40:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T12:41:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T12:42:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T12:43:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T12:44:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T12:45:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T12:46:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T12:47:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T12:48:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T12:49:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T12:50:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T12:51:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T12:52:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T12:53:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T12:54:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T12:55:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T12:56:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T12:57:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T12:58:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T12:59:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T13:00:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T13:01:51.462Z', + value: '1.295225759754669', + }, + { + time: '2017-08-27T13:02:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T13:03:51.462Z', + value: '1.2952627669098458', + }, + { + time: '2017-08-27T13:04:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T13:05:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T13:06:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T13:07:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T13:08:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T13:09:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T13:10:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T13:11:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T13:12:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T13:13:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T13:14:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T13:15:51.462Z', + value: '1.2571428571428571', + }, + { + time: '2017-08-27T13:16:51.462Z', + value: '1.3333587306424883', + }, + { + time: '2017-08-27T13:17:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T13:18:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T13:19:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T13:20:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T13:21:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T13:22:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T13:23:51.462Z', + value: '1.276190476190476', + }, + { + time: '2017-08-27T13:24:51.462Z', + value: '1.2571428571428571', + }, + { + time: '2017-08-27T13:25:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T13:26:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T13:27:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T13:28:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T13:29:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T13:30:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T13:31:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T13:32:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T13:33:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T13:34:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T13:35:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T13:36:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T13:37:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T13:38:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T13:39:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T13:40:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T13:41:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T13:42:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T13:43:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T13:44:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T13:45:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T13:46:51.462Z', + value: '1.2571428571428571', + }, + { + time: '2017-08-27T13:47:51.462Z', + value: '1.276190476190476', + }, + { + time: '2017-08-27T13:48:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T13:49:51.462Z', + value: '1.295225759754669', + }, + { + time: '2017-08-27T13:50:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T13:51:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T13:52:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T13:53:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T13:54:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T13:55:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T13:56:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T13:57:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T13:58:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T13:59:51.462Z', + value: '1.295225759754669', + }, + { + time: '2017-08-27T14:00:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T14:01:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T14:02:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T14:03:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T14:04:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T14:05:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T14:06:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T14:07:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T14:08:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T14:09:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T14:10:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T14:11:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T14:12:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T14:13:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T14:14:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T14:15:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T14:16:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T14:17:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T14:18:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T14:19:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T14:20:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T14:21:51.462Z', + value: '1.3333079369916765', + }, + { + time: '2017-08-27T14:22:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T14:23:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T14:24:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T14:25:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T14:26:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T14:27:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T14:28:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T14:29:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T14:30:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T14:31:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T14:32:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T14:33:51.462Z', + value: '1.2571428571428571', + }, + { + time: '2017-08-27T14:34:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T14:35:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T14:36:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T14:37:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T14:38:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T14:39:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T14:40:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T14:41:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T14:42:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T14:43:51.462Z', + value: '1.276190476190476', + }, + { + time: '2017-08-27T14:44:51.462Z', + value: '1.2571428571428571', + }, + { + time: '2017-08-27T14:45:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T14:46:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T14:47:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T14:48:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T14:49:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T14:50:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T14:51:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T14:52:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T14:53:51.462Z', + value: '1.333320635041571', + }, + { + time: '2017-08-27T14:54:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T14:55:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T14:56:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T14:57:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T14:58:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T14:59:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T15:00:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T15:01:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T15:02:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T15:03:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T15:04:51.462Z', + value: '1.2571428571428571', + }, + { + time: '2017-08-27T15:05:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T15:06:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T15:07:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T15:08:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T15:09:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T15:10:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T15:11:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T15:12:51.462Z', + value: '1.31427319739812', + }, + { + time: '2017-08-27T15:13:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T15:14:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T15:15:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T15:16:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T15:17:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T15:18:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T15:19:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T15:20:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T15:21:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T15:22:51.462Z', + value: '1.3333460318669703', + }, + { + time: '2017-08-27T15:23:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T15:24:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T15:25:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T15:26:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T15:27:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T15:28:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T15:29:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T15:30:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T15:31:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T15:32:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T15:33:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T15:34:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T15:35:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T15:36:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T15:37:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T15:38:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T15:39:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T15:40:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T15:41:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T15:42:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T15:43:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T15:44:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T15:45:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T15:46:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T15:47:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T15:48:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T15:49:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T15:50:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T15:51:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T15:52:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T15:53:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T15:54:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T15:55:51.462Z', + value: '1.3333587306424883', + }, + { + time: '2017-08-27T15:56:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T15:57:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T15:58:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T15:59:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T16:00:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T16:01:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T16:02:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T16:03:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T16:04:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T16:05:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T16:06:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T16:07:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T16:08:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T16:09:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T16:10:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T16:11:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T16:12:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T16:13:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T16:14:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T16:15:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T16:16:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T16:17:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T16:18:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T16:19:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T16:20:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T16:21:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T16:22:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T16:23:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T16:24:51.462Z', + value: '1.295225759754669', + }, + { + time: '2017-08-27T16:25:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T16:26:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T16:27:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T16:28:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T16:29:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T16:30:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T16:31:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T16:32:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T16:33:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T16:34:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T16:35:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T16:36:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T16:37:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T16:38:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T16:39:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T16:40:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T16:41:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T16:42:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T16:43:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T16:44:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T16:45:51.462Z', + value: '1.3142982314117277', + }, + { + time: '2017-08-27T16:46:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T16:47:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T16:48:51.462Z', + value: '1.333320635041571', + }, + { + time: '2017-08-27T16:49:51.462Z', + value: '1.31427319739812', + }, + { + time: '2017-08-27T16:50:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T16:51:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T16:52:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T16:53:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T16:54:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T16:55:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T16:56:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T16:57:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T16:58:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T16:59:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T17:00:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T17:01:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T17:02:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T17:03:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T17:04:51.462Z', + value: '1.2952504309564854', + }, + { + time: '2017-08-27T17:05:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T17:06:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T17:07:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T17:08:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T17:09:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T17:10:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T17:11:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T17:12:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T17:13:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T17:14:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T17:15:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T17:16:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T17:17:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T17:18:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T17:19:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T17:20:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T17:21:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T17:22:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T17:23:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T17:24:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T17:25:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T17:26:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T17:27:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T17:28:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T17:29:51.462Z', + value: '1.295225759754669', + }, + { + time: '2017-08-27T17:30:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T17:31:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T17:32:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T17:33:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T17:34:51.462Z', + value: '1.295225759754669', + }, + { + time: '2017-08-27T17:35:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T17:36:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T17:37:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T17:38:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T17:39:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T17:40:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T17:41:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T17:42:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T17:43:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T17:44:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T17:45:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T17:46:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T17:47:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T17:48:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T17:49:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T17:50:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T17:51:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T17:52:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T17:53:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T17:54:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T17:55:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T17:56:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T17:57:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T17:58:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T17:59:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T18:00:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T18:01:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T18:02:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T18:03:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T18:04:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T18:05:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T18:06:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T18:07:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T18:08:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T18:09:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T18:10:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T18:11:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T18:12:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T18:13:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T18:14:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T18:15:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T18:16:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T18:17:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T18:18:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T18:19:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T18:20:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T18:21:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T18:22:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T18:23:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T18:24:51.462Z', + value: '1.2571428571428571', + }, + { + time: '2017-08-27T18:25:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T18:26:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T18:27:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T18:28:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T18:29:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T18:30:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T18:31:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T18:32:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T18:33:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T18:34:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T18:35:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T18:36:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T18:37:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T18:38:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T18:39:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T18:40:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T18:41:51.462Z', + value: '1.580952380952381', + }, + { + time: '2017-08-27T18:42:51.462Z', + value: '1.7333333333333334', + }, + { + time: '2017-08-27T18:43:51.462Z', + value: '2.057142857142857', + }, + { + time: '2017-08-27T18:44:51.462Z', + value: '2.1904761904761902', + }, + { + time: '2017-08-27T18:45:51.462Z', + value: '1.8285714285714287', + }, + { + time: '2017-08-27T18:46:51.462Z', + value: '2.1142857142857143', + }, + { + time: '2017-08-27T18:47:51.462Z', + value: '1.619047619047619', + }, + { + time: '2017-08-27T18:48:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T18:49:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T18:50:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T18:51:51.462Z', + value: '1.2952504309564854', + }, + { + time: '2017-08-27T18:52:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T18:53:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T18:54:51.462Z', + value: '1.3333333333333333', + }, + { + time: '2017-08-27T18:55:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T18:56:51.462Z', + value: '1.314285714285714', + }, + { + time: '2017-08-27T18:57:51.462Z', + value: '1.295238095238095', + }, + { + time: '2017-08-27T18:58:51.462Z', + value: '1.7142857142857142', + }, + { + time: '2017-08-27T18:59:51.462Z', + value: '1.7333333333333334', + }, + { + time: '2017-08-27T19:00:51.462Z', + value: '1.3904761904761904', + }, + { + time: '2017-08-27T19:01:51.462Z', + value: '1.5047619047619047', + }, + ], + }, + ], + when: [ + { + value: 'hundred(s)', + color: 'green', + }, + ], + }, + ], + }, + { + title: 'Throughput', + weight: 1, + y_label: 'Requests / Sec', + queries: [ + { + query_range: + "sum(rate(nginx_requests_total{server_zone!='*', server_zone!='_', container_name!='POD',environment='production'}[2m]))", + label: 'Total', + unit: 'req / sec', + result: [ + { + metric: {}, + values: [ + { + time: '2017-08-27T11:01:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T11:02:51.462Z', + value: '0.45714285714285713', + }, + { + time: '2017-08-27T11:03:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T11:04:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T11:05:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T11:06:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T11:07:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T11:08:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T11:09:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T11:10:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T11:11:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T11:12:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T11:13:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T11:14:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T11:15:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T11:16:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T11:17:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T11:18:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T11:19:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T11:20:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T11:21:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T11:22:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T11:23:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T11:24:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T11:25:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T11:26:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T11:27:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T11:28:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T11:29:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T11:30:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T11:31:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T11:32:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T11:33:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T11:34:51.462Z', + value: '0.4952333787297264', + }, + { + time: '2017-08-27T11:35:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T11:36:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T11:37:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T11:38:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T11:39:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T11:40:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T11:41:51.462Z', + value: '0.49524752852435283', + }, + { + time: '2017-08-27T11:42:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T11:43:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T11:44:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T11:45:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T11:46:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T11:47:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T11:48:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T11:49:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T11:50:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T11:51:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T11:52:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T11:53:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T11:54:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T11:55:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T11:56:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T11:57:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T11:58:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T11:59:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T12:00:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T12:01:51.462Z', + value: '0.49524281183630325', + }, + { + time: '2017-08-27T12:02:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T12:03:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T12:04:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T12:05:51.462Z', + value: '0.4857096599080009', + }, + { + time: '2017-08-27T12:06:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T12:07:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T12:08:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T12:09:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T12:10:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T12:11:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T12:12:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T12:13:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T12:14:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T12:15:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T12:16:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T12:17:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T12:18:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T12:19:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T12:20:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T12:21:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T12:22:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T12:23:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T12:24:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T12:25:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T12:26:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T12:27:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T12:28:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T12:29:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T12:30:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T12:31:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T12:32:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T12:33:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T12:34:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T12:35:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T12:36:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T12:37:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T12:38:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T12:39:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T12:40:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T12:41:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T12:42:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T12:43:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T12:44:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T12:45:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T12:46:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T12:47:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T12:48:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T12:49:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T12:50:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T12:51:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T12:52:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T12:53:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T12:54:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T12:55:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T12:56:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T12:57:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T12:58:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T12:59:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T13:00:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T13:01:51.462Z', + value: '0.4761859410862754', + }, + { + time: '2017-08-27T13:02:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T13:03:51.462Z', + value: '0.4761995466580315', + }, + { + time: '2017-08-27T13:04:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T13:05:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T13:06:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T13:07:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T13:08:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T13:09:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T13:10:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T13:11:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T13:12:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T13:13:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T13:14:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T13:15:51.462Z', + value: '0.45714285714285713', + }, + { + time: '2017-08-27T13:16:51.462Z', + value: '0.49524752852435283', + }, + { + time: '2017-08-27T13:17:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T13:18:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T13:19:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T13:20:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T13:21:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T13:22:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T13:23:51.462Z', + value: '0.4666666666666667', + }, + { + time: '2017-08-27T13:24:51.462Z', + value: '0.45714285714285713', + }, + { + time: '2017-08-27T13:25:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T13:26:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T13:27:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T13:28:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T13:29:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T13:30:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T13:31:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T13:32:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T13:33:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T13:34:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T13:35:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T13:36:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T13:37:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T13:38:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T13:39:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T13:40:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T13:41:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T13:42:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T13:43:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T13:44:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T13:45:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T13:46:51.462Z', + value: '0.45714285714285713', + }, + { + time: '2017-08-27T13:47:51.462Z', + value: '0.4666666666666667', + }, + { + time: '2017-08-27T13:48:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T13:49:51.462Z', + value: '0.4761859410862754', + }, + { + time: '2017-08-27T13:50:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T13:51:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T13:52:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T13:53:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T13:54:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T13:55:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T13:56:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T13:57:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T13:58:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T13:59:51.462Z', + value: '0.4761859410862754', + }, + { + time: '2017-08-27T14:00:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T14:01:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T14:02:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T14:03:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T14:04:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T14:05:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T14:06:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T14:07:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T14:08:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T14:09:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T14:10:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T14:11:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T14:12:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T14:13:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T14:14:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T14:15:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T14:16:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T14:17:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T14:18:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T14:19:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T14:20:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T14:21:51.462Z', + value: '0.4952286623111941', + }, + { + time: '2017-08-27T14:22:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T14:23:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T14:24:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T14:25:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T14:26:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T14:27:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T14:28:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T14:29:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T14:30:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T14:31:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T14:32:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T14:33:51.462Z', + value: '0.45714285714285713', + }, + { + time: '2017-08-27T14:34:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T14:35:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T14:36:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T14:37:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T14:38:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T14:39:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T14:40:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T14:41:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T14:42:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T14:43:51.462Z', + value: '0.4666666666666667', + }, + { + time: '2017-08-27T14:44:51.462Z', + value: '0.45714285714285713', + }, + { + time: '2017-08-27T14:45:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T14:46:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T14:47:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T14:48:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T14:49:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T14:50:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T14:51:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T14:52:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T14:53:51.462Z', + value: '0.4952333787297264', + }, + { + time: '2017-08-27T14:54:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T14:55:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T14:56:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T14:57:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T14:58:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T14:59:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T15:00:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T15:01:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T15:02:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T15:03:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T15:04:51.462Z', + value: '0.45714285714285713', + }, + { + time: '2017-08-27T15:05:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T15:06:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T15:07:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T15:08:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T15:09:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T15:10:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T15:11:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T15:12:51.462Z', + value: '0.4857096599080009', + }, + { + time: '2017-08-27T15:13:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T15:14:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T15:15:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T15:16:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T15:17:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T15:18:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T15:19:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T15:20:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T15:21:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T15:22:51.462Z', + value: '0.49524281183630325', + }, + { + time: '2017-08-27T15:23:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T15:24:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T15:25:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T15:26:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T15:27:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T15:28:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T15:29:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T15:30:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T15:31:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T15:32:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T15:33:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T15:34:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T15:35:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T15:36:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T15:37:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T15:38:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T15:39:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T15:40:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T15:41:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T15:42:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T15:43:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T15:44:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T15:45:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T15:46:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T15:47:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T15:48:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T15:49:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T15:50:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T15:51:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T15:52:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T15:53:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T15:54:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T15:55:51.462Z', + value: '0.49524752852435283', + }, + { + time: '2017-08-27T15:56:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T15:57:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T15:58:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T15:59:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T16:00:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T16:01:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T16:02:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T16:03:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T16:04:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T16:05:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T16:06:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T16:07:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T16:08:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T16:09:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T16:10:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T16:11:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T16:12:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T16:13:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T16:14:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T16:15:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T16:16:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T16:17:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T16:18:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T16:19:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T16:20:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T16:21:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T16:22:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T16:23:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T16:24:51.462Z', + value: '0.4761859410862754', + }, + { + time: '2017-08-27T16:25:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T16:26:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T16:27:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T16:28:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T16:29:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T16:30:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T16:31:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T16:32:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T16:33:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T16:34:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T16:35:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T16:36:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T16:37:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T16:38:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T16:39:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T16:40:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T16:41:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T16:42:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T16:43:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T16:44:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T16:45:51.462Z', + value: '0.485718911608682', + }, + { + time: '2017-08-27T16:46:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T16:47:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T16:48:51.462Z', + value: '0.4952333787297264', + }, + { + time: '2017-08-27T16:49:51.462Z', + value: '0.4857096599080009', + }, + { + time: '2017-08-27T16:50:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T16:51:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T16:52:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T16:53:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T16:54:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T16:55:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T16:56:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T16:57:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T16:58:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T16:59:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T17:00:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T17:01:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T17:02:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T17:03:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T17:04:51.462Z', + value: '0.47619501138106085', + }, + { + time: '2017-08-27T17:05:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T17:06:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T17:07:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T17:08:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T17:09:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T17:10:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T17:11:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T17:12:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T17:13:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T17:14:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T17:15:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T17:16:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T17:17:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T17:18:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T17:19:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T17:20:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T17:21:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T17:22:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T17:23:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T17:24:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T17:25:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T17:26:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T17:27:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T17:28:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T17:29:51.462Z', + value: '0.4761859410862754', + }, + { + time: '2017-08-27T17:30:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T17:31:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T17:32:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T17:33:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T17:34:51.462Z', + value: '0.4761859410862754', + }, + { + time: '2017-08-27T17:35:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T17:36:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T17:37:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T17:38:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T17:39:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T17:40:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T17:41:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T17:42:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T17:43:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T17:44:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T17:45:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T17:46:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T17:47:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T17:48:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T17:49:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T17:50:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T17:51:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T17:52:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T17:53:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T17:54:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T17:55:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T17:56:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T17:57:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T17:58:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T17:59:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T18:00:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T18:01:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T18:02:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T18:03:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T18:04:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T18:05:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T18:06:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T18:07:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T18:08:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T18:09:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T18:10:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T18:11:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T18:12:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T18:13:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T18:14:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T18:15:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T18:16:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T18:17:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T18:18:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T18:19:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T18:20:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T18:21:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T18:22:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T18:23:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T18:24:51.462Z', + value: '0.45714285714285713', + }, + { + time: '2017-08-27T18:25:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T18:26:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T18:27:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T18:28:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T18:29:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T18:30:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T18:31:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T18:32:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T18:33:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T18:34:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T18:35:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T18:36:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T18:37:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T18:38:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T18:39:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T18:40:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T18:41:51.462Z', + value: '0.6190476190476191', + }, + { + time: '2017-08-27T18:42:51.462Z', + value: '0.6952380952380952', + }, + { + time: '2017-08-27T18:43:51.462Z', + value: '0.857142857142857', + }, + { + time: '2017-08-27T18:44:51.462Z', + value: '0.9238095238095239', + }, + { + time: '2017-08-27T18:45:51.462Z', + value: '0.7428571428571429', + }, + { + time: '2017-08-27T18:46:51.462Z', + value: '0.8857142857142857', + }, + { + time: '2017-08-27T18:47:51.462Z', + value: '0.638095238095238', + }, + { + time: '2017-08-27T18:48:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T18:49:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T18:50:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T18:51:51.462Z', + value: '0.47619501138106085', + }, + { + time: '2017-08-27T18:52:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T18:53:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T18:54:51.462Z', + value: '0.4952380952380952', + }, + { + time: '2017-08-27T18:55:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T18:56:51.462Z', + value: '0.4857142857142857', + }, + { + time: '2017-08-27T18:57:51.462Z', + value: '0.47619047619047616', + }, + { + time: '2017-08-27T18:58:51.462Z', + value: '0.6857142857142856', + }, + { + time: '2017-08-27T18:59:51.462Z', + value: '0.6952380952380952', + }, + { + time: '2017-08-27T19:00:51.462Z', + value: '0.5238095238095237', + }, + { + time: '2017-08-27T19:01:51.462Z', + value: '0.5904761904761905', + }, + ], + }, + ], + }, + ], + }, ]; export function convertDatesMultipleSeries(multipleSeries) { const convertedMultiple = multipleSeries; multipleSeries.forEach((column, index) => { let convertedResult = []; - convertedResult = column.queries[0].result.map((resultObj) => { + convertedResult = column.queries[0].result.map(resultObj => { const convertedMetrics = {}; convertedMetrics.values = resultObj.values.map(val => ({ - time: new Date(val.time), - value: val.value, + time: new Date(val.time), + value: val.value, })); convertedMetrics.metric = resultObj.metric; return convertedMetrics; diff --git a/spec/javascripts/notes/mock_data.js b/spec/javascripts/notes/mock_data.js index 5be13ed0dfe..24388fba219 100644 --- a/spec/javascripts/notes/mock_data.js +++ b/spec/javascripts/notes/mock_data.js @@ -1,4 +1,3 @@ -/* eslint-disable */ export const notesDataMock = { discussionsPath: '/gitlab-org/gitlab-ce/issues/26/discussions.json', lastFetchedAt: 1501862675, @@ -43,7 +42,8 @@ export const noteableDataMock = { milestone: null, milestone_id: null, moved_to_id: null, - preview_note_path: '/gitlab-org/gitlab-ce/preview_markdown?quick_actions_target_id=98&quick_actions_target_type=Issue', + preview_note_path: + '/gitlab-org/gitlab-ce/preview_markdown?quick_actions_target_id=98&quick_actions_target_type=Issue', project_id: 2, state: 'opened', time_estimate: 0, @@ -52,6 +52,7 @@ export const noteableDataMock = { updated_at: '2017-08-04T09:53:01.226Z', updated_by_id: 1, web_url: '/gitlab-org/gitlab-ce/issues/26', + noteableType: 'issue', }; export const lastFetchedAt = '1501862675'; @@ -60,465 +61,504 @@ export const individualNote = { expanded: true, id: '0fb4e0e3f9276e55ff32eb4195add694aece4edd', individual_note: true, - notes: [{ - id: 1390, - attachment: { - url: null, - filename: null, - image: false, - }, - author: { - id: 1, - name: 'Root', - username: 'root', - state: 'active', - avatar_url: 'test', - path: '/root', + notes: [ + { + id: 1390, + attachment: { + url: null, + filename: null, + image: false, + }, + author: { + id: 1, + name: 'Root', + username: 'root', + state: 'active', + avatar_url: 'test', + path: '/root', + }, + created_at: '2017-08-01T17: 09: 33.762Z', + updated_at: '2017-08-01T17: 09: 33.762Z', + system: false, + noteable_id: 98, + noteable_type: 'Issue', + type: null, + human_access: 'Owner', + note: 'sdfdsaf', + note_html: "<p dir='auto'>sdfdsaf</p>", + current_user: { can_edit: true }, + discussion_id: '0fb4e0e3f9276e55ff32eb4195add694aece4edd', + emoji_awardable: true, + award_emoji: [ + { name: 'baseball', user: { id: 1, name: 'Root', username: 'root' } }, + { name: 'art', user: { id: 1, name: 'Root', username: 'root' } }, + ], + toggle_award_path: '/gitlab-org/gitlab-ce/notes/1390/toggle_award_emoji', + report_abuse_path: + '/abuse_reports/new?ref_url=http%3A%2F%2Flocalhost%3A3000%2Fgitlab-org%2Fgitlab-ce%2Fissues%2F26%23note_1390&user_id=1', + path: '/gitlab-org/gitlab-ce/notes/1390', }, - created_at: '2017-08-01T17: 09: 33.762Z', - updated_at: '2017-08-01T17: 09: 33.762Z', - system: false, - noteable_id: 98, - noteable_type: 'Issue', - type: null, - human_access: 'Owner', - note: 'sdfdsaf', - note_html: '<p dir=\'auto\'>sdfdsaf</p>', - current_user: { can_edit: true }, - discussion_id: '0fb4e0e3f9276e55ff32eb4195add694aece4edd', - emoji_awardable: true, - award_emoji: [ - { name: 'baseball', user: { id: 1, name: 'Root', username: 'root' } }, - { name: 'art', user: { id: 1, name: 'Root', username: 'root' } }, - ], - toggle_award_path: '/gitlab-org/gitlab-ce/notes/1390/toggle_award_emoji', - report_abuse_path: '/abuse_reports/new?ref_url=http%3A%2F%2Flocalhost%3A3000%2Fgitlab-org%2Fgitlab-ce%2Fissues%2F26%23note_1390&user_id=1', - path: '/gitlab-org/gitlab-ce/notes/1390', - }], + ], reply_id: '0fb4e0e3f9276e55ff32eb4195add694aece4edd', }; export const note = { - "id": 546, - "attachment": { - "url": null, - "filename": null, - "image": false + id: 546, + attachment: { + url: null, + filename: null, + image: false, }, - "author": { - "id": 1, - "name": "Administrator", - "username": "root", - "state": "active", - "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", - "path": "/root" + author: { + id: 1, + name: 'Administrator', + username: 'root', + state: 'active', + avatar_url: 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', + path: '/root', }, - "created_at": "2017-08-10T15:24:03.087Z", - "updated_at": "2017-08-10T15:24:03.087Z", - "system": false, - "noteable_id": 67, - "noteable_type": "Issue", - "noteable_iid": 7, - "type": null, - "human_access": "Owner", - "note": "Vel id placeat reprehenderit sit numquam.", - "note_html": "<p dir=\"auto\">Vel id placeat reprehenderit sit numquam.</p>", - "current_user": { - "can_edit": true + created_at: '2017-08-10T15:24:03.087Z', + updated_at: '2017-08-10T15:24:03.087Z', + system: false, + noteable_id: 67, + noteable_type: 'Issue', + noteable_iid: 7, + type: null, + human_access: 'Owner', + note: 'Vel id placeat reprehenderit sit numquam.', + note_html: '<p dir="auto">Vel id placeat reprehenderit sit numquam.</p>', + current_user: { + can_edit: true, }, - "discussion_id": "d3842a451b7f3d9a5dfce329515127b2d29a4cd0", - "emoji_awardable": true, - "award_emoji": [{ - "name": "baseball", - "user": { - "id": 1, - "name": "Administrator", - "username": "root" - } - }, { - "name": "bath_tone3", - "user": { - "id": 1, - "name": "Administrator", - "username": "root" - } - }], - "toggle_award_path": "/gitlab-org/gitlab-ce/notes/546/toggle_award_emoji", - "report_abuse_path": "/abuse_reports/new?ref_url=http%3A%2F%2Flocalhost%3A3000%2Fgitlab-org%2Fgitlab-ce%2Fissues%2F7%23note_546&user_id=1", - "path": "/gitlab-org/gitlab-ce/notes/546" - } + discussion_id: 'd3842a451b7f3d9a5dfce329515127b2d29a4cd0', + emoji_awardable: true, + award_emoji: [ + { + name: 'baseball', + user: { + id: 1, + name: 'Administrator', + username: 'root', + }, + }, + { + name: 'bath_tone3', + user: { + id: 1, + name: 'Administrator', + username: 'root', + }, + }, + ], + toggle_award_path: '/gitlab-org/gitlab-ce/notes/546/toggle_award_emoji', + report_abuse_path: + '/abuse_reports/new?ref_url=http%3A%2F%2Flocalhost%3A3000%2Fgitlab-org%2Fgitlab-ce%2Fissues%2F7%23note_546&user_id=1', + path: '/gitlab-org/gitlab-ce/notes/546', +}; export const discussionMock = { id: '9e3bd2f71a01de45fd166e6719eb380ad9f270b1', reply_id: '9e3bd2f71a01de45fd166e6719eb380ad9f270b1', expanded: true, - notes: [{ - id: 1395, - attachment: { - url: null, - filename: null, - image: false, - }, - author: { - id: 1, - name: 'Root', - username: 'root', - state: 'active', - avatar_url: null, - path: '/root', - }, - created_at: '2017-08-02T10:51:58.559Z', - updated_at: '2017-08-02T10:51:58.559Z', - system: false, - noteable_id: 98, - noteable_type: 'Issue', - type: 'DiscussionNote', - human_access: 'Owner', - note: 'THIS IS A DICUSSSION!', - note_html: '<p dir=\'auto\'>THIS IS A DICUSSSION!</p>', - current_user: { - can_edit: true, - }, - discussion_id: '9e3bd2f71a01de45fd166e6719eb380ad9f270b1', - emoji_awardable: true, - award_emoji: [], - toggle_award_path: '/gitlab-org/gitlab-ce/notes/1395/toggle_award_emoji', - report_abuse_path: '/abuse_reports/new?ref_url=http%3A%2F%2Flocalhost%3A3000%2Fgitlab-org%2Fgitlab-ce%2Fissues%2F26%23note_1395&user_id=1', - path: '/gitlab-org/gitlab-ce/notes/1395', - }, { - id: 1396, - attachment: { - url: null, - filename: null, - image: false, - }, - author: { - id: 1, - name: 'Root', - username: 'root', - state: 'active', - avatar_url: null, - path: '/root', - }, - created_at: '2017-08-02T10:56:50.980Z', - updated_at: '2017-08-03T14:19:35.691Z', - system: false, - noteable_id: 98, - noteable_type: 'Issue', - type: 'DiscussionNote', - human_access: 'Owner', - note: 'sadfasdsdgdsf', - note_html: '<p dir=\'auto\'>sadfasdsdgdsf</p>', - last_edited_at: '2017-08-03T14:19:35.691Z', - last_edited_by: { - id: 1, - name: 'Root', - username: 'root', - state: 'active', - avatar_url: null, - path: '/root', - }, - current_user: { - can_edit: true, + notes: [ + { + id: 1395, + attachment: { + url: null, + filename: null, + image: false, + }, + author: { + id: 1, + name: 'Root', + username: 'root', + state: 'active', + avatar_url: null, + path: '/root', + }, + created_at: '2017-08-02T10:51:58.559Z', + updated_at: '2017-08-02T10:51:58.559Z', + system: false, + noteable_id: 98, + noteable_type: 'Issue', + type: 'DiscussionNote', + human_access: 'Owner', + note: 'THIS IS A DICUSSSION!', + note_html: "<p dir='auto'>THIS IS A DICUSSSION!</p>", + current_user: { + can_edit: true, + }, + discussion_id: '9e3bd2f71a01de45fd166e6719eb380ad9f270b1', + emoji_awardable: true, + award_emoji: [], + toggle_award_path: '/gitlab-org/gitlab-ce/notes/1395/toggle_award_emoji', + report_abuse_path: + '/abuse_reports/new?ref_url=http%3A%2F%2Flocalhost%3A3000%2Fgitlab-org%2Fgitlab-ce%2Fissues%2F26%23note_1395&user_id=1', + path: '/gitlab-org/gitlab-ce/notes/1395', }, - discussion_id: '9e3bd2f71a01de45fd166e6719eb380ad9f270b1', - emoji_awardable: true, - award_emoji: [], - toggle_award_path: '/gitlab-org/gitlab-ce/notes/1396/toggle_award_emoji', - report_abuse_path: '/abuse_reports/new?ref_url=http%3A%2F%2Flocalhost%3A3000%2Fgitlab-org%2Fgitlab-ce%2Fissues%2F26%23note_1396&user_id=1', - path: '/gitlab-org/gitlab-ce/notes/1396', - }, { - id: 1437, - attachment: { - url: null, - filename: null, - image: false, + { + id: 1396, + attachment: { + url: null, + filename: null, + image: false, + }, + author: { + id: 1, + name: 'Root', + username: 'root', + state: 'active', + avatar_url: null, + path: '/root', + }, + created_at: '2017-08-02T10:56:50.980Z', + updated_at: '2017-08-03T14:19:35.691Z', + system: false, + noteable_id: 98, + noteable_type: 'Issue', + type: 'DiscussionNote', + human_access: 'Owner', + note: 'sadfasdsdgdsf', + note_html: "<p dir='auto'>sadfasdsdgdsf</p>", + last_edited_at: '2017-08-03T14:19:35.691Z', + last_edited_by: { + id: 1, + name: 'Root', + username: 'root', + state: 'active', + avatar_url: null, + path: '/root', + }, + current_user: { + can_edit: true, + }, + discussion_id: '9e3bd2f71a01de45fd166e6719eb380ad9f270b1', + emoji_awardable: true, + award_emoji: [], + toggle_award_path: '/gitlab-org/gitlab-ce/notes/1396/toggle_award_emoji', + report_abuse_path: + '/abuse_reports/new?ref_url=http%3A%2F%2Flocalhost%3A3000%2Fgitlab-org%2Fgitlab-ce%2Fissues%2F26%23note_1396&user_id=1', + path: '/gitlab-org/gitlab-ce/notes/1396', }, - author: { - id: 1, - name: 'Root', - username: 'root', - state: 'active', - avatar_url: null, - path: '/root', + { + id: 1437, + attachment: { + url: null, + filename: null, + image: false, + }, + author: { + id: 1, + name: 'Root', + username: 'root', + state: 'active', + avatar_url: null, + path: '/root', + }, + created_at: '2017-08-03T18:11:18.780Z', + updated_at: '2017-08-04T09:52:31.062Z', + system: false, + noteable_id: 98, + noteable_type: 'Issue', + type: 'DiscussionNote', + human_access: 'Owner', + note: 'adsfasf Should disappear', + note_html: "<p dir='auto'>adsfasf Should disappear</p>", + last_edited_at: '2017-08-04T09:52:31.062Z', + last_edited_by: { + id: 1, + name: 'Root', + username: 'root', + state: 'active', + avatar_url: null, + path: '/root', + }, + current_user: { + can_edit: true, + }, + discussion_id: '9e3bd2f71a01de45fd166e6719eb380ad9f270b1', + emoji_awardable: true, + award_emoji: [], + toggle_award_path: '/gitlab-org/gitlab-ce/notes/1437/toggle_award_emoji', + report_abuse_path: + '/abuse_reports/new?ref_url=http%3A%2F%2Flocalhost%3A3000%2Fgitlab-org%2Fgitlab-ce%2Fissues%2F26%23note_1437&user_id=1', + path: '/gitlab-org/gitlab-ce/notes/1437', }, - created_at: '2017-08-03T18:11:18.780Z', - updated_at: '2017-08-04T09:52:31.062Z', - system: false, - noteable_id: 98, - noteable_type: 'Issue', - type: 'DiscussionNote', - human_access: 'Owner', - note: 'adsfasf Should disappear', - note_html: '<p dir=\'auto\'>adsfasf Should disappear</p>', - last_edited_at: '2017-08-04T09:52:31.062Z', - last_edited_by: { + ], + individual_note: false, +}; + +export const loggedOutnoteableData = { + id: 98, + iid: 26, + author_id: 1, + description: '', + lock_version: 1, + milestone_id: null, + state: 'opened', + title: 'asdsa', + updated_by_id: 1, + created_at: '2017-02-07T10:11:18.395Z', + updated_at: '2017-08-08T10:22:51.564Z', + time_estimate: 0, + total_time_spent: 0, + human_time_estimate: null, + human_total_time_spent: null, + milestone: null, + labels: [], + branch_name: null, + confidential: false, + assignees: [ + { id: 1, name: 'Root', username: 'root', state: 'active', avatar_url: null, - path: '/root', + web_url: 'http://localhost:3000/root', }, - current_user: { - can_edit: true, - }, - discussion_id: '9e3bd2f71a01de45fd166e6719eb380ad9f270b1', - emoji_awardable: true, - award_emoji: [], - toggle_award_path: '/gitlab-org/gitlab-ce/notes/1437/toggle_award_emoji', - report_abuse_path: '/abuse_reports/new?ref_url=http%3A%2F%2Flocalhost%3A3000%2Fgitlab-org%2Fgitlab-ce%2Fissues%2F26%23note_1437&user_id=1', - path: '/gitlab-org/gitlab-ce/notes/1437', - }], - individual_note: false, -}; - -export const loggedOutnoteableData = { - "id": 98, - "iid": 26, - "author_id": 1, - "description": "", - "lock_version": 1, - "milestone_id": null, - "state": "opened", - "title": "asdsa", - "updated_by_id": 1, - "created_at": "2017-02-07T10:11:18.395Z", - "updated_at": "2017-08-08T10:22:51.564Z", - "time_estimate": 0, - "total_time_spent": 0, - "human_time_estimate": null, - "human_total_time_spent": null, - "milestone": null, - "labels": [], - "branch_name": null, - "confidential": false, - "assignees": [{ - "id": 1, - "name": "Root", - "username": "root", - "state": "active", - "avatar_url": null, - "web_url": "http://localhost:3000/root" - }], - "due_date": null, - "moved_to_id": null, - "project_id": 2, - "web_url": "/gitlab-org/gitlab-ce/issues/26", - "current_user": { - "can_create_note": false, - "can_update": false + ], + due_date: null, + moved_to_id: null, + project_id: 2, + web_url: '/gitlab-org/gitlab-ce/issues/26', + current_user: { + can_create_note: false, + can_update: false, }, - "create_note_path": "/gitlab-org/gitlab-ce/notes?target_id=98&target_type=issue", - "preview_note_path": "/gitlab-org/gitlab-ce/preview_markdown?quick_actions_target_id=98&quick_actions_target_type=Issue" -} + create_note_path: '/gitlab-org/gitlab-ce/notes?target_id=98&target_type=issue', + preview_note_path: + '/gitlab-org/gitlab-ce/preview_markdown?quick_actions_target_id=98&quick_actions_target_type=Issue', +}; export const INDIVIDUAL_NOTE_RESPONSE_MAP = { - 'GET': { - '/gitlab-org/gitlab-ce/issues/26/discussions.json': [{ - "id": "0fb4e0e3f9276e55ff32eb4195add694aece4edd", - "reply_id": "0fb4e0e3f9276e55ff32eb4195add694aece4edd", - "expanded": true, - "notes": [{ - "id": 1390, - "attachment": { - "url": null, - "filename": null, - "image": false - }, - "author": { - "id": 1, - "name": "Root", - "username": "root", - "state": "active", - "avatar_url": null, - "path": "/root" - }, - "created_at": "2017-08-01T17:09:33.762Z", - "updated_at": "2017-08-01T17:09:33.762Z", - "system": false, - "noteable_id": 98, - "noteable_type": "Issue", - "type": null, - "human_access": "Owner", - "note": "sdfdsaf", - "note_html": "\u003cp dir=\"auto\"\u003esdfdsaf\u003c/p\u003e", - "current_user": { - "can_edit": true - }, - "discussion_id": "0fb4e0e3f9276e55ff32eb4195add694aece4edd", - "emoji_awardable": true, - "award_emoji": [{ - "name": "baseball", - "user": { - "id": 1, - "name": "Root", - "username": "root" - } - }, { - "name": "art", - "user": { - "id": 1, - "name": "Root", - "username": "root" - } - }], - "toggle_award_path": "/gitlab-org/gitlab-ce/notes/1390/toggle_award_emoji", - "report_abuse_path": "/abuse_reports/new?ref_url=http%3A%2F%2Flocalhost%3A3000%2Fgitlab-org%2Fgitlab-ce%2Fissues%2F26%23note_1390\u0026user_id=1", - "path": "/gitlab-org/gitlab-ce/notes/1390" - }], - "individual_note": true - }, { - "id": "70d5c92a4039a36c70100c6691c18c27e4b0a790", - "reply_id": "70d5c92a4039a36c70100c6691c18c27e4b0a790", - "expanded": true, - "notes": [{ - "id": 1391, - "attachment": { - "url": null, - "filename": null, - "image": false - }, - "author": { - "id": 1, - "name": "Root", - "username": "root", - "state": "active", - "avatar_url": null, - "path": "/root" - }, - "created_at": "2017-08-02T10:51:38.685Z", - "updated_at": "2017-08-02T10:51:38.685Z", - "system": false, - "noteable_id": 98, - "noteable_type": "Issue", - "type": null, - "human_access": "Owner", - "note": "New note!", - "note_html": "\u003cp dir=\"auto\"\u003eNew note!\u003c/p\u003e", - "current_user": { - "can_edit": true - }, - "discussion_id": "70d5c92a4039a36c70100c6691c18c27e4b0a790", - "emoji_awardable": true, - "award_emoji": [], - "toggle_award_path": "/gitlab-org/gitlab-ce/notes/1391/toggle_award_emoji", - "report_abuse_path": "/abuse_reports/new?ref_url=http%3A%2F%2Flocalhost%3A3000%2Fgitlab-org%2Fgitlab-ce%2Fissues%2F26%23note_1391\u0026user_id=1", - "path": "/gitlab-org/gitlab-ce/notes/1391" - }], - "individual_note": true - }], + GET: { + '/gitlab-org/gitlab-ce/issues/26/discussions.json': [ + { + id: '0fb4e0e3f9276e55ff32eb4195add694aece4edd', + reply_id: '0fb4e0e3f9276e55ff32eb4195add694aece4edd', + expanded: true, + notes: [ + { + id: 1390, + attachment: { + url: null, + filename: null, + image: false, + }, + author: { + id: 1, + name: 'Root', + username: 'root', + state: 'active', + avatar_url: null, + path: '/root', + }, + created_at: '2017-08-01T17:09:33.762Z', + updated_at: '2017-08-01T17:09:33.762Z', + system: false, + noteable_id: 98, + noteable_type: 'Issue', + type: null, + human_access: 'Owner', + note: 'sdfdsaf', + note_html: '\u003cp dir="auto"\u003esdfdsaf\u003c/p\u003e', + current_user: { + can_edit: true, + }, + discussion_id: '0fb4e0e3f9276e55ff32eb4195add694aece4edd', + emoji_awardable: true, + award_emoji: [ + { + name: 'baseball', + user: { + id: 1, + name: 'Root', + username: 'root', + }, + }, + { + name: 'art', + user: { + id: 1, + name: 'Root', + username: 'root', + }, + }, + ], + toggle_award_path: '/gitlab-org/gitlab-ce/notes/1390/toggle_award_emoji', + report_abuse_path: + '/abuse_reports/new?ref_url=http%3A%2F%2Flocalhost%3A3000%2Fgitlab-org%2Fgitlab-ce%2Fissues%2F26%23note_1390\u0026user_id=1', + path: '/gitlab-org/gitlab-ce/notes/1390', + }, + ], + individual_note: true, + }, + { + id: '70d5c92a4039a36c70100c6691c18c27e4b0a790', + reply_id: '70d5c92a4039a36c70100c6691c18c27e4b0a790', + expanded: true, + notes: [ + { + id: 1391, + attachment: { + url: null, + filename: null, + image: false, + }, + author: { + id: 1, + name: 'Root', + username: 'root', + state: 'active', + avatar_url: null, + path: '/root', + }, + created_at: '2017-08-02T10:51:38.685Z', + updated_at: '2017-08-02T10:51:38.685Z', + system: false, + noteable_id: 98, + noteable_type: 'Issue', + type: null, + human_access: 'Owner', + note: 'New note!', + note_html: '\u003cp dir="auto"\u003eNew note!\u003c/p\u003e', + current_user: { + can_edit: true, + }, + discussion_id: '70d5c92a4039a36c70100c6691c18c27e4b0a790', + emoji_awardable: true, + award_emoji: [], + toggle_award_path: '/gitlab-org/gitlab-ce/notes/1391/toggle_award_emoji', + report_abuse_path: + '/abuse_reports/new?ref_url=http%3A%2F%2Flocalhost%3A3000%2Fgitlab-org%2Fgitlab-ce%2Fissues%2F26%23note_1391\u0026user_id=1', + path: '/gitlab-org/gitlab-ce/notes/1391', + }, + ], + individual_note: true, + }, + ], '/gitlab-org/gitlab-ce/noteable/issue/98/notes': { last_fetched_at: 1512900838, notes: [], }, }, - 'PUT': { + PUT: { '/gitlab-org/gitlab-ce/notes/1471': { - "commands_changes": null, - "valid": true, - "id": 1471, - "attachment": null, - "author": { - "id": 1, - "name": "Root", - "username": "root", - "state": "active", - "avatar_url": null, - "path": "/root" + commands_changes: null, + valid: true, + id: 1471, + attachment: null, + author: { + id: 1, + name: 'Root', + username: 'root', + state: 'active', + avatar_url: null, + path: '/root', }, - "created_at": "2017-08-08T16:53:00.666Z", - "updated_at": "2017-12-10T11:03:21.876Z", - "system": false, - "noteable_id": 124, - "noteable_type": "Issue", - "noteable_iid": 29, - "type": "DiscussionNote", - "human_access": "Owner", - "note": "Adding a comment", - "note_html": "\u003cp dir=\"auto\"\u003eAdding a comment\u003c/p\u003e", - "last_edited_at": "2017-12-10T11:03:21.876Z", - "last_edited_by": { - "id": 1, - "name": 'Root', - "username": 'root', - "state": 'active', - "avatar_url": null, - "path": '/root', + created_at: '2017-08-08T16:53:00.666Z', + updated_at: '2017-12-10T11:03:21.876Z', + system: false, + noteable_id: 124, + noteable_type: 'Issue', + noteable_iid: 29, + type: 'DiscussionNote', + human_access: 'Owner', + note: 'Adding a comment', + note_html: '\u003cp dir="auto"\u003eAdding a comment\u003c/p\u003e', + last_edited_at: '2017-12-10T11:03:21.876Z', + last_edited_by: { + id: 1, + name: 'Root', + username: 'root', + state: 'active', + avatar_url: null, + path: '/root', }, - "current_user": { - "can_edit": true + current_user: { + can_edit: true, }, - "discussion_id": "a3ed36e29b1957efb3b68c53e2d7a2b24b1df052", - "emoji_awardable": true, - "award_emoji": [], - "toggle_award_path": "/gitlab-org/gitlab-ce/notes/1471/toggle_award_emoji", - "report_abuse_path": "/abuse_reports/new?ref_url=http%3A%2F%2Flocalhost%3A3000%2Fgitlab-org%2Fgitlab-ce%2Fissues%2F29%23note_1471\u0026user_id=1", - "path": "/gitlab-org/gitlab-ce/notes/1471" + discussion_id: 'a3ed36e29b1957efb3b68c53e2d7a2b24b1df052', + emoji_awardable: true, + award_emoji: [], + toggle_award_path: '/gitlab-org/gitlab-ce/notes/1471/toggle_award_emoji', + report_abuse_path: + '/abuse_reports/new?ref_url=http%3A%2F%2Flocalhost%3A3000%2Fgitlab-org%2Fgitlab-ce%2Fissues%2F29%23note_1471\u0026user_id=1', + path: '/gitlab-org/gitlab-ce/notes/1471', }, - } + }, }; export const DISCUSSION_NOTE_RESPONSE_MAP = { ...INDIVIDUAL_NOTE_RESPONSE_MAP, - 'GET': { + GET: { ...INDIVIDUAL_NOTE_RESPONSE_MAP.GET, - '/gitlab-org/gitlab-ce/issues/26/discussions.json': [{ - "id": "a3ed36e29b1957efb3b68c53e2d7a2b24b1df052", - "reply_id": "a3ed36e29b1957efb3b68c53e2d7a2b24b1df052", - "expanded": true, - "notes": [{ - "id": 1471, - "attachment": { - "url": null, - "filename": null, - "image": false - }, - "author": { - "id": 1, - "name": "Root", - "username": "root", - "state": "active", - "avatar_url": null, - "path": "/root" - }, - "created_at": "2017-08-08T16:53:00.666Z", - "updated_at": "2017-08-08T16:53:00.666Z", - "system": false, - "noteable_id": 124, - "noteable_type": "Issue", - "noteable_iid": 29, - "type": "DiscussionNote", - "human_access": "Owner", - "note": "Adding a comment", - "note_html": "\u003cp dir=\"auto\"\u003eAdding a comment\u003c/p\u003e", - "current_user": { - "can_edit": true - }, - "discussion_id": "a3ed36e29b1957efb3b68c53e2d7a2b24b1df052", - "emoji_awardable": true, - "award_emoji": [], - "toggle_award_path": "/gitlab-org/gitlab-ce/notes/1471/toggle_award_emoji", - "report_abuse_path": "/abuse_reports/new?ref_url=http%3A%2F%2Flocalhost%3A3000%2Fgitlab-org%2Fgitlab-ce%2Fissues%2F29%23note_1471\u0026user_id=1", - "path": "/gitlab-org/gitlab-ce/notes/1471" - }], - "individual_note": false - }], + '/gitlab-org/gitlab-ce/issues/26/discussions.json': [ + { + id: 'a3ed36e29b1957efb3b68c53e2d7a2b24b1df052', + reply_id: 'a3ed36e29b1957efb3b68c53e2d7a2b24b1df052', + expanded: true, + notes: [ + { + id: 1471, + attachment: { + url: null, + filename: null, + image: false, + }, + author: { + id: 1, + name: 'Root', + username: 'root', + state: 'active', + avatar_url: null, + path: '/root', + }, + created_at: '2017-08-08T16:53:00.666Z', + updated_at: '2017-08-08T16:53:00.666Z', + system: false, + noteable_id: 124, + noteable_type: 'Issue', + noteable_iid: 29, + type: 'DiscussionNote', + human_access: 'Owner', + note: 'Adding a comment', + note_html: '\u003cp dir="auto"\u003eAdding a comment\u003c/p\u003e', + current_user: { + can_edit: true, + }, + discussion_id: 'a3ed36e29b1957efb3b68c53e2d7a2b24b1df052', + emoji_awardable: true, + award_emoji: [], + toggle_award_path: '/gitlab-org/gitlab-ce/notes/1471/toggle_award_emoji', + report_abuse_path: + '/abuse_reports/new?ref_url=http%3A%2F%2Flocalhost%3A3000%2Fgitlab-org%2Fgitlab-ce%2Fissues%2F29%23note_1471\u0026user_id=1', + path: '/gitlab-org/gitlab-ce/notes/1471', + }, + ], + individual_note: false, + }, + ], }, }; export function individualNoteInterceptor(request, next) { const body = INDIVIDUAL_NOTE_RESPONSE_MAP[request.method.toUpperCase()][request.url]; - next(request.respondWith(JSON.stringify(body), { - status: 200, - })); + next( + request.respondWith(JSON.stringify(body), { + status: 200, + }), + ); } export function discussionNoteInterceptor(request, next) { const body = DISCUSSION_NOTE_RESPONSE_MAP[request.method.toUpperCase()][request.url]; - next(request.respondWith(JSON.stringify(body), { - status: 200, - })); + next( + request.respondWith(JSON.stringify(body), { + status: 200, + }), + ); } diff --git a/spec/javascripts/pipelines/graph/action_component_spec.js b/spec/javascripts/pipelines/graph/action_component_spec.js index e8fcd4b1a36..581209f215d 100644 --- a/spec/javascripts/pipelines/graph/action_component_spec.js +++ b/spec/javascripts/pipelines/graph/action_component_spec.js @@ -1,25 +1,30 @@ import Vue from 'vue'; import actionComponent from '~/pipelines/components/graph/action_component.vue'; +import eventHub from '~/pipelines/event_hub'; +import mountComponent from '../../helpers/vue_mount_component_helper'; describe('pipeline graph action component', () => { let component; beforeEach((done) => { const ActionComponent = Vue.extend(actionComponent); - component = new ActionComponent({ - propsData: { - tooltipText: 'bar', - link: 'foo', - actionMethod: 'post', - actionIcon: 'cancel', - }, - }).$mount(); + component = mountComponent(ActionComponent, { + tooltipText: 'bar', + link: 'foo', + actionIcon: 'cancel', + }); Vue.nextTick(done); }); - it('should render a link', () => { - expect(component.$el.getAttribute('href')).toEqual('foo'); + afterEach(() => { + component.$destroy(); + }); + + it('should emit an event with the provided link', () => { + eventHub.$on('graphAction', (link) => { + expect(link).toEqual('foo'); + }); }); it('should render the provided title as a bootstrap tooltip', () => { diff --git a/spec/javascripts/pipelines/graph/job_component_spec.js b/spec/javascripts/pipelines/graph/job_component_spec.js index ce181a1e515..c9677ae209a 100644 --- a/spec/javascripts/pipelines/graph/job_component_spec.js +++ b/spec/javascripts/pipelines/graph/job_component_spec.js @@ -13,6 +13,7 @@ describe('pipeline graph job component', () => { icon: 'icon_status_success', text: 'passed', label: 'passed', + tooltip: 'passed', group: 'success', details_path: '/root/ci-mock/builds/4256', has_details: true, @@ -137,6 +138,7 @@ describe('pipeline graph job component', () => { status: { icon: 'icon_status_success', label: 'success', + tooltip: 'success', }, }, }); diff --git a/spec/javascripts/pipelines/graph/mock_data.js b/spec/javascripts/pipelines/graph/mock_data.js index b9494f86d74..70eba98e939 100644 --- a/spec/javascripts/pipelines/graph/mock_data.js +++ b/spec/javascripts/pipelines/graph/mock_data.js @@ -1,232 +1,261 @@ -/* eslint-disable quote-props, quotes, comma-dangle */ export default { - "id": 123, - "user": { - "name": "Root", - "username": "root", - "id": 1, - "state": "active", - "avatar_url": null, - "web_url": "http://localhost:3000/root" + id: 123, + user: { + name: 'Root', + username: 'root', + id: 1, + state: 'active', + avatar_url: null, + web_url: 'http://localhost:3000/root', }, - "active": false, - "coverage": null, - "path": "/root/ci-mock/pipelines/123", - "details": { - "status": { - "icon": "icon_status_success", - "text": "passed", - "label": "passed", - "group": "success", - "has_details": true, - "details_path": "/root/ci-mock/pipelines/123", - "favicon": "/assets/ci_favicons/dev/favicon_status_success-308b4fc054cdd1b68d0865e6cfb7b02e92e3472f201507418f8eddb74ac11a59.ico" + active: false, + coverage: null, + path: '/root/ci-mock/pipelines/123', + details: { + status: { + icon: 'icon_status_success', + text: 'passed', + label: 'passed', + group: 'success', + has_details: true, + details_path: '/root/ci-mock/pipelines/123', + favicon: + '/assets/ci_favicons/dev/favicon_status_success-308b4fc054cdd1b68d0865e6cfb7b02e92e3472f201507418f8eddb74ac11a59.ico', }, - "duration": 9, - "finished_at": "2017-04-19T14:30:27.542Z", - "stages": [{ - "name": "test", - "title": "test: passed", - "groups": [{ - "name": "test", - "size": 1, - "status": { - "icon": "icon_status_success", - "text": "passed", - "label": "passed", - "group": "success", - "has_details": true, - "details_path": "/root/ci-mock/builds/4153", - "favicon": "/assets/ci_favicons/dev/favicon_status_success-308b4fc054cdd1b68d0865e6cfb7b02e92e3472f201507418f8eddb74ac11a59.ico", - "action": { - "icon": "retry", - "title": "Retry", - "path": "/root/ci-mock/builds/4153/retry", - "method": "post" - } + duration: 9, + finished_at: '2017-04-19T14:30:27.542Z', + stages: [ + { + name: 'test', + title: 'test: passed', + groups: [ + { + name: 'test', + size: 1, + status: { + icon: 'icon_status_success', + text: 'passed', + label: 'passed', + group: 'success', + has_details: true, + details_path: '/root/ci-mock/builds/4153', + favicon: + '/assets/ci_favicons/dev/favicon_status_success-308b4fc054cdd1b68d0865e6cfb7b02e92e3472f201507418f8eddb74ac11a59.ico', + action: { + icon: 'retry', + title: 'Retry', + path: '/root/ci-mock/builds/4153/retry', + method: 'post', + }, + }, + jobs: [ + { + id: 4153, + name: 'test', + build_path: '/root/ci-mock/builds/4153', + retry_path: '/root/ci-mock/builds/4153/retry', + playable: false, + created_at: '2017-04-13T09:25:18.959Z', + updated_at: '2017-04-13T09:25:23.118Z', + status: { + icon: 'icon_status_success', + text: 'passed', + label: 'passed', + group: 'success', + has_details: true, + details_path: '/root/ci-mock/builds/4153', + favicon: + '/assets/ci_favicons/dev/favicon_status_success-308b4fc054cdd1b68d0865e6cfb7b02e92e3472f201507418f8eddb74ac11a59.ico', + action: { + icon: 'retry', + title: 'Retry', + path: '/root/ci-mock/builds/4153/retry', + method: 'post', + }, + }, + }, + ], + }, + ], + status: { + icon: 'icon_status_success', + text: 'passed', + label: 'passed', + group: 'success', + has_details: true, + details_path: '/root/ci-mock/pipelines/123#test', + favicon: + '/assets/ci_favicons/dev/favicon_status_success-308b4fc054cdd1b68d0865e6cfb7b02e92e3472f201507418f8eddb74ac11a59.ico', }, - "jobs": [{ - "id": 4153, - "name": "test", - "build_path": "/root/ci-mock/builds/4153", - "retry_path": "/root/ci-mock/builds/4153/retry", - "playable": false, - "created_at": "2017-04-13T09:25:18.959Z", - "updated_at": "2017-04-13T09:25:23.118Z", - "status": { - "icon": "icon_status_success", - "text": "passed", - "label": "passed", - "group": "success", - "has_details": true, - "details_path": "/root/ci-mock/builds/4153", - "favicon": "/assets/ci_favicons/dev/favicon_status_success-308b4fc054cdd1b68d0865e6cfb7b02e92e3472f201507418f8eddb74ac11a59.ico", - "action": { - "icon": "retry", - "title": "Retry", - "path": "/root/ci-mock/builds/4153/retry", - "method": "post" - } - } - }] - }], - "status": { - "icon": "icon_status_success", - "text": "passed", - "label": "passed", - "group": "success", - "has_details": true, - "details_path": "/root/ci-mock/pipelines/123#test", - "favicon": "/assets/ci_favicons/dev/favicon_status_success-308b4fc054cdd1b68d0865e6cfb7b02e92e3472f201507418f8eddb74ac11a59.ico" + path: '/root/ci-mock/pipelines/123#test', + dropdown_path: '/root/ci-mock/pipelines/123/stage.json?stage=test', }, - "path": "/root/ci-mock/pipelines/123#test", - "dropdown_path": "/root/ci-mock/pipelines/123/stage.json?stage=test" - }, { - "name": "deploy", - "title": "deploy: passed", - "groups": [{ - "name": "deploy to production", - "size": 1, - "status": { - "icon": "icon_status_success", - "text": "passed", - "label": "passed", - "group": "success", - "has_details": true, - "details_path": "/root/ci-mock/builds/4166", - "favicon": "/assets/ci_favicons/dev/favicon_status_success-308b4fc054cdd1b68d0865e6cfb7b02e92e3472f201507418f8eddb74ac11a59.ico", - "action": { - "icon": "retry", - "title": "Retry", - "path": "/root/ci-mock/builds/4166/retry", - "method": "post" - } + { + name: 'deploy', + title: 'deploy: passed', + groups: [ + { + name: 'deploy to production', + size: 1, + status: { + icon: 'icon_status_success', + text: 'passed', + label: 'passed', + group: 'success', + has_details: true, + details_path: '/root/ci-mock/builds/4166', + favicon: + '/assets/ci_favicons/dev/favicon_status_success-308b4fc054cdd1b68d0865e6cfb7b02e92e3472f201507418f8eddb74ac11a59.ico', + action: { + icon: 'retry', + title: 'Retry', + path: '/root/ci-mock/builds/4166/retry', + method: 'post', + }, + }, + jobs: [ + { + id: 4166, + name: 'deploy to production', + build_path: '/root/ci-mock/builds/4166', + retry_path: '/root/ci-mock/builds/4166/retry', + playable: false, + created_at: '2017-04-19T14:29:46.463Z', + updated_at: '2017-04-19T14:30:27.498Z', + status: { + icon: 'icon_status_success', + text: 'passed', + label: 'passed', + group: 'success', + has_details: true, + details_path: '/root/ci-mock/builds/4166', + favicon: + '/assets/ci_favicons/dev/favicon_status_success-308b4fc054cdd1b68d0865e6cfb7b02e92e3472f201507418f8eddb74ac11a59.ico', + action: { + icon: 'retry', + title: 'Retry', + path: '/root/ci-mock/builds/4166/retry', + method: 'post', + }, + }, + }, + ], + }, + { + name: 'deploy to staging', + size: 1, + status: { + icon: 'icon_status_success', + text: 'passed', + label: 'passed', + group: 'success', + has_details: true, + details_path: '/root/ci-mock/builds/4159', + favicon: + '/assets/ci_favicons/dev/favicon_status_success-308b4fc054cdd1b68d0865e6cfb7b02e92e3472f201507418f8eddb74ac11a59.ico', + action: { + icon: 'retry', + title: 'Retry', + path: '/root/ci-mock/builds/4159/retry', + method: 'post', + }, + }, + jobs: [ + { + id: 4159, + name: 'deploy to staging', + build_path: '/root/ci-mock/builds/4159', + retry_path: '/root/ci-mock/builds/4159/retry', + playable: false, + created_at: '2017-04-18T16:32:08.420Z', + updated_at: '2017-04-18T16:32:12.631Z', + status: { + icon: 'icon_status_success', + text: 'passed', + label: 'passed', + group: 'success', + has_details: true, + details_path: '/root/ci-mock/builds/4159', + favicon: + '/assets/ci_favicons/dev/favicon_status_success-308b4fc054cdd1b68d0865e6cfb7b02e92e3472f201507418f8eddb74ac11a59.ico', + action: { + icon: 'retry', + title: 'Retry', + path: '/root/ci-mock/builds/4159/retry', + method: 'post', + }, + }, + }, + ], + }, + ], + status: { + icon: 'icon_status_success', + text: 'passed', + label: 'passed', + group: 'success', + has_details: true, + details_path: '/root/ci-mock/pipelines/123#deploy', + favicon: + '/assets/ci_favicons/dev/favicon_status_success-308b4fc054cdd1b68d0865e6cfb7b02e92e3472f201507418f8eddb74ac11a59.ico', }, - "jobs": [{ - "id": 4166, - "name": "deploy to production", - "build_path": "/root/ci-mock/builds/4166", - "retry_path": "/root/ci-mock/builds/4166/retry", - "playable": false, - "created_at": "2017-04-19T14:29:46.463Z", - "updated_at": "2017-04-19T14:30:27.498Z", - "status": { - "icon": "icon_status_success", - "text": "passed", - "label": "passed", - "group": "success", - "has_details": true, - "details_path": "/root/ci-mock/builds/4166", - "favicon": "/assets/ci_favicons/dev/favicon_status_success-308b4fc054cdd1b68d0865e6cfb7b02e92e3472f201507418f8eddb74ac11a59.ico", - "action": { - "icon": "retry", - "title": "Retry", - "path": "/root/ci-mock/builds/4166/retry", - "method": "post" - } - } - }] - }, { - "name": "deploy to staging", - "size": 1, - "status": { - "icon": "icon_status_success", - "text": "passed", - "label": "passed", - "group": "success", - "has_details": true, - "details_path": "/root/ci-mock/builds/4159", - "favicon": "/assets/ci_favicons/dev/favicon_status_success-308b4fc054cdd1b68d0865e6cfb7b02e92e3472f201507418f8eddb74ac11a59.ico", - "action": { - "icon": "retry", - "title": "Retry", - "path": "/root/ci-mock/builds/4159/retry", - "method": "post" - } - }, - "jobs": [{ - "id": 4159, - "name": "deploy to staging", - "build_path": "/root/ci-mock/builds/4159", - "retry_path": "/root/ci-mock/builds/4159/retry", - "playable": false, - "created_at": "2017-04-18T16:32:08.420Z", - "updated_at": "2017-04-18T16:32:12.631Z", - "status": { - "icon": "icon_status_success", - "text": "passed", - "label": "passed", - "group": "success", - "has_details": true, - "details_path": "/root/ci-mock/builds/4159", - "favicon": "/assets/ci_favicons/dev/favicon_status_success-308b4fc054cdd1b68d0865e6cfb7b02e92e3472f201507418f8eddb74ac11a59.ico", - "action": { - "icon": "retry", - "title": "Retry", - "path": "/root/ci-mock/builds/4159/retry", - "method": "post" - } - } - }] - }], - "status": { - "icon": "icon_status_success", - "text": "passed", - "label": "passed", - "group": "success", - "has_details": true, - "details_path": "/root/ci-mock/pipelines/123#deploy", - "favicon": "/assets/ci_favicons/dev/favicon_status_success-308b4fc054cdd1b68d0865e6cfb7b02e92e3472f201507418f8eddb74ac11a59.ico" + path: '/root/ci-mock/pipelines/123#deploy', + dropdown_path: '/root/ci-mock/pipelines/123/stage.json?stage=deploy', + }, + ], + artifacts: [], + manual_actions: [ + { + name: 'deploy to production', + path: '/root/ci-mock/builds/4166/play', + playable: false, }, - "path": "/root/ci-mock/pipelines/123#deploy", - "dropdown_path": "/root/ci-mock/pipelines/123/stage.json?stage=deploy" - }], - "artifacts": [], - "manual_actions": [{ - "name": "deploy to production", - "path": "/root/ci-mock/builds/4166/play", - "playable": false - }] + ], }, - "flags": { - "latest": true, - "triggered": false, - "stuck": false, - "yaml_errors": false, - "retryable": false, - "cancelable": false + flags: { + latest: true, + triggered: false, + stuck: false, + yaml_errors: false, + retryable: false, + cancelable: false, }, - "ref": { - "name": "master", - "path": "/root/ci-mock/tree/master", - "tag": false, - "branch": true + ref: { + name: 'master', + path: '/root/ci-mock/tree/master', + tag: false, + branch: true, }, - "commit": { - "id": "798e5f902592192afaba73f4668ae30e56eae492", - "short_id": "798e5f90", - "title": "Merge branch 'new-branch' into 'master'\r", - "created_at": "2017-04-13T10:25:17.000+01:00", - "parent_ids": ["54d483b1ed156fbbf618886ddf7ab023e24f8738", "c8e2d38a6c538822e81c57022a6e3a0cfedebbcc"], - "message": "Merge branch 'new-branch' into 'master'\r\n\r\nAdd new file\r\n\r\nSee merge request !1", - "author_name": "Root", - "author_email": "admin@example.com", - "authored_date": "2017-04-13T10:25:17.000+01:00", - "committer_name": "Root", - "committer_email": "admin@example.com", - "committed_date": "2017-04-13T10:25:17.000+01:00", - "author": { - "name": "Root", - "username": "root", - "id": 1, - "state": "active", - "avatar_url": null, - "web_url": "http://localhost:3000/root" + commit: { + id: '798e5f902592192afaba73f4668ae30e56eae492', + short_id: '798e5f90', + title: "Merge branch 'new-branch' into 'master'\r", + created_at: '2017-04-13T10:25:17.000+01:00', + parent_ids: [ + '54d483b1ed156fbbf618886ddf7ab023e24f8738', + 'c8e2d38a6c538822e81c57022a6e3a0cfedebbcc', + ], + message: + "Merge branch 'new-branch' into 'master'\r\n\r\nAdd new file\r\n\r\nSee merge request !1", + author_name: 'Root', + author_email: 'admin@example.com', + authored_date: '2017-04-13T10:25:17.000+01:00', + committer_name: 'Root', + committer_email: 'admin@example.com', + committed_date: '2017-04-13T10:25:17.000+01:00', + author: { + name: 'Root', + username: 'root', + id: 1, + state: 'active', + avatar_url: null, + web_url: 'http://localhost:3000/root', }, - "author_gravatar_url": null, - "commit_url": "http://localhost:3000/root/ci-mock/commit/798e5f902592192afaba73f4668ae30e56eae492", - "commit_path": "/root/ci-mock/commit/798e5f902592192afaba73f4668ae30e56eae492" + author_gravatar_url: null, + commit_url: + 'http://localhost:3000/root/ci-mock/commit/798e5f902592192afaba73f4668ae30e56eae492', + commit_path: '/root/ci-mock/commit/798e5f902592192afaba73f4668ae30e56eae492', }, - "created_at": "2017-04-13T09:25:18.881Z", - "updated_at": "2017-04-19T14:30:27.561Z" + created_at: '2017-04-13T09:25:18.881Z', + updated_at: '2017-04-19T14:30:27.561Z', }; diff --git a/spec/javascripts/pipelines/pipelines_spec.js b/spec/javascripts/pipelines/pipelines_spec.js index 7e242eb45e1..d79544f83ad 100644 --- a/spec/javascripts/pipelines/pipelines_spec.js +++ b/spec/javascripts/pipelines/pipelines_spec.js @@ -1,5 +1,6 @@ -import _ from 'underscore'; import Vue from 'vue'; +import MockAdapter from 'axios-mock-adapter'; +import axios from '~/lib/utils/axios_utils'; import pipelinesComp from '~/pipelines/components/pipelines.vue'; import Store from '~/pipelines/stores/pipelines_store'; import mountComponent from 'spec/helpers/vue_mount_component_helper'; @@ -12,6 +13,8 @@ describe('Pipelines', () => { let PipelinesComponent; let pipelines; let vm; + let mock; + const paths = { endpoint: 'twitter/flight/pipelines.json', autoDevopsPath: '/help/topics/autodevops/index.md', @@ -34,6 +37,8 @@ describe('Pipelines', () => { }; beforeEach(() => { + mock = new MockAdapter(axios); + pipelines = getJSONFixture(jsonFixtureName); PipelinesComponent = Vue.extend(pipelinesComp); @@ -41,38 +46,14 @@ describe('Pipelines', () => { afterEach(() => { vm.$destroy(); + mock.restore(); }); - const pipelinesInterceptor = (request, next) => { - next(request.respondWith(JSON.stringify(pipelines), { - status: 200, - })); - }; - - const emptyStateInterceptor = (request, next) => { - next(request.respondWith(JSON.stringify({ - pipelines: [], - count: { - all: 0, - pending: 0, - running: 0, - finished: 0, - }, - }), { - status: 200, - })); - }; - - const errorInterceptor = (request, next) => { - next(request.respondWith(JSON.stringify({}), { - status: 500, - })); - }; - describe('With permission', () => { describe('With pipelines in main tab', () => { beforeEach((done) => { - Vue.http.interceptors.push(pipelinesInterceptor); + mock.onGet('twitter/flight/pipelines.json').reply(200, pipelines); + vm = mountComponent(PipelinesComponent, { store: new Store(), hasGitlabCi: true, @@ -85,12 +66,6 @@ describe('Pipelines', () => { }); }); - afterEach(() => { - Vue.http.interceptors = _.without( - Vue.http.interceptors, pipelinesInterceptor, - ); - }); - it('renders tabs', () => { expect(vm.$el.querySelector('.js-pipelines-tab-all').textContent.trim()).toContain('All'); }); @@ -116,7 +91,15 @@ describe('Pipelines', () => { describe('Without pipelines on main tab with CI', () => { beforeEach((done) => { - Vue.http.interceptors.push(emptyStateInterceptor); + mock.onGet('twitter/flight/pipelines.json').reply(200, { + pipelines: [], + count: { + all: 0, + pending: 0, + running: 0, + finished: 0, + }, + }); vm = mountComponent(PipelinesComponent, { store: new Store(), hasGitlabCi: true, @@ -129,12 +112,6 @@ describe('Pipelines', () => { }); }); - afterEach(() => { - Vue.http.interceptors = _.without( - Vue.http.interceptors, emptyStateInterceptor, - ); - }); - it('renders tabs', () => { expect(vm.$el.querySelector('.js-pipelines-tab-all').textContent.trim()).toContain('All'); }); @@ -158,7 +135,15 @@ describe('Pipelines', () => { describe('Without pipelines nor CI', () => { beforeEach((done) => { - Vue.http.interceptors.push(emptyStateInterceptor); + mock.onGet('twitter/flight/pipelines.json').reply(200, { + pipelines: [], + count: { + all: 0, + pending: 0, + running: 0, + finished: 0, + }, + }); vm = mountComponent(PipelinesComponent, { store: new Store(), hasGitlabCi: false, @@ -171,12 +156,6 @@ describe('Pipelines', () => { }); }); - afterEach(() => { - Vue.http.interceptors = _.without( - Vue.http.interceptors, emptyStateInterceptor, - ); - }); - it('renders empty state', () => { expect(vm.$el.querySelector('.js-empty-state h4').textContent.trim()).toEqual('Build with confidence'); expect(vm.$el.querySelector('.js-get-started-pipelines').getAttribute('href')).toEqual(paths.helpPagePath); @@ -192,7 +171,7 @@ describe('Pipelines', () => { describe('When API returns error', () => { beforeEach((done) => { - Vue.http.interceptors.push(errorInterceptor); + mock.onGet('twitter/flight/pipelines.json').reply(500, {}); vm = mountComponent(PipelinesComponent, { store: new Store(), hasGitlabCi: false, @@ -205,12 +184,6 @@ describe('Pipelines', () => { }); }); - afterEach(() => { - Vue.http.interceptors = _.without( - Vue.http.interceptors, errorInterceptor, - ); - }); - it('renders tabs', () => { expect(vm.$el.querySelector('.js-pipelines-tab-all').textContent.trim()).toContain('All'); }); @@ -230,7 +203,8 @@ describe('Pipelines', () => { describe('Without permission', () => { describe('With pipelines in main tab', () => { beforeEach((done) => { - Vue.http.interceptors.push(pipelinesInterceptor); + mock.onGet('twitter/flight/pipelines.json').reply(200, pipelines); + vm = mountComponent(PipelinesComponent, { store: new Store(), hasGitlabCi: false, @@ -243,12 +217,6 @@ describe('Pipelines', () => { }); }); - afterEach(() => { - Vue.http.interceptors = _.without( - Vue.http.interceptors, pipelinesInterceptor, - ); - }); - it('renders tabs', () => { expect(vm.$el.querySelector('.js-pipelines-tab-all').textContent.trim()).toContain('All'); }); @@ -268,7 +236,16 @@ describe('Pipelines', () => { describe('Without pipelines on main tab with CI', () => { beforeEach((done) => { - Vue.http.interceptors.push(emptyStateInterceptor); + mock.onGet('twitter/flight/pipelines.json').reply(200, { + pipelines: [], + count: { + all: 0, + pending: 0, + running: 0, + finished: 0, + }, + }); + vm = mountComponent(PipelinesComponent, { store: new Store(), hasGitlabCi: true, @@ -281,11 +258,6 @@ describe('Pipelines', () => { }); }); - afterEach(() => { - Vue.http.interceptors = _.without( - Vue.http.interceptors, emptyStateInterceptor, - ); - }); it('renders tabs', () => { expect(vm.$el.querySelector('.js-pipelines-tab-all').textContent.trim()).toContain('All'); }); @@ -303,7 +275,16 @@ describe('Pipelines', () => { describe('Without pipelines nor CI', () => { beforeEach((done) => { - Vue.http.interceptors.push(emptyStateInterceptor); + mock.onGet('twitter/flight/pipelines.json').reply(200, { + pipelines: [], + count: { + all: 0, + pending: 0, + running: 0, + finished: 0, + }, + }); + vm = mountComponent(PipelinesComponent, { store: new Store(), hasGitlabCi: false, @@ -316,12 +297,6 @@ describe('Pipelines', () => { }); }); - afterEach(() => { - Vue.http.interceptors = _.without( - Vue.http.interceptors, emptyStateInterceptor, - ); - }); - it('renders empty state without button to set CI', () => { expect(vm.$el.querySelector('.js-empty-state').textContent.trim()).toEqual('This project is not currently set up to run pipelines.'); expect(vm.$el.querySelector('.js-get-started-pipelines')).toBeNull(); @@ -337,7 +312,8 @@ describe('Pipelines', () => { describe('When API returns error', () => { beforeEach((done) => { - Vue.http.interceptors.push(errorInterceptor); + mock.onGet('twitter/flight/pipelines.json').reply(500, {}); + vm = mountComponent(PipelinesComponent, { store: new Store(), hasGitlabCi: false, @@ -350,12 +326,6 @@ describe('Pipelines', () => { }); }); - afterEach(() => { - Vue.http.interceptors = _.without( - Vue.http.interceptors, errorInterceptor, - ); - }); - it('renders tabs', () => { expect(vm.$el.querySelector('.js-pipelines-tab-all').textContent.trim()).toContain('All'); }); @@ -375,7 +345,8 @@ describe('Pipelines', () => { describe('successfull request', () => { describe('with pipelines', () => { beforeEach(() => { - Vue.http.interceptors.push(pipelinesInterceptor); + mock.onGet('twitter/flight/pipelines.json').reply(200, pipelines); + vm = mountComponent(PipelinesComponent, { store: new Store(), hasGitlabCi: true, @@ -384,12 +355,6 @@ describe('Pipelines', () => { }); }); - afterEach(() => { - Vue.http.interceptors = _.without( - Vue.http.interceptors, pipelinesInterceptor, - ); - }); - it('should render table', (done) => { setTimeout(() => { expect(vm.$el.querySelector('.table-holder')).toBeDefined(); diff --git a/spec/javascripts/profile/account/components/update_username_spec.js b/spec/javascripts/profile/account/components/update_username_spec.js new file mode 100644 index 00000000000..bac306edf5a --- /dev/null +++ b/spec/javascripts/profile/account/components/update_username_spec.js @@ -0,0 +1,172 @@ +import Vue from 'vue'; +import axios from '~/lib/utils/axios_utils'; +import MockAdapter from 'axios-mock-adapter'; + +import updateUsername from '~/profile/account/components/update_username.vue'; +import mountComponent from 'spec/helpers/vue_mount_component_helper'; + +describe('UpdateUsername component', () => { + const rootUrl = gl.TEST_HOST; + const actionUrl = `${gl.TEST_HOST}/update/username`; + const username = 'hasnoname'; + const newUsername = 'new_username'; + let Component; + let vm; + let axiosMock; + + beforeEach(() => { + axiosMock = new MockAdapter(axios); + Component = Vue.extend(updateUsername); + vm = mountComponent(Component, { + actionUrl, + rootUrl, + initialUsername: username, + }); + }); + + afterEach(() => { + vm.$destroy(); + axiosMock.restore(); + }); + + const findElements = () => { + const modalSelector = `#${vm.$options.modalId}`; + + return { + input: vm.$el.querySelector(`#${vm.$options.inputId}`), + openModalBtn: vm.$el.querySelector(`[data-target="${modalSelector}"]`), + modal: vm.$el.querySelector(modalSelector), + modalBody: vm.$el.querySelector(`${modalSelector} .modal-body`), + modalHeader: vm.$el.querySelector(`${modalSelector} .modal-title`), + confirmModalBtn: vm.$el.querySelector(`${modalSelector} .btn-warning`), + }; + }; + + it('has a disabled button if the username was not changed', done => { + const { input, openModalBtn } = findElements(); + input.dispatchEvent(new Event('input')); + + Vue.nextTick() + .then(() => { + expect(vm.username).toBe(username); + expect(vm.newUsername).toBe(username); + expect(openModalBtn).toBeDisabled(); + }) + .then(done) + .catch(done.fail); + }); + + it('has an enabled button which if the username was changed', done => { + const { input, openModalBtn } = findElements(); + input.value = newUsername; + input.dispatchEvent(new Event('input')); + + Vue.nextTick() + .then(() => { + expect(vm.username).toBe(username); + expect(vm.newUsername).toBe(newUsername); + expect(openModalBtn).not.toBeDisabled(); + }) + .then(done) + .catch(done.fail); + }); + + it('confirmation modal contains proper header and body', done => { + const { modalBody, modalHeader } = findElements(); + + vm.newUsername = newUsername; + + Vue.nextTick() + .then(() => { + expect(modalHeader.textContent).toContain('Change username?'); + expect(modalBody.textContent).toContain( + `You are going to change the username ${username} to ${newUsername}`, + ); + }) + .then(done) + .catch(done.fail); + }); + + it('confirmation modal should escape usernames properly', done => { + const { modalBody } = findElements(); + + vm.username = vm.newUsername = '<i>Italic</i>'; + + Vue.nextTick() + .then(() => { + expect(modalBody.innerHTML).toContain('<i>Italic</i>'); + expect(modalBody.innerHTML).not.toContain(vm.username); + }) + .then(done) + .catch(done.fail); + }); + + it('executes API call on confirmation button click', done => { + const { confirmModalBtn } = findElements(); + + axiosMock.onPut(actionUrl).replyOnce(() => [200, { message: 'Username changed' }]); + spyOn(axios, 'put').and.callThrough(); + + vm.newUsername = newUsername; + + Vue.nextTick() + .then(() => { + confirmModalBtn.click(); + expect(axios.put).toHaveBeenCalledWith(actionUrl, { user: { username: newUsername } }); + }) + .then(done) + .catch(done.fail); + }); + + it('sets the username after a successful update', done => { + const { input, openModalBtn } = findElements(); + + axiosMock.onPut(actionUrl).replyOnce(() => { + expect(input).toBeDisabled(); + expect(openModalBtn).toBeDisabled(); + + return [200, { message: 'Username changed' }]; + }); + + vm.newUsername = newUsername; + + vm + .onConfirm() + .then(() => { + expect(vm.username).toBe(newUsername); + expect(vm.newUsername).toBe(newUsername); + expect(input).not.toBeDisabled(); + expect(input.value).toBe(newUsername); + expect(openModalBtn).toBeDisabled(); + }) + .then(done) + .catch(done.fail); + }); + + it('does not set the username after a erroneous update', done => { + const { input, openModalBtn } = findElements(); + + axiosMock.onPut(actionUrl).replyOnce(() => { + expect(input).toBeDisabled(); + expect(openModalBtn).toBeDisabled(); + + return [400, { message: 'Invalid username' }]; + }); + + const invalidUsername = 'anything.git'; + vm.newUsername = invalidUsername; + + vm + .onConfirm() + .then(() => done.fail('Expected onConfirm to throw!')) + .catch(() => { + expect(vm.username).toBe(username); + expect(vm.newUsername).toBe(invalidUsername); + expect(input).not.toBeDisabled(); + expect(input.value).toBe(invalidUsername); + expect(openModalBtn).not.toBeDisabled(); + }) + .then(done) + .catch(done.fail); + }); +}); diff --git a/spec/javascripts/search_autocomplete_spec.js b/spec/javascripts/search_autocomplete_spec.js index 40115792652..1a27955983d 100644 --- a/spec/javascripts/search_autocomplete_spec.js +++ b/spec/javascripts/search_autocomplete_spec.js @@ -6,8 +6,21 @@ import SearchAutocomplete from '~/search_autocomplete'; import '~/lib/utils/common_utils'; import * as urlUtils from '~/lib/utils/url_utility'; -(function() { - var assertLinks, dashboardIssuesPath, dashboardMRsPath, groupIssuesPath, groupMRsPath, groupName, mockDashboardOptions, mockGroupOptions, mockProjectOptions, projectIssuesPath, projectMRsPath, projectName, userId, widget; +describe('Search autocomplete dropdown', () => { + var assertLinks, + dashboardIssuesPath, + dashboardMRsPath, + groupIssuesPath, + groupMRsPath, + groupName, + mockDashboardOptions, + mockGroupOptions, + mockProjectOptions, + projectIssuesPath, + projectMRsPath, + projectName, + userId, + widget; var userName = 'root'; widget = null; @@ -66,133 +79,126 @@ import * as urlUtils from '~/lib/utils/url_utility'; // Mock `gl` object in window for dashboard specific page. App code will need it. mockDashboardOptions = function() { window.gl || (window.gl = {}); - return window.gl.dashboardOptions = { + return (window.gl.dashboardOptions = { issuesPath: dashboardIssuesPath, - mrPath: dashboardMRsPath - }; + mrPath: dashboardMRsPath, + }); }; // Mock `gl` object in window for project specific page. App code will need it. mockProjectOptions = function() { window.gl || (window.gl = {}); - return window.gl.projectOptions = { + return (window.gl.projectOptions = { 'gitlab-ce': { issuesPath: projectIssuesPath, mrPath: projectMRsPath, - projectName: projectName - } - }; + projectName: projectName, + }, + }); }; mockGroupOptions = function() { window.gl || (window.gl = {}); - return window.gl.groupOptions = { + return (window.gl.groupOptions = { 'gitlab-org': { issuesPath: groupIssuesPath, mrPath: groupMRsPath, - projectName: groupName - } - }; + projectName: groupName, + }, + }); }; assertLinks = function(list, issuesPath, mrsPath) { - var a1, a2, a3, a4, issuesAssignedToMeLink, issuesIHaveCreatedLink, mrsAssignedToMeLink, mrsIHaveCreatedLink; if (issuesPath) { - issuesAssignedToMeLink = issuesPath + "/?assignee_username=" + userName; - issuesIHaveCreatedLink = issuesPath + "/?author_username=" + userName; - a1 = "a[href='" + issuesAssignedToMeLink + "']"; - a2 = "a[href='" + issuesIHaveCreatedLink + "']"; - expect(list.find(a1).length).toBe(1); - expect(list.find(a1).text()).toBe('Issues assigned to me'); - expect(list.find(a2).length).toBe(1); - expect(list.find(a2).text()).toBe("Issues I've created"); + const issuesAssignedToMeLink = `a[href="${issuesPath}/?assignee_id=${userId}"]`; + const issuesIHaveCreatedLink = `a[href="${issuesPath}/?author_id=${userId}"]`; + expect(list.find(issuesAssignedToMeLink).length).toBe(1); + expect(list.find(issuesAssignedToMeLink).text()).toBe('Issues assigned to me'); + expect(list.find(issuesIHaveCreatedLink).length).toBe(1); + expect(list.find(issuesIHaveCreatedLink).text()).toBe("Issues I've created"); } - mrsAssignedToMeLink = mrsPath + "/?assignee_username=" + userName; - mrsIHaveCreatedLink = mrsPath + "/?author_username=" + userName; - a3 = "a[href='" + mrsAssignedToMeLink + "']"; - a4 = "a[href='" + mrsIHaveCreatedLink + "']"; - expect(list.find(a3).length).toBe(1); - expect(list.find(a3).text()).toBe('Merge requests assigned to me'); - expect(list.find(a4).length).toBe(1); - return expect(list.find(a4).text()).toBe("Merge requests I've created"); + const mrsAssignedToMeLink = `a[href="${mrsPath}/?assignee_id=${userId}"]`; + const mrsIHaveCreatedLink = `a[href="${mrsPath}/?author_id=${userId}"]`; + expect(list.find(mrsAssignedToMeLink).length).toBe(1); + expect(list.find(mrsAssignedToMeLink).text()).toBe('Merge requests assigned to me'); + expect(list.find(mrsIHaveCreatedLink).length).toBe(1); + expect(list.find(mrsIHaveCreatedLink).text()).toBe("Merge requests I've created"); }; - describe('Search autocomplete dropdown', function() { - preloadFixtures('static/search_autocomplete.html.raw'); - beforeEach(function() { - loadFixtures('static/search_autocomplete.html.raw'); + preloadFixtures('static/search_autocomplete.html.raw'); + beforeEach(function() { + loadFixtures('static/search_autocomplete.html.raw'); - // Prevent turbolinks from triggering within gl_dropdown - spyOn(urlUtils, 'visitUrl').and.returnValue(true); + // Prevent turbolinks from triggering within gl_dropdown + spyOn(urlUtils, 'visitUrl').and.returnValue(true); - window.gon = {}; - window.gon.current_user_id = userId; - window.gon.current_username = userName; + window.gon = {}; + window.gon.current_user_id = userId; + window.gon.current_username = userName; - return widget = new SearchAutocomplete(); - }); + return (widget = new SearchAutocomplete()); + }); - afterEach(function() { - // Undo what we did to the shared <body> - removeBodyAttributes(); - window.gon = {}; - }); - it('should show Dashboard specific dropdown menu', function() { - var list; - addBodyAttributes(); - mockDashboardOptions(); - widget.searchInput.triggerHandler('focus'); - list = widget.wrap.find('.dropdown-menu').find('ul'); - return assertLinks(list, dashboardIssuesPath, dashboardMRsPath); - }); - it('should show Group specific dropdown menu', function() { - var list; - addBodyAttributes('group'); - mockGroupOptions(); - widget.searchInput.triggerHandler('focus'); - list = widget.wrap.find('.dropdown-menu').find('ul'); - return assertLinks(list, groupIssuesPath, groupMRsPath); - }); - it('should show Project specific dropdown menu', function() { - var list; - addBodyAttributes('project'); - mockProjectOptions(); - widget.searchInput.triggerHandler('focus'); - list = widget.wrap.find('.dropdown-menu').find('ul'); - return assertLinks(list, projectIssuesPath, projectMRsPath); - }); - it('should show only Project mergeRequest dropdown menu items when project issues are disabled', function() { - addBodyAttributes('project'); - disableProjectIssues(); - mockProjectOptions(); - widget.searchInput.triggerHandler('focus'); - const list = widget.wrap.find('.dropdown-menu').find('ul'); - assertLinks(list, null, projectMRsPath); - }); - it('should not show category related menu if there is text in the input', function() { - var link, list; - addBodyAttributes('project'); - mockProjectOptions(); - widget.searchInput.val('help'); - widget.searchInput.triggerHandler('focus'); - list = widget.wrap.find('.dropdown-menu').find('ul'); - link = "a[href='" + projectIssuesPath + "/?assignee_id=" + userId + "']"; - return expect(list.find(link).length).toBe(0); - }); - return it('should not submit the search form when selecting an autocomplete row with the keyboard', function() { - var ENTER = 13; - var DOWN = 40; - addBodyAttributes(); - mockDashboardOptions(true); - var submitSpy = spyOnEvent('form', 'submit'); - widget.searchInput.triggerHandler('focus'); - widget.wrap.trigger($.Event('keydown', { which: DOWN })); - var enterKeyEvent = $.Event('keydown', { which: ENTER }); - widget.searchInput.trigger(enterKeyEvent); - // This does not currently catch failing behavior. For security reasons, - // browsers will not trigger default behavior (form submit, in this - // example) on JavaScript-created keypresses. - expect(submitSpy).not.toHaveBeenTriggered(); - }); + afterEach(function() { + // Undo what we did to the shared <body> + removeBodyAttributes(); + window.gon = {}; + }); + it('should show Dashboard specific dropdown menu', function() { + var list; + addBodyAttributes(); + mockDashboardOptions(); + widget.searchInput.triggerHandler('focus'); + list = widget.wrap.find('.dropdown-menu').find('ul'); + return assertLinks(list, dashboardIssuesPath, dashboardMRsPath); + }); + it('should show Group specific dropdown menu', function() { + var list; + addBodyAttributes('group'); + mockGroupOptions(); + widget.searchInput.triggerHandler('focus'); + list = widget.wrap.find('.dropdown-menu').find('ul'); + return assertLinks(list, groupIssuesPath, groupMRsPath); + }); + it('should show Project specific dropdown menu', function() { + var list; + addBodyAttributes('project'); + mockProjectOptions(); + widget.searchInput.triggerHandler('focus'); + list = widget.wrap.find('.dropdown-menu').find('ul'); + return assertLinks(list, projectIssuesPath, projectMRsPath); + }); + it('should show only Project mergeRequest dropdown menu items when project issues are disabled', function() { + addBodyAttributes('project'); + disableProjectIssues(); + mockProjectOptions(); + widget.searchInput.triggerHandler('focus'); + const list = widget.wrap.find('.dropdown-menu').find('ul'); + assertLinks(list, null, projectMRsPath); + }); + it('should not show category related menu if there is text in the input', function() { + var link, list; + addBodyAttributes('project'); + mockProjectOptions(); + widget.searchInput.val('help'); + widget.searchInput.triggerHandler('focus'); + list = widget.wrap.find('.dropdown-menu').find('ul'); + link = "a[href='" + projectIssuesPath + '/?assignee_id=' + userId + "']"; + return expect(list.find(link).length).toBe(0); + }); + it('should not submit the search form when selecting an autocomplete row with the keyboard', function() { + var ENTER = 13; + var DOWN = 40; + addBodyAttributes(); + mockDashboardOptions(true); + var submitSpy = spyOnEvent('form', 'submit'); + widget.searchInput.triggerHandler('focus'); + widget.wrap.trigger($.Event('keydown', { which: DOWN })); + var enterKeyEvent = $.Event('keydown', { which: ENTER }); + widget.searchInput.trigger(enterKeyEvent); + // This does not currently catch failing behavior. For security reasons, + // browsers will not trigger default behavior (form submit, in this + // example) on JavaScript-created keypresses. + expect(submitSpy).not.toHaveBeenTriggered(); }); -}).call(window); +}); diff --git a/spec/javascripts/sidebar/confidential_issue_sidebar_spec.js b/spec/javascripts/sidebar/confidential_issue_sidebar_spec.js index 88a33caf2e3..0c173062835 100644 --- a/spec/javascripts/sidebar/confidential_issue_sidebar_spec.js +++ b/spec/javascripts/sidebar/confidential_issue_sidebar_spec.js @@ -62,4 +62,22 @@ describe('Confidential Issue Sidebar Block', () => { done(); }); }); + + it('displays the edit form when opened from collapsed state', (done) => { + expect(vm1.edit).toBe(false); + + vm1.$el.querySelector('.sidebar-collapsed-icon').click(); + + expect(vm1.edit).toBe(true); + + setTimeout(() => { + expect( + vm1.$el + .innerHTML + .includes('You are going to turn off the confidentiality.'), + ).toBe(true); + + done(); + }); + }); }); diff --git a/spec/javascripts/sidebar/lock/lock_issue_sidebar_spec.js b/spec/javascripts/sidebar/lock/lock_issue_sidebar_spec.js index 696fca516bc..9abc3daf221 100644 --- a/spec/javascripts/sidebar/lock/lock_issue_sidebar_spec.js +++ b/spec/javascripts/sidebar/lock/lock_issue_sidebar_spec.js @@ -68,4 +68,22 @@ describe('LockIssueSidebar', () => { done(); }); }); + + it('displays the edit form when opened from collapsed state', (done) => { + expect(vm1.isLockDialogOpen).toBe(false); + + vm1.$el.querySelector('.sidebar-collapsed-icon').click(); + + expect(vm1.isLockDialogOpen).toBe(true); + + setTimeout(() => { + expect( + vm1.$el + .innerHTML + .includes('Unlock this issue?'), + ).toBe(true); + + done(); + }); + }); }); diff --git a/spec/javascripts/sidebar/mock_data.js b/spec/javascripts/sidebar/mock_data.js index d9e84e35f69..8b6e8b24f00 100644 --- a/spec/javascripts/sidebar/mock_data.js +++ b/spec/javascripts/sidebar/mock_data.js @@ -1,7 +1,5 @@ -/* eslint-disable quote-props*/ - const RESPONSE_MAP = { - 'GET': { + GET: { '/gitlab-org/gitlab-shell/issues/5.json': { id: 45, iid: 5, @@ -27,7 +25,8 @@ const RESPONSE_MAP = { username: 'user0', id: 22, state: 'active', - avatar_url: 'https://www.gravatar.com/avatar/52e4ce24a915fb7e51e1ad3b57f4b00a?s=80\u0026d=identicon', + avatar_url: + 'https://www.gravatar.com/avatar/52e4ce24a915fb7e51e1ad3b57f4b00a?s=80\u0026d=identicon', web_url: 'http: //localhost:3001/user0', }, { @@ -35,7 +34,8 @@ const RESPONSE_MAP = { username: 'tajuana', id: 18, state: 'active', - avatar_url: 'https://www.gravatar.com/avatar/4852a41fb41616bf8f140d3701673f53?s=80\u0026d=identicon', + avatar_url: + 'https://www.gravatar.com/avatar/4852a41fb41616bf8f140d3701673f53?s=80\u0026d=identicon', web_url: 'http: //localhost:3001/tajuana', }, { @@ -43,7 +43,8 @@ const RESPONSE_MAP = { username: 'michaele.will', id: 16, state: 'active', - avatar_url: 'https://www.gravatar.com/avatar/e301827eb03be955c9c172cb9a8e4e8a?s=80\u0026d=identicon', + avatar_url: + 'https://www.gravatar.com/avatar/e301827eb03be955c9c172cb9a8e4e8a?s=80\u0026d=identicon', web_url: 'http: //localhost:3001/michaele.will', }, ], @@ -72,7 +73,8 @@ const RESPONSE_MAP = { username: 'user0', id: 22, state: 'active', - avatar_url: 'https://www.gravatar.com/avatar/52e4ce24a915fb7e51e1ad3b57f4b00a?s=80\u0026d=identicon', + avatar_url: + 'https://www.gravatar.com/avatar/52e4ce24a915fb7e51e1ad3b57f4b00a?s=80\u0026d=identicon', web_url: 'http://localhost:3001/user0', }, { @@ -80,7 +82,8 @@ const RESPONSE_MAP = { username: 'tajuana', id: 18, state: 'active', - avatar_url: 'https://www.gravatar.com/avatar/4852a41fb41616bf8f140d3701673f53?s=80\u0026d=identicon', + avatar_url: + 'https://www.gravatar.com/avatar/4852a41fb41616bf8f140d3701673f53?s=80\u0026d=identicon', web_url: 'http://localhost:3001/tajuana', }, { @@ -88,7 +91,8 @@ const RESPONSE_MAP = { username: 'michaele.will', id: 16, state: 'active', - avatar_url: 'https://www.gravatar.com/avatar/e301827eb03be955c9c172cb9a8e4e8a?s=80\u0026d=identicon', + avatar_url: + 'https://www.gravatar.com/avatar/e301827eb03be955c9c172cb9a8e4e8a?s=80\u0026d=identicon', web_url: 'http://localhost:3001/michaele.will', }, ], @@ -100,7 +104,8 @@ const RESPONSE_MAP = { username: 'user0', id: 22, state: 'active', - avatar_url: 'https://www.gravatar.com/avatar/52e4ce24a915fb7e51e1ad3b57f4b00a?s=80\u0026d=identicon', + avatar_url: + 'https://www.gravatar.com/avatar/52e4ce24a915fb7e51e1ad3b57f4b00a?s=80\u0026d=identicon', web_url: 'http://localhost:3001/user0', }, { @@ -108,7 +113,8 @@ const RESPONSE_MAP = { username: 'tajuana', id: 18, state: 'active', - avatar_url: 'https://www.gravatar.com/avatar/4852a41fb41616bf8f140d3701673f53?s=80\u0026d=identicon', + avatar_url: + 'https://www.gravatar.com/avatar/4852a41fb41616bf8f140d3701673f53?s=80\u0026d=identicon', web_url: 'http://localhost:3001/tajuana', }, { @@ -116,7 +122,8 @@ const RESPONSE_MAP = { username: 'michaele.will', id: 16, state: 'active', - avatar_url: 'https://www.gravatar.com/avatar/e301827eb03be955c9c172cb9a8e4e8a?s=80\u0026d=identicon', + avatar_url: + 'https://www.gravatar.com/avatar/e301827eb03be955c9c172cb9a8e4e8a?s=80\u0026d=identicon', web_url: 'http://localhost:3001/michaele.will', }, ], @@ -126,20 +133,21 @@ const RESPONSE_MAP = { }, '/autocomplete/projects?project_id=15': [ { - 'id': 0, - 'name_with_namespace': 'No project', - }, { - 'id': 20, - 'name_with_namespace': 'foo / bar', + id: 0, + name_with_namespace: 'No project', + }, + { + id: 20, + name_with_namespace: 'foo / bar', }, ], }, - 'PUT': { + PUT: { '/gitlab-org/gitlab-shell/issues/5.json': { data: {}, }, }, - 'POST': { + POST: { '/gitlab-org/gitlab-shell/issues/5/move': { id: 123, iid: 5, @@ -182,7 +190,8 @@ const mockData = { id: 1, name: 'Administrator', username: 'root', - avatar_url: 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', + avatar_url: + 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', }, rootPath: '/', fullPath: '/gitlab-org/gitlab-shell', @@ -201,12 +210,14 @@ const mockData = { }, }; -mockData.sidebarMockInterceptor = function (request, next) { +mockData.sidebarMockInterceptor = function(request, next) { const body = this.responseMap[request.method.toUpperCase()][request.url]; - next(request.respondWith(JSON.stringify(body), { - status: 200, - })); + next( + request.respondWith(JSON.stringify(body), { + status: 200, + }), + ); }.bind(mockData); export default mockData; diff --git a/spec/javascripts/test_bundle.js b/spec/javascripts/test_bundle.js index 1bcfdfe72b6..d158786e484 100644 --- a/spec/javascripts/test_bundle.js +++ b/spec/javascripts/test_bundle.js @@ -7,6 +7,9 @@ import Vue from 'vue'; import VueResource from 'vue-resource'; import { getDefaultAdapter } from '~/lib/utils/axios_utils'; +import { FIXTURES_PATH, TEST_HOST } from './test_constants'; + +import customMatchers from './matchers'; const isHeadlessChrome = /\bHeadlessChrome\//.test(navigator.userAgent); Vue.config.devtools = !isHeadlessChrome; @@ -27,15 +30,17 @@ Vue.config.errorHandler = function (err) { Vue.use(VueResource); // enable test fixtures -jasmine.getFixtures().fixturesPath = '/base/spec/javascripts/fixtures'; -jasmine.getJSONFixtures().fixturesPath = '/base/spec/javascripts/fixtures'; +jasmine.getFixtures().fixturesPath = FIXTURES_PATH; +jasmine.getJSONFixtures().fixturesPath = FIXTURES_PATH; + +beforeAll(() => jasmine.addMatchers(customMatchers)); // globalize common libraries window.$ = window.jQuery = $; // stub expected globals window.gl = window.gl || {}; -window.gl.TEST_HOST = 'http://test.host'; +window.gl.TEST_HOST = TEST_HOST; window.gon = window.gon || {}; window.gon.test_env = true; diff --git a/spec/javascripts/test_constants.js b/spec/javascripts/test_constants.js new file mode 100644 index 00000000000..df59195e9f6 --- /dev/null +++ b/spec/javascripts/test_constants.js @@ -0,0 +1,4 @@ +export const FIXTURES_PATH = '/base/spec/javascripts/fixtures'; +export const TEST_HOST = 'http://test.host'; + +export const DUMMY_IMAGE_URL = `${FIXTURES_PATH}/one_white_pixel.png`; diff --git a/spec/javascripts/vue_mr_widget/components/mr_widget_header_spec.js b/spec/javascripts/vue_mr_widget/components/mr_widget_header_spec.js index 235c33fac0d..9b9c9656979 100644 --- a/spec/javascripts/vue_mr_widget/components/mr_widget_header_spec.js +++ b/spec/javascripts/vue_mr_widget/components/mr_widget_header_spec.js @@ -17,46 +17,58 @@ describe('MRWidgetHeader', () => { describe('computed', () => { describe('shouldShowCommitsBehindText', () => { it('return true when there are divergedCommitsCount', () => { - vm = mountComponent(Component, { mr: { - divergedCommitsCount: 12, - sourceBranch: 'mr-widget-refactor', - sourceBranchLink: '<a href="/foo/bar/mr-widget-refactor">Link</a>', - targetBranch: 'master', - } }); + vm = mountComponent(Component, { + mr: { + divergedCommitsCount: 12, + sourceBranch: 'mr-widget-refactor', + sourceBranchLink: '<a href="/foo/bar/mr-widget-refactor">Link</a>', + targetBranch: 'master', + statusPath: 'abc', + }, + }); expect(vm.shouldShowCommitsBehindText).toEqual(true); }); it('returns false where there are no divergedComits count', () => { - vm = mountComponent(Component, { mr: { - divergedCommitsCount: 0, - sourceBranch: 'mr-widget-refactor', - sourceBranchLink: '<a href="/foo/bar/mr-widget-refactor">Link</a>', - targetBranch: 'master', - } }); + vm = mountComponent(Component, { + mr: { + divergedCommitsCount: 0, + sourceBranch: 'mr-widget-refactor', + sourceBranchLink: '<a href="/foo/bar/mr-widget-refactor">Link</a>', + targetBranch: 'master', + statusPath: 'abc', + }, + }); expect(vm.shouldShowCommitsBehindText).toEqual(false); }); }); describe('commitsText', () => { it('returns singular when there is one commit', () => { - vm = mountComponent(Component, { mr: { - divergedCommitsCount: 1, - sourceBranch: 'mr-widget-refactor', - sourceBranchLink: '<a href="/foo/bar/mr-widget-refactor">Link</a>', - targetBranch: 'master', - } }); + vm = mountComponent(Component, { + mr: { + divergedCommitsCount: 1, + sourceBranch: 'mr-widget-refactor', + sourceBranchLink: '<a href="/foo/bar/mr-widget-refactor">Link</a>', + targetBranch: 'master', + statusPath: 'abc', + }, + }); expect(vm.commitsText).toEqual('1 commit behind'); }); it('returns plural when there is more than one commit', () => { - vm = mountComponent(Component, { mr: { - divergedCommitsCount: 2, - sourceBranch: 'mr-widget-refactor', - sourceBranchLink: '<a href="/foo/bar/mr-widget-refactor">Link</a>', - targetBranch: 'master', - } }); + vm = mountComponent(Component, { + mr: { + divergedCommitsCount: 2, + sourceBranch: 'mr-widget-refactor', + sourceBranchLink: '<a href="/foo/bar/mr-widget-refactor">Link</a>', + targetBranch: 'master', + statusPath: 'abc', + }, + }); expect(vm.commitsText).toEqual('2 commits behind'); }); @@ -66,24 +78,27 @@ describe('MRWidgetHeader', () => { describe('template', () => { describe('common elements', () => { beforeEach(() => { - vm = mountComponent(Component, { mr: { - divergedCommitsCount: 12, - sourceBranch: 'mr-widget-refactor', - sourceBranchLink: '<a href="/foo/bar/mr-widget-refactor">mr-widget-refactor</a>', - sourceBranchRemoved: false, - targetBranchPath: 'foo/bar/commits-path', - targetBranchTreePath: 'foo/bar/tree/path', - targetBranch: 'master', - isOpen: true, - emailPatchesPath: '/mr/email-patches', - plainDiffPath: '/mr/plainDiffPath', - } }); + vm = mountComponent(Component, { + mr: { + divergedCommitsCount: 12, + sourceBranch: 'mr-widget-refactor', + sourceBranchLink: '<a href="/foo/bar/mr-widget-refactor">mr-widget-refactor</a>', + sourceBranchRemoved: false, + targetBranchPath: 'foo/bar/commits-path', + targetBranchTreePath: 'foo/bar/tree/path', + targetBranch: 'master', + isOpen: true, + emailPatchesPath: '/mr/email-patches', + plainDiffPath: '/mr/plainDiffPath', + statusPath: 'abc', + }, + }); }); it('renders source branch link', () => { - expect( - vm.$el.querySelector('.js-source-branch').innerHTML, - ).toEqual('<a href="/foo/bar/mr-widget-refactor">mr-widget-refactor</a>'); + expect(vm.$el.querySelector('.js-source-branch').innerHTML).toEqual( + '<a href="/foo/bar/mr-widget-refactor">mr-widget-refactor</a>', + ); }); it('renders clipboard button', () => { @@ -101,18 +116,21 @@ describe('MRWidgetHeader', () => { }); beforeEach(() => { - vm = mountComponent(Component, { mr: { - divergedCommitsCount: 12, - sourceBranch: 'mr-widget-refactor', - sourceBranchLink: '<a href="/foo/bar/mr-widget-refactor">mr-widget-refactor</a>', - sourceBranchRemoved: false, - targetBranchPath: 'foo/bar/commits-path', - targetBranchTreePath: 'foo/bar/tree/path', - targetBranch: 'master', - isOpen: true, - emailPatchesPath: '/mr/email-patches', - plainDiffPath: '/mr/plainDiffPath', - } }); + vm = mountComponent(Component, { + mr: { + divergedCommitsCount: 12, + sourceBranch: 'mr-widget-refactor', + sourceBranchLink: '<a href="/foo/bar/mr-widget-refactor">mr-widget-refactor</a>', + sourceBranchRemoved: false, + targetBranchPath: 'foo/bar/commits-path', + targetBranchTreePath: 'foo/bar/tree/path', + targetBranch: 'master', + isOpen: true, + emailPatchesPath: '/mr/email-patches', + plainDiffPath: '/mr/plainDiffPath', + statusPath: 'abc', + }, + }); }); it('renders checkout branch button with modal trigger', () => { @@ -123,39 +141,49 @@ describe('MRWidgetHeader', () => { expect(button.getAttribute('data-toggle')).toEqual('modal'); }); + it('renders web ide button', () => { + const button = vm.$el.querySelector('.js-web-ide'); + + expect(button.textContent.trim()).toEqual('Web IDE'); + expect(button.getAttribute('href')).toEqual('undefined/-/ide/projectabc'); + }); + it('renders download dropdown with links', () => { - expect( - vm.$el.querySelector('.js-download-email-patches').textContent.trim(), - ).toEqual('Email patches'); + expect(vm.$el.querySelector('.js-download-email-patches').textContent.trim()).toEqual( + 'Email patches', + ); - expect( - vm.$el.querySelector('.js-download-email-patches').getAttribute('href'), - ).toEqual('/mr/email-patches'); + expect(vm.$el.querySelector('.js-download-email-patches').getAttribute('href')).toEqual( + '/mr/email-patches', + ); - expect( - vm.$el.querySelector('.js-download-plain-diff').textContent.trim(), - ).toEqual('Plain diff'); + expect(vm.$el.querySelector('.js-download-plain-diff').textContent.trim()).toEqual( + 'Plain diff', + ); - expect( - vm.$el.querySelector('.js-download-plain-diff').getAttribute('href'), - ).toEqual('/mr/plainDiffPath'); + expect(vm.$el.querySelector('.js-download-plain-diff').getAttribute('href')).toEqual( + '/mr/plainDiffPath', + ); }); }); describe('with a closed merge request', () => { beforeEach(() => { - vm = mountComponent(Component, { mr: { - divergedCommitsCount: 12, - sourceBranch: 'mr-widget-refactor', - sourceBranchLink: '<a href="/foo/bar/mr-widget-refactor">mr-widget-refactor</a>', - sourceBranchRemoved: false, - targetBranchPath: 'foo/bar/commits-path', - targetBranchTreePath: 'foo/bar/tree/path', - targetBranch: 'master', - isOpen: false, - emailPatchesPath: '/mr/email-patches', - plainDiffPath: '/mr/plainDiffPath', - } }); + vm = mountComponent(Component, { + mr: { + divergedCommitsCount: 12, + sourceBranch: 'mr-widget-refactor', + sourceBranchLink: '<a href="/foo/bar/mr-widget-refactor">mr-widget-refactor</a>', + sourceBranchRemoved: false, + targetBranchPath: 'foo/bar/commits-path', + targetBranchTreePath: 'foo/bar/tree/path', + targetBranch: 'master', + isOpen: false, + emailPatchesPath: '/mr/email-patches', + plainDiffPath: '/mr/plainDiffPath', + statusPath: 'abc', + }, + }); }); it('does not render checkout branch button with modal trigger', () => { @@ -165,30 +193,29 @@ describe('MRWidgetHeader', () => { }); it('does not render download dropdown with links', () => { - expect( - vm.$el.querySelector('.js-download-email-patches'), - ).toEqual(null); + expect(vm.$el.querySelector('.js-download-email-patches')).toEqual(null); - expect( - vm.$el.querySelector('.js-download-plain-diff'), - ).toEqual(null); + expect(vm.$el.querySelector('.js-download-plain-diff')).toEqual(null); }); }); describe('without diverged commits', () => { beforeEach(() => { - vm = mountComponent(Component, { mr: { - divergedCommitsCount: 0, - sourceBranch: 'mr-widget-refactor', - sourceBranchLink: '<a href="/foo/bar/mr-widget-refactor">mr-widget-refactor</a>', - sourceBranchRemoved: false, - targetBranchPath: 'foo/bar/commits-path', - targetBranchTreePath: 'foo/bar/tree/path', - targetBranch: 'master', - isOpen: true, - emailPatchesPath: '/mr/email-patches', - plainDiffPath: '/mr/plainDiffPath', - } }); + vm = mountComponent(Component, { + mr: { + divergedCommitsCount: 0, + sourceBranch: 'mr-widget-refactor', + sourceBranchLink: '<a href="/foo/bar/mr-widget-refactor">mr-widget-refactor</a>', + sourceBranchRemoved: false, + targetBranchPath: 'foo/bar/commits-path', + targetBranchTreePath: 'foo/bar/tree/path', + targetBranch: 'master', + isOpen: true, + emailPatchesPath: '/mr/email-patches', + plainDiffPath: '/mr/plainDiffPath', + statusPath: 'abc', + }, + }); }); it('does not render diverged commits info', () => { @@ -198,22 +225,27 @@ describe('MRWidgetHeader', () => { describe('with diverged commits', () => { beforeEach(() => { - vm = mountComponent(Component, { mr: { - divergedCommitsCount: 12, - sourceBranch: 'mr-widget-refactor', - sourceBranchLink: '<a href="/foo/bar/mr-widget-refactor">mr-widget-refactor</a>', - sourceBranchRemoved: false, - targetBranchPath: 'foo/bar/commits-path', - targetBranchTreePath: 'foo/bar/tree/path', - targetBranch: 'master', - isOpen: true, - emailPatchesPath: '/mr/email-patches', - plainDiffPath: '/mr/plainDiffPath', - } }); + vm = mountComponent(Component, { + mr: { + divergedCommitsCount: 12, + sourceBranch: 'mr-widget-refactor', + sourceBranchLink: '<a href="/foo/bar/mr-widget-refactor">mr-widget-refactor</a>', + sourceBranchRemoved: false, + targetBranchPath: 'foo/bar/commits-path', + targetBranchTreePath: 'foo/bar/tree/path', + targetBranch: 'master', + isOpen: true, + emailPatchesPath: '/mr/email-patches', + plainDiffPath: '/mr/plainDiffPath', + statusPath: 'abc', + }, + }); }); it('renders diverged commits info', () => { - expect(vm.$el.querySelector('.diverged-commits-count').textContent.trim()).toEqual('(12 commits behind)'); + expect(vm.$el.querySelector('.diverged-commits-count').textContent.trim()).toEqual( + '(12 commits behind)', + ); }); }); }); diff --git a/spec/javascripts/vue_mr_widget/components/mr_widget_pipeline_spec.js b/spec/javascripts/vue_mr_widget/components/mr_widget_pipeline_spec.js index 431cb7f3913..ea8007d2029 100644 --- a/spec/javascripts/vue_mr_widget/components/mr_widget_pipeline_spec.js +++ b/spec/javascripts/vue_mr_widget/components/mr_widget_pipeline_spec.js @@ -113,6 +113,46 @@ describe('MRWidgetPipeline', () => { }); }); + describe('without commit path', () => { + beforeEach(() => { + const mockCopy = Object.assign({}, mockData); + delete mockCopy.pipeline.commit; + + vm = mountComponent(Component, { + pipeline: mockCopy.pipeline, + hasCi: true, + ciStatus: 'success', + }); + }); + + it('should render pipeline ID', () => { + expect( + vm.$el.querySelector('.pipeline-id').textContent.trim(), + ).toEqual(`#${mockData.pipeline.id}`); + }); + + it('should render pipeline status', () => { + expect( + vm.$el.querySelector('.media-body').textContent.trim(), + ).toContain(mockData.pipeline.details.status.label); + + expect( + vm.$el.querySelector('.js-commit-link'), + ).toBeNull(); + }); + + it('should render pipeline graph', () => { + expect(vm.$el.querySelector('.mr-widget-pipeline-graph')).toBeDefined(); + expect(vm.$el.querySelectorAll('.stage-container').length).toEqual(mockData.pipeline.details.stages.length); + }); + + it('should render coverage information', () => { + expect( + vm.$el.querySelector('.media-body').textContent, + ).toContain(`Coverage ${mockData.pipeline.coverage}`); + }); + }); + describe('without coverage', () => { it('should not render a coverage', () => { const mockCopy = Object.assign({}, mockData); diff --git a/spec/javascripts/vue_mr_widget/mock_data.js b/spec/javascripts/vue_mr_widget/mock_data.js index 3dd75307484..3fc7663b9c2 100644 --- a/spec/javascripts/vue_mr_widget/mock_data.js +++ b/spec/javascripts/vue_mr_widget/mock_data.js @@ -1,213 +1,218 @@ -/* eslint-disable */ - export default { - "id": 132, - "iid": 22, - "assignee_id": null, - "author_id": 1, - "description": "", - "lock_version": null, - "milestone_id": null, - "position": 0, - "state": "merged", - "title": "Update README.md", - "updated_by_id": null, - "created_at": "2017-04-07T12:27:26.718Z", - "updated_at": "2017-04-07T15:39:25.852Z", - "time_estimate": 0, - "total_time_spent": 0, - "human_time_estimate": null, - "human_total_time_spent": null, - "in_progress_merge_commit_sha": null, - "merge_commit_sha": "53027d060246c8f47e4a9310fb332aa52f221775", - "merge_error": null, - "merge_params": { - "force_remove_source_branch": null + id: 132, + iid: 22, + assignee_id: null, + author_id: 1, + description: '', + lock_version: null, + milestone_id: null, + position: 0, + state: 'merged', + title: 'Update README.md', + updated_by_id: null, + created_at: '2017-04-07T12:27:26.718Z', + updated_at: '2017-04-07T15:39:25.852Z', + time_estimate: 0, + total_time_spent: 0, + human_time_estimate: null, + human_total_time_spent: null, + in_progress_merge_commit_sha: null, + merge_commit_sha: '53027d060246c8f47e4a9310fb332aa52f221775', + merge_error: null, + merge_params: { + force_remove_source_branch: null, }, - "merge_status": "can_be_merged", - "merge_user_id": null, - "merge_when_pipeline_succeeds": false, - "source_branch": "daaaa", - "source_branch_link": "daaaa", - "source_project_id": 19, - "target_branch": "master", - "target_project_id": 19, - "metrics": { - "merged_by": { - "name": "Administrator", - "username": "root", - "id": 1, - "state": "active", - "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", - "web_url": "http://localhost:3000/root" + merge_status: 'can_be_merged', + merge_user_id: null, + merge_when_pipeline_succeeds: false, + source_branch: 'daaaa', + source_branch_link: 'daaaa', + source_project_id: 19, + target_branch: 'master', + target_project_id: 19, + metrics: { + merged_by: { + name: 'Administrator', + username: 'root', + id: 1, + state: 'active', + avatar_url: + 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', + web_url: 'http://localhost:3000/root', }, - "merged_at": "2017-04-07T15:39:25.696Z", - "closed_by": null, - "closed_at": null + merged_at: '2017-04-07T15:39:25.696Z', + closed_by: null, + closed_at: null, }, - "author": { - "name": "Administrator", - "username": "root", - "id": 1, - "state": "active", - "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", - "web_url": "http://localhost:3000/root" + author: { + name: 'Administrator', + username: 'root', + id: 1, + state: 'active', + avatar_url: 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', + web_url: 'http://localhost:3000/root', }, - "merge_user": null, - "diff_head_sha": "104096c51715e12e7ae41f9333e9fa35b73f385d", - "diff_head_commit_short_id": "104096c5", - "merge_commit_message": "Merge branch 'daaaa' into 'master'\n\nUpdate README.md\n\nSee merge request !22", - "pipeline": { - "id": 172, - "user": { - "name": "Administrator", - "username": "root", - "id": 1, - "state": "active", - "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", - "web_url": "http://localhost:3000/root" + merge_user: null, + diff_head_sha: '104096c51715e12e7ae41f9333e9fa35b73f385d', + diff_head_commit_short_id: '104096c5', + merge_commit_message: + "Merge branch 'daaaa' into 'master'\n\nUpdate README.md\n\nSee merge request !22", + pipeline: { + id: 172, + user: { + name: 'Administrator', + username: 'root', + id: 1, + state: 'active', + avatar_url: + 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', + web_url: 'http://localhost:3000/root', }, - "active": false, - "coverage": "92.16", - "path": "/root/acets-app/pipelines/172", - "details": { - "status": { - "icon": "icon_status_success", - "favicon": "favicon_status_success", - "text": "passed", - "label": "passed", - "group": "success", - "has_details": true, - "details_path": "/root/acets-app/pipelines/172" + active: false, + coverage: '92.16', + path: '/root/acets-app/pipelines/172', + details: { + status: { + icon: 'icon_status_success', + favicon: 'favicon_status_success', + text: 'passed', + label: 'passed', + group: 'success', + has_details: true, + details_path: '/root/acets-app/pipelines/172', }, - "duration": null, - "finished_at": "2017-04-07T14:00:14.256Z", - "stages": [ + duration: null, + finished_at: '2017-04-07T14:00:14.256Z', + stages: [ { - "name": "build", - "title": "build: failed", - "status": { - "icon": "icon_status_failed", - "favicon": "favicon_status_failed", - "text": "failed", - "label": "failed", - "group": "failed", - "has_details": true, - "details_path": "/root/acets-app/pipelines/172#build" + name: 'build', + title: 'build: failed', + status: { + icon: 'icon_status_failed', + favicon: 'favicon_status_failed', + text: 'failed', + label: 'failed', + group: 'failed', + has_details: true, + details_path: '/root/acets-app/pipelines/172#build', }, - "path": "/root/acets-app/pipelines/172#build", - "dropdown_path": "/root/acets-app/pipelines/172/stage.json?stage=build" + path: '/root/acets-app/pipelines/172#build', + dropdown_path: '/root/acets-app/pipelines/172/stage.json?stage=build', }, { - "name": "review", - "title": "review: skipped", - "status": { - "icon": "icon_status_skipped", - "favicon": "favicon_status_skipped", - "text": "skipped", - "label": "skipped", - "group": "skipped", - "has_details": true, - "details_path": "/root/acets-app/pipelines/172#review" + name: 'review', + title: 'review: skipped', + status: { + icon: 'icon_status_skipped', + favicon: 'favicon_status_skipped', + text: 'skipped', + label: 'skipped', + group: 'skipped', + has_details: true, + details_path: '/root/acets-app/pipelines/172#review', }, - "path": "/root/acets-app/pipelines/172#review", - "dropdown_path": "/root/acets-app/pipelines/172/stage.json?stage=review" - } - ], - "artifacts": [ - + path: '/root/acets-app/pipelines/172#review', + dropdown_path: '/root/acets-app/pipelines/172/stage.json?stage=review', + }, ], - "manual_actions": [ + artifacts: [], + manual_actions: [ { - "name": "stop_review", - "path": "/root/acets-app/builds/1427/play", - "playable": false - } - ] + name: 'stop_review', + path: '/root/acets-app/builds/1427/play', + playable: false, + }, + ], }, - "flags": { - "latest": false, - "triggered": false, - "stuck": false, - "yaml_errors": false, - "retryable": true, - "cancelable": false + flags: { + latest: false, + triggered: false, + stuck: false, + yaml_errors: false, + retryable: true, + cancelable: false, }, - "ref": { - "name": "daaaa", - "path": "/root/acets-app/tree/daaaa", - "tag": false, - "branch": true + ref: { + name: 'daaaa', + path: '/root/acets-app/tree/daaaa', + tag: false, + branch: true, }, - "commit": { - "id": "104096c51715e12e7ae41f9333e9fa35b73f385d", - "short_id": "104096c5", - "title": "Update README.md", - "created_at": "2017-04-07T15:27:18.000+03:00", - "parent_ids": [ - "2396536178668d8930c29d904e53bd4d06228b32" - ], - "message": "Update README.md", - "author_name": "Administrator", - "author_email": "admin@example.com", - "authored_date": "2017-04-07T15:27:18.000+03:00", - "committer_name": "Administrator", - "committer_email": "admin@example.com", - "committed_date": "2017-04-07T15:27:18.000+03:00", - "author": { - "name": "Administrator", - "username": "root", - "id": 1, - "state": "active", - "avatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", - "web_url": "http://localhost:3000/root" + commit: { + id: '104096c51715e12e7ae41f9333e9fa35b73f385d', + short_id: '104096c5', + title: 'Update README.md', + created_at: '2017-04-07T15:27:18.000+03:00', + parent_ids: ['2396536178668d8930c29d904e53bd4d06228b32'], + message: 'Update README.md', + author_name: 'Administrator', + author_email: 'admin@example.com', + authored_date: '2017-04-07T15:27:18.000+03:00', + committer_name: 'Administrator', + committer_email: 'admin@example.com', + committed_date: '2017-04-07T15:27:18.000+03:00', + author: { + name: 'Administrator', + username: 'root', + id: 1, + state: 'active', + avatar_url: + 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', + web_url: 'http://localhost:3000/root', }, - "author_gravatar_url": "https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon", - "commit_url": "http://localhost:3000/root/acets-app/commit/104096c51715e12e7ae41f9333e9fa35b73f385d", - "commit_path": "/root/acets-app/commit/104096c51715e12e7ae41f9333e9fa35b73f385d" + author_gravatar_url: + 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', + commit_url: + 'http://localhost:3000/root/acets-app/commit/104096c51715e12e7ae41f9333e9fa35b73f385d', + commit_path: '/root/acets-app/commit/104096c51715e12e7ae41f9333e9fa35b73f385d', }, - "retry_path": "/root/acets-app/pipelines/172/retry", - "created_at": "2017-04-07T12:27:19.520Z", - "updated_at": "2017-04-07T15:28:44.800Z" + retry_path: '/root/acets-app/pipelines/172/retry', + created_at: '2017-04-07T12:27:19.520Z', + updated_at: '2017-04-07T15:28:44.800Z', }, - "work_in_progress": false, - "source_branch_exists": false, - "mergeable_discussions_state": true, - "conflicts_can_be_resolved_in_ui": false, - "branch_missing": true, - "commits_count": 1, - "has_conflicts": false, - "can_be_merged": true, - "has_ci": true, - "ci_status": "success", - "pipeline_status_path": "/root/acets-app/merge_requests/22/pipeline_status", - "issues_links": { - "closing": "", - "mentioned_but_not_closing": "" + work_in_progress: false, + source_branch_exists: false, + mergeable_discussions_state: true, + conflicts_can_be_resolved_in_ui: false, + branch_missing: true, + commits_count: 1, + has_conflicts: false, + can_be_merged: true, + has_ci: true, + ci_status: 'success', + pipeline_status_path: '/root/acets-app/merge_requests/22/pipeline_status', + issues_links: { + closing: '', + mentioned_but_not_closing: '', }, - "current_user": { - "can_resolve_conflicts": true, - "can_remove_source_branch": false, - "can_revert_on_current_merge_request": true, - "can_cherry_pick_on_current_merge_request": true + current_user: { + can_resolve_conflicts: true, + can_remove_source_branch: false, + can_revert_on_current_merge_request: true, + can_cherry_pick_on_current_merge_request: true, }, - "target_branch_path": "/root/acets-app/branches/master", - "source_branch_path": "/root/acets-app/branches/daaaa", - "conflict_resolution_ui_path": "/root/acets-app/merge_requests/22/conflicts", - "remove_wip_path": "/root/acets-app/merge_requests/22/remove_wip", - "cancel_merge_when_pipeline_succeeds_path": "/root/acets-app/merge_requests/22/cancel_merge_when_pipeline_succeeds", - "create_issue_to_resolve_discussions_path": "/root/acets-app/issues/new?merge_request_to_resolve_discussions_of=22", - "merge_path": "/root/acets-app/merge_requests/22/merge", - "cherry_pick_in_fork_path": "/root/acets-app/forks?continue%5Bnotice%5D=You%27re+not+allowed+to+make+changes+to+this+project+directly.+A+fork+of+this+project+has+been+created+that+you+can+make+changes+in%2C+so+you+can+submit+a+merge+request.+Try+to+revert+this+commit+again.&continue%5Bnotice_now%5D=You%27re+not+allowed+to+make+changes+to+this+project+directly.+A+fork+of+this+project+is+being+created+that+you+can+make+changes+in%2C+so+you+can+submit+a+merge+request.&continue%5Bto%5D=%2Froot%2Facets-app%2Fmerge_requests%2F22&namespace_key=1", - "revert_in_fork_path": "/root/acets-app/forks?continue%5Bnotice%5D=You%27re+not+allowed+to+make+changes+to+this+project+directly.+A+fork+of+this+project+has+been+created+that+you+can+make+changes+in%2C+so+you+can+submit+a+merge+request.+Try+to+cherry-pick+this+commit+again.&continue%5Bnotice_now%5D=You%27re+not+allowed+to+make+changes+to+this+project+directly.+A+fork+of+this+project+is+being+created+that+you+can+make+changes+in%2C+so+you+can+submit+a+merge+request.&continue%5Bto%5D=%2Froot%2Facets-app%2Fmerge_requests%2F22&namespace_key=1", - "email_patches_path": "/root/acets-app/merge_requests/22.patch", - "plain_diff_path": "/root/acets-app/merge_requests/22.diff", - "status_path": "/root/acets-app/merge_requests/22.json", - "merge_check_path": "/root/acets-app/merge_requests/22/merge_check", - "ci_environments_status_url": "/root/acets-app/merge_requests/22/ci_environments_status", - "project_archived": false, - "merge_commit_message_with_description": "Merge branch 'daaaa' into 'master'\n\nUpdate README.md\n\nSee merge request !22", - "diverged_commits_count": 0, - "only_allow_merge_if_pipeline_succeeds": false, - "commit_change_content_path": "/root/acets-app/merge_requests/22/commit_change_content" -} + target_branch_path: '/root/acets-app/branches/master', + source_branch_path: '/root/acets-app/branches/daaaa', + conflict_resolution_ui_path: '/root/acets-app/merge_requests/22/conflicts', + remove_wip_path: '/root/acets-app/merge_requests/22/remove_wip', + cancel_merge_when_pipeline_succeeds_path: + '/root/acets-app/merge_requests/22/cancel_merge_when_pipeline_succeeds', + create_issue_to_resolve_discussions_path: + '/root/acets-app/issues/new?merge_request_to_resolve_discussions_of=22', + merge_path: '/root/acets-app/merge_requests/22/merge', + cherry_pick_in_fork_path: + '/root/acets-app/forks?continue%5Bnotice%5D=You%27re+not+allowed+to+make+changes+to+this+project+directly.+A+fork+of+this+project+has+been+created+that+you+can+make+changes+in%2C+so+you+can+submit+a+merge+request.+Try+to+revert+this+commit+again.&continue%5Bnotice_now%5D=You%27re+not+allowed+to+make+changes+to+this+project+directly.+A+fork+of+this+project+is+being+created+that+you+can+make+changes+in%2C+so+you+can+submit+a+merge+request.&continue%5Bto%5D=%2Froot%2Facets-app%2Fmerge_requests%2F22&namespace_key=1', + revert_in_fork_path: + '/root/acets-app/forks?continue%5Bnotice%5D=You%27re+not+allowed+to+make+changes+to+this+project+directly.+A+fork+of+this+project+has+been+created+that+you+can+make+changes+in%2C+so+you+can+submit+a+merge+request.+Try+to+cherry-pick+this+commit+again.&continue%5Bnotice_now%5D=You%27re+not+allowed+to+make+changes+to+this+project+directly.+A+fork+of+this+project+is+being+created+that+you+can+make+changes+in%2C+so+you+can+submit+a+merge+request.&continue%5Bto%5D=%2Froot%2Facets-app%2Fmerge_requests%2F22&namespace_key=1', + email_patches_path: '/root/acets-app/merge_requests/22.patch', + plain_diff_path: '/root/acets-app/merge_requests/22.diff', + status_path: '/root/acets-app/merge_requests/22.json', + merge_check_path: '/root/acets-app/merge_requests/22/merge_check', + ci_environments_status_url: '/root/acets-app/merge_requests/22/ci_environments_status', + project_archived: false, + merge_commit_message_with_description: + "Merge branch 'daaaa' into 'master'\n\nUpdate README.md\n\nSee merge request !22", + diverged_commits_count: 0, + only_allow_merge_if_pipeline_succeeds: false, + commit_change_content_path: '/root/acets-app/merge_requests/22/commit_change_content', +}; diff --git a/spec/javascripts/vue_shared/components/content_viewer/content_viewer_spec.js b/spec/javascripts/vue_shared/components/content_viewer/content_viewer_spec.js new file mode 100644 index 00000000000..383f0cd29ea --- /dev/null +++ b/spec/javascripts/vue_shared/components/content_viewer/content_viewer_spec.js @@ -0,0 +1,70 @@ +import Vue from 'vue'; +import MockAdapter from 'axios-mock-adapter'; +import axios from '~/lib/utils/axios_utils'; +import contentViewer from '~/vue_shared/components/content_viewer/content_viewer.vue'; +import mountComponent from 'spec/helpers/vue_mount_component_helper'; + +describe('ContentViewer', () => { + let vm; + let mock; + + function createComponent(props) { + const ContentViewer = Vue.extend(contentViewer); + vm = mountComponent(ContentViewer, props); + } + + afterEach(() => { + vm.$destroy(); + if (mock) mock.restore(); + }); + + it('markdown preview renders + loads rendered markdown from server', done => { + mock = new MockAdapter(axios); + mock.onPost(`${gon.relative_url_root}/testproject/preview_markdown`).reply(200, { + body: '<b>testing</b>', + }); + + createComponent({ + path: 'test.md', + content: '* Test', + projectPath: 'testproject', + }); + + const previewContainer = vm.$el.querySelector('.md-previewer'); + + setTimeout(() => { + expect(previewContainer.textContent).toContain('testing'); + + done(); + }); + }); + + it('renders image preview', done => { + createComponent({ + path: 'test.jpg', + fileSize: 1024, + }); + + setTimeout(() => { + expect(vm.$el.querySelector('.image_file img').getAttribute('src')).toBe('test.jpg'); + + done(); + }); + }); + + it('renders fallback download control', done => { + createComponent({ + path: 'test.abc', + fileSize: 1024, + }); + + setTimeout(() => { + expect(vm.$el.querySelector('.file-info').textContent.trim()).toContain( + 'test.abc (1.00 KiB)', + ); + expect(vm.$el.querySelector('.btn.btn-default').textContent.trim()).toContain('Download'); + + done(); + }); + }); +}); diff --git a/spec/javascripts/vue_shared/components/mock_data.js b/spec/javascripts/vue_shared/components/mock_data.js index 0d781bdca74..15b56c58c33 100644 --- a/spec/javascripts/vue_shared/components/mock_data.js +++ b/spec/javascripts/vue_shared/components/mock_data.js @@ -1,5 +1,3 @@ -/* eslint-disable */ - export const mockMetrics = [ [1493716685, '4.30859375'], [1493716745, '4.30859375'], diff --git a/spec/lib/backup/files_spec.rb b/spec/lib/backup/files_spec.rb new file mode 100644 index 00000000000..14d055cbcc1 --- /dev/null +++ b/spec/lib/backup/files_spec.rb @@ -0,0 +1,66 @@ +require 'spec_helper' + +describe Backup::Files do + let(:progress) { StringIO.new } + let!(:project) { create(:project) } + + before do + allow(progress).to receive(:puts) + allow(progress).to receive(:print) + allow(FileUtils).to receive(:mkdir_p).and_return(true) + allow(FileUtils).to receive(:mv).and_return(true) + allow(File).to receive(:exist?).and_return(true) + allow(File).to receive(:realpath).with("/var/gitlab-registry").and_return("/var/gitlab-registry") + allow(File).to receive(:realpath).with("/var/gitlab-registry/..").and_return("/var") + + allow_any_instance_of(String).to receive(:color) do |string, _color| + string + end + + allow_any_instance_of(described_class).to receive(:progress).and_return(progress) + end + + describe '#restore' do + subject { described_class.new('registry', '/var/gitlab-registry') } + let(:timestamp) { Time.utc(2017, 3, 22) } + + around do |example| + Timecop.freeze(timestamp) { example.run } + end + + describe 'folders with permission' do + before do + allow(subject).to receive(:run_pipeline!).and_return(true) + allow(subject).to receive(:backup_existing_files).and_return(true) + allow(Dir).to receive(:glob).with("/var/gitlab-registry/*", File::FNM_DOTMATCH).and_return(["/var/gitlab-registry/.", "/var/gitlab-registry/..", "/var/gitlab-registry/sample1"]) + end + + it 'moves all necessary files' do + allow(subject).to receive(:backup_existing_files).and_call_original + expect(FileUtils).to receive(:mv).with(["/var/gitlab-registry/sample1"], File.join(Gitlab.config.backup.path, "tmp", "registry.#{Time.now.to_i}")) + subject.restore + end + + it 'raises no errors' do + expect { subject.restore }.not_to raise_error + end + + it 'calls tar command with unlink' do + expect(subject).to receive(:run_pipeline!).with([%w(gzip -cd), %w(tar --unlink-first --recursive-unlink -C /var/gitlab-registry -xf -)], any_args) + subject.restore + end + end + + describe 'folders without permissions' do + before do + allow(FileUtils).to receive(:mv).and_raise(Errno::EACCES) + allow(subject).to receive(:run_pipeline!).and_return(true) + end + + it 'shows error message' do + expect(subject).to receive(:access_denied_error).with("/var/gitlab-registry") + subject.restore + end + end + end +end diff --git a/spec/lib/backup/repository_spec.rb b/spec/lib/backup/repository_spec.rb index 03573c304aa..e4c1c9bafc0 100644 --- a/spec/lib/backup/repository_spec.rb +++ b/spec/lib/backup/repository_spec.rb @@ -7,6 +7,8 @@ describe Backup::Repository do before do allow(progress).to receive(:puts) allow(progress).to receive(:print) + allow(FileUtils).to receive(:mkdir_p).and_return(true) + allow(FileUtils).to receive(:mv).and_return(true) allow_any_instance_of(String).to receive(:color) do |string, _color| string @@ -68,6 +70,17 @@ describe Backup::Repository do end end end + + describe 'folders without permissions' do + before do + allow(FileUtils).to receive(:mv).and_raise(Errno::EACCES) + end + + it 'shows error message' do + expect(subject).to receive(:access_denied_error) + subject.restore + end + end end describe '#empty_repo?' do diff --git a/spec/lib/banzai/cross_project_reference_spec.rb b/spec/lib/banzai/cross_project_reference_spec.rb index 68ca960caab..aadfe7637dd 100644 --- a/spec/lib/banzai/cross_project_reference_spec.rb +++ b/spec/lib/banzai/cross_project_reference_spec.rb @@ -14,6 +14,16 @@ describe Banzai::CrossProjectReference do end end + context 'when no project was referenced in group context' do + it 'returns the group from context' do + group = double + + allow(self).to receive(:context).and_return({ group: group }) + + expect(parent_from_ref(nil)).to eq group + end + end + context 'when referenced project does not exist' do it 'returns nil' do expect(parent_from_ref('invalid/reference')).to be_nil diff --git a/spec/lib/banzai/filter/commit_reference_filter_spec.rb b/spec/lib/banzai/filter/commit_reference_filter_spec.rb index 35f8792ff35..b18af806118 100644 --- a/spec/lib/banzai/filter/commit_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/commit_reference_filter_spec.rb @@ -207,4 +207,35 @@ describe Banzai::Filter::CommitReferenceFilter do expect(reference_filter(act).to_html).to match(%r{<a.+>#{Regexp.escape(invalidate_reference(reference))}</a>}) end end + + context 'URL reference for a commit patch' do + let(:namespace) { create(:namespace) } + let(:project2) { create(:project, :public, :repository, namespace: namespace) } + let(:commit) { project2.commit } + let(:link) { urls.project_commit_url(project2, commit.id) } + let(:extension) { '.patch' } + let(:reference) { link + extension } + + it 'links to a valid reference' do + doc = reference_filter("See #{reference}") + + expect(doc.css('a').first.attr('href')) + .to eq reference + end + + it 'has valid text' do + doc = reference_filter("See #{reference}") + + expect(doc.text).to eq("See #{commit.reference_link_text(project)} (patch)") + end + + it 'does not link to patch when extension match is after the path' do + invalidate_commit_reference = reference_filter("#{link}/builds.patch") + + doc = reference_filter("See (#{invalidate_commit_reference})") + + expect(doc.css('a').first.attr('href')).to eq "#{link}/builds" + expect(doc.text).to eq("See (#{commit.reference_link_text(project)} (builds).patch)") + end + end end diff --git a/spec/lib/banzai/filter/commit_trailers_filter_spec.rb b/spec/lib/banzai/filter/commit_trailers_filter_spec.rb new file mode 100644 index 00000000000..1fd145116df --- /dev/null +++ b/spec/lib/banzai/filter/commit_trailers_filter_spec.rb @@ -0,0 +1,171 @@ +require 'spec_helper' +require 'ffaker' + +describe Banzai::Filter::CommitTrailersFilter do + include FilterSpecHelper + include CommitTrailersSpecHelper + + let(:secondary_email) { create(:email, :confirmed) } + let(:user) { create(:user) } + + let(:trailer) { "#{FFaker::Lorem.word}-by:"} + + let(:commit_message) { trailer_line(trailer, user.name, user.email) } + let(:commit_message_html) { commit_html(commit_message) } + + context 'detects' do + let(:email) { FFaker::Internet.email } + + it 'trailers in the form of *-by and replace users with links' do + doc = filter(commit_message_html) + + expect_to_have_user_link_with_avatar(doc, user: user, trailer: trailer) + end + + it 'trailers prefixed with whitespaces' do + message_html = commit_html("\n\r #{commit_message}") + + doc = filter(message_html) + + expect_to_have_user_link_with_avatar(doc, user: user, trailer: trailer) + end + + it 'GitLab users via a secondary email' do + _, message_html = build_commit_message( + trailer: trailer, + name: secondary_email.user.name, + email: secondary_email.email + ) + + doc = filter(message_html) + + expect_to_have_user_link_with_avatar( + doc, + user: secondary_email.user, + trailer: trailer, + email: secondary_email.email + ) + end + + it 'non GitLab users and replaces them with mailto links' do + _, message_html = build_commit_message( + trailer: trailer, + name: FFaker::Name.name, + email: email + ) + + doc = filter(message_html) + + expect_to_have_mailto_link(doc, email: email, trailer: trailer) + end + + it 'multiple trailers in the same message' do + different_trailer = "#{FFaker::Lorem.word}-by:" + message = commit_html %( + #{commit_message} + #{trailer_line(different_trailer, FFaker::Name.name, email)} + ) + + doc = filter(message) + + expect_to_have_user_link_with_avatar(doc, user: user, trailer: trailer) + expect_to_have_mailto_link(doc, email: email, trailer: different_trailer) + end + + context 'special names' do + where(:name) do + [ + 'John S. Doe', + 'L33t H@x0r' + ] + end + + with_them do + it do + message, message_html = build_commit_message( + trailer: trailer, + name: name, + email: email + ) + + doc = filter(message_html) + + expect_to_have_mailto_link(doc, email: email, trailer: trailer) + expect(doc.text).to match Regexp.escape(message) + end + end + end + end + + context "ignores" do + it 'commit messages without trailers' do + exp = message = commit_html(FFaker::Lorem.sentence) + doc = filter(message) + + expect(doc.to_html).to match Regexp.escape(exp) + end + + it 'trailers that are inline the commit message body' do + message = commit_html %( + #{FFaker::Lorem.sentence} #{commit_message} #{FFaker::Lorem.sentence} + ) + + doc = filter(message) + + expect(doc.css('a').size).to eq 0 + end + end + + context "structure" do + it 'preserves the commit trailer structure' do + doc = filter(commit_message_html) + + expect_to_have_user_link_with_avatar(doc, user: user, trailer: trailer) + expect(doc.text).to match Regexp.escape(commit_message) + end + + it 'preserves the original name used in the commit message' do + message, message_html = build_commit_message( + trailer: trailer, + name: FFaker::Name.name, + email: user.email + ) + + doc = filter(message_html) + + expect_to_have_user_link_with_avatar(doc, user: user, trailer: trailer) + expect(doc.text).to match Regexp.escape(message) + end + + it 'preserves the original email used in the commit message' do + message, message_html = build_commit_message( + trailer: trailer, + name: secondary_email.user.name, + email: secondary_email.email + ) + + doc = filter(message_html) + + expect_to_have_user_link_with_avatar( + doc, + user: secondary_email.user, + trailer: trailer, + email: secondary_email.email + ) + expect(doc.text).to match Regexp.escape(message) + end + + it 'only replaces trailer lines not the full commit message' do + commit_body = FFaker::Lorem.paragraph + message = commit_html %( + #{commit_body} + #{commit_message} + ) + + doc = filter(message) + + expect_to_have_user_link_with_avatar(doc, user: user, trailer: trailer) + expect(doc.text).to include(commit_body) + end + end +end diff --git a/spec/lib/banzai/filter/label_reference_filter_spec.rb b/spec/lib/banzai/filter/label_reference_filter_spec.rb index 0c524a1551f..392905076dc 100644 --- a/spec/lib/banzai/filter/label_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/label_reference_filter_spec.rb @@ -596,6 +596,27 @@ describe Banzai::Filter::LabelReferenceFilter do end describe 'group context' do + it 'points to the page defined in label_url_method' do + group = create(:group) + label = create(:group_label, group: group) + reference = "~#{label.name}" + + result = reference_filter("See #{reference}", { project: nil, group: group, label_url_method: :group_url } ) + + expect(result.css('a').first.attr('href')).to eq(urls.group_url(group, label_name: label.name)) + end + + it 'finds labels also in ancestor groups' do + group = create(:group) + label = create(:group_label, group: group) + subgroup = create(:group, parent: group) + reference = "~#{label.name}" + + result = reference_filter("See #{reference}", { project: nil, group: subgroup, label_url_method: :group_url } ) + + expect(result.css('a').first.attr('href')).to eq(urls.group_url(subgroup, label_name: label.name)) + end + it 'points to referenced project issues page' do project = create(:project) label = create(:label, project: project) @@ -604,6 +625,7 @@ describe Banzai::Filter::LabelReferenceFilter do result = reference_filter("See #{reference}", { project: nil, group: create(:group) } ) expect(result.css('a').first.attr('href')).to eq(urls.project_issues_url(project, label_name: label.name)) + expect(result.css('a').first.text).to eq "#{label.name} in #{project.full_name}" end end end diff --git a/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb b/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb index eeb82822f68..a1dd72c498f 100644 --- a/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb @@ -196,6 +196,41 @@ describe Banzai::Filter::MergeRequestReferenceFilter do end end + context 'URL reference for a commit' do + let(:mr) { create(:merge_request, :with_diffs) } + let(:reference) do + urls.project_merge_request_url(mr.project, mr) + "/diffs?commit_id=#{mr.diff_head_sha}" + end + let(:commit) { mr.commits.find { |commit| commit.sha == mr.diff_head_sha } } + + it 'links to a valid reference' do + doc = reference_filter("See #{reference}") + + expect(doc.css('a').first.attr('href')) + .to eq reference + end + + it 'has valid text' do + doc = reference_filter("See #{reference}") + + expect(doc.text).to eq("See #{mr.to_reference(full: true)} (#{commit.short_id})") + end + + it 'has valid title attribute' do + doc = reference_filter("See #{reference}") + + expect(doc.css('a').first.attr('title')).to eq(commit.title) + end + + it 'ignores invalid commit short_ids on link text' do + invalidate_commit_reference = + urls.project_merge_request_url(mr.project, mr) + "/diffs?commit_id=12345678" + doc = reference_filter("See #{invalidate_commit_reference}") + + expect(doc.text).to eq("See #{mr.to_reference(full: true)} (diffs)") + end + end + context 'cross-project URL reference' do let(:namespace) { create(:namespace, name: 'cross-reference') } let(:project2) { create(:project, :public, namespace: namespace) } diff --git a/spec/lib/banzai/reference_parser/issue_parser_spec.rb b/spec/lib/banzai/reference_parser/issue_parser_spec.rb index 0a63567ee40..cb7f8b20dda 100644 --- a/spec/lib/banzai/reference_parser/issue_parser_spec.rb +++ b/spec/lib/banzai/reference_parser/issue_parser_spec.rb @@ -117,4 +117,27 @@ describe Banzai::ReferenceParser::IssueParser do expect(subject.records_for_nodes(nodes)).to eq({ link => issue }) end end + + context 'when checking multiple merge requests on another project' do + let(:other_project) { create(:project, :public) } + let(:other_issue) { create(:issue, project: other_project) } + + let(:control_links) do + [issue_link(other_issue)] + end + + let(:actual_links) do + control_links + [issue_link(create(:issue, project: other_project))] + end + + def issue_link(issue) + Nokogiri::HTML.fragment(%Q{<a data-issue="#{issue.id}"></a>}).children[0] + end + + before do + project.add_developer(user) + end + + it_behaves_like 'no N+1 queries' + end end diff --git a/spec/lib/banzai/reference_parser/merge_request_parser_spec.rb b/spec/lib/banzai/reference_parser/merge_request_parser_spec.rb index 775749ae3a7..14542342cf6 100644 --- a/spec/lib/banzai/reference_parser/merge_request_parser_spec.rb +++ b/spec/lib/banzai/reference_parser/merge_request_parser_spec.rb @@ -4,14 +4,13 @@ describe Banzai::ReferenceParser::MergeRequestParser do include ReferenceParserHelpers let(:user) { create(:user) } - let(:merge_request) { create(:merge_request) } - subject { described_class.new(merge_request.target_project, user) } + let(:project) { create(:project, :public) } + let(:merge_request) { create(:merge_request, source_project: project) } + subject { described_class.new(project, user) } let(:link) { empty_html_link } describe '#nodes_visible_to_user' do context 'when the link has a data-issue attribute' do - let(:project) { merge_request.target_project } - before do project.update_attribute(:visibility_level, Gitlab::VisibilityLevel::PUBLIC) link['data-merge-request'] = merge_request.id.to_s @@ -40,4 +39,27 @@ describe Banzai::ReferenceParser::MergeRequestParser do end end end + + context 'when checking multiple merge requests on another project' do + let(:other_project) { create(:project, :public) } + let(:other_merge_request) { create(:merge_request, source_project: other_project) } + + let(:control_links) do + [merge_request_link(other_merge_request)] + end + + let(:actual_links) do + control_links + [merge_request_link(create(:merge_request, :conflict, source_project: other_project))] + end + + def merge_request_link(merge_request) + Nokogiri::HTML.fragment(%Q{<a data-merge-request="#{merge_request.id}"></a>}).children[0] + end + + before do + project.add_developer(user) + end + + it_behaves_like 'no N+1 queries' + end end diff --git a/spec/lib/forever_spec.rb b/spec/lib/forever_spec.rb new file mode 100644 index 00000000000..cf40c467c72 --- /dev/null +++ b/spec/lib/forever_spec.rb @@ -0,0 +1,21 @@ +require 'spec_helper' + +describe Forever do + describe '.date' do + subject { described_class.date } + + context 'when using PostgreSQL' do + it 'should return Postgresql future date' do + allow(Gitlab::Database).to receive(:postgresql?).and_return(true) + expect(subject).to eq(described_class::POSTGRESQL_DATE) + end + end + + context 'when using MySQL' do + it 'should return MySQL future date' do + allow(Gitlab::Database).to receive(:postgresql?).and_return(false) + expect(subject).to eq(described_class::MYSQL_DATE) + end + end + end +end diff --git a/spec/lib/gitlab/auth/ldap/access_spec.rb b/spec/lib/gitlab/auth/ldap/access_spec.rb index 9b3916bf9e3..6b251d824f7 100644 --- a/spec/lib/gitlab/auth/ldap/access_spec.rb +++ b/spec/lib/gitlab/auth/ldap/access_spec.rb @@ -1,6 +1,8 @@ require 'spec_helper' describe Gitlab::Auth::LDAP::Access do + include LdapHelpers + let(:access) { described_class.new user } let(:user) { create(:omniauth_user) } @@ -32,8 +34,10 @@ describe Gitlab::Auth::LDAP::Access do end context 'when the user is found' do + let(:ldap_user) { Gitlab::Auth::LDAP::Person.new(Net::LDAP::Entry.new, 'ldapmain') } + before do - allow(Gitlab::Auth::LDAP::Person).to receive(:find_by_dn).and_return(:ldap_user) + allow(Gitlab::Auth::LDAP::Person).to receive(:find_by_dn).and_return(ldap_user) end context 'and the user is disabled via active directory' do @@ -120,6 +124,22 @@ describe Gitlab::Auth::LDAP::Access do end end end + + context 'when the connection fails' do + before do + raise_ldap_connection_error + end + + it 'does not block the user' do + access.allowed? + + expect(user.ldap_blocked?).to be_falsey + end + + it 'denies access' do + expect(access.allowed?).to be_falsey + end + end end describe '#block_user' do diff --git a/spec/lib/gitlab/auth/ldap/adapter_spec.rb b/spec/lib/gitlab/auth/ldap/adapter_spec.rb index 10c60d792bd..3eeaf3862f6 100644 --- a/spec/lib/gitlab/auth/ldap/adapter_spec.rb +++ b/spec/lib/gitlab/auth/ldap/adapter_spec.rb @@ -124,16 +124,36 @@ describe Gitlab::Auth::LDAP::Adapter do context "when the search raises an LDAP exception" do before do + allow(adapter).to receive(:renew_connection_adapter).and_return(ldap) allow(ldap).to receive(:search) { raise Net::LDAP::Error, "some error" } allow(Rails.logger).to receive(:warn) end - it { is_expected.to eq [] } + context 'retries the operation' do + before do + stub_const("#{described_class}::MAX_SEARCH_RETRIES", 3) + end + + it 'as many times as MAX_SEARCH_RETRIES' do + expect(ldap).to receive(:search).exactly(3).times + expect { subject }.to raise_error(Gitlab::Auth::LDAP::LDAPConnectionError) + end + + context 'when no more retries' do + before do + stub_const("#{described_class}::MAX_SEARCH_RETRIES", 1) + end - it 'logs the error' do - subject - expect(Rails.logger).to have_received(:warn).with( - "LDAP search raised exception Net::LDAP::Error: some error") + it 'raises the exception' do + expect { subject }.to raise_error(Gitlab::Auth::LDAP::LDAPConnectionError) + end + + it 'logs the error' do + expect { subject }.to raise_error(Gitlab::Auth::LDAP::LDAPConnectionError) + expect(Rails.logger).to have_received(:warn).with( + "LDAP search raised exception Net::LDAP::Error: some error") + end + end end end end diff --git a/spec/lib/gitlab/auth/o_auth/user_spec.rb b/spec/lib/gitlab/auth/o_auth/user_spec.rb index 0c71f1d8ca6..64f3d09a25b 100644 --- a/spec/lib/gitlab/auth/o_auth/user_spec.rb +++ b/spec/lib/gitlab/auth/o_auth/user_spec.rb @@ -1,6 +1,8 @@ require 'spec_helper' describe Gitlab::Auth::OAuth::User do + include LdapHelpers + let(:oauth_user) { described_class.new(auth_hash) } let(:gl_user) { oauth_user.gl_user } let(:uid) { 'my-uid' } @@ -38,10 +40,6 @@ describe Gitlab::Auth::OAuth::User do end describe '#save' do - def stub_ldap_config(messages) - allow(Gitlab::Auth::LDAP::Config).to receive_messages(messages) - end - let(:provider) { 'twitter' } describe 'when account exists on server' do @@ -269,20 +267,47 @@ describe Gitlab::Auth::OAuth::User do end context 'when an LDAP person is not found by uid' do - it 'tries to find an LDAP person by DN and adds the omniauth identity to the user' do + it 'tries to find an LDAP person by email and adds the omniauth identity to the user' do allow(Gitlab::Auth::LDAP::Person).to receive(:find_by_uid).and_return(nil) - allow(Gitlab::Auth::LDAP::Person).to receive(:find_by_dn).and_return(ldap_user) + allow(Gitlab::Auth::LDAP::Person).to receive(:find_by_email).and_return(ldap_user) + + oauth_user.save + + identities_as_hash = gl_user.identities.map { |id| { provider: id.provider, extern_uid: id.extern_uid } } + expect(identities_as_hash).to match_array(result_identities(dn, uid)) + end + + context 'when also not found by email' do + it 'tries to find an LDAP person by DN and adds the omniauth identity to the user' do + allow(Gitlab::Auth::LDAP::Person).to receive(:find_by_uid).and_return(nil) + allow(Gitlab::Auth::LDAP::Person).to receive(:find_by_email).and_return(nil) + allow(Gitlab::Auth::LDAP::Person).to receive(:find_by_dn).and_return(ldap_user) + + oauth_user.save + + identities_as_hash = gl_user.identities.map { |id| { provider: id.provider, extern_uid: id.extern_uid } } + expect(identities_as_hash).to match_array(result_identities(dn, uid)) + end + end + end + def result_identities(dn, uid) + [ + { provider: 'ldapmain', extern_uid: dn }, + { provider: 'twitter', extern_uid: uid } + ] + end + + context 'when there is an LDAP connection error' do + before do + raise_ldap_connection_error + end + + it 'does not save the identity' do oauth_user.save identities_as_hash = gl_user.identities.map { |id| { provider: id.provider, extern_uid: id.extern_uid } } - expect(identities_as_hash) - .to match_array( - [ - { provider: 'ldapmain', extern_uid: dn }, - { provider: 'twitter', extern_uid: uid } - ] - ) + expect(identities_as_hash).to match_array([{ provider: 'twitter', extern_uid: uid }]) end end end @@ -739,4 +764,19 @@ describe Gitlab::Auth::OAuth::User do expect(oauth_user.find_user).to eql gl_user end end + + describe '#find_ldap_person' do + context 'when LDAP connection fails' do + before do + raise_ldap_connection_error + end + + it 'returns nil' do + adapter = Gitlab::Auth::LDAP::Adapter.new('ldapmain') + hash = OmniAuth::AuthHash.new(uid: 'whatever', provider: 'ldapmain') + + expect(oauth_user.send(:find_ldap_person, hash, adapter)).to be_nil + end + end + end end diff --git a/spec/lib/gitlab/auth_spec.rb b/spec/lib/gitlab/auth_spec.rb index 18cef8ec996..9ccd0b206cc 100644 --- a/spec/lib/gitlab/auth_spec.rb +++ b/spec/lib/gitlab/auth_spec.rb @@ -5,7 +5,7 @@ describe Gitlab::Auth do describe 'constants' do it 'API_SCOPES contains all scopes for API access' do - expect(subject::API_SCOPES).to eq %i[api read_user sudo] + expect(subject::API_SCOPES).to eq %i[api read_user sudo read_repository] end it 'OPENID_SCOPES contains all scopes for OpenID Connect' do @@ -19,7 +19,7 @@ describe Gitlab::Auth do it 'optional_scopes contains all non-default scopes' do stub_container_registry_config(enabled: true) - expect(subject.optional_scopes).to eq %i[read_user sudo read_registry openid] + expect(subject.optional_scopes).to eq %i[read_user sudo read_repository read_registry openid] end context 'registry_scopes' do @@ -231,7 +231,7 @@ describe Gitlab::Auth do .to eq(Gitlab::Auth::Result.new(user, nil, :gitlab_or_ldap, full_authentication_abilities)) end - it 'falls through oauth authentication when the username is oauth2' do + it 'fails through oauth authentication when the username is oauth2' do user = create( :user, username: 'oauth2', @@ -255,6 +255,122 @@ describe Gitlab::Auth do expect { gl_auth.find_for_git_client('foo', 'bar', project: nil, ip: 'ip') }.to raise_error(Gitlab::Auth::MissingPersonalAccessTokenError) end + + context 'while using deploy tokens' do + let(:project) { create(:project) } + let(:auth_failure) { Gitlab::Auth::Result.new(nil, nil) } + + context 'when the deploy token has read_repository as scope' do + let(:deploy_token) { create(:deploy_token, read_registry: false, projects: [project]) } + let(:login) { deploy_token.username } + + it 'succeeds when login and token are valid' do + auth_success = Gitlab::Auth::Result.new(deploy_token, project, :deploy_token, [:download_code]) + + expect(gl_auth).to receive(:rate_limit!).with('ip', success: true, login: login) + expect(gl_auth.find_for_git_client(login, deploy_token.token, project: project, ip: 'ip')) + .to eq(auth_success) + end + + it 'fails when login is not valid' do + expect(gl_auth).to receive(:rate_limit!).with('ip', success: false, login: 'random_login') + expect(gl_auth.find_for_git_client('random_login', deploy_token.token, project: project, ip: 'ip')) + .to eq(auth_failure) + end + + it 'fails when token is not valid' do + expect(gl_auth).to receive(:rate_limit!).with('ip', success: false, login: login) + expect(gl_auth.find_for_git_client(login, '123123', project: project, ip: 'ip')) + .to eq(auth_failure) + end + + it 'fails if token is nil' do + expect(gl_auth).to receive(:rate_limit!).with('ip', success: false, login: login) + expect(gl_auth.find_for_git_client(login, nil, project: project, ip: 'ip')) + .to eq(auth_failure) + end + + it 'fails if token is not related to project' do + another_deploy_token = create(:deploy_token) + expect(gl_auth).to receive(:rate_limit!).with('ip', success: false, login: login) + expect(gl_auth.find_for_git_client(login, another_deploy_token.token, project: project, ip: 'ip')) + .to eq(auth_failure) + end + + it 'fails if token has been revoked' do + deploy_token.revoke! + + expect(deploy_token.revoked?).to be_truthy + expect(gl_auth).to receive(:rate_limit!).with('ip', success: false, login: 'deploy-token') + expect(gl_auth.find_for_git_client('deploy-token', deploy_token.token, project: project, ip: 'ip')) + .to eq(auth_failure) + end + end + + context 'when the deploy token has read_registry as a scope' do + let(:deploy_token) { create(:deploy_token, read_repository: false, projects: [project]) } + let(:login) { deploy_token.username } + + context 'when registry enabled' do + before do + stub_container_registry_config(enabled: true) + end + + it 'succeeds when login and token are valid' do + auth_success = Gitlab::Auth::Result.new(deploy_token, project, :deploy_token, [:read_container_image]) + + expect(gl_auth).to receive(:rate_limit!).with('ip', success: true, login: login) + expect(gl_auth.find_for_git_client(login, deploy_token.token, project: nil, ip: 'ip')) + .to eq(auth_success) + end + + it 'fails when login is not valid' do + expect(gl_auth).to receive(:rate_limit!).with('ip', success: false, login: 'random_login') + expect(gl_auth.find_for_git_client('random_login', deploy_token.token, project: project, ip: 'ip')) + .to eq(auth_failure) + end + + it 'fails when token is not valid' do + expect(gl_auth).to receive(:rate_limit!).with('ip', success: false, login: login) + expect(gl_auth.find_for_git_client(login, '123123', project: project, ip: 'ip')) + .to eq(auth_failure) + end + + it 'fails if token is nil' do + expect(gl_auth).to receive(:rate_limit!).with('ip', success: false, login: login) + expect(gl_auth.find_for_git_client(login, nil, project: nil, ip: 'ip')) + .to eq(auth_failure) + end + + it 'fails if token is not related to project' do + expect(gl_auth).to receive(:rate_limit!).with('ip', success: false, login: login) + expect(gl_auth.find_for_git_client(login, 'abcdef', project: nil, ip: 'ip')) + .to eq(auth_failure) + end + + it 'fails if token has been revoked' do + deploy_token.revoke! + + expect(deploy_token.revoked?).to be_truthy + expect(gl_auth).to receive(:rate_limit!).with('ip', success: false, login: 'deploy-token') + expect(gl_auth.find_for_git_client('deploy-token', deploy_token.token, project: nil, ip: 'ip')) + .to eq(auth_failure) + end + end + + context 'when registry disabled' do + before do + stub_container_registry_config(enabled: false) + end + + it 'fails when login and token are valid' do + expect(gl_auth).to receive(:rate_limit!).with('ip', success: false, login: login) + expect(gl_auth.find_for_git_client(login, deploy_token.token, project: nil, ip: 'ip')) + .to eq(auth_failure) + end + end + end + end end describe 'find_with_user_password' do diff --git a/spec/lib/gitlab/background_migration/set_confidential_note_events_on_services_spec.rb b/spec/lib/gitlab/background_migration/set_confidential_note_events_on_services_spec.rb new file mode 100644 index 00000000000..6f3fb994f17 --- /dev/null +++ b/spec/lib/gitlab/background_migration/set_confidential_note_events_on_services_spec.rb @@ -0,0 +1,31 @@ +require 'spec_helper' + +describe Gitlab::BackgroundMigration::SetConfidentialNoteEventsOnServices, :migration, schema: 20180122154930 do + let(:services) { table(:services) } + + describe '#perform' do + it 'migrates services where note_events is true' do + service = services.create(confidential_note_events: nil, note_events: true) + + subject.perform(service.id, service.id) + + expect(service.reload.confidential_note_events).to eq(true) + end + + it 'ignores services where note_events is false' do + service = services.create(confidential_note_events: nil, note_events: false) + + subject.perform(service.id, service.id) + + expect(service.reload.confidential_note_events).to eq(nil) + end + + it 'ignores services where confidential_note_events has already been set' do + service = services.create(confidential_note_events: false, note_events: true) + + subject.perform(service.id, service.id) + + expect(service.reload.confidential_note_events).to eq(false) + end + end +end diff --git a/spec/lib/gitlab/background_migration/set_confidential_note_events_on_webhooks_spec.rb b/spec/lib/gitlab/background_migration/set_confidential_note_events_on_webhooks_spec.rb new file mode 100644 index 00000000000..82b484b7d5b --- /dev/null +++ b/spec/lib/gitlab/background_migration/set_confidential_note_events_on_webhooks_spec.rb @@ -0,0 +1,31 @@ +require 'spec_helper' + +describe Gitlab::BackgroundMigration::SetConfidentialNoteEventsOnWebhooks, :migration, schema: 20180104131052 do + let(:web_hooks) { table(:web_hooks) } + + describe '#perform' do + it 'migrates hooks where note_events is true' do + hook = web_hooks.create(confidential_note_events: nil, note_events: true) + + subject.perform(hook.id, hook.id) + + expect(hook.reload.confidential_note_events).to eq(true) + end + + it 'ignores hooks where note_events is false' do + hook = web_hooks.create(confidential_note_events: nil, note_events: false) + + subject.perform(hook.id, hook.id) + + expect(hook.reload.confidential_note_events).to eq(nil) + end + + it 'ignores hooks where confidential_note_events has already been set' do + hook = web_hooks.create(confidential_note_events: false, note_events: true) + + subject.perform(hook.id, hook.id) + + expect(hook.reload.confidential_note_events).to eq(false) + end + end +end diff --git a/spec/lib/gitlab/bitbucket_import/importer_spec.rb b/spec/lib/gitlab/bitbucket_import/importer_spec.rb index a6a1d9e619f..c63120b0b29 100644 --- a/spec/lib/gitlab/bitbucket_import/importer_spec.rb +++ b/spec/lib/gitlab/bitbucket_import/importer_spec.rb @@ -137,7 +137,7 @@ describe Gitlab::BitbucketImport::Importer do it 'imports to the project disk_path' do expect(project.wiki).to receive(:repository_exists?) { false } expect(importer.gitlab_shell).to receive(:import_repository).with( - project.repository_storage_path, + project.repository_storage, project.wiki.disk_path, project.import_url + '/wiki' ) diff --git a/spec/lib/gitlab/ci/build/policy/variables_spec.rb b/spec/lib/gitlab/ci/build/policy/variables_spec.rb new file mode 100644 index 00000000000..2ce858836e3 --- /dev/null +++ b/spec/lib/gitlab/ci/build/policy/variables_spec.rb @@ -0,0 +1,72 @@ +require 'spec_helper' + +describe Gitlab::Ci::Build::Policy::Variables do + set(:project) { create(:project) } + + let(:pipeline) do + build(:ci_empty_pipeline, project: project, ref: 'master', source: :push) + end + + let(:ci_build) do + build(:ci_build, pipeline: pipeline, project: project, ref: 'master') + end + + let(:seed) { double('build seed', to_resource: ci_build) } + + before do + pipeline.variables.build(key: 'CI_PROJECT_NAME', value: '') + end + + describe '#satisfied_by?' do + it 'is satisfied by at least one matching statement' do + policy = described_class.new(['$CI_PROJECT_ID', '$UNDEFINED']) + + expect(policy).to be_satisfied_by(pipeline, seed) + end + + it 'is not satisfied by an overriden empty variable' do + policy = described_class.new(['$CI_PROJECT_NAME']) + + expect(policy).not_to be_satisfied_by(pipeline, seed) + end + + it 'is satisfied by a truthy pipeline expression' do + policy = described_class.new([%($CI_PIPELINE_SOURCE == "push")]) + + expect(policy).to be_satisfied_by(pipeline, seed) + end + + it 'is not satisfied by a falsy pipeline expression' do + policy = described_class.new([%($CI_PIPELINE_SOURCE == "invalid source")]) + + expect(policy).not_to be_satisfied_by(pipeline, seed) + end + + it 'is satisfied by a truthy expression using undefined variable' do + policy = described_class.new(['$UNDEFINED == null']) + + expect(policy).to be_satisfied_by(pipeline, seed) + end + + it 'is not satisfied by a falsy expression using undefined variable' do + policy = described_class.new(['$UNDEFINED']) + + expect(policy).not_to be_satisfied_by(pipeline, seed) + end + + it 'allows to evaluate regular secret variables' do + create(:ci_variable, project: project, key: 'SECRET', value: 'my secret') + + policy = described_class.new(["$SECRET == 'my secret'"]) + + expect(policy).to be_satisfied_by(pipeline, seed) + end + + it 'does not persist neither pipeline nor build' do + described_class.new('$VAR').satisfied_by?(pipeline, seed) + + expect(pipeline).not_to be_persisted + expect(seed.to_resource).not_to be_persisted + end + end +end diff --git a/spec/lib/gitlab/ci/config/entry/policy_spec.rb b/spec/lib/gitlab/ci/config/entry/policy_spec.rb index 5e83abf645b..08718c382b9 100644 --- a/spec/lib/gitlab/ci/config/entry/policy_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/policy_spec.rb @@ -83,6 +83,39 @@ describe Gitlab::Ci::Config::Entry::Policy do end end + context 'when specifying valid variables expressions policy' do + let(:config) { { variables: ['$VAR == null'] } } + + it 'is a correct configuraton' do + expect(entry).to be_valid + expect(entry.value).to eq(config) + end + end + + context 'when specifying variables expressions in invalid format' do + let(:config) { { variables: '$MY_VAR' } } + + it 'reports an error about invalid format' do + expect(entry.errors).to include /should be an array of strings/ + end + end + + context 'when specifying invalid variables expressions statement' do + let(:config) { { variables: ['$MY_VAR =='] } } + + it 'reports an error about invalid statement' do + expect(entry.errors).to include /invalid expression syntax/ + end + end + + context 'when specifying invalid variables expressions token' do + let(:config) { { variables: ['$MY_VAR == 123'] } } + + it 'reports an error about invalid statement' do + expect(entry.errors).to include /invalid expression syntax/ + end + end + context 'when specifying unknown policy' do let(:config) { { refs: ['master'], invalid: :something } } diff --git a/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb b/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb index 2258ae83f38..8312fa47cfa 100644 --- a/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/chain/populate_spec.rb @@ -6,7 +6,8 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do let(:pipeline) do build(:ci_pipeline_with_one_job, project: project, - ref: 'master') + ref: 'master', + user: user) end let(:command) do @@ -42,6 +43,10 @@ describe Gitlab::Ci::Pipeline::Chain::Populate do expect(pipeline.stages.first.builds).to be_one expect(pipeline.stages.first.builds.first).not_to be_persisted end + + it 'correctly assigns user' do + expect(pipeline.builds).to all(have_attributes(user: user)) + end end context 'when pipeline is empty' do diff --git a/spec/lib/gitlab/ci/pipeline/expression/lexeme/string_spec.rb b/spec/lib/gitlab/ci/pipeline/expression/lexeme/string_spec.rb index 86234dfb9e5..1ccb792d1da 100644 --- a/spec/lib/gitlab/ci/pipeline/expression/lexeme/string_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/expression/lexeme/string_spec.rb @@ -73,6 +73,22 @@ describe Gitlab::Ci::Pipeline::Expression::Lexeme::String do expect(token).not_to be_nil expect(token.build.evaluate).to eq 'some " string' end + + it 'allows to use an empty string inside single quotes' do + scanner = StringScanner.new(%('')) + + token = described_class.scan(scanner) + + expect(token.build.evaluate).to eq '' + end + + it 'allow to use an empty string inside double quotes' do + scanner = StringScanner.new(%("")) + + token = described_class.scan(scanner) + + expect(token.build.evaluate).to eq '' + end end end diff --git a/spec/lib/gitlab/ci/pipeline/expression/statement_spec.rb b/spec/lib/gitlab/ci/pipeline/expression/statement_spec.rb index 472a58599d8..6685bf5385b 100644 --- a/spec/lib/gitlab/ci/pipeline/expression/statement_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/expression/statement_spec.rb @@ -1,14 +1,23 @@ require 'spec_helper' describe Gitlab::Ci::Pipeline::Expression::Statement do - let(:pipeline) { build(:ci_pipeline) } - subject do - described_class.new(text, pipeline) + described_class.new(text, variables) + end + + let(:variables) do + { 'PRESENT_VARIABLE' => 'my variable', + EMPTY_VARIABLE: '' } end - before do - pipeline.variables.build([key: 'VARIABLE', value: 'my variable']) + describe '.new' do + context 'when variables are not provided' do + it 'allows to properly initializes the statement' do + statement = described_class.new('$PRESENT_VARIABLE') + + expect(statement.evaluate).to be_nil + end + end end describe '#parse_tree' do @@ -23,18 +32,26 @@ describe Gitlab::Ci::Pipeline::Expression::Statement do context 'when expression grammar is incorrect' do table = [ - '$VAR "text"', # missing operator - '== "123"', # invalid right side - "'single quotes'", # single quotes string - '$VAR ==', # invalid right side - '12345', # unknown syntax - '' # empty statement + '$VAR "text"', # missing operator + '== "123"', # invalid left side + '"some string"', # only string provided + '$VAR ==', # invalid right side + '12345', # unknown syntax + '' # empty statement ] table.each do |syntax| - it "raises an error when syntax is `#{syntax}`" do - expect { described_class.new(syntax, pipeline).parse_tree } - .to raise_error described_class::StatementError + context "when expression grammar is #{syntax.inspect}" do + let(:text) { syntax } + + it 'aises a statement error exception' do + expect { subject.parse_tree } + .to raise_error described_class::StatementError + end + + it 'is an invalid statement' do + expect(subject).not_to be_valid + end end end end @@ -47,10 +64,14 @@ describe Gitlab::Ci::Pipeline::Expression::Statement do expect(subject.parse_tree) .to be_a Gitlab::Ci::Pipeline::Expression::Lexeme::Equals end + + it 'is a valid statement' do + expect(subject).to be_valid + end end context 'when using a single token' do - let(:text) { '$VARIABLE' } + let(:text) { '$PRESENT_VARIABLE' } it 'returns a single token instance' do expect(subject.parse_tree) @@ -62,14 +83,17 @@ describe Gitlab::Ci::Pipeline::Expression::Statement do describe '#evaluate' do statements = [ - ['$VARIABLE == "my variable"', true], - ["$VARIABLE == 'my variable'", true], - ['"my variable" == $VARIABLE', true], - ['$VARIABLE == null', false], - ['$VAR == null', true], - ['null == $VAR', true], - ['$VARIABLE', 'my variable'], - ['$VAR', nil] + ['$PRESENT_VARIABLE == "my variable"', true], + ["$PRESENT_VARIABLE == 'my variable'", true], + ['"my variable" == $PRESENT_VARIABLE', true], + ['$PRESENT_VARIABLE == null', false], + ['$EMPTY_VARIABLE == null', false], + ['"" == $EMPTY_VARIABLE', true], + ['$EMPTY_VARIABLE', ''], + ['$UNDEFINED_VARIABLE == null', true], + ['null == $UNDEFINED_VARIABLE', true], + ['$PRESENT_VARIABLE', 'my variable'], + ['$UNDEFINED_VARIABLE', nil] ] statements.each do |expression, value| @@ -82,4 +106,25 @@ describe Gitlab::Ci::Pipeline::Expression::Statement do end end end + + describe '#truthful?' do + statements = [ + ['$PRESENT_VARIABLE == "my variable"', true], + ["$PRESENT_VARIABLE == 'no match'", false], + ['$UNDEFINED_VARIABLE == null', true], + ['$PRESENT_VARIABLE', true], + ['$UNDEFINED_VARIABLE', false], + ['$EMPTY_VARIABLE', false] + ] + + statements.each do |expression, value| + context "when using expression `#{expression}`" do + let(:text) { expression } + + it "returns `#{value.inspect}`" do + expect(subject.truthful?).to eq value + end + end + end + end end diff --git a/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb b/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb index 116573379e0..fffa727c2ed 100644 --- a/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb @@ -21,16 +21,6 @@ describe Gitlab::Ci::Pipeline::Seed::Build do end end - describe '#user=' do - let(:user) { build(:user) } - - it 'assignes user to a build' do - subject.user = user - - expect(subject.attributes).to include(user: user) - end - end - describe '#to_resource' do it 'returns a valid build resource' do expect(subject.to_resource).to be_a(::Ci::Build) diff --git a/spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb b/spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb index 8f0bf40d624..eb1b285c7bd 100644 --- a/spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb @@ -95,16 +95,6 @@ describe Gitlab::Ci::Pipeline::Seed::Stage do end end - describe '#user=' do - let(:user) { build(:user) } - - it 'assignes relevant pipeline attributes' do - subject.user = user - - expect(subject.seeds.map(&:attributes)).to all(include(user: user)) - end - end - describe '#to_resource' do it 'builds a valid stage object with all builds' do subject.to_resource.save! diff --git a/spec/lib/gitlab/ci/status/build/action_spec.rb b/spec/lib/gitlab/ci/status/build/action_spec.rb index d612d29e3e0..bdec582b57b 100644 --- a/spec/lib/gitlab/ci/status/build/action_spec.rb +++ b/spec/lib/gitlab/ci/status/build/action_spec.rb @@ -53,4 +53,14 @@ describe Gitlab::Ci::Status::Build::Action do end end end + + describe '#badge_tooltip' do + let(:user) { create(:user) } + let(:build) { create(:ci_build, :non_playable) } + let(:status) { Gitlab::Ci::Status::Core.new(build, user) } + + it 'returns the status' do + expect(subject.badge_tooltip).to eq('created') + end + end end diff --git a/spec/lib/gitlab/ci/status/build/cancelable_spec.rb b/spec/lib/gitlab/ci/status/build/cancelable_spec.rb index 9cdebaa5cf2..78d6fa65b5a 100644 --- a/spec/lib/gitlab/ci/status/build/cancelable_spec.rb +++ b/spec/lib/gitlab/ci/status/build/cancelable_spec.rb @@ -40,6 +40,24 @@ describe Gitlab::Ci::Status::Build::Cancelable do end end + describe '#status_tooltip' do + it 'does not override status status_tooltip' do + expect(status).to receive(:status_tooltip) + + subject.status_tooltip + end + end + + describe '#badge_tooltip' do + let(:user) { create(:user) } + let(:build) { create(:ci_build) } + let(:status) { Gitlab::Ci::Status::Core.new(build, user) } + + it 'returns the status' do + expect(subject.badge_tooltip).to eq('pending') + end + end + describe 'action details' do let(:user) { create(:user) } let(:build) { create(:ci_build) } @@ -72,6 +90,10 @@ describe Gitlab::Ci::Status::Build::Cancelable do describe '#action_title' do it { expect(subject.action_title).to eq 'Cancel' } end + + describe '#action_button_title' do + it { expect(subject.action_button_title).to eq 'Cancel this job' } + end end describe '.matches?' do diff --git a/spec/lib/gitlab/ci/status/build/canceled_spec.rb b/spec/lib/gitlab/ci/status/build/canceled_spec.rb new file mode 100644 index 00000000000..c6b5cc68770 --- /dev/null +++ b/spec/lib/gitlab/ci/status/build/canceled_spec.rb @@ -0,0 +1,33 @@ +require 'spec_helper' + +describe Gitlab::Ci::Status::Build::Canceled do + let(:user) { create(:user) } + + subject do + described_class.new(double('subject')) + end + + describe '#illustration' do + it { expect(subject.illustration).to include(:image, :size, :title) } + end + + describe '.matches?' do + subject {described_class.matches?(build, user) } + + context 'when build is canceled' do + let(:build) { create(:ci_build, :canceled) } + + it 'is a correct match' do + expect(subject).to be true + end + end + + context 'when build is not canceled' do + let(:build) { create(:ci_build) } + + it 'does not match' do + expect(subject).to be false + end + end + end +end diff --git a/spec/lib/gitlab/ci/status/build/created_spec.rb b/spec/lib/gitlab/ci/status/build/created_spec.rb new file mode 100644 index 00000000000..8bdfe6ef7a2 --- /dev/null +++ b/spec/lib/gitlab/ci/status/build/created_spec.rb @@ -0,0 +1,33 @@ +require 'spec_helper' + +describe Gitlab::Ci::Status::Build::Created do + let(:user) { create(:user) } + + subject do + described_class.new(double('subject')) + end + + describe '#illustration' do + it { expect(subject.illustration).to include(:image, :size, :title, :content) } + end + + describe '.matches?' do + subject {described_class.matches?(build, user) } + + context 'when build is created' do + let(:build) { create(:ci_build, :created) } + + it 'is a correct match' do + expect(subject).to be true + end + end + + context 'when build is not created' do + let(:build) { create(:ci_build) } + + it 'does not match' do + expect(subject).to be false + end + end + end +end diff --git a/spec/lib/gitlab/ci/status/build/erased_spec.rb b/spec/lib/gitlab/ci/status/build/erased_spec.rb new file mode 100644 index 00000000000..0acd271e375 --- /dev/null +++ b/spec/lib/gitlab/ci/status/build/erased_spec.rb @@ -0,0 +1,33 @@ +require 'spec_helper' + +describe Gitlab::Ci::Status::Build::Erased do + let(:user) { create(:user) } + + subject do + described_class.new(double('subject')) + end + + describe '#illustration' do + it { expect(subject.illustration).to include(:image, :size, :title) } + end + + describe '.matches?' do + subject { described_class.matches?(build, user) } + + context 'when build is erased' do + let(:build) { create(:ci_build, :success, :erased) } + + it 'is a correct match' do + expect(subject).to be true + end + end + + context 'when build is not erased' do + let(:build) { create(:ci_build, :success, :trace_artifact) } + + it 'does not match' do + expect(subject).to be false + end + end + end +end diff --git a/spec/lib/gitlab/ci/status/build/factory_spec.rb b/spec/lib/gitlab/ci/status/build/factory_spec.rb index d196bc6a4c2..6d5b73bb01b 100644 --- a/spec/lib/gitlab/ci/status/build/factory_spec.rb +++ b/spec/lib/gitlab/ci/status/build/factory_spec.rb @@ -13,7 +13,7 @@ describe Gitlab::Ci::Status::Build::Factory do end context 'when build is successful' do - let(:build) { create(:ci_build, :success) } + let(:build) { create(:ci_build, :success, :trace_artifact) } it 'matches correct core status' do expect(factory.core_status).to be_a Gitlab::Ci::Status::Success @@ -38,6 +38,33 @@ describe Gitlab::Ci::Status::Build::Factory do end end + context 'when build is erased' do + let(:build) { create(:ci_build, :success, :erased) } + + it 'matches correct core status' do + expect(factory.core_status).to be_a Gitlab::Ci::Status::Success + end + + it 'matches correct extended statuses' do + expect(factory.extended_statuses) + .to eq [Gitlab::Ci::Status::Build::Erased, + Gitlab::Ci::Status::Build::Retryable] + end + + it 'fabricates a retryable build status' do + expect(status).to be_a Gitlab::Ci::Status::Build::Retryable + end + + it 'fabricates status with correct details' do + expect(status.text).to eq 'passed' + expect(status.icon).to eq 'status_success' + expect(status.favicon).to eq 'favicon_status_success' + expect(status.label).to eq 'passed' + expect(status).to have_details + expect(status).to have_action + end + end + context 'when build is failed' do context 'when build is not allowed to fail' do let(:build) { create(:ci_build, :failed) } @@ -48,11 +75,11 @@ describe Gitlab::Ci::Status::Build::Factory do it 'matches correct extended statuses' do expect(factory.extended_statuses) - .to eq [Gitlab::Ci::Status::Build::Retryable] + .to eq [Gitlab::Ci::Status::Build::Retryable, Gitlab::Ci::Status::Build::Failed] end - it 'fabricates a retryable build status' do - expect(status).to be_a Gitlab::Ci::Status::Build::Retryable + it 'fabricates a failed build status' do + expect(status).to be_a Gitlab::Ci::Status::Build::Failed end it 'fabricates status with correct details' do @@ -60,6 +87,7 @@ describe Gitlab::Ci::Status::Build::Factory do expect(status.icon).to eq 'status_failed' expect(status.favicon).to eq 'favicon_status_failed' expect(status.label).to eq 'failed' + expect(status.status_tooltip).to eq 'failed <br> (unknown failure)' expect(status).to have_details expect(status).to have_action end @@ -75,6 +103,7 @@ describe Gitlab::Ci::Status::Build::Factory do it 'matches correct extended statuses' do expect(factory.extended_statuses) .to eq [Gitlab::Ci::Status::Build::Retryable, + Gitlab::Ci::Status::Build::Failed, Gitlab::Ci::Status::Build::FailedAllowed] end @@ -104,7 +133,7 @@ describe Gitlab::Ci::Status::Build::Factory do it 'matches correct extended statuses' do expect(factory.extended_statuses) - .to eq [Gitlab::Ci::Status::Build::Retryable] + .to eq [Gitlab::Ci::Status::Build::Canceled, Gitlab::Ci::Status::Build::Retryable] end it 'fabricates a retryable build status' do @@ -115,6 +144,7 @@ describe Gitlab::Ci::Status::Build::Factory do expect(status.text).to eq 'canceled' expect(status.icon).to eq 'status_canceled' expect(status.favicon).to eq 'favicon_status_canceled' + expect(status.illustration).to include(:image, :size, :title) expect(status.label).to eq 'canceled' expect(status).to have_details expect(status).to have_action @@ -156,7 +186,7 @@ describe Gitlab::Ci::Status::Build::Factory do it 'matches correct extended statuses' do expect(factory.extended_statuses) - .to eq [Gitlab::Ci::Status::Build::Cancelable] + .to eq [Gitlab::Ci::Status::Build::Pending, Gitlab::Ci::Status::Build::Cancelable] end it 'fabricates a cancelable build status' do @@ -167,6 +197,7 @@ describe Gitlab::Ci::Status::Build::Factory do expect(status.text).to eq 'pending' expect(status.icon).to eq 'status_pending' expect(status.favicon).to eq 'favicon_status_pending' + expect(status.illustration).to include(:image, :size, :title, :content) expect(status.label).to eq 'pending' expect(status).to have_details expect(status).to have_action @@ -180,18 +211,19 @@ describe Gitlab::Ci::Status::Build::Factory do expect(factory.core_status).to be_a Gitlab::Ci::Status::Skipped end - it 'does not match extended statuses' do - expect(factory.extended_statuses).to be_empty + it 'matches correct extended statuses' do + expect(factory.extended_statuses).to eq [Gitlab::Ci::Status::Build::Skipped] end - it 'fabricates a core skipped status' do - expect(status).to be_a Gitlab::Ci::Status::Skipped + it 'fabricates a skipped build status' do + expect(status).to be_a Gitlab::Ci::Status::Build::Skipped end it 'fabricates status with correct details' do expect(status.text).to eq 'skipped' expect(status.icon).to eq 'status_skipped' expect(status.favicon).to eq 'favicon_status_skipped' + expect(status.illustration).to include(:image, :size, :title) expect(status.label).to eq 'skipped' expect(status).to have_details expect(status).not_to have_action @@ -208,7 +240,8 @@ describe Gitlab::Ci::Status::Build::Factory do it 'matches correct extended statuses' do expect(factory.extended_statuses) - .to eq [Gitlab::Ci::Status::Build::Play, + .to eq [Gitlab::Ci::Status::Build::Manual, + Gitlab::Ci::Status::Build::Play, Gitlab::Ci::Status::Build::Action] end @@ -221,6 +254,7 @@ describe Gitlab::Ci::Status::Build::Factory do expect(status.group).to eq 'manual' expect(status.icon).to eq 'status_manual' expect(status.favicon).to eq 'favicon_status_manual' + expect(status.illustration).to include(:image, :size, :title, :content) expect(status.label).to include 'manual play action' expect(status).to have_details expect(status.action_path).to include 'play' @@ -255,7 +289,8 @@ describe Gitlab::Ci::Status::Build::Factory do it 'matches correct extended statuses' do expect(factory.extended_statuses) - .to eq [Gitlab::Ci::Status::Build::Stop, + .to eq [Gitlab::Ci::Status::Build::Manual, + Gitlab::Ci::Status::Build::Stop, Gitlab::Ci::Status::Build::Action] end diff --git a/spec/lib/gitlab/ci/status/build/failed_allowed_spec.rb b/spec/lib/gitlab/ci/status/build/failed_allowed_spec.rb index 99a5a7e4aca..bfaa508785e 100644 --- a/spec/lib/gitlab/ci/status/build/failed_allowed_spec.rb +++ b/spec/lib/gitlab/ci/status/build/failed_allowed_spec.rb @@ -3,6 +3,7 @@ require 'spec_helper' describe Gitlab::Ci::Status::Build::FailedAllowed do let(:status) { double('core status') } let(:user) { double('user') } + let(:build) { create(:ci_build, :failed, :allowed_to_fail) } subject do described_class.new(status) @@ -68,6 +69,28 @@ describe Gitlab::Ci::Status::Build::FailedAllowed do end end + describe '#badge_tooltip' do + let(:user) { create(:user) } + let(:failed_status) { Gitlab::Ci::Status::Failed.new(build, user) } + let(:build_status) { Gitlab::Ci::Status::Build::Failed.new(failed_status) } + let(:status) { described_class.new(build_status) } + + it 'does override badge_tooltip' do + expect(status.badge_tooltip).to eq('failed <br> (unknown failure)') + end + end + + describe '#status_tooltip' do + let(:user) { create(:user) } + let(:failed_status) { Gitlab::Ci::Status::Failed.new(build, user) } + let(:build_status) { Gitlab::Ci::Status::Build::Failed.new(failed_status) } + let(:status) { described_class.new(build_status) } + + it 'does override status_tooltip' do + expect(status.status_tooltip).to eq 'failed <br> (unknown failure) (allowed to fail)' + end + end + describe '.matches?' do subject { described_class.matches?(build, user) } diff --git a/spec/lib/gitlab/ci/status/build/failed_spec.rb b/spec/lib/gitlab/ci/status/build/failed_spec.rb new file mode 100644 index 00000000000..cadb424ea2c --- /dev/null +++ b/spec/lib/gitlab/ci/status/build/failed_spec.rb @@ -0,0 +1,83 @@ +require 'spec_helper' + +describe Gitlab::Ci::Status::Build::Failed do + let(:build) { create(:ci_build, :script_failure) } + let(:status) { double('core status') } + let(:user) { double('user') } + + subject { described_class.new(status) } + + describe '#text' do + it 'does not override status text' do + expect(status).to receive(:text) + + subject.text + end + end + + describe '#icon' do + it 'does not override status icon' do + expect(status).to receive(:icon) + + subject.icon + end + end + + describe '#group' do + it 'does not override status group' do + expect(status).to receive(:group) + + subject.group + end + end + + describe '#favicon' do + it 'does not override status label' do + expect(status).to receive(:favicon) + + subject.favicon + end + end + + describe '#label' do + it 'does not override label' do + expect(status).to receive(:label) + + subject.label + end + end + + describe '#badge_tooltip' do + let(:user) { create(:user) } + let(:status) { Gitlab::Ci::Status::Failed.new(build, user) } + + it 'does override badge_tooltip' do + expect(subject.badge_tooltip).to eq 'failed <br> (script failure)' + end + end + + describe '#status_tooltip' do + let(:user) { create(:user) } + let(:status) { Gitlab::Ci::Status::Failed.new(build, user) } + + it 'does override status_tooltip' do + expect(subject.status_tooltip).to eq 'failed <br> (script failure)' + end + end + + describe '.matches?' do + context 'with a failed build' do + it 'returns true' do + expect(described_class.matches?(build, user)).to be_truthy + end + end + + context 'with any other type of build' do + let(:build) { create(:ci_build, :success) } + + it 'returns false' do + expect(described_class.matches?(build, user)).to be_falsy + end + end + end +end diff --git a/spec/lib/gitlab/ci/status/build/manual_spec.rb b/spec/lib/gitlab/ci/status/build/manual_spec.rb new file mode 100644 index 00000000000..6386296f992 --- /dev/null +++ b/spec/lib/gitlab/ci/status/build/manual_spec.rb @@ -0,0 +1,34 @@ +require 'spec_helper' + +describe Gitlab::Ci::Status::Build::Manual do + let(:user) { create(:user) } + + subject do + build = create(:ci_build, :manual) + described_class.new(Gitlab::Ci::Status::Core.new(build, user)) + end + + describe '#illustration' do + it { expect(subject.illustration).to include(:image, :size, :title, :content) } + end + + describe '.matches?' do + subject {described_class.matches?(build, user) } + + context 'when build is manual' do + let(:build) { create(:ci_build, :manual) } + + it 'is a correct match' do + expect(subject).to be true + end + end + + context 'when build is not manual' do + let(:build) { create(:ci_build) } + + it 'does not match' do + expect(subject).to be false + end + end + end +end diff --git a/spec/lib/gitlab/ci/status/build/pending_spec.rb b/spec/lib/gitlab/ci/status/build/pending_spec.rb new file mode 100644 index 00000000000..4cf70828e53 --- /dev/null +++ b/spec/lib/gitlab/ci/status/build/pending_spec.rb @@ -0,0 +1,33 @@ +require 'spec_helper' + +describe Gitlab::Ci::Status::Build::Pending do + let(:user) { create(:user) } + + subject do + described_class.new(double('subject')) + end + + describe '#illustration' do + it { expect(subject.illustration).to include(:image, :size, :title, :content) } + end + + describe '.matches?' do + subject {described_class.matches?(build, user) } + + context 'when build is pending' do + let(:build) { create(:ci_build, :pending) } + + it 'is a correct match' do + expect(subject).to be true + end + end + + context 'when build is not pending' do + let(:build) { create(:ci_build, :success) } + + it 'does not match' do + expect(subject).to be false + end + end + end +end diff --git a/spec/lib/gitlab/ci/status/build/play_spec.rb b/spec/lib/gitlab/ci/status/build/play_spec.rb index 81d5f553fd1..f128c1d4ca4 100644 --- a/spec/lib/gitlab/ci/status/build/play_spec.rb +++ b/spec/lib/gitlab/ci/status/build/play_spec.rb @@ -14,6 +14,22 @@ describe Gitlab::Ci::Status::Build::Play do end end + describe '#status_tooltip' do + it 'does not override status status_tooltip' do + expect(status).to receive(:status_tooltip) + + subject.status_tooltip + end + end + + describe '#badge_tooltip' do + it 'does not override status badge_tooltip' do + expect(status).to receive(:badge_tooltip) + + subject.badge_tooltip + end + end + describe '#has_action?' do context 'when user is allowed to update build' do context 'when user is allowed to trigger protected action' do @@ -53,6 +69,10 @@ describe Gitlab::Ci::Status::Build::Play do it { expect(subject.action_title).to eq 'Play' } end + describe '#action_button_title' do + it { expect(subject.action_button_title).to eq 'Trigger this manual action' } + end + describe '.matches?' do subject { described_class.matches?(build, user) } diff --git a/spec/lib/gitlab/ci/status/build/retried_spec.rb b/spec/lib/gitlab/ci/status/build/retried_spec.rb new file mode 100644 index 00000000000..ee9acaf1c21 --- /dev/null +++ b/spec/lib/gitlab/ci/status/build/retried_spec.rb @@ -0,0 +1,96 @@ +require 'spec_helper' + +describe Gitlab::Ci::Status::Build::Retried do + let(:build) { create(:ci_build, :retried) } + let(:status) { double('core status') } + let(:user) { double('user') } + + subject { described_class.new(status) } + + describe '#text' do + it 'does not override status text' do + expect(status).to receive(:text) + + subject.text + end + end + + describe '#icon' do + it 'does not override status icon' do + expect(status).to receive(:icon) + + subject.icon + end + end + + describe '#group' do + it 'does not override status group' do + expect(status).to receive(:group) + + subject.group + end + end + + describe '#favicon' do + it 'does not override status label' do + expect(status).to receive(:favicon) + + subject.favicon + end + end + + describe '#label' do + it 'does not override status label' do + expect(status).to receive(:label) + + subject.label + end + end + + describe '#badge_tooltip' do + let(:user) { create(:user) } + let(:build) { create(:ci_build, :retried) } + let(:status) { Gitlab::Ci::Status::Success.new(build, user) } + + it 'returns status' do + expect(status.badge_tooltip).to eq('pending') + end + end + + describe '#status_tooltip' do + let(:user) { create(:user) } + + context 'with a failed build' do + let(:build) { create(:ci_build, :failed, :retried) } + let(:failed_status) { Gitlab::Ci::Status::Failed.new(build, user) } + let(:status) { Gitlab::Ci::Status::Build::Failed.new(failed_status) } + + it 'does override status_tooltip' do + expect(subject.status_tooltip).to eq 'failed <br> (unknown failure) (retried)' + end + end + + context 'with another build' do + let(:build) { create(:ci_build, :retried) } + let(:status) { Gitlab::Ci::Status::Success.new(build, user) } + + it 'does override status_tooltip' do + expect(subject.status_tooltip).to eq 'passed (retried)' + end + end + end + + describe '.matches?' do + subject { described_class.matches?(build, user) } + + context 'with a retried build' do + it { is_expected.to be_truthy } + end + + context 'with a build that has not been retried' do + let(:build) { create(:ci_build, :success) } + + it { is_expected.to be_falsy } + end + end +end diff --git a/spec/lib/gitlab/ci/status/build/retryable_spec.rb b/spec/lib/gitlab/ci/status/build/retryable_spec.rb index 14d42e0d70f..84d98588f2d 100644 --- a/spec/lib/gitlab/ci/status/build/retryable_spec.rb +++ b/spec/lib/gitlab/ci/status/build/retryable_spec.rb @@ -40,6 +40,24 @@ describe Gitlab::Ci::Status::Build::Retryable do end end + describe '#status_tooltip' do + it 'does not override status status_tooltip' do + expect(status).to receive(:status_tooltip) + + subject.status_tooltip + end + end + + describe '#badge_tooltip' do + let(:user) { create(:user) } + let(:build) { create(:ci_build) } + let(:status) { Gitlab::Ci::Status::Core.new(build, user) } + + it 'does return status' do + expect(status.badge_tooltip).to eq('pending') + end + end + describe 'action details' do let(:user) { create(:user) } let(:build) { create(:ci_build) } @@ -72,6 +90,10 @@ describe Gitlab::Ci::Status::Build::Retryable do describe '#action_title' do it { expect(subject.action_title).to eq 'Retry' } end + + describe '#action_button_title' do + it { expect(subject.action_button_title).to eq 'Retry this job' } + end end describe '.matches?' do diff --git a/spec/lib/gitlab/ci/status/build/skipped_spec.rb b/spec/lib/gitlab/ci/status/build/skipped_spec.rb new file mode 100644 index 00000000000..46f6933025a --- /dev/null +++ b/spec/lib/gitlab/ci/status/build/skipped_spec.rb @@ -0,0 +1,33 @@ +require 'spec_helper' + +describe Gitlab::Ci::Status::Build::Skipped do + let(:user) { create(:user) } + + subject do + described_class.new(double('subject')) + end + + describe '#illustration' do + it { expect(subject.illustration).to include(:image, :size, :title) } + end + + describe '.matches?' do + subject {described_class.matches?(build, user) } + + context 'when build is skipped' do + let(:build) { create(:ci_build, :skipped) } + + it 'is a correct match' do + expect(subject).to be true + end + end + + context 'when build is not skipped' do + let(:build) { create(:ci_build) } + + it 'does not match' do + expect(subject).to be false + end + end + end +end diff --git a/spec/lib/gitlab/ci/status/build/stop_spec.rb b/spec/lib/gitlab/ci/status/build/stop_spec.rb index 18e250772f0..5b7534c96c1 100644 --- a/spec/lib/gitlab/ci/status/build/stop_spec.rb +++ b/spec/lib/gitlab/ci/status/build/stop_spec.rb @@ -44,6 +44,10 @@ describe Gitlab::Ci::Status::Build::Stop do describe '#action_title' do it { expect(subject.action_title).to eq 'Stop' } end + + describe '#action_button_title' do + it { expect(subject.action_button_title).to eq 'Stop this environment' } + end end describe '.matches?' do @@ -77,4 +81,24 @@ describe Gitlab::Ci::Status::Build::Stop do end end end + + describe '#status_tooltip' do + it 'does not override status status_tooltip' do + expect(status).to receive(:status_tooltip) + + subject.status_tooltip + end + end + + describe '#badge_tooltip' do + let(:user) { create(:user) } + let(:build) { create(:ci_build, :playable) } + let(:status) { Gitlab::Ci::Status::Core.new(build, user) } + + it 'does not override status badge_tooltip' do + expect(status).to receive(:badge_tooltip) + + subject.badge_tooltip + end + end end diff --git a/spec/lib/gitlab/ci/status/success_warning_spec.rb b/spec/lib/gitlab/ci/status/success_warning_spec.rb index 4582354e739..6d05545d1d8 100644 --- a/spec/lib/gitlab/ci/status/success_warning_spec.rb +++ b/spec/lib/gitlab/ci/status/success_warning_spec.rb @@ -1,8 +1,10 @@ require 'spec_helper' describe Gitlab::Ci::Status::SuccessWarning do + let(:status) { double('status') } + subject do - described_class.new(double('status')) + described_class.new(status) end describe '#test' do diff --git a/spec/lib/gitlab/ci/variables/collection/item_spec.rb b/spec/lib/gitlab/ci/variables/collection/item_spec.rb index cc1257484d2..bf9208f1ff4 100644 --- a/spec/lib/gitlab/ci/variables/collection/item_spec.rb +++ b/spec/lib/gitlab/ci/variables/collection/item_spec.rb @@ -46,9 +46,13 @@ describe Gitlab::Ci::Variables::Collection::Item do end end - describe '#to_hash' do - it 'returns a hash representation of a collection item' do - expect(described_class.new(**variable).to_hash).to eq variable + describe '#to_runner_variable' do + it 'returns a runner-compatible hash representation' do + runner_variable = described_class + .new(**variable) + .to_runner_variable + + expect(runner_variable).to eq variable end end end diff --git a/spec/lib/gitlab/ci/variables/collection_spec.rb b/spec/lib/gitlab/ci/variables/collection_spec.rb index 90b6e178242..cb2f7718c9c 100644 --- a/spec/lib/gitlab/ci/variables/collection_spec.rb +++ b/spec/lib/gitlab/ci/variables/collection_spec.rb @@ -7,7 +7,7 @@ describe Gitlab::Ci::Variables::Collection do collection = described_class.new([variable]) - expect(collection.first.to_hash).to eq variable + expect(collection.first.to_runner_variable).to eq variable end it 'can be initialized without an argument' do @@ -96,4 +96,19 @@ describe Gitlab::Ci::Variables::Collection do .to eq [{ key: 'TEST', value: 1, public: true }] end end + + describe '#to_hash' do + it 'returns regular hash in valid order without duplicates' do + collection = described_class.new + .append(key: 'TEST1', value: 'test-1') + .append(key: 'TEST2', value: 'test-2') + .append(key: 'TEST1', value: 'test-3') + + expect(collection.to_hash).to eq('TEST1' => 'test-3', + 'TEST2' => 'test-2') + + expect(collection.to_hash).to include(TEST1: 'test-3') + expect(collection.to_hash).not_to include(TEST1: 'test-1') + end + end end diff --git a/spec/lib/gitlab/ci/yaml_processor_spec.rb b/spec/lib/gitlab/ci/yaml_processor_spec.rb index fbc2af29b98..ecb16daec96 100644 --- a/spec/lib/gitlab/ci/yaml_processor_spec.rb +++ b/spec/lib/gitlab/ci/yaml_processor_spec.rb @@ -1311,6 +1311,14 @@ module Gitlab Gitlab::Ci::YamlProcessor.new(config) end.to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, "jobs:rspec dependencies should be an array of strings") end + + it 'returns errors if pipeline variables expression is invalid' do + config = YAML.dump({ rspec: { script: 'test', only: { variables: ['== null'] } } }) + + expect { Gitlab::Ci::YamlProcessor.new(config) } + .to raise_error(Gitlab::Ci::YamlProcessor::ValidationError, + 'jobs:rspec:only variables invalid expression syntax') + end end describe "Validate configuration templates" do diff --git a/spec/lib/gitlab/data_builder/note_spec.rb b/spec/lib/gitlab/data_builder/note_spec.rb index aaa42566a4d..4f8412108ba 100644 --- a/spec/lib/gitlab/data_builder/note_spec.rb +++ b/spec/lib/gitlab/data_builder/note_spec.rb @@ -55,6 +55,14 @@ describe Gitlab::DataBuilder::Note do .to be > issue.hook_attrs['updated_at'] end + context 'with confidential issue' do + let(:issue) { create(:issue, project: project, confidential: true) } + + it 'sets event_type to confidential_note' do + expect(data[:event_type]).to eq('confidential_note') + end + end + include_examples 'project hook data' include_examples 'deprecated repository hook data' end diff --git a/spec/lib/gitlab/database/sha_attribute_spec.rb b/spec/lib/gitlab/database/sha_attribute_spec.rb index 62c1d37ea1c..778bfa2cc47 100644 --- a/spec/lib/gitlab/database/sha_attribute_spec.rb +++ b/spec/lib/gitlab/database/sha_attribute_spec.rb @@ -19,15 +19,15 @@ describe Gitlab::Database::ShaAttribute do let(:attribute) { described_class.new } - describe '#type_cast_from_database' do + describe '#deserialize' do it 'converts the binary SHA to a String' do - expect(attribute.type_cast_from_database(binary_from_db)).to eq(sha) + expect(attribute.deserialize(binary_from_db)).to eq(sha) end end - describe '#type_cast_for_database' do + describe '#serialize' do it 'converts a SHA String to binary data' do - expect(attribute.type_cast_for_database(sha).to_s).to eq(binary_sha) + expect(attribute.serialize(sha).to_s).to eq(binary_sha) end end end diff --git a/spec/lib/gitlab/email/handler_spec.rb b/spec/lib/gitlab/email/handler_spec.rb index 650b01c4df4..386d73e6115 100644 --- a/spec/lib/gitlab/email/handler_spec.rb +++ b/spec/lib/gitlab/email/handler_spec.rb @@ -14,4 +14,28 @@ describe Gitlab::Email::Handler do expect(described_class.for('email', '')).to be_nil end end + + describe 'regexps are set properly' do + let(:addresses) do + %W(sent_notification_key#{Gitlab::IncomingEmail::UNSUBSCRIBE_SUFFIX} sent_notification_key path/to/project+merge-request+user_email_token path/to/project+user_email_token) + end + + it 'picks each handler at least once' do + matched_handlers = addresses.map do |address| + described_class.for('email', address).class + end + + expect(matched_handlers.uniq).to match_array(Gitlab::Email::Handler::HANDLERS) + end + + it 'can pick exactly one handler for each address' do + addresses.each do |address| + matched_handlers = Gitlab::Email::Handler::HANDLERS.select do |handler| + handler.new('email', address).can_handle? + end + + expect(matched_handlers.count).to eq(1), "#{address} matches #{matched_handlers.count} handlers: #{matched_handlers}" + end + end + end end diff --git a/spec/lib/gitlab/git/gitlab_projects_spec.rb b/spec/lib/gitlab/git/gitlab_projects_spec.rb index dfccc15a4f3..8b715d717c1 100644 --- a/spec/lib/gitlab/git/gitlab_projects_spec.rb +++ b/spec/lib/gitlab/git/gitlab_projects_spec.rb @@ -16,7 +16,7 @@ describe Gitlab::Git::GitlabProjects do let(:tmp_repos_path) { TestEnv.repos_path } let(:repo_name) { project.disk_path + '.git' } let(:tmp_repo_path) { File.join(tmp_repos_path, repo_name) } - let(:gl_projects) { build_gitlab_projects(tmp_repos_path, repo_name) } + let(:gl_projects) { build_gitlab_projects(TestEnv::REPOS_STORAGE, repo_name) } describe '#initialize' do it { expect(gl_projects.shard_path).to eq(tmp_repos_path) } @@ -223,11 +223,12 @@ describe Gitlab::Git::GitlabProjects do end describe '#fork_repository' do + let(:dest_repos) { TestEnv::REPOS_STORAGE } let(:dest_repos_path) { tmp_repos_path } let(:dest_repo_name) { File.join('@hashed', 'aa', 'bb', 'xyz.git') } let(:dest_repo) { File.join(dest_repos_path, dest_repo_name) } - subject { gl_projects.fork_repository(dest_repos_path, dest_repo_name) } + subject { gl_projects.fork_repository(dest_repos, dest_repo_name) } before do FileUtils.mkdir_p(dest_repos_path) @@ -268,7 +269,12 @@ describe Gitlab::Git::GitlabProjects do # that is not very straight-forward so I'm leaving this test here for now till # https://gitlab.com/gitlab-org/gitlab-ce/issues/41393 is fixed. context 'different storages' do - let(:dest_repos_path) { File.join(File.dirname(tmp_repos_path), 'alternative') } + let(:dest_repos) { 'alternative' } + let(:dest_repos_path) { File.join(File.dirname(tmp_repos_path), dest_repos) } + + before do + stub_storage_settings(dest_repos => { 'path' => dest_repos_path }) + end it 'forks the repo' do is_expected.to be_truthy diff --git a/spec/lib/gitlab/git/gitmodules_parser_spec.rb b/spec/lib/gitlab/git/gitmodules_parser_spec.rb index 143aa2218c9..6fd2b33486b 100644 --- a/spec/lib/gitlab/git/gitmodules_parser_spec.rb +++ b/spec/lib/gitlab/git/gitmodules_parser_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Gitlab::Git::GitmodulesParser do it 'should parse a .gitmodules file correctly' do - parser = described_class.new(<<-'GITMODULES'.strip_heredoc) + data = <<~GITMODULES [submodule "vendor/libgit2"] path = vendor/libgit2 [submodule "vendor/libgit2"] @@ -16,6 +16,7 @@ describe Gitlab::Git::GitmodulesParser do url = https://example.com/another/project GITMODULES + parser = described_class.new(data.gsub("\n", "\r\n")) modules = parser.parse expect(modules).to eq({ diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb index 5cbe2808d0b..d3ab61746f4 100644 --- a/spec/lib/gitlab/git/repository_spec.rb +++ b/spec/lib/gitlab/git/repository_spec.rb @@ -247,38 +247,44 @@ describe Gitlab::Git::Repository, seed_helper: true do end it 'returns parameterised string for a ref containing slashes' do - prefix = repository.archive_prefix('test/branch', 'SHA') + prefix = repository.archive_prefix('test/branch', 'SHA', append_sha: nil) expect(prefix).to eq("#{project_name}-test-branch-SHA") end it 'returns correct string for a ref containing dots' do - prefix = repository.archive_prefix('test.branch', 'SHA') + prefix = repository.archive_prefix('test.branch', 'SHA', append_sha: nil) expect(prefix).to eq("#{project_name}-test.branch-SHA") end + + it 'returns string with sha when append_sha is false' do + prefix = repository.archive_prefix('test.branch', 'SHA', append_sha: false) + + expect(prefix).to eq("#{project_name}-test.branch") + end end describe '#archive' do - let(:metadata) { repository.archive_metadata('master', '/tmp') } + let(:metadata) { repository.archive_metadata('master', '/tmp', append_sha: true) } it_should_behave_like 'archive check', '.tar.gz' end describe '#archive_zip' do - let(:metadata) { repository.archive_metadata('master', '/tmp', 'zip') } + let(:metadata) { repository.archive_metadata('master', '/tmp', 'zip', append_sha: true) } it_should_behave_like 'archive check', '.zip' end describe '#archive_bz2' do - let(:metadata) { repository.archive_metadata('master', '/tmp', 'tbz2') } + let(:metadata) { repository.archive_metadata('master', '/tmp', 'tbz2', append_sha: true) } it_should_behave_like 'archive check', '.tar.bz2' end describe '#archive_fallback' do - let(:metadata) { repository.archive_metadata('master', '/tmp', 'madeup') } + let(:metadata) { repository.archive_metadata('master', '/tmp', 'madeup', append_sha: true) } it_should_behave_like 'archive check', '.tar.gz' end @@ -2178,6 +2184,55 @@ describe Gitlab::Git::Repository, seed_helper: true do end end + describe '#checksum' do + shared_examples 'calculating checksum' do + it 'calculates the checksum for non-empty repo' do + expect(repository.checksum).to eq '54f21be4c32c02f6788d72207fa03ad3bce725e4' + end + + it 'returns 0000000000000000000000000000000000000000 for an empty repo' do + FileUtils.rm_rf(File.join(storage_path, 'empty-repo.git')) + + system(git_env, *%W(#{Gitlab.config.git.bin_path} init --bare empty-repo.git), + chdir: storage_path, + out: '/dev/null', + err: '/dev/null') + + empty_repo = described_class.new('default', 'empty-repo.git', '') + + expect(empty_repo.checksum).to eq '0000000000000000000000000000000000000000' + end + + it 'raises a no repository exception when there is no repo' do + broken_repo = described_class.new('default', 'a/path.git', '') + + expect { broken_repo.checksum }.to raise_error(Gitlab::Git::Repository::NoRepository) + end + end + + context 'when calculate_checksum Gitaly feature is enabled' do + it_behaves_like 'calculating checksum' + end + + context 'when calculate_checksum Gitaly feature is disabled', :disable_gitaly do + it_behaves_like 'calculating checksum' + + describe 'when storage is broken', :broken_storage do + it 'raises a storage exception when storage is not available' do + broken_repo = described_class.new('broken', 'a/path.git', '') + + expect { broken_repo.rugged }.to raise_error(Gitlab::Git::Storage::Inaccessible) + end + end + + it "raises a Gitlab::Git::Repository::Failure error if the `popen` call to git returns a non-zero exit code" do + allow(repository).to receive(:popen).and_return(['output', nil]) + + expect { repository.checksum }.to raise_error Gitlab::Git::Repository::ChecksumError + end + end + end + context 'gitlab_projects commands' do let(:gitlab_projects) { repository.gitlab_projects } let(:timeout) { Gitlab.config.gitlab_shell.git_timeout } @@ -2251,6 +2306,39 @@ describe Gitlab::Git::Repository, seed_helper: true do end end + describe '#clean_stale_repository_files' do + let(:worktree_path) { File.join(repository.path, 'worktrees', 'delete-me') } + + it 'cleans up the files' do + repository.with_worktree(worktree_path, 'master', env: ENV) do + FileUtils.touch(worktree_path, mtime: Time.now - 8.hours) + # git rev-list --all will fail in git 2.16 if HEAD is pointing to a non-existent object, + # but the HEAD must be 40 characters long or git will ignore it. + File.write(File.join(worktree_path, 'HEAD'), Gitlab::Git::BLANK_SHA) + + # git 2.16 fails with "fatal: bad object HEAD" + expect { repository.rev_list(including: :all) }.to raise_error(Gitlab::Git::Repository::GitError) + + repository.clean_stale_repository_files + + expect { repository.rev_list(including: :all) }.not_to raise_error + expect(File.exist?(worktree_path)).to be_falsey + end + end + + it 'increments a counter upon an error' do + expect(repository.gitaly_repository_client).to receive(:cleanup).and_raise(Gitlab::Git::CommandError) + + counter = double(:counter) + + expect(counter).to receive(:increment) + expect(Gitlab::Metrics).to receive(:counter).with(:failed_repository_cleanup_total, + 'Number of failed repository cleanup events').and_return(counter) + + repository.clean_stale_repository_files + end + end + describe '#delete_remote_branches' do subject do repository.delete_remote_branches('downstream-remote', ['master']) diff --git a/spec/lib/gitlab/git_access_spec.rb b/spec/lib/gitlab/git_access_spec.rb index f8f09d29c73..6c625596605 100644 --- a/spec/lib/gitlab/git_access_spec.rb +++ b/spec/lib/gitlab/git_access_spec.rb @@ -10,12 +10,13 @@ describe Gitlab::GitAccess do let(:protocol) { 'ssh' } let(:authentication_abilities) { %i[read_project download_code push_code] } let(:redirected_path) { nil } + let(:auth_result_type) { nil } let(:access) do described_class.new(actor, project, protocol, authentication_abilities: authentication_abilities, namespace_path: namespace_path, project_path: project_path, - redirected_path: redirected_path) + redirected_path: redirected_path, auth_result_type: auth_result_type) end let(:changes) { '_any' } @@ -45,6 +46,7 @@ describe Gitlab::GitAccess do before do disable_protocol('http') + project.add_master(user) end it 'blocks http push and pull' do @@ -53,6 +55,26 @@ describe Gitlab::GitAccess do expect { pull_access_check }.to raise_unauthorized('Git access over HTTP is not allowed') end end + + context 'when request is made from CI' do + let(:auth_result_type) { :build } + + it "doesn't block http pull" do + aggregate_failures do + expect { pull_access_check }.not_to raise_unauthorized('Git access over HTTP is not allowed') + end + end + + context 'when legacy CI credentials are used' do + let(:auth_result_type) { :ci } + + it "doesn't block http pull" do + aggregate_failures do + expect { pull_access_check }.not_to raise_unauthorized('Git access over HTTP is not allowed') + end + end + end + end end end @@ -123,6 +145,33 @@ describe Gitlab::GitAccess do expect { push_access_check }.to raise_unauthorized(described_class::ERROR_MESSAGES[:auth_upload]) end end + + context 'when actor is DeployToken' do + let(:actor) { create(:deploy_token, projects: [project]) } + + context 'when DeployToken is active and belongs to project' do + it 'allows pull access' do + expect { pull_access_check }.not_to raise_error + end + + it 'blocks the push' do + expect { push_access_check }.to raise_unauthorized(described_class::ERROR_MESSAGES[:upload]) + end + end + + context 'when DeployToken does not belong to project' do + let(:another_project) { create(:project) } + let(:actor) { create(:deploy_token, projects: [another_project]) } + + it 'blocks pull access' do + expect { pull_access_check }.to raise_not_found + end + + it 'blocks the push' do + expect { push_access_check }.to raise_not_found + end + end + end end context 'when actor is nil' do @@ -572,6 +621,41 @@ describe Gitlab::GitAccess do end end + describe 'deploy token permissions' do + let(:deploy_token) { create(:deploy_token) } + let(:actor) { deploy_token } + + context 'pull code' do + context 'when project is authorized' do + before do + deploy_token.projects << project + end + + it { expect { pull_access_check }.not_to raise_error } + end + + context 'when unauthorized' do + context 'from public project' do + let(:project) { create(:project, :public, :repository) } + + it { expect { pull_access_check }.not_to raise_error } + end + + context 'from internal project' do + let(:project) { create(:project, :internal, :repository) } + + it { expect { pull_access_check }.to raise_not_found } + end + + context 'from private project' do + let(:project) { create(:project, :private, :repository) } + + it { expect { pull_access_check }.to raise_not_found } + end + end + end + end + describe 'build authentication_abilities permissions' do let(:authentication_abilities) { build_authentication_abilities } @@ -833,6 +917,20 @@ describe Gitlab::GitAccess do admin: { push_protected_branch: false, push_all: false, merge_into_protected_branch: false })) end end + + context 'when pushing to a project' do + let(:project) { create(:project, :public, :repository) } + let(:changes) { "#{Gitlab::Git::BLANK_SHA} 570e7b2ab refs/heads/wow" } + + before do + project.add_developer(user) + end + + it 'cleans up the files' do + expect(project.repository).to receive(:clean_stale_repository_files).and_call_original + expect { push_access_check }.not_to raise_error + end + end end describe 'build authentication abilities' do diff --git a/spec/lib/gitlab/gitaly_client/repository_service_spec.rb b/spec/lib/gitlab/gitaly_client/repository_service_spec.rb index 1c41dbcb9ef..21592688bf0 100644 --- a/spec/lib/gitlab/gitaly_client/repository_service_spec.rb +++ b/spec/lib/gitlab/gitaly_client/repository_service_spec.rb @@ -17,6 +17,16 @@ describe Gitlab::GitalyClient::RepositoryService do end end + describe '#cleanup' do + it 'sends a cleanup message' do + expect_any_instance_of(Gitaly::RepositoryService::Stub) + .to receive(:cleanup) + .with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash)) + + client.cleanup + end + end + describe '#garbage_collect' do it 'sends a garbage_collect message' do expect_any_instance_of(Gitaly::RepositoryService::Stub) @@ -124,4 +134,15 @@ describe Gitlab::GitalyClient::RepositoryService do client.squash_in_progress?(squash_id) end end + + describe '#calculate_checksum' do + it 'sends a calculate_checksum message' do + expect_any_instance_of(Gitaly::RepositoryService::Stub) + .to receive(:calculate_checksum) + .with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash)) + .and_return(double(checksum: 0)) + + client.calculate_checksum + end + end end diff --git a/spec/lib/gitlab/github_import/importer/repository_importer_spec.rb b/spec/lib/gitlab/github_import/importer/repository_importer_spec.rb index 1f0f1fdd7da..879b1d9fb0f 100644 --- a/spec/lib/gitlab/github_import/importer/repository_importer_spec.rb +++ b/spec/lib/gitlab/github_import/importer/repository_importer_spec.rb @@ -9,7 +9,7 @@ describe Gitlab::GithubImport::Importer::RepositoryImporter do :project, import_url: 'foo.git', import_source: 'foo/bar', - repository_storage_path: 'foo', + repository_storage: 'foo', disk_path: 'foo', repository: repository, create_wiki: true diff --git a/spec/lib/gitlab/http_spec.rb b/spec/lib/gitlab/http_spec.rb index b0bc081a3c8..d0dadfa78da 100644 --- a/spec/lib/gitlab/http_spec.rb +++ b/spec/lib/gitlab/http_spec.rb @@ -12,11 +12,11 @@ describe Gitlab::HTTP do end it 'deny requests to localhost' do - expect { described_class.get('http://localhost:3003') }.to raise_error(URI::InvalidURIError) + expect { described_class.get('http://localhost:3003') }.to raise_error(Gitlab::HTTP::BlockedUrlError) end it 'deny requests to private network' do - expect { described_class.get('http://192.168.1.2:3003') }.to raise_error(URI::InvalidURIError) + expect { described_class.get('http://192.168.1.2:3003') }.to raise_error(Gitlab::HTTP::BlockedUrlError) end context 'if allow_local_requests set to true' do @@ -41,7 +41,7 @@ describe Gitlab::HTTP do context 'if allow_local_requests set to false' do it 'override the global value and ban requests to localhost or private network' do - expect { described_class.get('http://localhost:3003', allow_local_requests: false) }.to raise_error(URI::InvalidURIError) + expect { described_class.get('http://localhost:3003', allow_local_requests: false) }.to raise_error(Gitlab::HTTP::BlockedUrlError) end end end diff --git a/spec/lib/gitlab/import_export/after_export_strategies/base_after_export_strategy_spec.rb b/spec/lib/gitlab/import_export/after_export_strategies/base_after_export_strategy_spec.rb new file mode 100644 index 00000000000..ed54d87de4a --- /dev/null +++ b/spec/lib/gitlab/import_export/after_export_strategies/base_after_export_strategy_spec.rb @@ -0,0 +1,104 @@ +require 'spec_helper' + +describe Gitlab::ImportExport::AfterExportStrategies::BaseAfterExportStrategy do + let!(:service) { described_class.new } + let!(:project) { create(:project, :with_export) } + let(:shared) { project.import_export_shared } + let!(:user) { create(:user) } + + describe '#execute' do + before do + allow(service).to receive(:strategy_execute) + end + + it 'returns if project exported file is not found' do + allow(project).to receive(:export_project_path).and_return(nil) + + expect(service).not_to receive(:strategy_execute) + + service.execute(user, project) + end + + it 'creates a lock file in the export dir' do + allow(service).to receive(:delete_after_export_lock) + + service.execute(user, project) + + expect(lock_path_exist?).to be_truthy + end + + context 'when the method succeeds' do + it 'removes the lock file' do + service.execute(user, project) + + expect(lock_path_exist?).to be_falsey + end + end + + context 'when the method fails' do + before do + allow(service).to receive(:strategy_execute).and_call_original + end + + context 'when validation fails' do + before do + allow(service).to receive(:invalid?).and_return(true) + end + + it 'does not create the lock file' do + expect(service).not_to receive(:create_or_update_after_export_lock) + + service.execute(user, project) + end + + it 'does not execute main logic' do + expect(service).not_to receive(:strategy_execute) + + service.execute(user, project) + end + + it 'logs validation errors in shared context' do + expect(service).to receive(:log_validation_errors) + + service.execute(user, project) + end + end + + context 'when an exception is raised' do + it 'removes the lock' do + expect { service.execute(user, project) }.to raise_error(NotImplementedError) + + expect(lock_path_exist?).to be_falsey + end + end + end + end + + describe '#log_validation_errors' do + it 'add the message to the shared context' do + errors = %w(test_message test_message2) + + allow(service).to receive(:invalid?).and_return(true) + allow(service.errors).to receive(:full_messages).and_return(errors) + + expect(shared).to receive(:add_error_message).twice.and_call_original + + service.execute(user, project) + + expect(shared.errors).to eq errors + end + end + + describe '#to_json' do + it 'adds the current strategy class to the serialized attributes' do + params = { param1: 1 } + result = params.merge(klass: described_class.to_s).to_json + + expect(described_class.new(params).to_json).to eq result + end + end + + def lock_path_exist? + File.exist?(described_class.lock_file_path(project)) + end +end diff --git a/spec/lib/gitlab/import_export/after_export_strategies/web_upload_strategy_spec.rb b/spec/lib/gitlab/import_export/after_export_strategies/web_upload_strategy_spec.rb new file mode 100644 index 00000000000..5fe57d9987b --- /dev/null +++ b/spec/lib/gitlab/import_export/after_export_strategies/web_upload_strategy_spec.rb @@ -0,0 +1,36 @@ +require 'spec_helper' + +describe Gitlab::ImportExport::AfterExportStrategies::WebUploadStrategy do + let(:example_url) { 'http://www.example.com' } + let(:strategy) { subject.new(url: example_url, http_method: 'post') } + let!(:project) { create(:project, :with_export) } + let!(:user) { build(:user) } + + subject { described_class } + + describe 'validations' do + it 'only POST and PUT method allowed' do + %w(POST post PUT put).each do |method| + expect(subject.new(url: example_url, http_method: method)).to be_valid + end + + expect(subject.new(url: example_url, http_method: 'whatever')).not_to be_valid + end + + it 'onyl allow urls as upload urls' do + expect(subject.new(url: example_url)).to be_valid + expect(subject.new(url: 'whatever')).not_to be_valid + end + end + + describe '#execute' do + it 'removes the exported project file after the upload' do + allow(strategy).to receive(:send_file) + allow(strategy).to receive(:handle_response_error) + + expect(project).to receive(:remove_exported_project_file) + + strategy.execute(user, project) + end + end +end diff --git a/spec/lib/gitlab/import_export/after_export_strategy_builder_spec.rb b/spec/lib/gitlab/import_export/after_export_strategy_builder_spec.rb new file mode 100644 index 00000000000..bf727285a9f --- /dev/null +++ b/spec/lib/gitlab/import_export/after_export_strategy_builder_spec.rb @@ -0,0 +1,29 @@ +require 'spec_helper' + +describe Gitlab::ImportExport::AfterExportStrategyBuilder do + let!(:strategies_namespace) { 'Gitlab::ImportExport::AfterExportStrategies' } + + describe '.build!' do + context 'when klass param is' do + it 'null it returns the default strategy' do + expect(described_class.build!(nil).class).to eq described_class.default_strategy + end + + it 'not a valid class it raises StrategyNotFoundError exception' do + expect { described_class.build!('Whatever') }.to raise_error(described_class::StrategyNotFoundError) + end + + it 'not a descendant of AfterExportStrategy' do + expect { described_class.build!('User') }.to raise_error(described_class::StrategyNotFoundError) + end + end + + it 'initializes strategy with attributes param' do + params = { param1: 1, param2: 2, param3: 3 } + + strategy = described_class.build!("#{strategies_namespace}::DownloadNotificationStrategy", params) + + params.each { |k, v| expect(strategy.public_send(k)).to eq v } + end + end +end diff --git a/spec/lib/gitlab/import_export/all_models.yml b/spec/lib/gitlab/import_export/all_models.yml index a204a8f1ffe..897a5984782 100644 --- a/spec/lib/gitlab/import_export/all_models.yml +++ b/spec/lib/gitlab/import_export/all_models.yml @@ -18,6 +18,7 @@ issues: - metrics - timelogs - issue_assignees +- closed_by events: - author - project @@ -144,6 +145,9 @@ pipeline_schedule: - pipelines pipeline_schedule_variables: - pipeline_schedule +deploy_tokens: +- project_deploy_tokens +- projects deploy_keys: - user - deploy_keys_projects @@ -280,6 +284,8 @@ project: - project_badges - source_of_merge_requests - internal_ids +- project_deploy_tokens +- deploy_tokens award_emoji: - awardable - user diff --git a/spec/lib/gitlab/import_export/importer_spec.rb b/spec/lib/gitlab/import_export/importer_spec.rb new file mode 100644 index 00000000000..991e354f499 --- /dev/null +++ b/spec/lib/gitlab/import_export/importer_spec.rb @@ -0,0 +1,104 @@ +require 'spec_helper' + +describe Gitlab::ImportExport::Importer do + let(:user) { create(:user) } + let(:test_path) { "#{Dir.tmpdir}/importer_spec" } + let(:shared) { project.import_export_shared } + let(:project) { create(:project, import_source: File.join(test_path, 'exported-project.gz')) } + + subject(:importer) { described_class.new(project) } + + before do + allow_any_instance_of(Gitlab::ImportExport).to receive(:storage_path).and_return(test_path) + FileUtils.mkdir_p(shared.export_path) + FileUtils.cp(Rails.root.join('spec', 'fixtures', 'exported-project.gz'), test_path) + allow(subject).to receive(:remove_import_file) + end + + after do + FileUtils.rm_rf(test_path) + end + + describe '#execute' do + it 'succeeds' do + importer.execute + + expect(shared.errors).to be_empty + end + + it 'extracts the archive' do + expect(Gitlab::ImportExport::FileImporter).to receive(:import).and_call_original + + importer.execute + end + + it 'checks the version' do + expect(Gitlab::ImportExport::VersionChecker).to receive(:check!).and_call_original + + importer.execute + end + + context 'all restores are executed' do + [ + Gitlab::ImportExport::AvatarRestorer, + Gitlab::ImportExport::RepoRestorer, + Gitlab::ImportExport::WikiRestorer, + Gitlab::ImportExport::UploadsRestorer, + Gitlab::ImportExport::LfsRestorer, + Gitlab::ImportExport::StatisticsRestorer + ].each do |restorer| + it "calls the #{restorer}" do + fake_restorer = double(restorer.to_s) + + expect(fake_restorer).to receive(:restore).and_return(true).at_least(1) + expect(restorer).to receive(:new).and_return(fake_restorer).at_least(1) + + importer.execute + end + end + + it 'restores the ProjectTree' do + expect(Gitlab::ImportExport::ProjectTreeRestorer).to receive(:new).and_call_original + + importer.execute + end + end + + context 'when project successfully restored' do + let!(:existing_project) { create(:project, namespace: user.namespace) } + let(:project) { create(:project, namespace: user.namespace, name: 'whatever', path: 'whatever') } + + before do + restorers = double + + allow(subject).to receive(:import_file).and_return(true) + allow(subject).to receive(:check_version!).and_return(true) + allow(subject).to receive(:restorers).and_return(restorers) + allow(restorers).to receive(:all?).and_return(true) + allow(project).to receive(:import_data).and_return(double(data: { 'original_path' => existing_project.path })) + end + + context 'when import_data' do + context 'has original_path' do + it 'overwrites existing project' do + expect_any_instance_of(::Projects::OverwriteProjectService).to receive(:execute).with(existing_project) + + subject.execute + end + end + + context 'has not original_path' do + before do + allow(project).to receive(:import_data).and_return(double(data: {})) + end + + it 'does not call the overwrite service' do + expect_any_instance_of(::Projects::OverwriteProjectService).not_to receive(:execute).with(existing_project) + + subject.execute + end + end + end + end + end +end diff --git a/spec/lib/gitlab/import_export/lfs_restorer_spec.rb b/spec/lib/gitlab/import_export/lfs_restorer_spec.rb new file mode 100644 index 00000000000..70eeb9ee66b --- /dev/null +++ b/spec/lib/gitlab/import_export/lfs_restorer_spec.rb @@ -0,0 +1,75 @@ +require 'spec_helper' + +describe Gitlab::ImportExport::LfsRestorer do + include UploadHelpers + + let(:export_path) { "#{Dir.tmpdir}/lfs_object_restorer_spec" } + let(:project) { create(:project) } + let(:shared) { project.import_export_shared } + subject(:restorer) { described_class.new(project: project, shared: shared) } + + before do + allow_any_instance_of(Gitlab::ImportExport).to receive(:storage_path).and_return(export_path) + FileUtils.mkdir_p(shared.export_path) + end + + after do + FileUtils.rm_rf(shared.export_path) + end + + describe '#restore' do + context 'when the archive contains lfs files' do + let(:dummy_lfs_file_path) { File.join(shared.export_path, 'lfs-objects', 'dummy') } + + def create_lfs_object_with_content(content) + dummy_lfs_file = Tempfile.new('existing') + File.write(dummy_lfs_file.path, content) + size = dummy_lfs_file.size + oid = LfsObject.calculate_oid(dummy_lfs_file.path) + LfsObject.create!(oid: oid, size: size, file: dummy_lfs_file) + end + + before do + FileUtils.mkdir_p(File.dirname(dummy_lfs_file_path)) + File.write(dummy_lfs_file_path, 'not very large') + allow(restorer).to receive(:lfs_file_paths).and_return([dummy_lfs_file_path]) + end + + it 'creates an lfs object for the project' do + expect { restorer.restore }.to change { project.reload.lfs_objects.size }.by(1) + end + + it 'assigns the file correctly' do + restorer.restore + + expect(project.lfs_objects.first.file.read).to eq('not very large') + end + + it 'links an existing LFS object if it existed' do + lfs_object = create_lfs_object_with_content('not very large') + + restorer.restore + + expect(project.lfs_objects).to include(lfs_object) + end + + it 'succeeds' do + expect(restorer.restore).to be_truthy + expect(shared.errors).to be_empty + end + + it 'stores the upload' do + expect_any_instance_of(LfsObjectUploader).to receive(:store!) + + restorer.restore + end + end + + context 'without any LFS-objects' do + it 'succeeds' do + expect(restorer.restore).to be_truthy + expect(shared.errors).to be_empty + end + end + end +end diff --git a/spec/lib/gitlab/import_export/lfs_saver_spec.rb b/spec/lib/gitlab/import_export/lfs_saver_spec.rb new file mode 100644 index 00000000000..9b0e21deb2e --- /dev/null +++ b/spec/lib/gitlab/import_export/lfs_saver_spec.rb @@ -0,0 +1,62 @@ +require 'spec_helper' + +describe Gitlab::ImportExport::LfsSaver do + let(:shared) { project.import_export_shared } + let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" } + let(:project) { create(:project) } + + subject(:saver) { described_class.new(project: project, shared: shared) } + + before do + allow_any_instance_of(Gitlab::ImportExport).to receive(:storage_path).and_return(export_path) + FileUtils.mkdir_p(shared.export_path) + end + + after do + FileUtils.rm_rf(shared.export_path) + end + + describe '#save' do + context 'when the project has LFS objects locally stored' do + let(:lfs_object) { create(:lfs_object, :with_file) } + + before do + project.lfs_objects << lfs_object + end + + it 'does not cause errors' do + saver.save + + expect(shared.errors).to be_empty + end + + it 'copies the file in the correct location when there is an lfs object' do + saver.save + + expect(File).to exist("#{shared.export_path}/lfs-objects/#{lfs_object.oid}") + end + end + + context 'when the LFS objects are stored in object storage' do + let(:lfs_object) { create(:lfs_object, :object_storage) } + + before do + allow(LfsObjectUploader).to receive(:object_store_enabled?).and_return(true) + allow(lfs_object.file).to receive(:url).and_return('http://my-object-storage.local') + project.lfs_objects << lfs_object + end + + it 'downloads the file to include in an archive' do + fake_uri = double + exported_file_path = "#{shared.export_path}/lfs-objects/#{lfs_object.oid}" + + expect(fake_uri).to receive(:open).and_return(StringIO.new('LFS file content')) + expect(URI).to receive(:parse).with('http://my-object-storage.local').and_return(fake_uri) + + saver.save + + expect(File.read(exported_file_path)).to eq('LFS file content') + end + end + end +end diff --git a/spec/lib/gitlab/import_export/project.json b/spec/lib/gitlab/import_export/project.json index 4a51777ba9b..6d63749296e 100644 --- a/spec/lib/gitlab/import_export/project.json +++ b/spec/lib/gitlab/import_export/project.json @@ -2,7 +2,6 @@ "description": "Nisi et repellendus ut enim quo accusamus vel magnam.", "visibility_level": 10, "archived": false, - "description_html": "description", "labels": [ { "id": 2, @@ -6181,12 +6180,6 @@ "user_id": null, "target_url": null, "description": null, - "artifacts_file": { - "url": null - }, - "artifacts_metadata": { - "url": null - }, "erased_by_id": null, "erased_at": null, "type": "Ci::Build", @@ -6219,12 +6212,6 @@ "user_id": null, "target_url": null, "description": null, - "artifacts_file": { - "url": "/Users/Test/Test/gitlab-development-kit/gitlab/shared/artifacts/2016_03/5/72/p5_build_artifacts.zip" - }, - "artifacts_metadata": { - "url": "/Users/Test/Test/gitlab-development-kit/gitlab/shared/artifacts/2016_03/5/72/p5_build_artifacts_metadata.gz" - }, "erased_by_id": null, "erased_at": null } @@ -6293,12 +6280,6 @@ "user_id": null, "target_url": null, "description": null, - "artifacts_file": { - "url": "/Users/Test/Test/gitlab-development-kit/gitlab/shared/artifacts/2016_03/5/74/p5_build_artifacts.zip" - }, - "artifacts_metadata": { - "url": "/Users/Test/Test/gitlab-development-kit/gitlab/shared/artifacts/2016_03/5/74/p5_build_artifacts_metadata.gz" - }, "erased_by_id": null, "erased_at": null }, @@ -6328,12 +6309,6 @@ "user_id": null, "target_url": null, "description": null, - "artifacts_file": { - "url": null - }, - "artifacts_metadata": { - "url": null - }, "erased_by_id": null, "erased_at": null } @@ -6393,12 +6368,6 @@ "user_id": null, "target_url": null, "description": null, - "artifacts_file": { - "url": "/Users/Test/Test/gitlab-development-kit/gitlab/shared/artifacts/2016_03/5/76/p5_build_artifacts.zip" - }, - "artifacts_metadata": { - "url": "/Users/Test/Test/gitlab-development-kit/gitlab/shared/artifacts/2016_03/5/76/p5_build_artifacts_metadata.gz" - }, "erased_by_id": null, "erased_at": null }, @@ -6428,12 +6397,6 @@ "user_id": null, "target_url": null, "description": null, - "artifacts_file": { - "url": "/Users/Test/Test/gitlab-development-kit/gitlab/shared/artifacts/2016_03/5/75/p5_build_artifacts.zip" - }, - "artifacts_metadata": { - "url": "/Users/Test/Test/gitlab-development-kit/gitlab/shared/artifacts/2016_03/5/75/p5_build_artifacts_metadata.gz" - }, "erased_by_id": null, "erased_at": null } @@ -6493,12 +6456,6 @@ "user_id": null, "target_url": null, "description": null, - "artifacts_file": { - "url": "/Users/Test/Test/gitlab-development-kit/gitlab/shared/artifacts/2016_03/5/78/p5_build_artifacts.zip" - }, - "artifacts_metadata": { - "url": "/Users/Test/Test/gitlab-development-kit/gitlab/shared/artifacts/2016_03/5/78/p5_build_artifacts_metadata.gz" - }, "erased_by_id": null, "erased_at": null }, @@ -6528,12 +6485,6 @@ "user_id": null, "target_url": null, "description": null, - "artifacts_file": { - "url": "/Users/Test/Test/gitlab-development-kit/gitlab/shared/artifacts/2016_03/5/77/p5_build_artifacts.zip" - }, - "artifacts_metadata": { - "url": "/Users/Test/Test/gitlab-development-kit/gitlab/shared/artifacts/2016_03/5/77/p5_build_artifacts_metadata.gz" - }, "erased_by_id": null, "erased_at": null } @@ -6593,12 +6544,6 @@ "user_id": null, "target_url": null, "description": null, - "artifacts_file": { - "url": null - }, - "artifacts_metadata": { - "url": null - }, "erased_by_id": null, "erased_at": null }, @@ -6628,12 +6573,6 @@ "user_id": null, "target_url": null, "description": null, - "artifacts_file": { - "url": "/Users/Test/Test/gitlab-development-kit/gitlab/shared/artifacts/2016_03/5/80/p5_build_artifacts.zip" - }, - "artifacts_metadata": { - "url": "/Users/Test/Test/gitlab-development-kit/gitlab/shared/artifacts/2016_03/5/80/p5_build_artifacts_metadata.gz" - }, "erased_by_id": null, "erased_at": null } diff --git a/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb b/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb index 8e25cd26c2f..13a8c9adcee 100644 --- a/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb +++ b/spec/lib/gitlab/import_export/project_tree_restorer_spec.rb @@ -46,10 +46,6 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do expect(Project.find_by_path('project').description).to eq('Nisi et repellendus ut enim quo accusamus vel magnam.') end - it 'has the project html description' do - expect(Project.find_by_path('project').description_html).to eq('description') - end - it 'has the same label associated to two issues' do expect(ProjectLabel.find_by_title('test2').issues.count).to eq(2) end @@ -317,6 +313,24 @@ describe Gitlab::ImportExport::ProjectTreeRestorer do end end + context 'when the project has overriden params in import data' do + it 'overwrites the params stored in the JSON' do + project.create_import_data(data: { override_params: { description: "Overridden" } }) + + restored_project_json + + expect(project.description).to eq("Overridden") + end + + it 'does not allow setting params that are excluded from import_export settings' do + project.create_import_data(data: { override_params: { lfs_enabled: true } }) + + restored_project_json + + expect(project.lfs_enabled).to be_nil + end + end + context 'with a project that has a group' do let!(:project) do create(:project, diff --git a/spec/lib/gitlab/import_export/project_tree_saver_spec.rb b/spec/lib/gitlab/import_export/project_tree_saver_spec.rb index 0d20a551e2a..2b8a11ce8f9 100644 --- a/spec/lib/gitlab/import_export/project_tree_saver_spec.rb +++ b/spec/lib/gitlab/import_export/project_tree_saver_spec.rb @@ -245,10 +245,6 @@ describe Gitlab::ImportExport::ProjectTreeSaver do end context 'project attributes' do - it 'contains the html description' do - expect(saved_project_json).to include("description_html" => 'description') - end - it 'does not contain the runners token' do expect(saved_project_json).not_to include("runners_token" => 'token') end @@ -274,7 +270,6 @@ describe Gitlab::ImportExport::ProjectTreeSaver do releases: [release], group: group ) - project.update_column(:description_html, 'description') project_label = create(:label, project: project) group_label = create(:group_label, group: group) create(:label_link, label: project_label, target: issue) diff --git a/spec/lib/gitlab/import_export/safe_model_attributes.yml b/spec/lib/gitlab/import_export/safe_model_attributes.yml index 0716852f57f..f84a777a27f 100644 --- a/spec/lib/gitlab/import_export/safe_model_attributes.yml +++ b/spec/lib/gitlab/import_export/safe_model_attributes.yml @@ -15,6 +15,7 @@ Issue: - updated_by_id - confidential - closed_at +- closed_by_id - due_date - moved_to_id - lock_version @@ -389,6 +390,7 @@ Service: - default - wiki_page_events - confidential_issues_events +- confidential_note_events ProjectHook: - id - url @@ -409,6 +411,7 @@ ProjectHook: - token - group_id - confidential_issues_events +- confidential_note_events - repository_update_events ProtectedBranch: - id diff --git a/spec/lib/gitlab/metrics/sidekiq_metrics_exporter_spec.rb b/spec/lib/gitlab/metrics/sidekiq_metrics_exporter_spec.rb index 6721e02fb85..61eb059a731 100644 --- a/spec/lib/gitlab/metrics/sidekiq_metrics_exporter_spec.rb +++ b/spec/lib/gitlab/metrics/sidekiq_metrics_exporter_spec.rb @@ -38,7 +38,9 @@ describe Gitlab::Metrics::SidekiqMetricsExporter do expect(::WEBrick::HTTPServer).to have_received(:new).with( Port: port, - BindAddress: address + BindAddress: address, + Logger: anything, + AccessLog: anything ) end end diff --git a/spec/lib/gitlab/performance_bar_spec.rb b/spec/lib/gitlab/performance_bar_spec.rb index b8a2267f1a4..f480376acb4 100644 --- a/spec/lib/gitlab/performance_bar_spec.rb +++ b/spec/lib/gitlab/performance_bar_spec.rb @@ -25,6 +25,12 @@ describe Gitlab::PerformanceBar do expect(described_class.enabled?(nil)).to be_falsy end + it 'returns true when given user is an admin' do + user = build_stubbed(:user, :admin) + + expect(described_class.enabled?(user)).to be_truthy + end + it 'returns false when allowed_group_id is nil' do expect(described_class).to receive(:allowed_group_id).and_return(nil) diff --git a/spec/lib/gitlab/shell_spec.rb b/spec/lib/gitlab/shell_spec.rb index ea5ce58e34b..7ff2c0639ec 100644 --- a/spec/lib/gitlab/shell_spec.rb +++ b/spec/lib/gitlab/shell_spec.rb @@ -14,7 +14,7 @@ describe Gitlab::Shell do allow(Project).to receive(:find).and_return(project) allow(gitlab_shell).to receive(:gitlab_projects) - .with(project.repository_storage_path, project.disk_path + '.git') + .with(project.repository_storage, project.disk_path + '.git') .and_return(gitlab_projects) end @@ -487,21 +487,21 @@ describe Gitlab::Shell do describe '#fork_repository' do subject do gitlab_shell.fork_repository( - project.repository_storage_path, + project.repository_storage, project.disk_path, - 'new/storage', + 'nfs-file05', 'fork/path' ) end it 'returns true when the command succeeds' do - expect(gitlab_projects).to receive(:fork_repository).with('new/storage', 'fork/path.git') { true } + expect(gitlab_projects).to receive(:fork_repository).with('nfs-file05', 'fork/path.git') { true } is_expected.to be_truthy end it 'return false when the command fails' do - expect(gitlab_projects).to receive(:fork_repository).with('new/storage', 'fork/path.git') { false } + expect(gitlab_projects).to receive(:fork_repository).with('nfs-file05', 'fork/path.git') { false } is_expected.to be_falsy end @@ -661,7 +661,7 @@ describe Gitlab::Shell do it 'returns true when the command succeeds' do expect(gitlab_projects).to receive(:import_project).with(import_url, timeout) { true } - result = gitlab_shell.import_repository(project.repository_storage_path, project.disk_path, import_url) + result = gitlab_shell.import_repository(project.repository_storage, project.disk_path, import_url) expect(result).to be_truthy end @@ -671,7 +671,7 @@ describe Gitlab::Shell do expect(gitlab_projects).to receive(:import_project) { false } expect do - gitlab_shell.import_repository(project.repository_storage_path, project.disk_path, import_url) + gitlab_shell.import_repository(project.repository_storage, project.disk_path, import_url) end.to raise_error(Gitlab::Shell::Error, "error") end end diff --git a/spec/lib/gitlab/sidekiq_logging/json_formatter_spec.rb b/spec/lib/gitlab/sidekiq_logging/json_formatter_spec.rb new file mode 100644 index 00000000000..fed9aeba30c --- /dev/null +++ b/spec/lib/gitlab/sidekiq_logging/json_formatter_spec.rb @@ -0,0 +1,31 @@ +require 'spec_helper' + +describe Gitlab::SidekiqLogging::JSONFormatter do + let(:hash_input) { { foo: 1, bar: 'test' } } + let(:message) { 'This is a test' } + let(:timestamp) { Time.now } + + it 'wraps a Hash' do + result = subject.call('INFO', timestamp, 'my program', hash_input) + + data = JSON.parse(result) + expected_output = hash_input.stringify_keys + expected_output['severity'] = 'INFO' + expected_output['time'] = timestamp.utc.iso8601(3) + + expect(data).to eq(expected_output) + end + + it 'wraps a String' do + result = subject.call('DEBUG', timestamp, 'my string', message) + + data = JSON.parse(result) + expected_output = { + severity: 'DEBUG', + time: timestamp.utc.iso8601(3), + message: message + } + + expect(data).to eq(expected_output.stringify_keys) + end +end diff --git a/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb b/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb new file mode 100644 index 00000000000..2421b1e5a1a --- /dev/null +++ b/spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb @@ -0,0 +1,101 @@ +require 'spec_helper' + +describe Gitlab::SidekiqLogging::StructuredLogger do + describe '#call' do + let(:timestamp) { Time.new('2018-01-01 12:00:00').utc } + let(:job) do + { + "class" => "TestWorker", + "args" => [1234, 'hello'], + "retry" => false, + "queue" => "cronjob:test_queue", + "queue_namespace" => "cronjob", + "jid" => "da883554ee4fe414012f5f42", + "created_at" => timestamp.to_f, + "enqueued_at" => timestamp.to_f + } + end + let(:logger) { double() } + let(:start_payload) do + job.merge( + 'message' => 'TestWorker JID-da883554ee4fe414012f5f42: start', + 'job_status' => 'start', + 'pid' => Process.pid, + 'created_at' => timestamp.iso8601(3), + 'enqueued_at' => timestamp.iso8601(3) + ) + end + let(:end_payload) do + start_payload.merge( + 'message' => 'TestWorker JID-da883554ee4fe414012f5f42: done: 0.0 sec', + 'job_status' => 'done', + 'duration' => 0.0, + "completed_at" => timestamp.iso8601(3) + ) + end + let(:exception_payload) do + end_payload.merge( + 'message' => 'TestWorker JID-da883554ee4fe414012f5f42: fail: 0.0 sec', + 'job_status' => 'fail', + 'error' => ArgumentError, + 'error_message' => 'some exception' + ) + end + + before do + allow(Sidekiq).to receive(:logger).and_return(logger) + + allow(subject).to receive(:current_time).and_return(timestamp.to_f) + end + + subject { described_class.new } + + context 'with SIDEKIQ_LOG_ARGUMENTS enabled' do + before do + stub_env('SIDEKIQ_LOG_ARGUMENTS', '1') + end + + it 'logs start and end of job' do + Timecop.freeze(timestamp) do + expect(logger).to receive(:info).with(start_payload).ordered + expect(logger).to receive(:info).with(end_payload).ordered + expect(subject).to receive(:log_job_start).and_call_original + expect(subject).to receive(:log_job_done).and_call_original + + subject.call(job, 'test_queue') { } + end + end + + it 'logs an exception in job' do + Timecop.freeze(timestamp) do + expect(logger).to receive(:info).with(start_payload) + # This excludes the exception_backtrace + expect(logger).to receive(:warn).with(hash_including(exception_payload)) + expect(subject).to receive(:log_job_start).and_call_original + expect(subject).to receive(:log_job_done).and_call_original + + expect do + subject.call(job, 'test_queue') do + raise ArgumentError, 'some exception' + end + end.to raise_error(ArgumentError) + end + end + end + + context 'with SIDEKIQ_LOG_ARGUMENTS disabled' do + it 'logs start and end of job' do + Timecop.freeze(timestamp) do + start_payload.delete('args') + + expect(logger).to receive(:info).with(start_payload).ordered + expect(logger).to receive(:info).with(end_payload).ordered + expect(subject).to receive(:log_job_start).and_call_original + expect(subject).to receive(:log_job_done).and_call_original + + subject.call(job, 'test_queue') { } + end + end + end + end +end diff --git a/spec/lib/gitlab/url_blocker_spec.rb b/spec/lib/gitlab/url_blocker_spec.rb index 2d35b026485..a3b3dc3be6d 100644 --- a/spec/lib/gitlab/url_blocker_spec.rb +++ b/spec/lib/gitlab/url_blocker_spec.rb @@ -74,13 +74,13 @@ describe Gitlab::UrlBlocker do expect(described_class.blocked_url?('https://gitlab.com/foo/foo.git')).to be false end - context 'when allow_private_networks is' do - let(:private_networks) { ['192.168.1.2', '10.0.0.2', '172.16.0.2'] } + context 'when allow_local_network is' do + let(:local_ips) { ['192.168.1.2', '10.0.0.2', '172.16.0.2'] } let(:fake_domain) { 'www.fakedomain.fake' } context 'true (default)' do it 'does not block urls from private networks' do - private_networks.each do |ip| + local_ips.each do |ip| stub_domain_resolv(fake_domain, ip) expect(described_class).not_to be_blocked_url("http://#{fake_domain}") @@ -94,14 +94,14 @@ describe Gitlab::UrlBlocker do context 'false' do it 'blocks urls from private networks' do - private_networks.each do |ip| + local_ips.each do |ip| stub_domain_resolv(fake_domain, ip) - expect(described_class).to be_blocked_url("http://#{fake_domain}", allow_private_networks: false) + expect(described_class).to be_blocked_url("http://#{fake_domain}", allow_local_network: false) unstub_domain_resolv - expect(described_class).to be_blocked_url("http://#{ip}", allow_private_networks: false) + expect(described_class).to be_blocked_url("http://#{ip}", allow_local_network: false) end end end diff --git a/spec/lib/gitlab/usage_data_spec.rb b/spec/lib/gitlab/usage_data_spec.rb index 138d21ede97..9e6aa109a4b 100644 --- a/spec/lib/gitlab/usage_data_spec.rb +++ b/spec/lib/gitlab/usage_data_spec.rb @@ -12,6 +12,14 @@ describe Gitlab::UsageData do create(:service, project: projects[0], type: 'SlackSlashCommandsService', active: true) create(:service, project: projects[1], type: 'SlackService', active: true) create(:service, project: projects[2], type: 'SlackService', active: true) + + gcp_cluster = create(:cluster, :provided_by_gcp) + create(:cluster, :provided_by_user) + create(:cluster, :provided_by_user, :disabled) + create(:clusters_applications_helm, :installed, cluster: gcp_cluster) + create(:clusters_applications_ingress, :installed, cluster: gcp_cluster) + create(:clusters_applications_prometheus, :installed, cluster: gcp_cluster) + create(:clusters_applications_runner, :installed, cluster: gcp_cluster) end subject { described_class.data } @@ -64,6 +72,12 @@ describe Gitlab::UsageData do clusters clusters_enabled clusters_disabled + clusters_platforms_gke + clusters_platforms_user + clusters_applications_helm + clusters_applications_ingress + clusters_applications_prometheus + clusters_applications_runner in_review_folder groups issues @@ -97,6 +111,15 @@ describe Gitlab::UsageData do expect(count_data[:projects_jira_active]).to eq(2) expect(count_data[:projects_slack_notifications_active]).to eq(2) expect(count_data[:projects_slack_slash_active]).to eq(1) + + expect(count_data[:clusters_enabled]).to eq(6) + expect(count_data[:clusters_disabled]).to eq(1) + expect(count_data[:clusters_platforms_gke]).to eq(1) + expect(count_data[:clusters_platforms_user]).to eq(1) + expect(count_data[:clusters_applications_helm]).to eq(1) + expect(count_data[:clusters_applications_ingress]).to eq(1) + expect(count_data[:clusters_applications_prometheus]).to eq(1) + expect(count_data[:clusters_applications_runner]).to eq(1) end end diff --git a/spec/lib/gitlab/workhorse_spec.rb b/spec/lib/gitlab/workhorse_spec.rb index 2b3ffb2d7c0..d64ea72e346 100644 --- a/spec/lib/gitlab/workhorse_spec.rb +++ b/spec/lib/gitlab/workhorse_spec.rb @@ -16,7 +16,7 @@ describe Gitlab::Workhorse do let(:ref) { 'master' } let(:format) { 'zip' } let(:storage_path) { Gitlab.config.gitlab.repository_downloads_path } - let(:base_params) { repository.archive_metadata(ref, storage_path, format) } + let(:base_params) { repository.archive_metadata(ref, storage_path, format, append_sha: nil) } let(:gitaly_params) do base_params.merge( 'GitalyServer' => { @@ -29,7 +29,7 @@ describe Gitlab::Workhorse do let(:cache_disabled) { false } subject do - described_class.send_git_archive(repository, ref: ref, format: format) + described_class.send_git_archive(repository, ref: ref, format: format, append_sha: nil) end before do diff --git a/spec/lib/uploaded_file_spec.rb b/spec/lib/uploaded_file_spec.rb new file mode 100644 index 00000000000..cc99e7e8911 --- /dev/null +++ b/spec/lib/uploaded_file_spec.rb @@ -0,0 +1,116 @@ +require 'spec_helper' + +describe UploadedFile do + describe ".from_params" do + let(:temp_dir) { Dir.tmpdir } + let(:temp_file) { Tempfile.new("test", temp_dir) } + let(:upload_path) { nil } + + subject do + described_class.from_params(params, :file, upload_path) + end + + before do + FileUtils.touch(temp_file) + end + + after do + FileUtils.rm_f(temp_file) + FileUtils.rm_r(upload_path) if upload_path + end + + context 'when valid file is specified' do + context 'only local path is specified' do + let(:params) do + { 'file.path' => temp_file.path } + end + + it "succeeds" do + is_expected.not_to be_nil + end + + it "generates filename from path" do + expect(subject.original_filename).to eq(::File.basename(temp_file.path)) + end + end + + context 'all parameters are specified' do + let(:params) do + { 'file.path' => temp_file.path, + 'file.name' => 'my_file.txt', + 'file.type' => 'my/type', + 'file.sha256' => 'sha256', + 'file.remote_id' => 'remote_id' } + end + + it "succeeds" do + is_expected.not_to be_nil + end + + it "generates filename from path" do + expect(subject.original_filename).to eq('my_file.txt') + expect(subject.content_type).to eq('my/type') + expect(subject.sha256).to eq('sha256') + expect(subject.remote_id).to eq('remote_id') + end + end + end + + context 'when no params are specified' do + let(:params) do + {} + end + + it "does not return an object" do + is_expected.to be_nil + end + end + + context 'when only remote id is specified' do + let(:params) do + { 'file.remote_id' => 'remote_id' } + end + + it "raises an error" do + expect { subject }.to raise_error(UploadedFile::InvalidPathError, /file is invalid/) + end + end + + context 'when verifying allowed paths' do + let(:params) do + { 'file.path' => temp_file.path } + end + + context 'when file is stored in system temporary folder' do + let(:temp_dir) { Dir.tmpdir } + + it "succeeds" do + is_expected.not_to be_nil + end + end + + context 'when file is stored in user provided upload path' do + let(:upload_path) { Dir.mktmpdir } + let(:temp_dir) { upload_path } + + it "succeeds" do + is_expected.not_to be_nil + end + end + + context 'when file is stored outside of user provided upload path' do + let!(:generated_dir) { Dir.mktmpdir } + let!(:temp_dir) { Dir.mktmpdir } + + before do + # We overwrite default temporary path + allow(Dir).to receive(:tmpdir).and_return(generated_dir) + end + + it "raises an error" do + expect { subject }.to raise_error(UploadedFile::InvalidPathError, /insecure path used/) + end + end + end + end +end diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index 83c33797bbc..43e419cd7de 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -389,6 +389,48 @@ describe Notify do end end end + + shared_examples 'a push to an existing merge request' do + let(:push_user) { create(:user) } + + subject do + described_class.push_to_merge_request_email(recipient.id, merge_request.id, push_user.id, new_commits: merge_request.commits, existing_commits: existing_commits) + end + + it_behaves_like 'a multiple recipients email' + it_behaves_like 'an answer to an existing thread with reply-by-email enabled' do + let(:model) { merge_request } + end + it_behaves_like 'it should show Gmail Actions View Merge request link' + it_behaves_like 'an unsubscribeable thread' + + it 'is sent as the push user' do + sender = subject.header[:from].addrs[0] + + expect(sender.display_name).to eq(push_user.name) + expect(sender.address).to eq(gitlab_sender) + end + + it 'has the correct subject and body' do + aggregate_failures do + is_expected.to have_referable_subject(merge_request, reply: true) + is_expected.to have_body_text("#{push_user.name} pushed new commits") + is_expected.to have_body_text(project_merge_request_path(project, merge_request)) + end + end + end + + describe 'that have new commits' do + let(:existing_commits) { [] } + + it_behaves_like 'a push to an existing merge request' + end + + describe 'that have new commits on top of an existing one' do + let(:existing_commits) { [merge_request.commits.first] } + + it_behaves_like 'a push to an existing merge request' + end end context 'for issue notes' do diff --git a/spec/mailers/previews/email_rejection_mailer_preview.rb b/spec/mailers/previews/email_rejection_mailer_preview.rb new file mode 100644 index 00000000000..639e8471232 --- /dev/null +++ b/spec/mailers/previews/email_rejection_mailer_preview.rb @@ -0,0 +1,5 @@ +class EmailRejectionMailerPreview < ActionMailer::Preview + def rejection + EmailRejectionMailer.rejection("some rejection reason", "From: someone@example.com\nraw email here").message + end +end diff --git a/spec/mailers/previews/notify_preview.rb b/spec/mailers/previews/notify_preview.rb index 43c3c89f140..e32fd0bd120 100644 --- a/spec/mailers/previews/notify_preview.rb +++ b/spec/mailers/previews/notify_preview.rb @@ -58,16 +58,89 @@ class NotifyPreview < ActionMailer::Preview end end + def closed_issue_email + Notify.closed_issue_email(user.id, issue.id, user.id).message + end + + def issue_status_changed_email + Notify.issue_status_changed_email(user.id, issue.id, 'closed', user.id).message + end + + def closed_merge_request_email + Notify.closed_merge_request_email(user.id, issue.id, user.id).message + end + + def merge_request_status_email + Notify.merge_request_status_email(user.id, merge_request.id, 'closed', user.id).message + end + + def merged_merge_request_email + Notify.merged_merge_request_email(user.id, merge_request.id, user.id).message + end + + def member_access_denied_email + Notify.member_access_denied_email('project', project.id, user.id).message + end + + def member_access_granted_email + Notify.member_access_granted_email('project', user.id).message + end + + def member_access_requested_email + Notify.member_access_requested_email('group', user.id, 'some@example.com').message + end + + def member_invite_accepted_email + Notify.member_invite_accepted_email('project', user.id).message + end + + def member_invite_declined_email + Notify.member_invite_declined_email( + 'project', + project.id, + 'invite@example.com', + user.id + ).message + end + + def member_invited_email + Notify.member_invited_email('project', user.id, '1234').message + end + + def pages_domain_enabled_email + cleanup do + pages_domain = PagesDomain.new(domain: 'my.example.com', project: project, verified_at: Time.now, enabled_until: 1.week.from_now) + + Notify.pages_domain_enabled_email(pages_domain, user).message + end + end + + def pipeline_success_email + Notify.pipeline_success_email(pipeline, pipeline.user.try(:email)) + end + + def pipeline_failed_email + Notify.pipeline_failed_email(pipeline, pipeline.user.try(:email)) + end + private def project @project ||= Project.find_by_full_path('gitlab-org/gitlab-test') end + def issue + @merge_request ||= project.issues.first + end + def merge_request @merge_request ||= project.merge_requests.first end + def pipeline + @pipeline = Ci::Pipeline.last + end + def user @user ||= User.last end @@ -94,14 +167,4 @@ class NotifyPreview < ActionMailer::Preview email end - - def pipeline_success_email - pipeline = Ci::Pipeline.last - Notify.pipeline_success_email(pipeline, pipeline.user.try(:email)) - end - - def pipeline_failed_email - pipeline = Ci::Pipeline.last - Notify.pipeline_failed_email(pipeline, pipeline.user.try(:email)) - end end diff --git a/spec/mailers/previews/repository_check_mailer_preview.rb b/spec/mailers/previews/repository_check_mailer_preview.rb new file mode 100644 index 00000000000..19d4eab1805 --- /dev/null +++ b/spec/mailers/previews/repository_check_mailer_preview.rb @@ -0,0 +1,5 @@ +class RepositoryCheckMailerPreview < ActionMailer::Preview + def notify + RepositoryCheckMailer.notify(3).message + end +end diff --git a/spec/migrations/active_record/schedule_set_confidential_note_events_on_services_spec.rb b/spec/migrations/active_record/schedule_set_confidential_note_events_on_services_spec.rb new file mode 100644 index 00000000000..4395e2f8264 --- /dev/null +++ b/spec/migrations/active_record/schedule_set_confidential_note_events_on_services_spec.rb @@ -0,0 +1,44 @@ +require 'spec_helper' +require Rails.root.join('db', 'post_migrate', '20180122154930_schedule_set_confidential_note_events_on_services.rb') + +describe ScheduleSetConfidentialNoteEventsOnServices, :migration, :sidekiq do + let(:services_table) { table(:services) } + let(:migration_class) { Gitlab::BackgroundMigration::SetConfidentialNoteEventsOnServices } + let(:migration_name) { migration_class.to_s.demodulize } + + let!(:service_1) { services_table.create!(confidential_note_events: nil, note_events: true) } + let!(:service_2) { services_table.create!(confidential_note_events: nil, note_events: true) } + let!(:service_migrated) { services_table.create!(confidential_note_events: true, note_events: true) } + let!(:service_skip) { services_table.create!(confidential_note_events: nil, note_events: false) } + let!(:service_new) { services_table.create!(confidential_note_events: false, note_events: true) } + let!(:service_4) { services_table.create!(confidential_note_events: nil, note_events: true) } + + before do + stub_const("#{described_class}::BATCH_SIZE", 1) + end + + it 'schedules background migrations at correct time' do + Sidekiq::Testing.fake! do + Timecop.freeze do + migrate! + + expect(migration_name).to be_scheduled_delayed_migration(20.minutes, service_1.id, service_1.id) + expect(migration_name).to be_scheduled_delayed_migration(40.minutes, service_2.id, service_2.id) + expect(migration_name).to be_scheduled_delayed_migration(60.minutes, service_4.id, service_4.id) + expect(BackgroundMigrationWorker.jobs.size).to eq 3 + end + end + end + + it 'correctly processes services' do + Sidekiq::Testing.inline! do + expect(services_table.where(confidential_note_events: nil).count).to eq 4 + expect(services_table.where(confidential_note_events: true).count).to eq 1 + + migrate! + + expect(services_table.where(confidential_note_events: nil).count).to eq 1 + expect(services_table.where(confidential_note_events: true).count).to eq 4 + end + end +end diff --git a/spec/migrations/add_foreign_keys_to_todos_spec.rb b/spec/migrations/add_foreign_keys_to_todos_spec.rb index 4a22bd6f342..bf2fa5c0f56 100644 --- a/spec/migrations/add_foreign_keys_to_todos_spec.rb +++ b/spec/migrations/add_foreign_keys_to_todos_spec.rb @@ -4,8 +4,8 @@ require Rails.root.join('db', 'migrate', '20180201110056_add_foreign_keys_to_tod describe AddForeignKeysToTodos, :migration do let(:todos) { table(:todos) } - let(:project) { create(:project) } - let(:user) { create(:user) } + let(:project) { create(:project) } # rubocop:disable RSpec/FactoriesInMigrationSpecs + let(:user) { create(:user) } # rubocop:disable RSpec/FactoriesInMigrationSpecs context 'add foreign key on user_id' do let!(:todo_with_user) { create_todo(user_id: user.id) } @@ -34,7 +34,7 @@ describe AddForeignKeysToTodos, :migration do end context 'add foreign key on note_id' do - let(:note) { create(:note) } + let(:note) { create(:note) } # rubocop:disable RSpec/FactoriesInMigrationSpecs let!(:todo_with_note) { create_todo(note_id: note.id) } let!(:todo_with_invalid_note) { create_todo(note_id: 4711) } let!(:todo_without_note) { create_todo(note_id: nil) } diff --git a/spec/migrations/add_head_pipeline_for_each_merge_request_spec.rb b/spec/migrations/add_head_pipeline_for_each_merge_request_spec.rb index 63defcb39bf..d8dd7a2fb83 100644 --- a/spec/migrations/add_head_pipeline_for_each_merge_request_spec.rb +++ b/spec/migrations/add_head_pipeline_for_each_merge_request_spec.rb @@ -6,18 +6,18 @@ describe AddHeadPipelineForEachMergeRequest, :delete do let(:migration) { described_class.new } - let!(:project) { create(:project) } + let!(:project) { create(:project) } # rubocop:disable RSpec/FactoriesInMigrationSpecs let!(:other_project) { fork_project(project) } - let!(:pipeline_1) { create(:ci_pipeline, project: project, ref: "branch_1") } - let!(:pipeline_2) { create(:ci_pipeline, project: other_project, ref: "branch_1") } - let!(:pipeline_3) { create(:ci_pipeline, project: other_project, ref: "branch_1") } - let!(:pipeline_4) { create(:ci_pipeline, project: project, ref: "branch_2") } + let!(:pipeline_1) { create(:ci_pipeline, project: project, ref: "branch_1") } # rubocop:disable RSpec/FactoriesInMigrationSpecs + let!(:pipeline_2) { create(:ci_pipeline, project: other_project, ref: "branch_1") } # rubocop:disable RSpec/FactoriesInMigrationSpecs + let!(:pipeline_3) { create(:ci_pipeline, project: other_project, ref: "branch_1") } # rubocop:disable RSpec/FactoriesInMigrationSpecs + let!(:pipeline_4) { create(:ci_pipeline, project: project, ref: "branch_2") } # rubocop:disable RSpec/FactoriesInMigrationSpecs - let!(:mr_1) { create(:merge_request, source_project: project, target_project: project, source_branch: "branch_1", target_branch: "target_1") } - let!(:mr_2) { create(:merge_request, source_project: other_project, target_project: project, source_branch: "branch_1", target_branch: "target_2") } - let!(:mr_3) { create(:merge_request, source_project: project, target_project: project, source_branch: "branch_2", target_branch: "master") } - let!(:mr_4) { create(:merge_request, source_project: project, target_project: project, source_branch: "branch_3", target_branch: "master") } + let!(:mr_1) { create(:merge_request, source_project: project, target_project: project, source_branch: "branch_1", target_branch: "target_1") } # rubocop:disable RSpec/FactoriesInMigrationSpecs + let!(:mr_2) { create(:merge_request, source_project: other_project, target_project: project, source_branch: "branch_1", target_branch: "target_2") } # rubocop:disable RSpec/FactoriesInMigrationSpecs + let!(:mr_3) { create(:merge_request, source_project: project, target_project: project, source_branch: "branch_2", target_branch: "master") } # rubocop:disable RSpec/FactoriesInMigrationSpecs + let!(:mr_4) { create(:merge_request, source_project: project, target_project: project, source_branch: "branch_3", target_branch: "master") } # rubocop:disable RSpec/FactoriesInMigrationSpecs context "#up" do context "when source_project and source_branch of pipeline are the same of merge request" do diff --git a/spec/migrations/calculate_conv_dev_index_percentages_spec.rb b/spec/migrations/calculate_conv_dev_index_percentages_spec.rb index f3a46025376..19f06810e54 100644 --- a/spec/migrations/calculate_conv_dev_index_percentages_spec.rb +++ b/spec/migrations/calculate_conv_dev_index_percentages_spec.rb @@ -6,7 +6,7 @@ require Rails.root.join('db', 'post_migrate', '20170803090603_calculate_conv_dev describe CalculateConvDevIndexPercentages, :delete do let(:migration) { described_class.new } let!(:conv_dev_index) do - create(:conversational_development_index_metric, + create(:conversational_development_index_metric, # rubocop:disable RSpec/FactoriesInMigrationSpecs leader_notes: 0, instance_milestones: 0, percentage_issues: 0, diff --git a/spec/migrations/cleanup_namespaceless_pending_delete_projects_spec.rb b/spec/migrations/cleanup_namespaceless_pending_delete_projects_spec.rb index 033d0e7584d..b5980cb9ddb 100644 --- a/spec/migrations/cleanup_namespaceless_pending_delete_projects_spec.rb +++ b/spec/migrations/cleanup_namespaceless_pending_delete_projects_spec.rb @@ -10,9 +10,9 @@ describe CleanupNamespacelessPendingDeleteProjects, :migration, schema: 20180222 describe '#up' do it 'only cleans up pending delete projects' do - create(:project) - create(:project, pending_delete: true) - project = build(:project, pending_delete: true, namespace_id: nil) + create(:project) # rubocop:disable RSpec/FactoriesInMigrationSpecs + create(:project, pending_delete: true) # rubocop:disable RSpec/FactoriesInMigrationSpecs + project = build(:project, pending_delete: true, namespace_id: nil) # rubocop:disable RSpec/FactoriesInMigrationSpecs project.save(validate: false) expect(NamespacelessProjectDestroyWorker).to receive(:bulk_perform_async).with([[project.id]]) @@ -21,8 +21,8 @@ describe CleanupNamespacelessPendingDeleteProjects, :migration, schema: 20180222 end it 'does nothing when no pending delete projects without namespace found' do - create(:project) - create(:project, pending_delete: true) + create(:project) # rubocop:disable RSpec/FactoriesInMigrationSpecs + create(:project, pending_delete: true) # rubocop:disable RSpec/FactoriesInMigrationSpecs expect(NamespacelessProjectDestroyWorker).not_to receive(:bulk_perform_async) diff --git a/spec/migrations/cleanup_nonexisting_namespace_pending_delete_projects_spec.rb b/spec/migrations/cleanup_nonexisting_namespace_pending_delete_projects_spec.rb index 7879105a334..8f40ac3e38b 100644 --- a/spec/migrations/cleanup_nonexisting_namespace_pending_delete_projects_spec.rb +++ b/spec/migrations/cleanup_nonexisting_namespace_pending_delete_projects_spec.rb @@ -9,11 +9,11 @@ describe CleanupNonexistingNamespacePendingDeleteProjects do end describe '#up' do - set(:some_project) { create(:project) } + set(:some_project) { create(:project) } # rubocop:disable RSpec/FactoriesInMigrationSpecs it 'only cleans up when namespace does not exist' do - create(:project, pending_delete: true) - project = build(:project, pending_delete: true, namespace: nil, namespace_id: Namespace.maximum(:id).to_i.succ) + create(:project, pending_delete: true) # rubocop:disable RSpec/FactoriesInMigrationSpecs + project = build(:project, pending_delete: true, namespace: nil, namespace_id: Namespace.maximum(:id).to_i.succ) # rubocop:disable RSpec/FactoriesInMigrationSpecs project.save(validate: false) expect(NamespacelessProjectDestroyWorker).to receive(:bulk_perform_async).with([[project.id]]) @@ -22,7 +22,7 @@ describe CleanupNonexistingNamespacePendingDeleteProjects do end it 'does nothing when no pending delete projects without namespace found' do - create(:project, pending_delete: true, namespace: create(:namespace)) + create(:project, pending_delete: true, namespace: create(:namespace)) # rubocop:disable RSpec/FactoriesInMigrationSpecs expect(NamespacelessProjectDestroyWorker).not_to receive(:bulk_perform_async) diff --git a/spec/migrations/issues_moved_to_id_foreign_key_spec.rb b/spec/migrations/issues_moved_to_id_foreign_key_spec.rb index d2eef81f396..dd2b08099f2 100644 --- a/spec/migrations/issues_moved_to_id_foreign_key_spec.rb +++ b/spec/migrations/issues_moved_to_id_foreign_key_spec.rb @@ -5,9 +5,9 @@ require Rails.root.join('db', 'migrate', '20171106151218_issues_moved_to_id_fore # only_mirror_protected_branches column in the projects table to create a # project via FactoryBot. describe IssuesMovedToIdForeignKey, :migration, schema: 20171114150259 do - let!(:issue_first) { create(:issue, moved_to_id: issue_second.id) } - let!(:issue_second) { create(:issue, moved_to_id: issue_third.id) } - let!(:issue_third) { create(:issue) } + let!(:issue_first) { create(:issue, moved_to_id: issue_second.id) } # rubocop:disable RSpec/FactoriesInMigrationSpecs + let!(:issue_second) { create(:issue, moved_to_id: issue_third.id) } # rubocop:disable RSpec/FactoriesInMigrationSpecs + let!(:issue_third) { create(:issue) } # rubocop:disable RSpec/FactoriesInMigrationSpecs subject { described_class.new } diff --git a/spec/migrations/migrate_gcp_clusters_to_new_clusters_architectures_spec.rb b/spec/migrations/migrate_gcp_clusters_to_new_clusters_architectures_spec.rb index c81ec887ded..df009cec25c 100644 --- a/spec/migrations/migrate_gcp_clusters_to_new_clusters_architectures_spec.rb +++ b/spec/migrations/migrate_gcp_clusters_to_new_clusters_architectures_spec.rb @@ -4,8 +4,24 @@ require Rails.root.join('db', 'post_migrate', '20171013104327_migrate_gcp_cluste describe MigrateGcpClustersToNewClustersArchitectures, :migration do let(:projects) { table(:projects) } let(:project) { projects.create } - let(:user) { create(:user) } - let(:service) { create(:kubernetes_service, project_id: project.id) } + let(:users) { table(:users) } + let(:user) { users.create! } + let(:service) { GcpMigrationSpec::KubernetesService.create!(project_id: project.id) } + + module GcpMigrationSpec + class KubernetesService < ActiveRecord::Base + self.table_name = 'services' + + serialize :properties, JSON # rubocop:disable Cop/ActiveRecordSerialize + + default_value_for :active, true + default_value_for :type, 'KubernetesService' + default_value_for :properties, { + api_url: 'https://kubernetes.example.com', + token: 'a' * 40 + } + end + end context 'when cluster is being created' do let(:project_id) { project.id } diff --git a/spec/migrations/migrate_old_artifacts_spec.rb b/spec/migrations/migrate_old_artifacts_spec.rb index 638b2853374..4187ab149a5 100644 --- a/spec/migrations/migrate_old_artifacts_spec.rb +++ b/spec/migrations/migrate_old_artifacts_spec.rb @@ -16,18 +16,18 @@ describe MigrateOldArtifacts do end context 'with migratable data' do - set(:project1) { create(:project, ci_id: 2) } - set(:project2) { create(:project, ci_id: 3) } - set(:project3) { create(:project) } - - set(:pipeline1) { create(:ci_empty_pipeline, project: project1) } - set(:pipeline2) { create(:ci_empty_pipeline, project: project2) } - set(:pipeline3) { create(:ci_empty_pipeline, project: project3) } - - let!(:build_with_legacy_artifacts) { create(:ci_build, pipeline: pipeline1) } - let!(:build_without_artifacts) { create(:ci_build, pipeline: pipeline1) } - let!(:build2) { create(:ci_build, pipeline: pipeline2) } - let!(:build3) { create(:ci_build, pipeline: pipeline3) } + set(:project1) { create(:project, ci_id: 2) } # rubocop:disable RSpec/FactoriesInMigrationSpecs + set(:project2) { create(:project, ci_id: 3) } # rubocop:disable RSpec/FactoriesInMigrationSpecs + set(:project3) { create(:project) } # rubocop:disable RSpec/FactoriesInMigrationSpecs + + set(:pipeline1) { create(:ci_empty_pipeline, project: project1) } # rubocop:disable RSpec/FactoriesInMigrationSpecs + set(:pipeline2) { create(:ci_empty_pipeline, project: project2) } # rubocop:disable RSpec/FactoriesInMigrationSpecs + set(:pipeline3) { create(:ci_empty_pipeline, project: project3) } # rubocop:disable RSpec/FactoriesInMigrationSpecs + + let!(:build_with_legacy_artifacts) { create(:ci_build, pipeline: pipeline1) } # rubocop:disable RSpec/FactoriesInMigrationSpecs + let!(:build_without_artifacts) { create(:ci_build, pipeline: pipeline1) } # rubocop:disable RSpec/FactoriesInMigrationSpecs + let!(:build2) { create(:ci_build, pipeline: pipeline2) } # rubocop:disable RSpec/FactoriesInMigrationSpecs + let!(:build3) { create(:ci_build, pipeline: pipeline3) } # rubocop:disable RSpec/FactoriesInMigrationSpecs before do setup_builds(build2, build3) diff --git a/spec/migrations/migrate_process_commit_worker_jobs_spec.rb b/spec/migrations/migrate_process_commit_worker_jobs_spec.rb index 657113812bd..4ee1d255fbd 100644 --- a/spec/migrations/migrate_process_commit_worker_jobs_spec.rb +++ b/spec/migrations/migrate_process_commit_worker_jobs_spec.rb @@ -4,8 +4,8 @@ require 'spec_helper' require Rails.root.join('db', 'migrate', '20161124141322_migrate_process_commit_worker_jobs.rb') describe MigrateProcessCommitWorkerJobs do - let(:project) { create(:project, :legacy_storage, :repository) } - let(:user) { create(:user) } + let(:project) { create(:project, :legacy_storage, :repository) } # rubocop:disable RSpec/FactoriesInMigrationSpecs + let(:user) { create(:user) } # rubocop:disable RSpec/FactoriesInMigrationSpecs let(:commit) { project.commit.raw.rugged_commit } describe 'Project' do diff --git a/spec/migrations/migrate_user_activities_to_users_last_activity_on_spec.rb b/spec/migrations/migrate_user_activities_to_users_last_activity_on_spec.rb index a17c9c72bde..99173708190 100644 --- a/spec/migrations/migrate_user_activities_to_users_last_activity_on_spec.rb +++ b/spec/migrations/migrate_user_activities_to_users_last_activity_on_spec.rb @@ -5,8 +5,8 @@ require Rails.root.join('db', 'post_migrate', '20170324160416_migrate_user_activ describe MigrateUserActivitiesToUsersLastActivityOn, :clean_gitlab_redis_shared_state, :delete do let(:migration) { described_class.new } - let!(:user_active_1) { create(:user) } - let!(:user_active_2) { create(:user) } + let!(:user_active_1) { create(:user) } # rubocop:disable RSpec/FactoriesInMigrationSpecs + let!(:user_active_2) { create(:user) } # rubocop:disable RSpec/FactoriesInMigrationSpecs def record_activity(user, time) Gitlab::Redis::SharedState.with do |redis| diff --git a/spec/migrations/migrate_user_project_view_spec.rb b/spec/migrations/migrate_user_project_view_spec.rb index 31d16e17d7b..80468b9d01e 100644 --- a/spec/migrations/migrate_user_project_view_spec.rb +++ b/spec/migrations/migrate_user_project_view_spec.rb @@ -5,7 +5,7 @@ require Rails.root.join('db', 'post_migrate', '20170406142253_migrate_user_proje describe MigrateUserProjectView, :delete do let(:migration) { described_class.new } - let!(:user) { create(:user, project_view: 'readme') } + let!(:user) { create(:user, project_view: 'readme') } # rubocop:disable RSpec/FactoriesInMigrationSpecs describe '#up' do it 'updates project view setting with new value' do diff --git a/spec/migrations/move_personal_snippets_files_spec.rb b/spec/migrations/move_personal_snippets_files_spec.rb index 1a319eccc0d..1f39ad98fb8 100644 --- a/spec/migrations/move_personal_snippets_files_spec.rb +++ b/spec/migrations/move_personal_snippets_files_spec.rb @@ -16,14 +16,14 @@ describe MovePersonalSnippetsFiles do describe "#up" do let(:snippet) do - snippet = create(:personal_snippet) + snippet = create(:personal_snippet) # rubocop:disable RSpec/FactoriesInMigrationSpecs create_upload('picture.jpg', snippet) snippet.update(description: markdown_linking_file('picture.jpg', snippet)) snippet end let(:snippet_with_missing_file) do - snippet = create(:snippet) + snippet = create(:snippet) # rubocop:disable RSpec/FactoriesInMigrationSpecs create_upload('picture.jpg', snippet, create_file: false) snippet.update(description: markdown_linking_file('picture.jpg', snippet)) snippet @@ -62,7 +62,7 @@ describe MovePersonalSnippetsFiles do secret = "secret#{snippet.id}" file_location = "/uploads/-/system/personal_snippet/#{snippet.id}/#{secret}/picture.jpg" markdown = markdown_linking_file('picture.jpg', snippet) - note = create(:note_on_personal_snippet, noteable: snippet, note: "with #{markdown}") + note = create(:note_on_personal_snippet, noteable: snippet, note: "with #{markdown}") # rubocop:disable RSpec/FactoriesInMigrationSpecs migration.up @@ -73,14 +73,14 @@ describe MovePersonalSnippetsFiles do describe "#down" do let(:snippet) do - snippet = create(:personal_snippet) + snippet = create(:personal_snippet) # rubocop:disable RSpec/FactoriesInMigrationSpecs create_upload('picture.jpg', snippet, in_new_path: true) snippet.update(description: markdown_linking_file('picture.jpg', snippet, in_new_path: true)) snippet end let(:snippet_with_missing_file) do - snippet = create(:personal_snippet) + snippet = create(:personal_snippet) # rubocop:disable RSpec/FactoriesInMigrationSpecs create_upload('picture.jpg', snippet, create_file: false, in_new_path: true) snippet.update(description: markdown_linking_file('picture.jpg', snippet, in_new_path: true)) snippet @@ -119,7 +119,7 @@ describe MovePersonalSnippetsFiles do markdown = markdown_linking_file('picture.jpg', snippet, in_new_path: true) secret = "secret#{snippet.id}" file_location = "/uploads/personal_snippet/#{snippet.id}/#{secret}/picture.jpg" - note = create(:note_on_personal_snippet, noteable: snippet, note: "with #{markdown}") + note = create(:note_on_personal_snippet, noteable: snippet, note: "with #{markdown}") # rubocop:disable RSpec/FactoriesInMigrationSpecs migration.down @@ -135,7 +135,7 @@ describe MovePersonalSnippetsFiles do secret = '123456789' filename = 'hello.jpg' - snippet = create(:personal_snippet) + snippet = create(:personal_snippet) # rubocop:disable RSpec/FactoriesInMigrationSpecs path_before = "/uploads/personal_snippet/#{snippet.id}/#{secret}/#{filename}" path_after = "/uploads/system/personal_snippet/#{snippet.id}/#{secret}/#{filename}" @@ -161,7 +161,7 @@ describe MovePersonalSnippetsFiles do FileUtils.touch(absolute_path) end - create(:upload, model: snippet, path: "#{secret}/#{filename}", uploader: PersonalFileUploader) + create(:upload, model: snippet, path: "#{secret}/#{filename}", uploader: PersonalFileUploader) # rubocop:disable RSpec/FactoriesInMigrationSpecs end def markdown_linking_file(filename, snippet, in_new_path: false) diff --git a/spec/migrations/remove_dot_git_from_usernames_spec.rb b/spec/migrations/remove_dot_git_from_usernames_spec.rb index 3a88a66a476..f11880a83e9 100644 --- a/spec/migrations/remove_dot_git_from_usernames_spec.rb +++ b/spec/migrations/remove_dot_git_from_usernames_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require Rails.root.join('db', 'migrate', '20161226122833_remove_dot_git_from_usernames.rb') describe RemoveDotGitFromUsernames do - let(:user) { create(:user) } + let(:user) { create(:user) } # rubocop:disable RSpec/FactoriesInMigrationSpecs let(:migration) { described_class.new } describe '#up' do @@ -23,7 +23,7 @@ describe RemoveDotGitFromUsernames do context 'when new path exists already' do describe '#up' do - let(:user2) { create(:user) } + let(:user2) { create(:user) } # rubocop:disable RSpec/FactoriesInMigrationSpecs before do update_namespace(user, 'test.git') diff --git a/spec/migrations/remove_duplicate_mr_events_spec.rb b/spec/migrations/remove_duplicate_mr_events_spec.rb index e51872239ad..2509ac6afd6 100644 --- a/spec/migrations/remove_duplicate_mr_events_spec.rb +++ b/spec/migrations/remove_duplicate_mr_events_spec.rb @@ -5,17 +5,17 @@ describe RemoveDuplicateMrEvents, :delete do let(:migration) { described_class.new } describe '#up' do - let(:user) { create(:user) } - let(:merge_requests) { create_list(:merge_request, 2) } - let(:issue) { create(:issue) } + let(:user) { create(:user) } # rubocop:disable RSpec/FactoriesInMigrationSpecs + let(:merge_requests) { create_list(:merge_request, 2) } # rubocop:disable RSpec/FactoriesInMigrationSpecs + let(:issue) { create(:issue) } # rubocop:disable RSpec/FactoriesInMigrationSpecs let!(:events) do [ - create(:event, :created, author: user, target: merge_requests.first), - create(:event, :created, author: user, target: merge_requests.first), - create(:event, :updated, author: user, target: merge_requests.first), - create(:event, :created, author: user, target: merge_requests.second), - create(:event, :created, author: user, target: issue), - create(:event, :created, author: user, target: issue) + create(:event, :created, author: user, target: merge_requests.first), # rubocop:disable RSpec/FactoriesInMigrationSpecs + create(:event, :created, author: user, target: merge_requests.first), # rubocop:disable RSpec/FactoriesInMigrationSpecs + create(:event, :updated, author: user, target: merge_requests.first), # rubocop:disable RSpec/FactoriesInMigrationSpecs + create(:event, :created, author: user, target: merge_requests.second), # rubocop:disable RSpec/FactoriesInMigrationSpecs + create(:event, :created, author: user, target: issue), # rubocop:disable RSpec/FactoriesInMigrationSpecs + create(:event, :created, author: user, target: issue) # rubocop:disable RSpec/FactoriesInMigrationSpecs ] end diff --git a/spec/migrations/remove_project_labels_group_id_spec.rb b/spec/migrations/remove_project_labels_group_id_spec.rb index d80d61af20b..01b09e71d83 100644 --- a/spec/migrations/remove_project_labels_group_id_spec.rb +++ b/spec/migrations/remove_project_labels_group_id_spec.rb @@ -5,9 +5,9 @@ require Rails.root.join('db', 'post_migrate', '20180202111106_remove_project_lab describe RemoveProjectLabelsGroupId, :delete do let(:migration) { described_class.new } - let(:group) { create(:group) } - let!(:project_label) { create(:label, group_id: group.id) } - let!(:group_label) { create(:group_label) } + let(:group) { create(:group) } # rubocop:disable RSpec/FactoriesInMigrationSpecs + let!(:project_label) { create(:label, group_id: group.id) } # rubocop:disable RSpec/FactoriesInMigrationSpecs + let!(:group_label) { create(:group_label) } # rubocop:disable RSpec/FactoriesInMigrationSpecs describe '#up' do it 'updates the project labels group ID' do diff --git a/spec/migrations/remove_soft_removed_objects_spec.rb b/spec/migrations/remove_soft_removed_objects_spec.rb index ec089f9106d..fb70c284f5e 100644 --- a/spec/migrations/remove_soft_removed_objects_spec.rb +++ b/spec/migrations/remove_soft_removed_objects_spec.rb @@ -8,7 +8,7 @@ describe RemoveSoftRemovedObjects, :migration do create_with_deleted_at(:issue) end - regular_issue = create(:issue) + regular_issue = create(:issue) # rubocop:disable RSpec/FactoriesInMigrationSpecs run_migration @@ -28,7 +28,7 @@ describe RemoveSoftRemovedObjects, :migration do it 'removes routes of soft removed personal namespaces' do namespace = create_with_deleted_at(:namespace) - group = create(:group) + group = create(:group) # rubocop:disable RSpec/FactoriesInMigrationSpecs expect(Route.where(source: namespace).exists?).to eq(true) expect(Route.where(source: group).exists?).to eq(true) @@ -41,7 +41,7 @@ describe RemoveSoftRemovedObjects, :migration do it 'schedules the removal of soft removed groups' do group = create_with_deleted_at(:group) - admin = create(:user, admin: true) + admin = create(:user, admin: true) # rubocop:disable RSpec/FactoriesInMigrationSpecs expect_any_instance_of(GroupDestroyWorker) .to receive(:perform) @@ -67,7 +67,7 @@ describe RemoveSoftRemovedObjects, :migration do end def create_with_deleted_at(*args) - row = create(*args) + row = create(*args) # rubocop:disable RSpec/FactoriesInMigrationSpecs # We set "deleted_at" this way so we don't run into any column cache issues. row.class.where(id: row.id).update_all(deleted_at: 1.year.ago) diff --git a/spec/migrations/rename_more_reserved_project_names_spec.rb b/spec/migrations/rename_more_reserved_project_names_spec.rb index 75310075cc5..034e8a6a4e5 100644 --- a/spec/migrations/rename_more_reserved_project_names_spec.rb +++ b/spec/migrations/rename_more_reserved_project_names_spec.rb @@ -8,7 +8,7 @@ require Rails.root.join('db', 'post_migrate', '20170313133418_rename_more_reserv # around this we use the DELETE cleaning strategy. describe RenameMoreReservedProjectNames, :delete do let(:migration) { described_class.new } - let!(:project) { create(:project) } + let!(:project) { create(:project) } # rubocop:disable RSpec/FactoriesInMigrationSpecs before do project.path = 'artifacts' diff --git a/spec/migrations/rename_reserved_project_names_spec.rb b/spec/migrations/rename_reserved_project_names_spec.rb index 34336d705b1..592ac2b5fb9 100644 --- a/spec/migrations/rename_reserved_project_names_spec.rb +++ b/spec/migrations/rename_reserved_project_names_spec.rb @@ -12,7 +12,7 @@ require Rails.root.join('db', 'post_migrate', '20161221153951_rename_reserved_pr # Ideally, the test should not use factories and rely on the `table` helper instead. describe RenameReservedProjectNames, :migration, schema: :latest do let(:migration) { described_class.new } - let!(:project) { create(:project) } + let!(:project) { create(:project) } # rubocop:disable RSpec/FactoriesInMigrationSpecs before do project.path = 'projects' diff --git a/spec/migrations/rename_users_with_renamed_namespace_spec.rb b/spec/migrations/rename_users_with_renamed_namespace_spec.rb index cbc0ebeb44d..b8a4dc2b2c0 100644 --- a/spec/migrations/rename_users_with_renamed_namespace_spec.rb +++ b/spec/migrations/rename_users_with_renamed_namespace_spec.rb @@ -3,13 +3,13 @@ require Rails.root.join('db', 'post_migrate', '20170518200835_rename_users_with_ describe RenameUsersWithRenamedNamespace, :delete do it 'renames a user that had their namespace renamed to the namespace path' do - other_user = create(:user, username: 'kodingu') - other_user1 = create(:user, username: 'api0') + other_user = create(:user, username: 'kodingu') # rubocop:disable RSpec/FactoriesInMigrationSpecs + other_user1 = create(:user, username: 'api0') # rubocop:disable RSpec/FactoriesInMigrationSpecs - user = create(:user, username: "Users0") - user.update_attribute(:username, 'Users') - user1 = create(:user, username: "import0") - user1.update_attribute(:username, 'import') + user = create(:user, username: "Users0") # rubocop:disable RSpec/FactoriesInMigrationSpecs + user.update_column(:username, 'Users') + user1 = create(:user, username: "import0") # rubocop:disable RSpec/FactoriesInMigrationSpecs + user1.update_column(:username, 'import') described_class.new.up diff --git a/spec/migrations/schedule_build_stage_migration_spec.rb b/spec/migrations/reschedule_builds_stages_migration_spec.rb index e2ca35447fb..3bfd9dd9f6b 100644 --- a/spec/migrations/schedule_build_stage_migration_spec.rb +++ b/spec/migrations/reschedule_builds_stages_migration_spec.rb @@ -1,7 +1,8 @@ require 'spec_helper' -require Rails.root.join('db', 'post_migrate', '20180212101928_schedule_build_stage_migration') +require Rails.root.join('db', 'post_migrate', '20180405101928_reschedule_builds_stages_migration') -describe ScheduleBuildStageMigration, :sidekiq, :migration do +describe RescheduleBuildsStagesMigration, :sidekiq, :migration do + let(:namespaces) { table(:namespaces) } let(:projects) { table(:projects) } let(:pipelines) { table(:ci_pipelines) } let(:stages) { table(:ci_stages) } @@ -10,7 +11,8 @@ describe ScheduleBuildStageMigration, :sidekiq, :migration do before do stub_const("#{described_class}::BATCH_SIZE", 1) - projects.create!(id: 123, name: 'gitlab', path: 'gitlab-ce') + namespaces.create(id: 12, name: 'gitlab-org', path: 'gitlab-org') + projects.create!(id: 123, namespace_id: 12, name: 'gitlab', path: 'gitlab') pipelines.create!(id: 1, project_id: 123, ref: 'master', sha: 'adf43c3a') stages.create!(id: 1, project_id: 123, pipeline_id: 1, name: 'test') diff --git a/spec/migrations/schedule_create_gpg_key_subkeys_from_gpg_keys_spec.rb b/spec/migrations/schedule_create_gpg_key_subkeys_from_gpg_keys_spec.rb index 65ec07da31c..ed306fb3d62 100644 --- a/spec/migrations/schedule_create_gpg_key_subkeys_from_gpg_keys_spec.rb +++ b/spec/migrations/schedule_create_gpg_key_subkeys_from_gpg_keys_spec.rb @@ -3,8 +3,8 @@ require Rails.root.join('db', 'post_migrate', '20171005130944_schedule_create_gp describe ScheduleCreateGpgKeySubkeysFromGpgKeys, :migration, :sidekiq do before do - create(:gpg_key, id: 1, key: GpgHelpers::User1.public_key) - create(:gpg_key, id: 2, key: GpgHelpers::User3.public_key) + create(:gpg_key, id: 1, key: GpgHelpers::User1.public_key) # rubocop:disable RSpec/FactoriesInMigrationSpecs + create(:gpg_key, id: 2, key: GpgHelpers::User3.public_key) # rubocop:disable RSpec/FactoriesInMigrationSpecs # Delete all subkeys so they can be recreated GpgKeySubkey.destroy_all end diff --git a/spec/migrations/schedule_populate_merge_request_metrics_with_events_data_spec.rb b/spec/migrations/schedule_populate_merge_request_metrics_with_events_data_spec.rb index 7494624066a..578440cba20 100644 --- a/spec/migrations/schedule_populate_merge_request_metrics_with_events_data_spec.rb +++ b/spec/migrations/schedule_populate_merge_request_metrics_with_events_data_spec.rb @@ -8,7 +8,7 @@ describe SchedulePopulateMergeRequestMetricsWithEventsData, :migration, :sidekiq .to receive(:commits_count=).and_return(nil) end - let!(:mrs) { create_list(:merge_request, 3) } + let!(:mrs) { create_list(:merge_request, 3) } # rubocop:disable RSpec/FactoriesInMigrationSpecs it 'correctly schedules background migrations' do stub_const("#{described_class.name}::BATCH_SIZE", 2) diff --git a/spec/migrations/schedule_set_confidential_note_events_on_webhooks_spec.rb b/spec/migrations/schedule_set_confidential_note_events_on_webhooks_spec.rb new file mode 100644 index 00000000000..027f4a91c90 --- /dev/null +++ b/spec/migrations/schedule_set_confidential_note_events_on_webhooks_spec.rb @@ -0,0 +1,44 @@ +require 'spec_helper' +require Rails.root.join('db', 'post_migrate', '20180104131052_schedule_set_confidential_note_events_on_webhooks.rb') + +describe ScheduleSetConfidentialNoteEventsOnWebhooks, :migration, :sidekiq do + let(:web_hooks_table) { table(:web_hooks) } + let(:migration_class) { Gitlab::BackgroundMigration::SetConfidentialNoteEventsOnWebhooks } + let(:migration_name) { migration_class.to_s.demodulize } + + let!(:web_hook_1) { web_hooks_table.create!(confidential_note_events: nil, note_events: true) } + let!(:web_hook_2) { web_hooks_table.create!(confidential_note_events: nil, note_events: true) } + let!(:web_hook_migrated) { web_hooks_table.create!(confidential_note_events: true, note_events: true) } + let!(:web_hook_skip) { web_hooks_table.create!(confidential_note_events: nil, note_events: false) } + let!(:web_hook_new) { web_hooks_table.create!(confidential_note_events: false, note_events: true) } + let!(:web_hook_4) { web_hooks_table.create!(confidential_note_events: nil, note_events: true) } + + before do + stub_const("#{described_class}::BATCH_SIZE", 1) + end + + it 'schedules background migrations at correct time' do + Sidekiq::Testing.fake! do + Timecop.freeze do + migrate! + + expect(migration_name).to be_scheduled_delayed_migration(5.minutes, web_hook_1.id, web_hook_1.id) + expect(migration_name).to be_scheduled_delayed_migration(10.minutes, web_hook_2.id, web_hook_2.id) + expect(migration_name).to be_scheduled_delayed_migration(15.minutes, web_hook_4.id, web_hook_4.id) + expect(BackgroundMigrationWorker.jobs.size).to eq 3 + end + end + end + + it 'correctly processes web hooks' do + Sidekiq::Testing.inline! do + expect(web_hooks_table.where(confidential_note_events: nil).count).to eq 4 + expect(web_hooks_table.where(confidential_note_events: true).count).to eq 1 + + migrate! + + expect(web_hooks_table.where(confidential_note_events: nil).count).to eq 1 + expect(web_hooks_table.where(confidential_note_events: true).count).to eq 4 + end + end +end diff --git a/spec/migrations/turn_nested_groups_into_regular_groups_for_mysql_spec.rb b/spec/migrations/turn_nested_groups_into_regular_groups_for_mysql_spec.rb index 528dc54781d..560409f08de 100644 --- a/spec/migrations/turn_nested_groups_into_regular_groups_for_mysql_spec.rb +++ b/spec/migrations/turn_nested_groups_into_regular_groups_for_mysql_spec.rb @@ -2,10 +2,10 @@ require 'spec_helper' require Rails.root.join('db', 'migrate', '20170503140202_turn_nested_groups_into_regular_groups_for_mysql.rb') describe TurnNestedGroupsIntoRegularGroupsForMysql do - let!(:parent_group) { create(:group) } - let!(:child_group) { create(:group, parent: parent_group) } - let!(:project) { create(:project, :legacy_storage, :empty_repo, namespace: child_group) } - let!(:member) { create(:user) } + let!(:parent_group) { create(:group) } # rubocop:disable RSpec/FactoriesInMigrationSpecs + let!(:child_group) { create(:group, parent: parent_group) } # rubocop:disable RSpec/FactoriesInMigrationSpecs + let!(:project) { create(:project, :legacy_storage, :empty_repo, namespace: child_group) } # rubocop:disable RSpec/FactoriesInMigrationSpecs + let!(:member) { create(:user) } # rubocop:disable RSpec/FactoriesInMigrationSpecs let(:migration) { described_class.new } before do diff --git a/spec/migrations/update_retried_for_ci_build_spec.rb b/spec/migrations/update_retried_for_ci_build_spec.rb index ccb77766b84..637dcbb8e01 100644 --- a/spec/migrations/update_retried_for_ci_build_spec.rb +++ b/spec/migrations/update_retried_for_ci_build_spec.rb @@ -2,9 +2,9 @@ require 'spec_helper' require Rails.root.join('db', 'post_migrate', '20170503004427_update_retried_for_ci_build.rb') describe UpdateRetriedForCiBuild, :delete do - let(:pipeline) { create(:ci_pipeline) } - let!(:build_old) { create(:ci_build, pipeline: pipeline, name: 'test') } - let!(:build_new) { create(:ci_build, pipeline: pipeline, name: 'test') } + let(:pipeline) { create(:ci_pipeline) } # rubocop:disable RSpec/FactoriesInMigrationSpecs + let!(:build_old) { create(:ci_build, pipeline: pipeline, name: 'test') } # rubocop:disable RSpec/FactoriesInMigrationSpecs + let!(:build_new) { create(:ci_build, pipeline: pipeline, name: 'test') } # rubocop:disable RSpec/FactoriesInMigrationSpecs before do described_class.new.up diff --git a/spec/models/ci/artifact_blob_spec.rb b/spec/models/ci/artifact_blob_spec.rb index 4e72d9d748e..0014bbcf9f5 100644 --- a/spec/models/ci/artifact_blob_spec.rb +++ b/spec/models/ci/artifact_blob_spec.rb @@ -65,6 +65,19 @@ describe Ci::ArtifactBlob do expect(url).not_to be_nil expect(url).to eq("http://#{project.namespace.path}.#{Gitlab.config.pages.host}/-/#{project.path}/-/jobs/#{build.id}/artifacts/#{path}") end + + context 'when port is configured' do + let(:port) { 1234 } + + it 'returns an URL with port number' do + allow(Gitlab.config.pages).to receive(:url).and_return("#{Gitlab.config.pages.url}:#{port}") + + url = subject.external_url(build.project, build) + + expect(url).not_to be_nil + expect(url).to eq("http://#{project.namespace.path}.#{Gitlab.config.pages.host}:#{port}/-/#{project.path}/-/jobs/#{build.id}/artifacts/#{path}") + end + end end end diff --git a/spec/models/ci/build_metadata_spec.rb b/spec/models/ci/build_metadata_spec.rb index 268561ee941..7e75d5a5411 100644 --- a/spec/models/ci/build_metadata_spec.rb +++ b/spec/models/ci/build_metadata_spec.rb @@ -13,7 +13,7 @@ describe Ci::BuildMetadata do end let(:build) { create(:ci_build, pipeline: pipeline) } - let(:build_metadata) { create(:ci_build_metadata, build: build) } + let(:build_metadata) { build.metadata } describe '#update_timeout_state' do subject { build_metadata } diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index f5534d22a54..a12717835b0 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -1463,24 +1463,24 @@ describe Ci::Build do let(:container_registry_enabled) { false } let(:predefined_variables) do [ + { key: 'CI_JOB_ID', value: build.id.to_s, public: true }, + { key: 'CI_JOB_TOKEN', value: build.token, public: false }, + { key: 'CI_BUILD_ID', value: build.id.to_s, public: true }, + { key: 'CI_BUILD_TOKEN', value: build.token, public: false }, + { key: 'CI_REGISTRY_USER', value: 'gitlab-ci-token', public: true }, + { key: 'CI_REGISTRY_PASSWORD', value: build.token, public: false }, + { key: 'CI_REPOSITORY_URL', value: build.repo_url, public: false }, { key: 'CI', value: 'true', public: true }, { key: 'GITLAB_CI', value: 'true', public: true }, { key: 'GITLAB_FEATURES', value: project.namespace.features.join(','), public: true }, { key: 'CI_SERVER_NAME', value: 'GitLab', public: true }, { key: 'CI_SERVER_VERSION', value: Gitlab::VERSION, public: true }, { key: 'CI_SERVER_REVISION', value: Gitlab::REVISION, public: true }, - { key: 'CI_JOB_ID', value: build.id.to_s, public: true }, { key: 'CI_JOB_NAME', value: 'test', public: true }, { key: 'CI_JOB_STAGE', value: 'test', public: true }, - { key: 'CI_JOB_TOKEN', value: build.token, public: false }, { key: 'CI_COMMIT_SHA', value: build.sha, public: true }, { key: 'CI_COMMIT_REF_NAME', value: build.ref, public: true }, { key: 'CI_COMMIT_REF_SLUG', value: build.ref_slug, public: true }, - { key: 'CI_REGISTRY_USER', value: 'gitlab-ci-token', public: true }, - { key: 'CI_REGISTRY_PASSWORD', value: build.token, public: false }, - { key: 'CI_REPOSITORY_URL', value: build.repo_url, public: false }, - { key: 'CI_BUILD_ID', value: build.id.to_s, public: true }, - { key: 'CI_BUILD_TOKEN', value: build.token, public: false }, { key: 'CI_BUILD_REF', value: build.sha, public: true }, { key: 'CI_BUILD_BEFORE_SHA', value: build.before_sha, public: true }, { key: 'CI_BUILD_REF_NAME', value: build.ref, public: true }, @@ -1945,6 +1945,7 @@ describe Ci::Build do before do allow(build).to receive(:predefined_variables) { [build_pre_var] } allow(build).to receive(:yaml_variables) { [build_yaml_var] } + allow(build).to receive(:persisted_variables) { [] } allow_any_instance_of(Project) .to receive(:predefined_variables) { [project_pre_var] } @@ -1993,6 +1994,106 @@ describe Ci::Build do end end end + + context 'when build has not been persisted yet' do + let(:build) do + described_class.new( + name: 'rspec', + stage: 'test', + ref: 'feature', + project: project, + pipeline: pipeline + ) + end + + it 'returns static predefined variables' do + expect(build.variables.size).to be >= 28 + expect(build.variables) + .to include(key: 'CI_COMMIT_REF_NAME', value: 'feature', public: true) + expect(build).not_to be_persisted + end + end + end + + describe '#scoped_variables' do + context 'when build has not been persisted yet' do + let(:build) do + described_class.new( + name: 'rspec', + stage: 'test', + ref: 'feature', + project: project, + pipeline: pipeline + ) + end + + it 'does not persist the build' do + expect(build).to be_valid + expect(build).not_to be_persisted + + build.scoped_variables + + expect(build).not_to be_persisted + end + + it 'returns static predefined variables' do + keys = %w[CI_JOB_NAME + CI_COMMIT_SHA + CI_COMMIT_REF_NAME + CI_COMMIT_REF_SLUG + CI_JOB_STAGE] + + variables = build.scoped_variables + + variables.map { |env| env[:key] }.tap do |names| + expect(names).to include(*keys) + end + + expect(variables) + .to include(key: 'CI_COMMIT_REF_NAME', value: 'feature', public: true) + end + + it 'does not return prohibited variables' do + keys = %w[CI_JOB_ID + CI_JOB_TOKEN + CI_BUILD_ID + CI_BUILD_TOKEN + CI_REGISTRY_USER + CI_REGISTRY_PASSWORD + CI_REPOSITORY_URL + CI_ENVIRONMENT_URL] + + build.scoped_variables.map { |env| env[:key] }.tap do |names| + expect(names).not_to include(*keys) + end + end + end + end + + describe '#scoped_variables_hash' do + context 'when overriding secret variables' do + before do + project.variables.create!(key: 'MY_VAR', value: 'my value 1') + pipeline.variables.create!(key: 'MY_VAR', value: 'my value 2') + end + + it 'returns a regular hash created using valid ordering' do + expect(build.scoped_variables_hash).to include('MY_VAR': 'my value 2') + expect(build.scoped_variables_hash).not_to include('MY_VAR': 'my value 1') + end + end + + context 'when overriding user-provided variables' do + before do + pipeline.variables.build(key: 'MY_VAR', value: 'pipeline value') + build.yaml_variables = [{ key: 'MY_VAR', value: 'myvar', public: true }] + end + + it 'returns a hash including variable with higher precedence' do + expect(build.scoped_variables_hash).to include('MY_VAR': 'pipeline value') + expect(build.scoped_variables_hash).not_to include('MY_VAR': 'myvar') + end + end end describe 'state transition: any => [:pending]' do diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index 92f00cfbc19..dd94515b0a4 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -346,6 +346,20 @@ describe Ci::Pipeline, :mailer do end end end + + context 'when variables policy is specified' do + let(:config) do + { unit: { script: 'minitest', only: { variables: ['$CI_PIPELINE_SOURCE'] } }, + feature: { script: 'spinach', only: { variables: ['$UNDEFINED'] } } } + end + + it 'returns stage seeds only when variables expression is truthy' do + seeds = pipeline.stage_seeds + + expect(seeds.size).to eq 1 + expect(seeds.dig(0, 0, :name)).to eq 'unit' + end + end end describe '#seeds_size' do diff --git a/spec/models/clusters/applications/helm_spec.rb b/spec/models/clusters/applications/helm_spec.rb index ba7bad617b4..0eb1e3876e2 100644 --- a/spec/models/clusters/applications/helm_spec.rb +++ b/spec/models/clusters/applications/helm_spec.rb @@ -3,6 +3,18 @@ require 'rails_helper' describe Clusters::Applications::Helm do include_examples 'cluster application core specs', :clusters_applications_helm + describe '.installed' do + subject { described_class.installed } + + let!(:cluster) { create(:clusters_applications_helm, :installed) } + + before do + create(:clusters_applications_helm, :errored) + end + + it { is_expected.to contain_exactly(cluster) } + end + describe '#install_command' do let(:helm) { create(:clusters_applications_helm) } diff --git a/spec/models/clusters/applications/ingress_spec.rb b/spec/models/clusters/applications/ingress_spec.rb index 03f5b88a525..a47a07d908d 100644 --- a/spec/models/clusters/applications/ingress_spec.rb +++ b/spec/models/clusters/applications/ingress_spec.rb @@ -11,6 +11,18 @@ describe Clusters::Applications::Ingress do allow(ClusterWaitForIngressIpAddressWorker).to receive(:perform_async) end + describe '.installed' do + subject { described_class.installed } + + let!(:cluster) { create(:clusters_applications_ingress, :installed) } + + before do + create(:clusters_applications_ingress, :errored) + end + + it { is_expected.to contain_exactly(cluster) } + end + describe '#make_installed!' do before do application.make_installed! diff --git a/spec/models/clusters/applications/prometheus_spec.rb b/spec/models/clusters/applications/prometheus_spec.rb index 2905b58066b..aeca6ee903a 100644 --- a/spec/models/clusters/applications/prometheus_spec.rb +++ b/spec/models/clusters/applications/prometheus_spec.rb @@ -4,6 +4,18 @@ describe Clusters::Applications::Prometheus do include_examples 'cluster application core specs', :clusters_applications_prometheus include_examples 'cluster application status specs', :cluster_application_prometheus + describe '.installed' do + subject { described_class.installed } + + let!(:cluster) { create(:clusters_applications_prometheus, :installed) } + + before do + create(:clusters_applications_prometheus, :errored) + end + + it { is_expected.to contain_exactly(cluster) } + end + describe 'transition to installed' do let(:project) { create(:project) } let(:cluster) { create(:cluster, projects: [project]) } diff --git a/spec/models/clusters/applications/runner_spec.rb b/spec/models/clusters/applications/runner_spec.rb index a574779e39d..64d995a73c1 100644 --- a/spec/models/clusters/applications/runner_spec.rb +++ b/spec/models/clusters/applications/runner_spec.rb @@ -8,6 +8,18 @@ describe Clusters::Applications::Runner do it { is_expected.to belong_to(:runner) } + describe '.installed' do + subject { described_class.installed } + + let!(:cluster) { create(:clusters_applications_runner, :installed) } + + before do + create(:clusters_applications_runner, :errored) + end + + it { is_expected.to contain_exactly(cluster) } + end + describe '#install_command' do let(:kubeclient) { double('kubernetes client') } let(:gitlab_runner) { create(:clusters_applications_runner, runner: ci_runner) } diff --git a/spec/models/clusters/cluster_spec.rb b/spec/models/clusters/cluster_spec.rb index 8f12a0e3085..b942554d67b 100644 --- a/spec/models/clusters/cluster_spec.rb +++ b/spec/models/clusters/cluster_spec.rb @@ -39,6 +39,42 @@ describe Clusters::Cluster do it { is_expected.to contain_exactly(cluster) } end + describe '.user_provided' do + subject { described_class.user_provided } + + let!(:cluster) { create(:cluster, :provided_by_user) } + + before do + create(:cluster, :provided_by_gcp) + end + + it { is_expected.to contain_exactly(cluster) } + end + + describe '.gcp_provided' do + subject { described_class.gcp_provided } + + let!(:cluster) { create(:cluster, :provided_by_gcp) } + + before do + create(:cluster, :provided_by_user) + end + + it { is_expected.to contain_exactly(cluster) } + end + + describe '.gcp_installed' do + subject { described_class.gcp_installed } + + let!(:cluster) { create(:cluster, :provided_by_gcp) } + + before do + create(:cluster, :providing_by_gcp) + end + + it { is_expected.to contain_exactly(cluster) } + end + describe 'validation' do subject { cluster.valid? } diff --git a/spec/models/commit_status_spec.rb b/spec/models/commit_status_spec.rb index b7ed8be69fc..c536dab2681 100644 --- a/spec/models/commit_status_spec.rb +++ b/spec/models/commit_status_spec.rb @@ -368,9 +368,7 @@ describe CommitStatus do 'rspec:windows 0 : / 1' => 'rspec:windows', 'rspec:windows 0 : / 1 name' => 'rspec:windows name', '0 1 name ruby' => 'name ruby', - '0 :/ 1 name ruby' => 'name ruby', - 'golang test 1.8' => 'golang test', - '1.9 golang test' => 'golang test' + '0 :/ 1 name ruby' => 'name ruby' } tests.each do |name, group_name| diff --git a/spec/models/concerns/chronic_duration_attribute_spec.rb b/spec/models/concerns/chronic_duration_attribute_spec.rb index 27c86e60e60..8847623f705 100644 --- a/spec/models/concerns/chronic_duration_attribute_spec.rb +++ b/spec/models/concerns/chronic_duration_attribute_spec.rb @@ -63,8 +63,8 @@ shared_examples 'ChronicDurationAttribute writer' do subject.send("#{virtual_field}=", '') end - it 'writes nil' do - expect(subject.send(source_field)).to be_nil + it 'writes default value' do + expect(subject.send(source_field)).to eq(default_value) end it 'passes validation' do @@ -77,8 +77,8 @@ shared_examples 'ChronicDurationAttribute writer' do subject.send("#{virtual_field}=", nil) end - it 'writes nil' do - expect(subject.send(source_field)).to be_nil + it 'writes default value' do + expect(subject.send(source_field)).to eq(default_value) end it 'passes validation' do @@ -92,20 +92,34 @@ shared_examples 'ChronicDurationAttribute writer' do end describe 'ChronicDurationAttribute' do - let(:source_field) {:maximum_timeout} - let(:virtual_field) {:maximum_timeout_human_readable} + context 'when default value is not set' do + let(:source_field) {:maximum_timeout} + let(:virtual_field) {:maximum_timeout_human_readable} + let(:default_value) { nil } - subject { Ci::Runner.new } + subject { create(:ci_runner) } - it_behaves_like 'ChronicDurationAttribute reader' - it_behaves_like 'ChronicDurationAttribute writer' + it_behaves_like 'ChronicDurationAttribute reader' + it_behaves_like 'ChronicDurationAttribute writer' + end + + context 'when default value is set' do + let(:source_field) {:build_timeout} + let(:virtual_field) {:build_timeout_human_readable} + let(:default_value) { 3600 } + + subject { create(:project) } + + it_behaves_like 'ChronicDurationAttribute reader' + it_behaves_like 'ChronicDurationAttribute writer' + end end describe 'ChronicDurationAttribute - reader' do let(:source_field) {:timeout} let(:virtual_field) {:timeout_human_readable} - subject {Ci::BuildMetadata.new} + subject { create(:ci_build).ensure_metadata } it "doesn't contain dynamically created writer method" do expect(subject.class).not_to be_public_method_defined("#{virtual_field}=") diff --git a/spec/models/concerns/issuable_spec.rb b/spec/models/concerns/issuable_spec.rb index f8874d14e3f..05693f067e1 100644 --- a/spec/models/concerns/issuable_spec.rb +++ b/spec/models/concerns/issuable_spec.rb @@ -176,7 +176,7 @@ describe Issuable do end end - describe "#sort" do + describe "#sort_by_attribute" do let(:project) { create(:project) } context "by milestone due date" do @@ -193,12 +193,12 @@ describe Issuable do let!(:issue3) { create(:issue, project: project) } it "sorts desc" do - issues = project.issues.sort('milestone_due_desc') + issues = project.issues.sort_by_attribute('milestone_due_desc') expect(issues).to match_array([issue2, issue1, issue, issue3]) end it "sorts asc" do - issues = project.issues.sort('milestone_due_asc') + issues = project.issues.sort_by_attribute('milestone_due_asc') expect(issues).to match_array([issue1, issue2, issue, issue3]) end end @@ -210,7 +210,7 @@ describe Issuable do it 'has no duplicates across pages' do sorted_issue_ids = 1.upto(10).map do |i| - project.issues.sort('milestone_due_desc').page(i).per(1).first.id + project.issues.sort_by_attribute('milestone_due_desc').page(i).per(1).first.id end expect(sorted_issue_ids).to eq(sorted_issue_ids.uniq) diff --git a/spec/models/deploy_token_spec.rb b/spec/models/deploy_token_spec.rb new file mode 100644 index 00000000000..780b200e837 --- /dev/null +++ b/spec/models/deploy_token_spec.rb @@ -0,0 +1,145 @@ +require 'spec_helper' + +describe DeployToken do + subject(:deploy_token) { create(:deploy_token) } + + it { is_expected.to have_many :project_deploy_tokens } + it { is_expected.to have_many(:projects).through(:project_deploy_tokens) } + + describe '#ensure_token' do + it 'should ensure a token' do + deploy_token.token = nil + deploy_token.save + + expect(deploy_token.token).not_to be_empty + end + end + + describe '#ensure_at_least_one_scope' do + context 'with at least one scope' do + it 'should be valid' do + is_expected.to be_valid + end + end + + context 'with no scopes' do + it 'should be invalid' do + deploy_token = build(:deploy_token, read_repository: false, read_registry: false) + + expect(deploy_token).not_to be_valid + expect(deploy_token.errors[:base].first).to eq("Scopes can't be blank") + end + end + end + + describe '#scopes' do + context 'with all the scopes' do + it 'should return scopes assigned to DeployToken' do + expect(deploy_token.scopes).to eq([:read_repository, :read_registry]) + end + end + + context 'with only one scope' do + it 'should return scopes assigned to DeployToken' do + deploy_token = create(:deploy_token, read_registry: false) + expect(deploy_token.scopes).to eq([:read_repository]) + end + end + end + + describe '#revoke!' do + it 'should update revoke attribute' do + deploy_token.revoke! + expect(deploy_token.revoked?).to be_truthy + end + end + + describe "#active?" do + context "when it has been revoked" do + it 'should return false' do + deploy_token.revoke! + expect(deploy_token.active?).to be_falsy + end + end + + context "when it hasn't been revoked" do + it 'should return true' do + expect(deploy_token.active?).to be_truthy + end + end + end + + describe '#username' do + it 'returns a harcoded username' do + expect(deploy_token.username).to eq("gitlab+deploy-token-#{deploy_token.id}") + end + end + + describe '#has_access_to?' do + let(:project) { create(:project) } + + subject { deploy_token.has_access_to?(project) } + + context 'when deploy token is active and related to project' do + let(:deploy_token) { create(:deploy_token, projects: [project]) } + + it { is_expected.to be_truthy } + end + + context 'when deploy token is active but not related to project' do + let(:deploy_token) { create(:deploy_token) } + + it { is_expected.to be_falsy } + end + + context 'when deploy token is revoked and related to project' do + let(:deploy_token) { create(:deploy_token, :revoked, projects: [project]) } + + it { is_expected.to be_falsy } + end + + context 'when deploy token is revoked and not related to the project' do + let(:deploy_token) { create(:deploy_token, :revoked) } + + it { is_expected.to be_falsy } + end + end + + describe '#expires_at' do + context 'when using Forever.date' do + let(:deploy_token) { create(:deploy_token, expires_at: nil) } + + it 'should return nil' do + expect(deploy_token.expires_at).to be_nil + end + end + + context 'when using a personalized date' do + let(:expires_at) { Date.today + 5.months } + let(:deploy_token) { create(:deploy_token, expires_at: expires_at) } + + it 'should return the personalized date' do + expect(deploy_token.expires_at).to eq(expires_at) + end + end + end + + describe '#expires_at=' do + context 'when passing nil' do + let(:deploy_token) { create(:deploy_token, expires_at: nil) } + + it 'should assign Forever.date' do + expect(deploy_token.read_attribute(:expires_at)).to eq(Forever.date) + end + end + + context 'when passign a value' do + let(:expires_at) { Date.today + 5.months } + let(:deploy_token) { create(:deploy_token, expires_at: expires_at) } + + it 'should respect the value' do + expect(deploy_token.read_attribute(:expires_at)).to eq(expires_at) + end + end + end +end diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb index 412eca4a56b..56161bfcc28 100644 --- a/spec/models/environment_spec.rb +++ b/spec/models/environment_spec.rb @@ -368,6 +368,32 @@ describe Environment do end end + describe '#deployment_platform' do + context 'when there is a deployment platform for environment' do + let!(:cluster) do + create(:cluster, :provided_by_gcp, + environment_scope: '*', projects: [project]) + end + + it 'finds a deployment platform' do + expect(environment.deployment_platform).to eq cluster.platform + end + end + + context 'when there is no deployment platform for environment' do + it 'returns nil' do + expect(environment.deployment_platform).to be_nil + end + end + + it 'checks deployment platforms associated with a project' do + expect(project).to receive(:deployment_platform) + .with(environment: environment.name) + + environment.deployment_platform + end + end + describe '#terminals' do subject { environment.terminals } diff --git a/spec/models/merge_request_diff_commit_spec.rb b/spec/models/merge_request_diff_commit_spec.rb index 7709cf43200..8c01a7ac18f 100644 --- a/spec/models/merge_request_diff_commit_spec.rb +++ b/spec/models/merge_request_diff_commit_spec.rb @@ -36,7 +36,7 @@ describe MergeRequestDiffCommit do "committer_email": "dmitriy.zaporozhets@gmail.com", "merge_request_diff_id": merge_request_diff_id, "relative_order": 0, - "sha": sha_attribute.type_cast_for_database('5937ac0a7beb003549fc5fd26fc247adbce4a52e') + "sha": sha_attribute.serialize("5937ac0a7beb003549fc5fd26fc247adbce4a52e") }, { "message": "Change some files\n\nSigned-off-by: Dmitriy Zaporozhets \u003cdmitriy.zaporozhets@gmail.com\u003e\n", @@ -48,7 +48,7 @@ describe MergeRequestDiffCommit do "committer_email": "dmitriy.zaporozhets@gmail.com", "merge_request_diff_id": merge_request_diff_id, "relative_order": 1, - "sha": sha_attribute.type_cast_for_database('570e7b2abdd848b95f2f578043fc23bd6f6fd24d') + "sha": sha_attribute.serialize("570e7b2abdd848b95f2f578043fc23bd6f6fd24d") } ] end @@ -79,7 +79,7 @@ describe MergeRequestDiffCommit do "committer_email": "alejorro70@gmail.com", "merge_request_diff_id": merge_request_diff_id, "relative_order": 0, - "sha": sha_attribute.type_cast_for_database('ba3343bc4fa403a8dfbfcab7fc1a8c29ee34bd69') + "sha": sha_attribute.serialize("ba3343bc4fa403a8dfbfcab7fc1a8c29ee34bd69") }] end diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index c853f707e6d..86962cd8d61 100644 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -191,6 +191,21 @@ describe Note do end end + describe "confidential?" do + it "delegates to noteable" do + issue_note = build(:note, :on_issue) + confidential_note = build(:note, noteable: create(:issue, confidential: true)) + + expect(issue_note.confidential?).to be_falsy + expect(confidential_note.confidential?).to be_truthy + end + + it "is falsey when noteable can't be confidential" do + commit_note = build(:note_on_commit) + expect(commit_note.confidential?).to be_falsy + end + end + describe "cross_reference_not_visible_for?" do let(:private_user) { create(:user) } let(:private_project) { create(:project, namespace: private_user.namespace) { |p| p.add_master(private_user) } } diff --git a/spec/models/project_deploy_token_spec.rb b/spec/models/project_deploy_token_spec.rb new file mode 100644 index 00000000000..9e2e40c2e8f --- /dev/null +++ b/spec/models/project_deploy_token_spec.rb @@ -0,0 +1,14 @@ +require 'rails_helper' + +RSpec.describe ProjectDeployToken, type: :model do + let(:project) { create(:project) } + let(:deploy_token) { create(:deploy_token) } + subject(:project_deploy_token) { create(:project_deploy_token, project: project, deploy_token: deploy_token) } + + it { is_expected.to belong_to :project } + it { is_expected.to belong_to :deploy_token } + + it { is_expected.to validate_presence_of :deploy_token } + it { is_expected.to validate_presence_of :project } + it { is_expected.to validate_uniqueness_of(:deploy_token_id).scoped_to(:project_id) } +end diff --git a/spec/models/project_services/hipchat_service_spec.rb b/spec/models/project_services/hipchat_service_spec.rb index 3e2a166cdd6..0cd712e2f40 100644 --- a/spec/models/project_services/hipchat_service_spec.rb +++ b/spec/models/project_services/hipchat_service_spec.rb @@ -253,6 +253,21 @@ describe HipchatService do "<b>#{title}</b>" \ "<pre>issue <strong>note</strong></pre>") end + + context 'with confidential issue' do + before do + issue.update!(confidential: true) + end + + it 'calls Hipchat API with issue comment' do + data = Gitlab::DataBuilder::Note.build(issue_note, user) + hipchat.execute(data) + + message = hipchat.send(:create_message, data) + + expect(message).to include("<pre>issue <strong>note</strong></pre>") + end + end end context 'when snippet comment event triggered' do diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 1a7a6e035ea..2675c2f52c1 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -84,6 +84,8 @@ describe Project do it { is_expected.to have_many(:custom_attributes).class_name('ProjectCustomAttribute') } it { is_expected.to have_many(:project_badges).class_name('ProjectBadge') } it { is_expected.to have_many(:lfs_file_locks) } + it { is_expected.to have_many(:project_deploy_tokens) } + it { is_expected.to have_many(:deploy_tokens).through(:project_deploy_tokens) } context 'after initialized' do it "has a project_feature" do @@ -224,14 +226,14 @@ describe Project do project2 = build(:project, import_url: 'http://localhost:9000/t.git') expect(project2).to be_invalid - expect(project2.errors[:import_url]).to include('imports are not allowed from that URL') + expect(project2.errors[:import_url].first).to include('Requests to localhost are not allowed') end it "does not allow blocked import_url port" do project2 = build(:project, import_url: 'http://github.com:25/t.git') expect(project2).to be_invalid - expect(project2.errors[:import_url]).to include('imports are not allowed from that URL') + expect(project2.errors[:import_url].first).to include('Only allowed ports are 22, 80, 443') end describe 'project pending deletion' do @@ -1265,6 +1267,34 @@ describe Project do end end + describe '#pages_group_url' do + let(:group) { create :group, name: group_name } + let(:project) { create :project, namespace: group, name: project_name } + let(:domain) { 'Example.com' } + let(:port) { 1234 } + + subject { project.pages_group_url } + + before do + allow(Settings.pages).to receive(:host).and_return(domain) + allow(Gitlab.config.pages).to receive(:url).and_return("http://example.com:#{port}") + end + + context 'group page' do + let(:group_name) { 'Group' } + let(:project_name) { 'group.example.com' } + + it { is_expected.to eq("http://group.example.com:#{port}") } + end + + context 'project page' do + let(:group_name) { 'Group' } + let(:project_name) { 'Project' } + + it { is_expected.to eq("http://group.example.com:#{port}") } + end + end + describe '.search' do let(:project) { create(:project, description: 'kitten mittens') } @@ -1617,7 +1647,7 @@ describe Project do before do allow_any_instance_of(Gitlab::Shell).to receive(:import_repository) - .with(project.repository_storage_path, project.disk_path, project.import_url) + .with(project.repository_storage, project.disk_path, project.import_url) .and_return(true) expect_any_instance_of(Repository).to receive(:after_import) @@ -1770,10 +1800,7 @@ describe Project do let(:project) { forked_project_link.forked_to_project } it 'schedules a RepositoryForkWorker job' do - expect(RepositoryForkWorker).to receive(:perform_async).with( - project.id, - forked_from_project.repository_storage_path, - forked_from_project.disk_path).and_return(import_jid) + expect(RepositoryForkWorker).to receive(:perform_async).with(project.id).and_return(import_jid) expect(project.add_import_job).to eq(import_jid) end @@ -1997,6 +2024,22 @@ describe Project do expect(forked_project.lfs_storage_project).to eq forked_project end end + + describe '#all_lfs_objects' do + let(:lfs_object) { create(:lfs_object) } + + before do + project.lfs_objects << lfs_object + end + + it 'returns the lfs object for a project' do + expect(project.all_lfs_objects).to contain_exactly(lfs_object) + end + + it 'returns the lfs object for a fork' do + expect(forked_project.all_lfs_objects).to contain_exactly(lfs_object) + end + end end describe '#pushes_since_gc' do @@ -2532,7 +2575,7 @@ describe Project do end end - describe '#remove_exports' do + describe '#remove_export' do let(:legacy_project) { create(:project, :legacy_storage, :with_export) } let(:project) { create(:project, :with_export) } @@ -2580,6 +2623,23 @@ describe Project do end end + describe '#remove_exported_project_file' do + let(:project) { create(:project, :with_export) } + + it 'removes the exported project file' do + exported_file = project.export_project_path + + expect(File.exist?(exported_file)).to be_truthy + + allow(FileUtils).to receive(:rm_f).and_call_original + expect(FileUtils).to receive(:rm_f).with(exported_file).and_call_original + + project.remove_exported_project_file + + expect(File.exist?(exported_file)).to be_falsy + end + end + describe '#forks_count' do it 'returns the number of forks' do project = build(:project) @@ -3185,6 +3245,7 @@ describe Project do expect(project).to receive(:update_project_counter_caches) expect(project).to receive(:remove_import_jid) expect(project).to receive(:after_create_default_branch) + expect(project).to receive(:refresh_markdown_cache!) project.after_import end diff --git a/spec/models/service_spec.rb b/spec/models/service_spec.rb index 83ed3b203e6..28c908ea425 100644 --- a/spec/models/service_spec.rb +++ b/spec/models/service_spec.rb @@ -10,6 +10,22 @@ describe Service do it { is_expected.to validate_presence_of(:type) } end + describe 'Scopes' do + describe '.confidential_note_hooks' do + it 'includes services where confidential_note_events is true' do + create(:service, active: true, confidential_note_events: true) + + expect(described_class.confidential_note_hooks.count).to eq 1 + end + + it 'excludes services where confidential_note_events is false' do + create(:service, active: true, confidential_note_events: false) + + expect(described_class.confidential_note_hooks.count).to eq 0 + end + end + end + describe "Test Button" do describe '#can_test?' do let(:service) { create(:service, project: project) } diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 100418da804..35db7616efb 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1451,7 +1451,7 @@ describe User do end end - describe '#sort' do + describe '#sort_by_attribute' do before do described_class.delete_all @user = create :user, created_at: Date.today, current_sign_in_at: Date.today, name: 'Alpha' @@ -1460,7 +1460,7 @@ describe User do end context 'when sort by recent_sign_in' do - let(:users) { described_class.sort('recent_sign_in') } + let(:users) { described_class.sort_by_attribute('recent_sign_in') } it 'sorts users by recent sign-in time' do expect(users.first).to eq(@user) @@ -1473,7 +1473,7 @@ describe User do end context 'when sort by oldest_sign_in' do - let(:users) { described_class.sort('oldest_sign_in') } + let(:users) { described_class.sort_by_attribute('oldest_sign_in') } it 'sorts users by the oldest sign-in time' do expect(users.first).to eq(@user1) @@ -1486,15 +1486,15 @@ describe User do end it 'sorts users in descending order by their creation time' do - expect(described_class.sort('created_desc').first).to eq(@user) + expect(described_class.sort_by_attribute('created_desc').first).to eq(@user) end it 'sorts users in ascending order by their creation time' do - expect(described_class.sort('created_asc').first).to eq(@user2) + expect(described_class.sort_by_attribute('created_asc').first).to eq(@user2) end it 'sorts users by id in descending order when nil is passed' do - expect(described_class.sort(nil).first).to eq(@user2) + expect(described_class.sort_by_attribute(nil).first).to eq(@user2) end end @@ -1850,6 +1850,21 @@ describe User do it_behaves_like :member end + + context 'with subgroup with different owner for project runner', :nested_groups do + let(:group) { create(:group) } + let(:another_user) { create(:user) } + let(:subgroup) { create(:group, parent: group) } + let(:project) { create(:project, group: subgroup) } + + def add_user(access) + group.add_user(user, access) + group.add_user(another_user, :owner) + subgroup.add_user(another_user, :owner) + end + + it_behaves_like :member + end end describe '#projects_with_reporter_access_limited_to' do @@ -2071,6 +2086,8 @@ describe User do expect(ghost).to be_ghost expect(ghost).to be_persisted + expect(ghost.namespace).not_to be_nil + expect(ghost.namespace).to be_persisted end it "does not create a second ghost user if one is already present" do @@ -2232,6 +2249,20 @@ describe User do end end + context '#invalidate_personal_projects_count' do + let(:user) { build_stubbed(:user) } + + it 'invalidates cache for personal projects counter' do + cache_mock = double + + expect(cache_mock).to receive(:delete).with(['users', user.id, 'personal_projects_count']) + + allow(Rails).to receive(:cache).and_return(cache_mock) + + user.invalidate_personal_projects_count + end + end + describe '#allow_password_authentication_for_web?' do context 'regular user' do let(:user) { build(:user) } @@ -2281,11 +2312,9 @@ describe User do user = build(:user) projects = double(:projects, count: 1) - expect(user).to receive(:personal_projects).once.and_return(projects) + expect(user).to receive(:personal_projects).and_return(projects) - 2.times do - expect(user.personal_projects_count).to eq(1) - end + expect(user.personal_projects_count).to eq(1) end end diff --git a/spec/policies/deploy_token_policy_spec.rb b/spec/policies/deploy_token_policy_spec.rb new file mode 100644 index 00000000000..eea287d895e --- /dev/null +++ b/spec/policies/deploy_token_policy_spec.rb @@ -0,0 +1,45 @@ +require 'spec_helper' + +describe DeployTokenPolicy do + let(:current_user) { create(:user) } + let(:project) { create(:project) } + let(:deploy_token) { create(:deploy_token, projects: [project]) } + + subject { described_class.new(current_user, deploy_token) } + + describe 'creating a deploy key' do + context 'when user is master' do + before do + project.add_master(current_user) + end + + it { is_expected.to be_allowed(:create_deploy_token) } + end + + context 'when user is not master' do + before do + project.add_developer(current_user) + end + + it { is_expected.to be_disallowed(:create_deploy_token) } + end + end + + describe 'updating a deploy key' do + context 'when user is master' do + before do + project.add_master(current_user) + end + + it { is_expected.to be_allowed(:update_deploy_token) } + end + + context 'when user is not master' do + before do + project.add_developer(current_user) + end + + it { is_expected.to be_disallowed(:update_deploy_token) } + end + end +end diff --git a/spec/policies/project_policy_spec.rb b/spec/policies/project_policy_spec.rb index ea76e604153..905d82b3bb1 100644 --- a/spec/policies/project_policy_spec.rb +++ b/spec/policies/project_policy_spec.rb @@ -11,10 +11,10 @@ describe ProjectPolicy do let(:base_guest_permissions) do %i[ - read_project read_board read_list read_wiki read_issue read_label - read_milestone read_project_snippet read_project_member - read_note create_project create_issue create_note - upload_file + read_project read_board read_list read_wiki read_issue + read_project_for_iids read_issue_iid read_merge_request_iid read_label + read_milestone read_project_snippet read_project_member read_note + create_project create_issue create_note upload_file ] end @@ -120,7 +120,7 @@ describe ProjectPolicy do project.issues_enabled = false project.save! - expect_disallowed :read_issue, :create_issue, :update_issue, :admin_issue + expect_disallowed :read_issue, :read_issue_iid, :create_issue, :update_issue, :admin_issue end end @@ -131,7 +131,7 @@ describe ProjectPolicy do project.issues_enabled = false project.save! - expect_disallowed :read_issue, :create_issue, :update_issue, :admin_issue + expect_disallowed :read_issue, :read_issue_iid, :create_issue, :update_issue, :admin_issue end end end diff --git a/spec/presenters/ci/build_presenter_spec.rb b/spec/presenters/ci/build_presenter_spec.rb index 1a8001be6ab..cc16d0f156b 100644 --- a/spec/presenters/ci/build_presenter_spec.rb +++ b/spec/presenters/ci/build_presenter_spec.rb @@ -72,13 +72,44 @@ describe Ci::BuildPresenter do end end - context 'when build is not auto-canceled' do - before do - expect(build).to receive(:auto_canceled?).and_return(false) + context 'when build failed' do + let(:build) { create(:ci_build, :failed, pipeline: pipeline) } + + it 'returns the reason of failure' do + status_title = presenter.status_title + + expect(status_title).to eq('Failed <br> (unknown failure)') end + end + + context 'when build has failed && retried' do + let(:build) { create(:ci_build, :failed, :retried, pipeline: pipeline) } - it 'does not have a status title' do - expect(presenter.status_title).to be_nil + it 'does not include retried title' do + status_title = presenter.status_title + + expect(status_title).not_to include('(retried)') + expect(status_title).to eq('Failed <br> (unknown failure)') + end + end + + context 'when build has failed and is allowed to' do + let(:build) { create(:ci_build, :failed, :allowed_to_fail, pipeline: pipeline) } + + it 'returns the reason of failure' do + status_title = presenter.status_title + + expect(status_title).to eq('Failed <br> (unknown failure)') + end + end + + context 'For any other build' do + let(:build) { create(:ci_build, :success, pipeline: pipeline) } + + it 'returns the status' do + tooltip_description = presenter.status_title + + expect(tooltip_description).to eq('Success') end end end @@ -134,4 +165,56 @@ describe Ci::BuildPresenter do end end end + + describe '#tooltip_message' do + context 'When build has failed' do + let(:build) { create(:ci_build, :script_failure, pipeline: pipeline) } + + it 'returns the reason of failure' do + tooltip = subject.tooltip_message + + expect(tooltip).to eq("#{build.name} - failed <br> (script failure)") + end + end + + context 'When build has failed and retried' do + let(:build) { create(:ci_build, :script_failure, :retried, pipeline: pipeline) } + + it 'should include the reason of failure and the retried title' do + tooltip = subject.tooltip_message + + expect(tooltip).to eq("#{build.name} - failed <br> (script failure) (retried)") + end + end + + context 'When build has failed and is allowed to' do + let(:build) { create(:ci_build, :script_failure, :allowed_to_fail, pipeline: pipeline) } + + it 'should include the reason of failure' do + tooltip = subject.tooltip_message + + expect(tooltip).to eq("#{build.name} - failed <br> (script failure) (allowed to fail)") + end + end + + context 'For any other build (no retried)' do + let(:build) { create(:ci_build, :success, pipeline: pipeline) } + + it 'should include build name and status' do + tooltip = subject.tooltip_message + + expect(tooltip).to eq("#{build.name} - passed") + end + end + + context 'For any other build (retried)' do + let(:build) { create(:ci_build, :success, :retried, pipeline: pipeline) } + + it 'should include build name and status' do + tooltip = subject.tooltip_message + + expect(tooltip).to eq("#{build.name} - passed (retried)") + end + end + end end diff --git a/spec/requests/api/boards_spec.rb b/spec/requests/api/boards_spec.rb index c6c10025f7f..92b614b087e 100644 --- a/spec/requests/api/boards_spec.rb +++ b/spec/requests/api/boards_spec.rb @@ -48,5 +48,36 @@ describe API::Boards do expect(json_response['label']['name']).to eq(group_label.title) expect(json_response['position']).to eq(3) end + + it 'creates a new board list for ancestor group labels' do + group = create(:group) + sub_group = create(:group, parent: group) + group_label = create(:group_label, group: group) + board_parent.update(group: sub_group) + group.add_developer(user) + sub_group.add_developer(user) + + post api(url, user), label_id: group_label.id + + expect(response).to have_gitlab_http_status(201) + expect(json_response['label']['name']).to eq(group_label.title) + end + end + + describe "POST /groups/:id/boards/lists", :nested_groups do + set(:group) { create(:group) } + set(:board_parent) { create(:group, parent: group ) } + let(:url) { "/groups/#{board_parent.id}/boards/#{board.id}/lists" } + set(:board) { create(:board, group: board_parent) } + + it 'creates a new board list for ancestor group labels' do + group.add_developer(user) + group_label = create(:group_label, group: group) + + post api(url, user), label_id: group_label.id + + expect(response).to have_gitlab_http_status(201) + expect(json_response['label']['name']).to eq(group_label.title) + end end end diff --git a/spec/requests/api/features_spec.rb b/spec/requests/api/features_spec.rb index 267058d98ee..c5354c2d639 100644 --- a/spec/requests/api/features_spec.rb +++ b/spec/requests/api/features_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' describe API::Features do - let(:user) { create(:user) } - let(:admin) { create(:admin) } + set(:user) { create(:user) } + set(:admin) { create(:admin) } before do Flipper.unregister_groups @@ -249,4 +249,43 @@ describe API::Features do end end end + + describe 'DELETE /feature/:name' do + let(:feature_name) { 'my_feature' } + + context 'when the user has no access' do + it 'returns a 401 for anonymous users' do + delete api("/features/#{feature_name}") + + expect(response).to have_gitlab_http_status(401) + end + + it 'returns a 403 for users' do + delete api("/features/#{feature_name}", user) + + expect(response).to have_gitlab_http_status(403) + end + end + + context 'when the user has access' do + it 'returns 204 when the value is not set' do + delete api("/features/#{feature_name}", admin) + + expect(response).to have_gitlab_http_status(204) + end + + context 'when the gate value was set' do + before do + Feature.get(feature_name).enable + end + + it 'deletes an enabled feature' do + delete api("/features/#{feature_name}", admin) + + expect(response).to have_gitlab_http_status(204) + expect(Feature.get(feature_name)).not_to be_enabled + end + end + end + end end diff --git a/spec/requests/api/issues_spec.rb b/spec/requests/api/issues_spec.rb index 6614e8cea43..90f9c4ad214 100644 --- a/spec/requests/api/issues_spec.rb +++ b/spec/requests/api/issues_spec.rb @@ -384,6 +384,30 @@ describe API::Issues do end let(:base_url) { "/groups/#{group.id}/issues" } + context 'when group has subgroups', :nested_groups do + let(:subgroup_1) { create(:group, parent: group) } + let(:subgroup_2) { create(:group, parent: subgroup_1) } + + let(:subgroup_1_project) { create(:project, namespace: subgroup_1) } + let(:subgroup_2_project) { create(:project, namespace: subgroup_2) } + + let!(:issue_1) { create(:issue, project: subgroup_1_project) } + let!(:issue_2) { create(:issue, project: subgroup_2_project) } + + before do + group.add_developer(user) + end + + it 'also returns subgroups projects issues' do + get api(base_url, user) + + issue_ids = json_response.map { |issue| issue['id'] } + + expect_paginated_array_response(size: 5) + expect(issue_ids).to include(issue_1.id, issue_2.id) + end + end + it 'returns all group issues (including opened and closed)' do get api(base_url, admin) diff --git a/spec/requests/api/pipeline_schedules_spec.rb b/spec/requests/api/pipeline_schedules_spec.rb index 7ea25059756..91d4d5d3de9 100644 --- a/spec/requests/api/pipeline_schedules_spec.rb +++ b/spec/requests/api/pipeline_schedules_spec.rb @@ -17,6 +17,17 @@ describe API::PipelineSchedules do pipeline_schedule.pipelines << build(:ci_pipeline, project: project) end + def create_pipeline_schedules(count) + create_list(:ci_pipeline_schedule, count, project: project) + .each do |pipeline_schedule| + create(:user).tap do |user| + project.add_developer(user) + pipeline_schedule.update_attributes(owner: user) + end + pipeline_schedule.pipelines << build(:ci_pipeline, project: project) + end + end + it 'returns list of pipeline_schedules' do get api("/projects/#{project.id}/pipeline_schedules", developer) @@ -26,18 +37,14 @@ describe API::PipelineSchedules do end it 'avoids N + 1 queries' do + # We need at least two users to trigger a preload for that relation. + create_pipeline_schedules(1) + control_count = ActiveRecord::QueryRecorder.new do get api("/projects/#{project.id}/pipeline_schedules", developer) end.count - create_list(:ci_pipeline_schedule, 10, project: project) - .each do |pipeline_schedule| - create(:user).tap do |user| - project.add_developer(user) - pipeline_schedule.update_attributes(owner: user) - end - pipeline_schedule.pipelines << build(:ci_pipeline, project: project) - end + create_pipeline_schedules(10) expect do get api("/projects/#{project.id}/pipeline_schedules", developer) diff --git a/spec/requests/api/project_export_spec.rb b/spec/requests/api/project_export_spec.rb index 12583109b59..3834d27d0a9 100644 --- a/spec/requests/api/project_export_spec.rb +++ b/spec/requests/api/project_export_spec.rb @@ -5,6 +5,7 @@ describe API::ProjectExport do set(:project_none) { create(:project) } set(:project_started) { create(:project) } set(:project_finished) { create(:project) } + set(:project_after_export) { create(:project) } set(:user) { create(:user) } set(:admin) { create(:admin) } @@ -12,11 +13,13 @@ describe API::ProjectExport do let(:path_none) { "/projects/#{project_none.id}/export" } let(:path_started) { "/projects/#{project_started.id}/export" } let(:path_finished) { "/projects/#{project_finished.id}/export" } + let(:path_after_export) { "/projects/#{project_after_export.id}/export" } let(:download_path) { "/projects/#{project.id}/export/download" } let(:download_path_none) { "/projects/#{project_none.id}/export/download" } let(:download_path_started) { "/projects/#{project_started.id}/export/download" } let(:download_path_finished) { "/projects/#{project_finished.id}/export/download" } + let(:download_path_export_action) { "/projects/#{project_after_export.id}/export/download" } let(:export_path) { "#{Dir.tmpdir}/project_export_spec" } @@ -29,6 +32,11 @@ describe API::ProjectExport do # simulate exported FileUtils.mkdir_p project_finished.export_path FileUtils.touch File.join(project_finished.export_path, '_export.tar.gz') + + # simulate in after export action + FileUtils.mkdir_p project_after_export.export_path + FileUtils.touch File.join(project_after_export.export_path, '_export.tar.gz') + FileUtils.touch Gitlab::ImportExport::AfterExportStrategies::BaseAfterExportStrategy.lock_file_path(project_after_export) end after do @@ -73,6 +81,14 @@ describe API::ProjectExport do expect(json_response['export_status']).to eq('started') end + it 'is after_export' do + get api(path_after_export, user) + + expect(response).to have_gitlab_http_status(200) + expect(response).to match_response_schema('public_api/v4/project/export_status') + expect(json_response['export_status']).to eq('after_export_action') + end + it 'is finished' do get api(path_finished, user) @@ -99,6 +115,7 @@ describe API::ProjectExport do project_none.add_master(user) project_started.add_master(user) project_finished.add_master(user) + project_after_export.add_master(user) end it_behaves_like 'get project export status ok' @@ -163,6 +180,36 @@ describe API::ProjectExport do end end + shared_examples_for 'get project export upload after action' do + context 'and is uploading' do + it 'downloads' do + get api(download_path_export_action, user) + + expect(response).to have_gitlab_http_status(200) + end + end + + context 'when upload complete' do + before do + FileUtils.rm_rf(project_after_export.export_path) + end + + it_behaves_like '404 response' do + let(:request) { get api(download_path_export_action, user) } + end + end + end + + shared_examples_for 'get project download by strategy' do + context 'when upload strategy set' do + it_behaves_like 'get project export upload after action' + end + + context 'when download strategy set' do + it_behaves_like 'get project export download' + end + end + it_behaves_like 'when project export is disabled' do let(:request) { get api(download_path, admin) } end @@ -171,7 +218,7 @@ describe API::ProjectExport do context 'when user is an admin' do let(:user) { admin } - it_behaves_like 'get project export download' + it_behaves_like 'get project download by strategy' end context 'when user is a master' do @@ -180,9 +227,10 @@ describe API::ProjectExport do project_none.add_master(user) project_started.add_master(user) project_finished.add_master(user) + project_after_export.add_master(user) end - it_behaves_like 'get project export download' + it_behaves_like 'get project download by strategy' end context 'when user is a developer' do @@ -229,10 +277,30 @@ describe API::ProjectExport do end shared_examples_for 'post project export start' do - it 'starts' do - post api(path, user) + context 'with upload strategy' do + context 'when params invalid' do + it_behaves_like '400 response' do + let(:request) { post(api(path, user), 'upload[url]' => 'whatever') } + end + end + + it 'starts' do + allow_any_instance_of(Gitlab::ImportExport::AfterExportStrategies::WebUploadStrategy).to receive(:send_file) + + post(api(path, user), 'upload[url]' => 'http://gitlab.com') - expect(response).to have_gitlab_http_status(202) + expect(response).to have_gitlab_http_status(202) + end + end + + context 'with download strategy' do + it 'starts' do + expect_any_instance_of(Gitlab::ImportExport::AfterExportStrategies::WebUploadStrategy).not_to receive(:send_file) + + post api(path, user) + + expect(response).to have_gitlab_http_status(202) + end end end @@ -253,6 +321,7 @@ describe API::ProjectExport do project_none.add_master(user) project_started.add_master(user) project_finished.add_master(user) + project_after_export.add_master(user) end it_behaves_like 'post project export start' diff --git a/spec/requests/api/project_hooks_spec.rb b/spec/requests/api/project_hooks_spec.rb index 392cad667be..12a183fed1e 100644 --- a/spec/requests/api/project_hooks_spec.rb +++ b/spec/requests/api/project_hooks_spec.rb @@ -33,6 +33,7 @@ describe API::ProjectHooks, 'ProjectHooks' do expect(json_response.first['merge_requests_events']).to eq(true) expect(json_response.first['tag_push_events']).to eq(true) expect(json_response.first['note_events']).to eq(true) + expect(json_response.first['confidential_note_events']).to eq(true) expect(json_response.first['job_events']).to eq(true) expect(json_response.first['pipeline_events']).to eq(true) expect(json_response.first['wiki_page_events']).to eq(true) @@ -62,6 +63,7 @@ describe API::ProjectHooks, 'ProjectHooks' do expect(json_response['merge_requests_events']).to eq(hook.merge_requests_events) expect(json_response['tag_push_events']).to eq(hook.tag_push_events) expect(json_response['note_events']).to eq(hook.note_events) + expect(json_response['confidential_note_events']).to eq(hook.confidential_note_events) expect(json_response['job_events']).to eq(hook.job_events) expect(json_response['pipeline_events']).to eq(hook.pipeline_events) expect(json_response['wiki_page_events']).to eq(hook.wiki_page_events) @@ -104,6 +106,7 @@ describe API::ProjectHooks, 'ProjectHooks' do expect(json_response['merge_requests_events']).to eq(false) expect(json_response['tag_push_events']).to eq(false) expect(json_response['note_events']).to eq(false) + expect(json_response['confidential_note_events']).to eq(nil) expect(json_response['job_events']).to eq(true) expect(json_response['pipeline_events']).to eq(false) expect(json_response['wiki_page_events']).to eq(true) @@ -152,6 +155,7 @@ describe API::ProjectHooks, 'ProjectHooks' do expect(json_response['merge_requests_events']).to eq(hook.merge_requests_events) expect(json_response['tag_push_events']).to eq(hook.tag_push_events) expect(json_response['note_events']).to eq(hook.note_events) + expect(json_response['confidential_note_events']).to eq(hook.confidential_note_events) expect(json_response['job_events']).to eq(hook.job_events) expect(json_response['pipeline_events']).to eq(hook.pipeline_events) expect(json_response['wiki_page_events']).to eq(hook.wiki_page_events) diff --git a/spec/requests/api/project_import_spec.rb b/spec/requests/api/project_import_spec.rb index 987f6e26971..f68057a92a1 100644 --- a/spec/requests/api/project_import_spec.rb +++ b/spec/requests/api/project_import_spec.rb @@ -40,7 +40,7 @@ describe API::ProjectImport do expect(response).to have_gitlab_http_status(201) end - it 'schedules an import at the user namespace level' do + it 'does not shedule an import for a nampespace that does not exist' do expect_any_instance_of(Project).not_to receive(:import_schedule) expect(::Projects::CreateService).not_to receive(:new) @@ -71,6 +71,72 @@ describe API::ProjectImport do expect(json_response['error']).to eq('file is invalid') end + it 'stores params that can be overridden' do + stub_import(namespace) + override_params = { 'description' => 'Hello world' } + + post api('/projects/import', user), + path: 'test-import', + file: fixture_file_upload(file), + namespace: namespace.id, + override_params: override_params + import_project = Project.find(json_response['id']) + + expect(import_project.import_data.data['override_params']).to eq(override_params) + end + + it 'does not store params that are not allowed' do + stub_import(namespace) + override_params = { 'not_allowed' => 'Hello world' } + + post api('/projects/import', user), + path: 'test-import', + file: fixture_file_upload(file), + namespace: namespace.id, + override_params: override_params + import_project = Project.find(json_response['id']) + + expect(import_project.import_data.data['override_params']).to be_empty + end + + it 'correctly overrides params during the import' do + override_params = { 'description' => 'Hello world' } + + Sidekiq::Testing.inline! do + post api('/projects/import', user), + path: 'test-import', + file: fixture_file_upload(file), + namespace: namespace.id, + override_params: override_params + end + import_project = Project.find(json_response['id']) + + expect(import_project.description).to eq('Hello world') + end + + context 'when target path already exists in namespace' do + let(:existing_project) { create(:project, namespace: user.namespace) } + + it 'does not schedule an import' do + expect_any_instance_of(Project).not_to receive(:import_schedule) + + post api('/projects/import', user), path: existing_project.path, file: fixture_file_upload(file) + + expect(response).to have_gitlab_http_status(400) + expect(json_response['message']).to eq('Name has already been taken') + end + + context 'when param overwrite is true' do + it 'schedules an import' do + stub_import(user.namespace) + + post api('/projects/import', user), path: existing_project.path, file: fixture_file_upload(file), overwrite: true + + expect(response).to have_gitlab_http_status(201) + end + end + end + def stub_import(namespace) expect_any_instance_of(Project).to receive(:import_schedule) expect(::Projects::CreateService).to receive(:new).with(user, hash_including(namespace_id: namespace.id)).and_call_original diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index d73a42f48ad..2ec29a79e93 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -452,7 +452,8 @@ describe API::Projects do only_allow_merge_if_pipeline_succeeds: false, request_access_enabled: true, only_allow_merge_if_all_discussions_are_resolved: false, - ci_config_path: 'a/custom/path' + ci_config_path: 'a/custom/path', + merge_method: 'ff' }) post api('/projects', user), project @@ -569,6 +570,22 @@ describe API::Projects do expect(json_response['only_allow_merge_if_all_discussions_are_resolved']).to be_truthy end + it 'sets the merge method of a project to rebase merge' do + project = attributes_for(:project, merge_method: 'rebase_merge') + + post api('/projects', user), project + + expect(json_response['merge_method']).to eq('rebase_merge') + end + + it 'rejects invalid values for merge_method' do + project = attributes_for(:project, merge_method: 'totally_not_valid_method') + + post api('/projects', user), project + + expect(response).to have_gitlab_http_status(400) + end + it 'ignores import_url when it is nil' do project = attributes_for(:project, import_url: nil) @@ -823,6 +840,7 @@ describe API::Projects do expect(json_response['shared_with_groups'][0]['group_access_level']).to eq(link.group_access) expect(json_response['only_allow_merge_if_pipeline_succeeds']).to eq(project.only_allow_merge_if_pipeline_succeeds) expect(json_response['only_allow_merge_if_all_discussions_are_resolved']).to eq(project.only_allow_merge_if_all_discussions_are_resolved) + expect(json_response['merge_method']).to eq(project.merge_method.to_s) end it 'returns a project by path name' do @@ -1474,6 +1492,26 @@ describe API::Projects do expect(json_response[k.to_s]).to eq(v) end end + + it 'updates merge_method' do + project_param = { merge_method: 'ff' } + + put api("/projects/#{project3.id}", user), project_param + + expect(response).to have_gitlab_http_status(200) + + project_param.each_pair do |k, v| + expect(json_response[k.to_s]).to eq(v) + end + end + + it 'rejects to update merge_method when merge_method is invalid' do + project_param = { merge_method: 'invalid' } + + put api("/projects/#{project3.id}", user), project_param + + expect(response).to have_gitlab_http_status(400) + end end context 'when authenticated as project master' do @@ -1491,6 +1529,7 @@ describe API::Projects do wiki_enabled: true, snippets_enabled: true, merge_requests_enabled: true, + merge_method: 'ff', description: 'new description' } put api("/projects/#{project3.id}", user4), project_param diff --git a/spec/requests/api/runner_spec.rb b/spec/requests/api/runner_spec.rb index 5084b36c761..28d51ac86c6 100644 --- a/spec/requests/api/runner_spec.rb +++ b/spec/requests/api/runner_spec.rb @@ -950,12 +950,53 @@ describe API::Runner do describe 'POST /api/v4/jobs/:id/artifacts/authorize' do context 'when using token as parameter' do - it 'authorizes posting artifacts to running job' do - authorize_artifacts_with_token_in_params + context 'posting artifacts to running job' do + subject do + authorize_artifacts_with_token_in_params + end - expect(response).to have_gitlab_http_status(200) - expect(response.content_type.to_s).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE) - expect(json_response['TempPath']).not_to be_nil + shared_examples 'authorizes local file' do + it 'succeeds' do + subject + + expect(response).to have_gitlab_http_status(200) + expect(response.content_type.to_s).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE) + expect(json_response['TempPath']).to eq(JobArtifactUploader.workhorse_local_upload_path) + expect(json_response['RemoteObject']).to be_nil + end + end + + context 'when using local storage' do + it_behaves_like 'authorizes local file' + end + + context 'when using remote storage' do + context 'when direct upload is enabled' do + before do + stub_artifacts_object_storage(enabled: true, direct_upload: true) + end + + it 'succeeds' do + subject + + expect(response).to have_gitlab_http_status(200) + expect(response.content_type.to_s).to eq(Gitlab::Workhorse::INTERNAL_API_CONTENT_TYPE) + expect(json_response['TempPath']).to eq(JobArtifactUploader.workhorse_local_upload_path) + expect(json_response['RemoteObject']).to have_key('ID') + expect(json_response['RemoteObject']).to have_key('GetURL') + expect(json_response['RemoteObject']).to have_key('StoreURL') + expect(json_response['RemoteObject']).to have_key('DeleteURL') + end + end + + context 'when direct upload is disabled' do + before do + stub_artifacts_object_storage(enabled: true, direct_upload: false) + end + + it_behaves_like 'authorizes local file' + end + end end it 'fails to post too large artifact' do @@ -1051,20 +1092,45 @@ describe API::Runner do end end - context 'when uses regular file post' do - before do - upload_artifacts(file_upload, headers_with_token, false) + context 'when uses accelerated file post' do + context 'for file stored locally' do + before do + upload_artifacts(file_upload, headers_with_token) + end + + it_behaves_like 'successful artifacts upload' end - it_behaves_like 'successful artifacts upload' - end + context 'for file stored remotelly' do + let!(:fog_connection) do + stub_artifacts_object_storage(direct_upload: true) + end - context 'when uses accelerated file post' do - before do - upload_artifacts(file_upload, headers_with_token, true) - end + before do + fog_connection.directories.get('artifacts').files.create( + key: 'tmp/upload/12312300', + body: 'content' + ) - it_behaves_like 'successful artifacts upload' + upload_artifacts(file_upload, headers_with_token, + { 'file.remote_id' => remote_id }) + end + + context 'when valid remote_id is used' do + let(:remote_id) { '12312300' } + + it_behaves_like 'successful artifacts upload' + end + + context 'when invalid remote_id is used' do + let(:remote_id) { 'invalid id' } + + it 'responds with bad request' do + expect(response).to have_gitlab_http_status(500) + expect(json_response['message']).to eq("Missing file") + end + end + end end context 'when using runners token' do @@ -1159,11 +1225,13 @@ describe API::Runner do let!(:artifacts) { file_upload } let!(:artifacts_sha256) { Digest::SHA256.file(artifacts.path).hexdigest } let!(:metadata) { file_upload2 } + let!(:metadata_sha256) { Digest::SHA256.file(metadata.path).hexdigest } let(:stored_artifacts_file) { job.reload.artifacts_file.file } let(:stored_metadata_file) { job.reload.artifacts_metadata.file } let(:stored_artifacts_size) { job.reload.artifacts_size } let(:stored_artifacts_sha256) { job.reload.job_artifacts_archive.file_sha256 } + let(:stored_metadata_sha256) { job.reload.job_artifacts_metadata.file_sha256 } before do post(api("/jobs/#{job.id}/artifacts"), post_data, headers_with_token) @@ -1175,7 +1243,8 @@ describe API::Runner do 'file.name' => artifacts.original_filename, 'file.sha256' => artifacts_sha256, 'metadata.path' => metadata.path, - 'metadata.name' => metadata.original_filename } + 'metadata.name' => metadata.original_filename, + 'metadata.sha256' => metadata_sha256 } end it 'stores artifacts and artifacts metadata' do @@ -1184,6 +1253,7 @@ describe API::Runner do expect(stored_metadata_file.original_filename).to eq(metadata.original_filename) expect(stored_artifacts_size).to eq(72821) expect(stored_artifacts_sha256).to eq(artifacts_sha256) + expect(stored_metadata_sha256).to eq(metadata_sha256) end end @@ -1204,15 +1274,19 @@ describe API::Runner do end context 'when artifacts are being stored outside of tmp path' do + let(:new_tmpdir) { Dir.mktmpdir } + before do + # init before overwriting tmp dir + file_upload + # by configuring this path we allow to pass file from @tmpdir only # but all temporary files are stored in system tmp directory - @tmpdir = Dir.mktmpdir - allow(JobArtifactUploader).to receive(:workhorse_upload_path).and_return(@tmpdir) + allow(Dir).to receive(:tmpdir).and_return(new_tmpdir) end after do - FileUtils.remove_entry @tmpdir + FileUtils.remove_entry(new_tmpdir) end it' "fails to post artifacts for outside of tmp path"' do @@ -1222,12 +1296,11 @@ describe API::Runner do end end - def upload_artifacts(file, headers = {}, accelerated = true) - params = if accelerated - { 'file.path' => file.path, 'file.name' => file.original_filename } - else - { 'file' => file } - end + def upload_artifacts(file, headers = {}, params = {}) + params = params.merge({ + 'file.path' => file.path, + 'file.name' => file.original_filename + }) post api("/jobs/#{job.id}/artifacts"), params, headers end diff --git a/spec/requests/lfs_http_spec.rb b/spec/requests/lfs_http_spec.rb index 1e6bd993c08..f80abb06fca 100644 --- a/spec/requests/lfs_http_spec.rb +++ b/spec/requests/lfs_http_spec.rb @@ -1016,7 +1016,7 @@ describe 'Git LFS API and storage' do it_behaves_like 'a valid response' do it 'responds with status 200, location of lfs remote store and object details' do - expect(json_response['TempPath']).to be_nil + expect(json_response['TempPath']).to eq(LfsObjectUploader.workhorse_local_upload_path) expect(json_response['RemoteObject']).to have_key('ID') expect(json_response['RemoteObject']).to have_key('GetURL') expect(json_response['RemoteObject']).to have_key('StoreURL') @@ -1073,7 +1073,9 @@ describe 'Git LFS API and storage' do ['123123', '../../123123'].each do |remote_id| context "with invalid remote_id: #{remote_id}" do subject do - put_finalize_with_args('file.remote_id' => remote_id) + put_finalize(with_tempfile: true, args: { + 'file.remote_id' => remote_id + }) end it 'responds with status 403' do @@ -1093,9 +1095,10 @@ describe 'Git LFS API and storage' do end subject do - put_finalize_with_args( + put_finalize(with_tempfile: true, args: { 'file.remote_id' => '12312300', - 'file.name' => 'name') + 'file.name' => 'name' + }) end it 'responds with status 200' do @@ -1331,7 +1334,7 @@ describe 'Git LFS API and storage' do put "#{project.http_url_to_repo}/gitlab-lfs/objects/#{sample_oid}/#{sample_size}/authorize", nil, authorize_headers end - def put_finalize(lfs_tmp = lfs_tmp_file, with_tempfile: false) + def put_finalize(lfs_tmp = lfs_tmp_file, with_tempfile: false, args: {}) upload_path = LfsObjectUploader.workhorse_local_upload_path file_path = upload_path + '/' + lfs_tmp if lfs_tmp @@ -1340,12 +1343,12 @@ describe 'Git LFS API and storage' do FileUtils.touch(file_path) end - args = { + extra_args = { 'file.path' => file_path, 'file.name' => File.basename(file_path) - }.compact + } - put_finalize_with_args(args) + put_finalize_with_args(args.merge(extra_args).compact) end def put_finalize_with_args(args) diff --git a/spec/requests/projects/cycle_analytics_events_spec.rb b/spec/requests/projects/cycle_analytics_events_spec.rb index eef860821e5..bcc3e3a2678 100644 --- a/spec/requests/projects/cycle_analytics_events_spec.rb +++ b/spec/requests/projects/cycle_analytics_events_spec.rb @@ -23,7 +23,7 @@ describe 'cycle analytics events' do it 'lists the issue events' do get project_cycle_analytics_issue_path(project, format: :json) - first_issue_iid = project.issues.sort(: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) @@ -32,7 +32,7 @@ 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(:created_asc).first.commits.first.short_id + first_mr_short_sha = project.merge_requests.sort_by_attribute(:created_asc).first.commits.first.short_id expect(json_response['events']).not_to be_empty expect(json_response['events'].first['short_sha']).to eq(first_mr_short_sha) @@ -43,7 +43,7 @@ describe 'cycle analytics events' do expect(json_response['events']).not_to be_empty - first_mr_iid = project.merge_requests.sort(: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'].first['iid']).to eq(first_mr_iid) end @@ -58,7 +58,7 @@ describe 'cycle analytics events' do it 'lists the review events' do get project_cycle_analytics_review_path(project, format: :json) - first_mr_iid = project.merge_requests.sort(: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_mr_iid) @@ -74,7 +74,7 @@ describe 'cycle analytics events' do it 'lists the production events' do get project_cycle_analytics_production_path(project, format: :json) - first_issue_iid = project.issues.sort(: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) diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb index fb1281a6b42..e1b4e618092 100644 --- a/spec/routing/project_routing_spec.rb +++ b/spec/routing/project_routing_spec.rb @@ -164,20 +164,36 @@ describe 'project routing' do # archive_project_repository GET /:project_id/repository/archive(.:format) projects/repositories#archive # edit_project_repository GET /:project_id/repository/edit(.:format) projects/repositories#edit describe Projects::RepositoriesController, 'routing' do - it 'to #archive' do - expect(get('/gitlab/gitlabhq/repository/master/archive')).to route_to('projects/repositories#archive', namespace_id: 'gitlab', project_id: 'gitlabhq', ref: 'master') - end - it 'to #archive format:zip' do - expect(get('/gitlab/gitlabhq/repository/master/archive.zip')).to route_to('projects/repositories#archive', namespace_id: 'gitlab', project_id: 'gitlabhq', format: 'zip', ref: 'master') + expect(get('/gitlab/gitlabhq/-/archive/master/archive.zip')).to route_to('projects/repositories#archive', namespace_id: 'gitlab', project_id: 'gitlabhq', format: 'zip', id: 'master/archive') end it 'to #archive format:tar.bz2' do - expect(get('/gitlab/gitlabhq/repository/master/archive.tar.bz2')).to route_to('projects/repositories#archive', namespace_id: 'gitlab', project_id: 'gitlabhq', format: 'tar.bz2', ref: 'master') + expect(get('/gitlab/gitlabhq/-/archive/master/archive.tar.bz2')).to route_to('projects/repositories#archive', namespace_id: 'gitlab', project_id: 'gitlabhq', format: 'tar.bz2', id: 'master/archive') end it 'to #archive with "/" in route' do - expect(get('/gitlab/gitlabhq/repository/improve/awesome/archive')).to route_to('projects/repositories#archive', namespace_id: 'gitlab', project_id: 'gitlabhq', ref: 'improve/awesome') + expect(get('/gitlab/gitlabhq/-/archive/improve/awesome/gitlabhq-improve-awesome.tar.gz')).to route_to('projects/repositories#archive', namespace_id: 'gitlab', project_id: 'gitlabhq', format: 'tar.gz', id: 'improve/awesome/gitlabhq-improve-awesome') + end + + it 'to #archive_alternative' do + expect(get('/gitlab/gitlabhq/repository/archive')).to route_to('projects/repositories#archive', namespace_id: 'gitlab', project_id: 'gitlabhq', append_sha: true) + end + + it 'to #archive_deprecated' do + expect(get('/gitlab/gitlabhq/repository/master/archive')).to route_to('projects/repositories#archive', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'master', append_sha: true) + end + + it 'to #archive_deprecated format:zip' do + expect(get('/gitlab/gitlabhq/repository/master/archive.zip')).to route_to('projects/repositories#archive', namespace_id: 'gitlab', project_id: 'gitlabhq', format: 'zip', id: 'master', append_sha: true) + end + + it 'to #archive_deprecated format:tar.bz2' do + expect(get('/gitlab/gitlabhq/repository/master/archive.tar.bz2')).to route_to('projects/repositories#archive', namespace_id: 'gitlab', project_id: 'gitlabhq', format: 'tar.bz2', id: 'master', append_sha: true) + end + + it 'to #archive_deprecated with "/" in route' do + expect(get('/gitlab/gitlabhq/repository/improve/awesome/archive')).to route_to('projects/repositories#archive', namespace_id: 'gitlab', project_id: 'gitlabhq', id: 'improve/awesome', append_sha: true) end end diff --git a/spec/rubocop/cop/gitlab/has_many_through_scope_spec.rb b/spec/rubocop/cop/gitlab/has_many_through_scope_spec.rb new file mode 100644 index 00000000000..6d769c8e6fd --- /dev/null +++ b/spec/rubocop/cop/gitlab/has_many_through_scope_spec.rb @@ -0,0 +1,74 @@ +require 'spec_helper' + +require 'rubocop' +require 'rubocop/rspec/support' + +require_relative '../../../../rubocop/cop/gitlab/has_many_through_scope' + +describe RuboCop::Cop::Gitlab::HasManyThroughScope do # rubocop:disable RSpec/FilePath + include CopHelper + + subject(:cop) { described_class.new } + + context 'in a model file' do + before do + allow(cop).to receive(:in_model?).and_return(true) + end + + context 'when the model does not use has_many :through' do + it 'does not register an offense' do + expect_no_offenses(<<-RUBY) + class User < ActiveRecord::Base + has_many :tags, source: 'UserTag' + end + RUBY + end + end + + context 'when the model uses has_many :through' do + context 'when the association has no scope defined' do + it 'registers an offense on the association' do + expect_offense(<<-RUBY) + class User < ActiveRecord::Base + has_many :tags, through: :user_tags + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #{described_class::MSG} + end + RUBY + end + end + + context 'when the association has a scope defined' do + context 'when the scope does not disable auto-loading' do + it 'registers an offense on the scope' do + expect_offense(<<-RUBY) + class User < ActiveRecord::Base + has_many :tags, -> { where(active: true) }, through: :user_tags + ^^^^^^^^^^^^^^^^^^^^^^^^^^ #{described_class::MSG} + end + RUBY + end + end + + context 'when the scope has auto_include(false)' do + it 'does not register an offense' do + expect_no_offenses(<<-RUBY) + class User < ActiveRecord::Base + has_many :tags, -> { where(active: true).auto_include(false).reorder(nil) }, through: :user_tags + end + RUBY + end + end + end + end + end + + context 'outside of a migration spec file' do + it 'does not register an offense' do + expect_no_offenses(<<-RUBY) + class User < ActiveRecord::Base + has_many :tags, through: :user_tags + end + RUBY + end + end +end diff --git a/spec/rubocop/cop/rspec/factories_in_migration_specs_spec.rb b/spec/rubocop/cop/rspec/factories_in_migration_specs_spec.rb new file mode 100644 index 00000000000..2763f2bda21 --- /dev/null +++ b/spec/rubocop/cop/rspec/factories_in_migration_specs_spec.rb @@ -0,0 +1,48 @@ +require 'spec_helper' + +require 'rubocop' +require 'rubocop/rspec/support' + +require_relative '../../../../rubocop/cop/rspec/factories_in_migration_specs' + +describe RuboCop::Cop::RSpec::FactoriesInMigrationSpecs do + include CopHelper + + let(:source_file) { 'spec/migrations/foo_spec.rb' } + + subject(:cop) { described_class.new } + + shared_examples 'an offensive factory call' do |namespace| + %i[build build_list create create_list].each do |forbidden_method| + namespaced_forbidden_method = "#{namespace}#{forbidden_method}(:user)" + + it "registers an offense for #{namespaced_forbidden_method}" do + expect_offense(<<-RUBY) + describe 'foo' do + let(:user) { #{namespaced_forbidden_method} } + #{'^' * namespaced_forbidden_method.size} Don't use FactoryBot.#{forbidden_method} in migration specs, use `table` instead. + end + RUBY + end + end + end + + context 'in a migration spec file' do + before do + allow(cop).to receive(:in_migration_spec?).and_return(true) + end + + it_behaves_like 'an offensive factory call', '' + it_behaves_like 'an offensive factory call', 'FactoryBot.' + end + + context 'outside of a migration spec file' do + it "does not register an offense" do + expect_no_offenses(<<-RUBY) + describe 'foo' do + let(:user) { create(:user) } + end + RUBY + end + end +end diff --git a/spec/serializers/build_serializer_spec.rb b/spec/serializers/build_serializer_spec.rb index 9673b11c2a2..98cd15e248b 100644 --- a/spec/serializers/build_serializer_spec.rb +++ b/spec/serializers/build_serializer_spec.rb @@ -28,15 +28,31 @@ describe BuildSerializer do end describe '#represent_status' do - context 'when represents only status' do - let(:resource) { create(:ci_build) } + context 'for a failed build' do + let(:resource) { create(:ci_build, :failed) } + let(:status) { resource.detailed_status(double('user')) } + + subject { serializer.represent_status(resource) } + + it 'serializes only status' do + expect(subject[:text]).to eq(status.text) + expect(subject[:label]).to eq('failed') + expect(subject[:tooltip]).to eq('failed <br> (unknown failure)') + expect(subject[:icon]).to eq(status.icon) + expect(subject[:favicon]).to match_asset_path("/assets/ci_favicons/#{status.favicon}.ico") + end + end + + context 'for any other type of build' do + let(:resource) { create(:ci_build, :success) } let(:status) { resource.detailed_status(double('user')) } subject { serializer.represent_status(resource) } it 'serializes only status' do expect(subject[:text]).to eq(status.text) - expect(subject[:label]).to eq(status.label) + expect(subject[:label]).to eq('passed') + expect(subject[:tooltip]).to eq('passed') expect(subject[:icon]).to eq(status.icon) expect(subject[:favicon]).to match_asset_path("/assets/ci_favicons/#{status.favicon}.ico") end diff --git a/spec/serializers/discussion_entity_spec.rb b/spec/serializers/discussion_entity_spec.rb index 7ee8e38af1c..7e19e74ca00 100644 --- a/spec/serializers/discussion_entity_spec.rb +++ b/spec/serializers/discussion_entity_spec.rb @@ -6,7 +6,7 @@ describe DiscussionEntity do let(:user) { create(:user) } let(:note) { create(:discussion_note_on_merge_request) } let(:discussion) { note.discussion } - let(:request) { double('request') } + let(:request) { double('request', note_entity: ProjectNoteEntity) } let(:controller) { double('controller') } let(:entity) { described_class.new(discussion, request: request, context: controller) } diff --git a/spec/serializers/job_entity_spec.rb b/spec/serializers/job_entity_spec.rb index 026360e91a3..24a6f1a2a8a 100644 --- a/spec/serializers/job_entity_spec.rb +++ b/spec/serializers/job_entity_spec.rb @@ -38,7 +38,7 @@ describe JobEntity do it 'contains details' do expect(subject).to include :status - expect(subject[:status]).to include :icon, :favicon, :text, :label + expect(subject[:status]).to include :icon, :favicon, :text, :label, :tooltip end context 'when job is retryable' do @@ -126,7 +126,29 @@ describe JobEntity do it 'contains details' do expect(subject).to include :status - expect(subject[:status]).to include :icon, :favicon, :text, :label + expect(subject[:status]).to include :icon, :favicon, :text, :label, :tooltip + end + end + + context 'when job failed' do + let(:job) { create(:ci_build, :script_failure) } + + describe 'status' do + it 'should contain the failure reason inside label' do + expect(subject[:status]).to include :icon, :favicon, :text, :label, :tooltip + expect(subject[:status][:label]).to eq('failed') + expect(subject[:status][:tooltip]).to eq('failed <br> (script failure)') + end + end + end + + context 'when job passed' do + let(:job) { create(:ci_build, :success) } + + describe 'status' do + it 'should not contain the failure reason inside label' do + expect(subject[:status][:label]).to eq('passed') + end end end end diff --git a/spec/serializers/note_entity_spec.rb b/spec/serializers/note_entity_spec.rb index 51a8587ace9..13cda781cda 100644 --- a/spec/serializers/note_entity_spec.rb +++ b/spec/serializers/note_entity_spec.rb @@ -10,53 +10,5 @@ describe NoteEntity do let(:user) { create(:user) } subject { entity.as_json } - context 'basic note' do - it 'exposes correct elements' do - expect(subject).to include(:type, :author, :human_access, :note, :note_html, :current_user, - :discussion_id, :emoji_awardable, :award_emoji, :toggle_award_path, :report_abuse_path, :path, :attachment) - end - - it 'does not expose elements for specific notes cases' do - expect(subject).not_to include(:last_edited_by, :last_edited_at, :system_note_icon_name) - end - - it 'exposes author correctly' do - expect(subject[:author]).to include(:id, :name, :username, :state, :avatar_url, :path) - end - - it 'does not expose web_url for author' do - expect(subject[:author]).not_to include(:web_url) - end - end - - context 'when note was edited' do - before do - note.update(updated_at: 1.minute.from_now, updated_by: user) - end - - it 'exposes last_edited_at and last_edited_by elements' do - expect(subject).to include(:last_edited_at, :last_edited_by) - end - end - - context 'when note is a system note' do - before do - note.update(system: true) - end - - it 'exposes system_note_icon_name element' do - expect(subject).to include(:system_note_icon_name) - end - end - - context 'when note is part of resolvable discussion' do - before do - allow(note).to receive(:part_of_discussion?).and_return(true) - allow(note).to receive(:resolvable?).and_return(true) - end - - it 'exposes paths to resolve note' do - expect(subject).to include(:resolve_path, :resolve_with_issue_path) - end - end + it_behaves_like 'note entity' end diff --git a/spec/serializers/pipeline_entity_spec.rb b/spec/serializers/pipeline_entity_spec.rb index 248552d1858..2473c561f4b 100644 --- a/spec/serializers/pipeline_entity_spec.rb +++ b/spec/serializers/pipeline_entity_spec.rb @@ -30,7 +30,7 @@ describe PipelineEntity do expect(subject).to include :details expect(subject[:details]) .to include :duration, :finished_at - expect(subject[:details][:status]).to include :icon, :favicon, :text, :label + expect(subject[:details][:status]).to include :icon, :favicon, :text, :label, :tooltip end it 'contains flags' do diff --git a/spec/serializers/project_note_entity_spec.rb b/spec/serializers/project_note_entity_spec.rb new file mode 100644 index 00000000000..dafd1cf603e --- /dev/null +++ b/spec/serializers/project_note_entity_spec.rb @@ -0,0 +1,29 @@ +require 'spec_helper' + +describe ProjectNoteEntity do + include Gitlab::Routing + + let(:request) { double('request', current_user: user, noteable: note.noteable) } + + let(:entity) { described_class.new(note, request: request) } + let(:note) { create(:note) } + let(:user) { create(:user) } + subject { entity.as_json } + + it_behaves_like 'note entity' + + it 'exposes project-specific elements' do + expect(subject).to include(:human_access, :toggle_award_path, :path) + end + + context 'when note is part of resolvable discussion' do + before do + allow(note).to receive(:part_of_discussion?).and_return(true) + allow(note).to receive(:resolvable?).and_return(true) + end + + it 'exposes paths to resolve note' do + expect(subject).to include(:resolve_path, :resolve_with_issue_path) + end + end +end diff --git a/spec/serializers/stage_entity_spec.rb b/spec/serializers/stage_entity_spec.rb index 40e303f7b89..2034c7891ef 100644 --- a/spec/serializers/stage_entity_spec.rb +++ b/spec/serializers/stage_entity_spec.rb @@ -26,7 +26,7 @@ describe StageEntity do end it 'contains detailed status' do - expect(subject[:status]).to include :text, :label, :group, :icon + expect(subject[:status]).to include :text, :label, :group, :icon, :tooltip expect(subject[:status][:label]).to eq 'passed' end diff --git a/spec/serializers/status_entity_spec.rb b/spec/serializers/status_entity_spec.rb index 70402bac2e2..559475e571c 100644 --- a/spec/serializers/status_entity_spec.rb +++ b/spec/serializers/status_entity_spec.rb @@ -16,7 +16,7 @@ describe StatusEntity do subject { entity.as_json } it 'contains status details' do - expect(subject).to include :text, :icon, :favicon, :label, :group + expect(subject).to include :text, :icon, :favicon, :label, :group, :tooltip expect(subject).to include :has_details, :details_path expect(subject[:favicon]).to match_asset_path('/assets/ci_favicons/favicon_status_success.ico') end diff --git a/spec/services/auth/container_registry_authentication_service_spec.rb b/spec/services/auth/container_registry_authentication_service_spec.rb index 290eeae828e..da8e660c16b 100644 --- a/spec/services/auth/container_registry_authentication_service_spec.rb +++ b/spec/services/auth/container_registry_authentication_service_spec.rb @@ -585,4 +585,140 @@ describe Auth::ContainerRegistryAuthenticationService do it_behaves_like 'not a container repository factory' end end + + context 'for deploy tokens' do + let(:current_params) do + { scope: "repository:#{project.full_path}:pull" } + end + + context 'when deploy token has read_registry as a scope' do + let(:current_user) { create(:deploy_token, projects: [project]) } + + context 'for public project' do + let(:project) { create(:project, :public) } + + context 'when pulling' do + it_behaves_like 'a pullable' + end + + context 'when pushing' do + let(:current_params) do + { scope: "repository:#{project.full_path}:push" } + end + + it_behaves_like 'an inaccessible' + end + end + + context 'for internal project' do + let(:project) { create(:project, :internal) } + + context 'when pulling' do + it_behaves_like 'a pullable' + end + + context 'when pushing' do + let(:current_params) do + { scope: "repository:#{project.full_path}:push" } + end + + it_behaves_like 'an inaccessible' + end + end + + context 'for private project' do + let(:project) { create(:project, :private) } + + context 'when pulling' do + it_behaves_like 'a pullable' + end + + context 'when pushing' do + let(:current_params) do + { scope: "repository:#{project.full_path}:push" } + end + + it_behaves_like 'an inaccessible' + end + end + end + + context 'when deploy token does not have read_registry scope' do + let(:current_user) { create(:deploy_token, projects: [project], read_registry: false) } + + context 'for public project' do + let(:project) { create(:project, :public) } + + context 'when pulling' do + it_behaves_like 'a pullable' + end + end + + context 'for internal project' do + let(:project) { create(:project, :internal) } + + context 'when pulling' do + it_behaves_like 'an inaccessible' + end + end + + context 'for private project' do + let(:project) { create(:project, :internal) } + + context 'when pulling' do + it_behaves_like 'an inaccessible' + end + end + end + + context 'when deploy token is not related to the project' do + let(:current_user) { create(:deploy_token, read_registry: false) } + + context 'for public project' do + let(:project) { create(:project, :public) } + + context 'when pulling' do + it_behaves_like 'a pullable' + end + end + + context 'for internal project' do + let(:project) { create(:project, :internal) } + + context 'when pulling' do + it_behaves_like 'an inaccessible' + end + end + + context 'for private project' do + let(:project) { create(:project, :internal) } + + context 'when pulling' do + it_behaves_like 'an inaccessible' + end + end + end + + context 'when deploy token has been revoked' do + let(:current_user) { create(:deploy_token, :revoked, projects: [project]) } + + context 'for public project' do + let(:project) { create(:project, :public) } + + it_behaves_like 'a pullable' + end + + context 'for internal project' do + let(:project) { create(:project, :internal) } + + it_behaves_like 'an inaccessible' + end + + context 'for private project' do + let(:project) { create(:project, :internal) } + + it_behaves_like 'an inaccessible' + end + end + end end diff --git a/spec/services/boards/issues/list_service_spec.rb b/spec/services/boards/issues/list_service_spec.rb index b4efa3e44b6..27a7bf0e605 100644 --- a/spec/services/boards/issues/list_service_spec.rb +++ b/spec/services/boards/issues/list_service_spec.rb @@ -48,10 +48,8 @@ describe Boards::Issues::ListService do context 'when parent is a group' do let(:user) { create(:user) } - let(:group) { create(:group) } let(:project) { create(:project, :empty_repo, namespace: group) } let(:project1) { create(:project, :empty_repo, namespace: group) } - let(:board) { create(:board, group: group) } let(:m1) { create(:milestone, group: group) } let(:m2) { create(:milestone, group: group) } @@ -92,13 +90,30 @@ describe Boards::Issues::ListService do let!(:closed_issue4) { create(:labeled_issue, :closed, project: project1, labels: [p1, p1_project1]) } let!(:closed_issue5) { create(:labeled_issue, :closed, project: project1, labels: [development]) } - let(:parent) { group } - before do group.add_developer(user) end - it_behaves_like 'issues list service' + context 'and group has no parent' do + let(:parent) { group } + let(:group) { create(:group) } + let(:board) { create(:board, group: group) } + + it_behaves_like 'issues list service' + end + + context 'and group is an ancestor', :nested_groups do + let(:parent) { create(:group) } + let(:group) { create(:group, parent: parent) } + let!(:backlog) { create(:backlog_list, board: board) } + let(:board) { create(:board, group: parent) } + + before do + parent.add_developer(user) + end + + it_behaves_like 'issues list service' + end end end end diff --git a/spec/services/boards/issues/move_service_spec.rb b/spec/services/boards/issues/move_service_spec.rb index 0a6b6d880d3..dd0ad5f11bd 100644 --- a/spec/services/boards/issues/move_service_spec.rb +++ b/spec/services/boards/issues/move_service_spec.rb @@ -48,7 +48,7 @@ describe Boards::Issues::MoveService do parent.add_developer(user) end - it_behaves_like 'issues move service' + it_behaves_like 'issues move service', true end end end diff --git a/spec/services/ci/register_job_service_spec.rb b/spec/services/ci/register_job_service_spec.rb index 97a563c1ce1..aa7cc268dd7 100644 --- a/spec/services/ci/register_job_service_spec.rb +++ b/spec/services/ci/register_job_service_spec.rb @@ -370,10 +370,89 @@ module Ci it_behaves_like 'validation is not active' end end + end - def execute(runner) - described_class.new(runner).execute.build + describe '#register_success' do + let!(:current_time) { Time.new(2018, 4, 5, 14, 0, 0) } + let!(:attempt_counter) { double('Gitlab::Metrics::NullMetric') } + let!(:job_queue_duration_seconds) { double('Gitlab::Metrics::NullMetric') } + + before do + allow(Time).to receive(:now).and_return(current_time) + + # Stub defaults for any metrics other than the ones we're testing + allow(Gitlab::Metrics).to receive(:counter) + .with(any_args) + .and_return(Gitlab::Metrics::NullMetric.instance) + allow(Gitlab::Metrics).to receive(:histogram) + .with(any_args) + .and_return(Gitlab::Metrics::NullMetric.instance) + + # Stub tested metrics + allow(Gitlab::Metrics).to receive(:counter) + .with(:job_register_attempts_total, anything) + .and_return(attempt_counter) + allow(Gitlab::Metrics).to receive(:histogram) + .with(:job_queue_duration_seconds, anything, anything, anything) + .and_return(job_queue_duration_seconds) + + project.update(shared_runners_enabled: true) + pending_job.update(created_at: current_time - 3600, queued_at: current_time - 1800) end + + shared_examples 'metrics collector' do + it 'increments attempt counter' do + allow(job_queue_duration_seconds).to receive(:observe) + expect(attempt_counter).to receive(:increment) + + execute(runner) + end + + it 'counts job queuing time histogram with expected labels' do + allow(attempt_counter).to receive(:increment) + expect(job_queue_duration_seconds).to receive(:observe) + .with({ shared_runner: expected_shared_runner, + jobs_running_for_project: expected_jobs_running_for_project_first_job }, 1800) + + execute(runner) + end + + context 'when project already has running jobs' do + let!(:build2) { create( :ci_build, :running, pipeline: pipeline, runner: shared_runner) } + let!(:build3) { create( :ci_build, :running, pipeline: pipeline, runner: shared_runner) } + + it 'counts job queuing time histogram with expected labels' do + allow(attempt_counter).to receive(:increment) + expect(job_queue_duration_seconds).to receive(:observe) + .with({ shared_runner: expected_shared_runner, + jobs_running_for_project: expected_jobs_running_for_project_third_job }, 1800) + + execute(runner) + end + end + end + + context 'when shared runner is used' do + let(:runner) { shared_runner } + let(:expected_shared_runner) { true } + let(:expected_jobs_running_for_project_first_job) { 0 } + let(:expected_jobs_running_for_project_third_job) { 2 } + + it_behaves_like 'metrics collector' + end + + context 'when specific runner is used' do + let(:runner) { specific_runner } + let(:expected_shared_runner) { false } + let(:expected_jobs_running_for_project_first_job) { '+Inf' } + let(:expected_jobs_running_for_project_third_job) { '+Inf' } + + it_behaves_like 'metrics collector' + end + end + + def execute(runner) + described_class.new(runner).execute.build end end end diff --git a/spec/services/deploy_tokens/create_service_spec.rb b/spec/services/deploy_tokens/create_service_spec.rb new file mode 100644 index 00000000000..3a2bbf1ecd1 --- /dev/null +++ b/spec/services/deploy_tokens/create_service_spec.rb @@ -0,0 +1,45 @@ +require 'spec_helper' + +describe DeployTokens::CreateService do + let(:project) { create(:project) } + let(:user) { create(:user) } + let(:deploy_token_params) { attributes_for(:deploy_token) } + + describe '#execute' do + subject { described_class.new(project, user, deploy_token_params).execute } + + context 'when the deploy token is valid' do + it 'should create a new DeployToken' do + expect { subject }.to change { DeployToken.count }.by(1) + end + + it 'should create a new ProjectDeployToken' do + expect { subject }.to change { ProjectDeployToken.count }.by(1) + end + + it 'returns a DeployToken' do + expect(subject).to be_an_instance_of DeployToken + end + end + + context 'when expires at date is not passed' do + let(:deploy_token_params) { attributes_for(:deploy_token, expires_at: '') } + + it 'should set Forever.date' do + expect(subject.read_attribute(:expires_at)).to eq(Forever.date) + end + end + + context 'when the deploy token is invalid' do + let(:deploy_token_params) { attributes_for(:deploy_token, read_repository: false, read_registry: false) } + + it 'should not create a new DeployToken' do + expect { subject }.not_to change { DeployToken.count } + end + + it 'should not create a new ProjectDeployToken' do + expect { subject }.not_to change { ProjectDeployToken.count } + end + end + end +end diff --git a/spec/services/issuable/destroy_service_spec.rb b/spec/services/issuable/destroy_service_spec.rb index 0a3647a814f..8ccbba7fa58 100644 --- a/spec/services/issuable/destroy_service_spec.rb +++ b/spec/services/issuable/destroy_service_spec.rb @@ -8,7 +8,7 @@ describe Issuable::DestroyService do describe '#execute' do context 'when issuable is an issue' do - let!(:issue) { create(:issue, project: project, author: user) } + let!(:issue) { create(:issue, project: project, author: user, assignees: [user]) } it 'destroys the issue' do expect { service.execute(issue) }.to change { project.issues.count }.by(-1) @@ -26,10 +26,15 @@ describe Issuable::DestroyService do expect { service.execute(issue) } .to change { user.todos_pending_count }.from(1).to(0) end + + it 'invalidates the issues count cache for the assignees' do + expect_any_instance_of(User).to receive(:invalidate_cache_counts).once + service.execute(issue) + end end context 'when issuable is a merge request' do - let!(:merge_request) { create(:merge_request, target_project: project, source_project: project, author: user) } + let!(:merge_request) { create(:merge_request, target_project: project, source_project: project, author: user, assignee: user) } it 'destroys the merge request' do expect { service.execute(merge_request) }.to change { project.merge_requests.count }.by(-1) @@ -41,6 +46,11 @@ describe Issuable::DestroyService do service.execute(merge_request) end + it 'invalidates the merge request caches for the MR assignee' do + expect_any_instance_of(User).to receive(:invalidate_cache_counts).once + service.execute(merge_request) + end + it 'updates the todo caches for users with todos on the merge request' do create(:todo, target: merge_request, user: user, author: user, project: project) diff --git a/spec/services/issues/close_service_spec.rb b/spec/services/issues/close_service_spec.rb index 47c1ebbeb81..7ae49c06896 100644 --- a/spec/services/issues/close_service_spec.rb +++ b/spec/services/issues/close_service_spec.rb @@ -67,6 +67,10 @@ describe Issues::CloseService do expect(issue).to be_closed end + it 'records closed user' do + expect(issue.closed_by_id).to be(user.id) + end + it 'sends email to user2 about assign of new issue' do email = ActionMailer::Base.deliveries.last expect(email.to.first).to eq(user2.email) diff --git a/spec/services/issues/update_service_spec.rb b/spec/services/issues/update_service_spec.rb index 41237dd7160..23b1134b5a3 100644 --- a/spec/services/issues/update_service_spec.rb +++ b/spec/services/issues/update_service_spec.rb @@ -97,6 +97,39 @@ describe Issues::UpdateService, :mailer do expect(issue.relative_position).to be_between(issue1.relative_position, issue2.relative_position) end + context 'when moving issue between issues from different projects', :nested_groups do + let(:group) { create(:group) } + let(:subgroup) { create(:group, parent: group) } + + let(:project_1) { create(:project, namespace: group) } + let(:project_2) { create(:project, namespace: group) } + let(:project_3) { create(:project, namespace: subgroup) } + + let(:issue_1) { create(:issue, project: project_1) } + let(:issue_2) { create(:issue, project: project_2) } + let(:issue_3) { create(:issue, project: project_3) } + + before do + group.add_developer(user) + end + + it 'sorts issues as specified by parameters' do + # Moving all issues to end here like the last example won't work since + # all projects only have the same issue count + # so their relative_position will be the same. + issue_1.move_to_end + issue_2.move_after(issue_1) + issue_3.move_after(issue_2) + [issue_1, issue_2, issue_3].map(&:save) + + opts[:move_between_ids] = [issue_1.id, issue_2.id] + opts[:board_group_id] = group.id + + described_class.new(issue_3.project, user, opts).execute(issue_3) + expect(issue_2.relative_position).to be_between(issue_1.relative_position, issue_2.relative_position) + end + end + context 'when current user cannot admin issues in the project' do let(:guest) { create(:user) } before do diff --git a/spec/services/merge_requests/conflicts/list_service_spec.rb b/spec/services/merge_requests/conflicts/list_service_spec.rb index 6cadcd438c3..837b8a56d12 100644 --- a/spec/services/merge_requests/conflicts/list_service_spec.rb +++ b/spec/services/merge_requests/conflicts/list_service_spec.rb @@ -77,6 +77,14 @@ describe MergeRequests::Conflicts::ListService do expect(service.can_be_resolved_in_ui?).to be_falsey end + it 'returns a falsey value when the MR has a missing revision after a force push' do + merge_request = create_merge_request('conflict-resolvable') + service = conflicts_service(merge_request) + allow(merge_request).to receive_message_chain(:target_branch_head, :raw, :id).and_return(Gitlab::Git::BLANK_SHA) + + expect(service.can_be_resolved_in_ui?).to be_falsey + end + context 'with gitaly disabled', :skip_gitaly_mock do it 'returns a falsey value when the MR has a missing ref after a force push' do merge_request = create_merge_request('conflict-resolvable') @@ -85,6 +93,14 @@ describe MergeRequests::Conflicts::ListService do expect(service.can_be_resolved_in_ui?).to be_falsey end + + it 'returns a falsey value when the MR has a missing revision after a force push' do + merge_request = create_merge_request('conflict-resolvable') + service = conflicts_service(merge_request) + allow(merge_request).to receive_message_chain(:target_branch_head, :raw, :id).and_return(Gitlab::Git::BLANK_SHA) + + expect(service.can_be_resolved_in_ui?).to be_falsey + end end end end diff --git a/spec/services/notes/post_process_service_spec.rb b/spec/services/notes/post_process_service_spec.rb index 6ef5e93cb20..4e2ab919f0f 100644 --- a/spec/services/notes/post_process_service_spec.rb +++ b/spec/services/notes/post_process_service_spec.rb @@ -23,5 +23,23 @@ describe Notes::PostProcessService do described_class.new(@note).execute end + + context 'with a confidential issue' do + let(:issue) { create(:issue, :confidential, project: project) } + + it "doesn't call note hooks/services" do + expect(project).not_to receive(:execute_hooks).with(anything, :note_hooks) + expect(project).not_to receive(:execute_services).with(anything, :note_hooks) + + described_class.new(@note).execute + end + + it "calls confidential-note hooks/services" do + expect(project).to receive(:execute_hooks).with(anything, :confidential_note_hooks) + expect(project).to receive(:execute_services).with(anything, :confidential_note_hooks) + + described_class.new(@note).execute + end + end end end diff --git a/spec/services/projects/create_service_spec.rb b/spec/services/projects/create_service_spec.rb index 2cacb97a293..e35f0f6337a 100644 --- a/spec/services/projects/create_service_spec.rb +++ b/spec/services/projects/create_service_spec.rb @@ -28,6 +28,14 @@ describe Projects::CreateService, '#execute' do end end + describe 'after create actions' do + it 'invalidate personal_projects_count caches' do + expect(user).to receive(:invalidate_personal_projects_count) + + create_project(user, opts) + end + end + context "admin creates project with other user's namespace_id" do it 'sets the correct permissions' do admin = create(:admin) diff --git a/spec/services/projects/destroy_service_spec.rb b/spec/services/projects/destroy_service_spec.rb index 0bec2054f50..a66e3c5e995 100644 --- a/spec/services/projects/destroy_service_spec.rb +++ b/spec/services/projects/destroy_service_spec.rb @@ -66,6 +66,12 @@ describe Projects::DestroyService do end it_behaves_like 'deleting the project' + + it 'invalidates personal_project_count cache' do + expect(user).to receive(:invalidate_personal_projects_count) + + destroy_project(project, user) + end end context 'Sidekiq fake' do @@ -242,6 +248,28 @@ describe Projects::DestroyService do end end + context '#attempt_restore_repositories' do + let(:path) { project.disk_path + '.git' } + + before do + expect(project.gitlab_shell.exists?(project.repository_storage_path, path)).to be_truthy + expect(project.gitlab_shell.exists?(project.repository_storage_path, remove_path)).to be_falsey + + # Dont run sidekiq to check if renamed repository exists + Sidekiq::Testing.fake! { destroy_project(project, user, {}) } + + expect(project.gitlab_shell.exists?(project.repository_storage_path, path)).to be_falsey + expect(project.gitlab_shell.exists?(project.repository_storage_path, remove_path)).to be_truthy + end + + it 'restores the repositories' do + Sidekiq::Testing.fake! { described_class.new(project, user).attempt_repositories_rollback } + + expect(project.gitlab_shell.exists?(project.repository_storage_path, path)).to be_truthy + expect(project.gitlab_shell.exists?(project.repository_storage_path, remove_path)).to be_falsey + end + end + def destroy_project(project, user, params = {}) if async Projects::DestroyService.new(project, user, params).async_execute diff --git a/spec/services/projects/gitlab_projects_import_service_spec.rb b/spec/services/projects/gitlab_projects_import_service_spec.rb index 6b8f9619bc4..ee1a886f5d6 100644 --- a/spec/services/projects/gitlab_projects_import_service_spec.rb +++ b/spec/services/projects/gitlab_projects_import_service_spec.rb @@ -2,8 +2,11 @@ require 'spec_helper' describe Projects::GitlabProjectsImportService do set(:namespace) { create(:namespace) } + let(:path) { 'test-path' } let(:file) { fixture_file_upload(Rails.root + 'spec/fixtures/doc_sample.txt', 'text/plain') } - subject { described_class.new(namespace.owner, { namespace_id: namespace.id, path: path, file: file }) } + let(:overwrite) { false } + let(:import_params) { { namespace_id: namespace.id, path: path, file: file, overwrite: overwrite } } + subject { described_class.new(namespace.owner, import_params) } describe '#execute' do context 'with an invalid path' do @@ -18,8 +21,6 @@ describe Projects::GitlabProjectsImportService do end context 'with a valid path' do - let(:path) { 'test-path' } - it 'creates a project' do project = subject.execute @@ -27,5 +28,38 @@ describe Projects::GitlabProjectsImportService do expect(project).to be_valid end end + + context 'override params' do + it 'stores them as import data when passed' do + project = described_class + .new(namespace.owner, import_params, description: 'Hello') + .execute + + expect(project.import_data.data['override_params']['description']).to eq('Hello') + end + end + + context 'when there is a project with the same path' do + let(:existing_project) { create(:project, namespace: namespace) } + let(:path) { existing_project.path} + + it 'does not create the project' do + project = subject.execute + + expect(project).to be_invalid + expect(project).not_to be_persisted + end + + context 'when overwrite param is set' do + let(:overwrite) { true } + + it 'creates a project in a temporary full_path' do + project = subject.execute + + expect(project).to be_valid + expect(project).to be_persisted + end + end + end end end diff --git a/spec/services/projects/import_export/export_service_spec.rb b/spec/services/projects/import_export/export_service_spec.rb new file mode 100644 index 00000000000..f9e5530bc9d --- /dev/null +++ b/spec/services/projects/import_export/export_service_spec.rb @@ -0,0 +1,128 @@ +require 'spec_helper' + +describe Projects::ImportExport::ExportService do + describe '#execute' do + let!(:user) { create(:user) } + let(:project) { create(:project) } + let(:shared) { project.import_export_shared } + let(:service) { described_class.new(project, user) } + let!(:after_export_strategy) { Gitlab::ImportExport::AfterExportStrategies::DownloadNotificationStrategy.new } + + it 'saves the version' do + expect(Gitlab::ImportExport::VersionSaver).to receive(:new).and_call_original + + service.execute + end + + it 'saves the avatar' do + expect(Gitlab::ImportExport::AvatarSaver).to receive(:new).and_call_original + + service.execute + end + + it 'saves the models' do + expect(Gitlab::ImportExport::ProjectTreeSaver).to receive(:new).and_call_original + + service.execute + end + + it 'saves the uploads' do + expect(Gitlab::ImportExport::UploadsSaver).to receive(:new).and_call_original + + service.execute + end + + it 'saves the repo' do + # once for the normal repo, once for the wiki + expect(Gitlab::ImportExport::RepoSaver).to receive(:new).twice.and_call_original + + service.execute + end + + it 'saves the lfs objects' do + expect(Gitlab::ImportExport::LfsSaver).to receive(:new).and_call_original + + service.execute + end + + it 'saves the wiki repo' do + expect(Gitlab::ImportExport::WikiRepoSaver).to receive(:new).and_call_original + + service.execute + end + + context 'when all saver services succeed' do + before do + allow(service).to receive(:save_services).and_return(true) + end + + it 'saves the project in the file system' do + expect(Gitlab::ImportExport::Saver).to receive(:save).with(project: project, shared: shared) + + service.execute + end + + it 'calls the after export strategy' do + expect(after_export_strategy).to receive(:execute) + + service.execute(after_export_strategy) + end + + context 'when after export strategy fails' do + before do + allow(after_export_strategy).to receive(:execute).and_return(false) + end + + after do + service.execute(after_export_strategy) + end + + it 'removes the remaining exported data' do + allow(shared).to receive(:export_path).and_return('whatever') + allow(FileUtils).to receive(:rm_rf) + + expect(FileUtils).to receive(:rm_rf).with(shared.export_path) + end + + it 'notifies the user' do + expect_any_instance_of(NotificationService).to receive(:project_not_exported) + end + + it 'notifies logger' do + allow(Rails.logger).to receive(:error) + + expect(Rails.logger).to receive(:error) + end + end + end + + context 'when saver services fail' do + before do + allow(service).to receive(:save_services).and_return(false) + end + + after do + expect { service.execute }.to raise_error(Gitlab::ImportExport::Error) + end + + it 'removes the remaining exported data' do + allow(shared).to receive(:export_path).and_return('whatever') + allow(FileUtils).to receive(:rm_rf) + + expect(FileUtils).to receive(:rm_rf).with(shared.export_path) + end + + it 'notifies the user' do + expect_any_instance_of(NotificationService).to receive(:project_not_exported) + end + + it 'notifies logger' do + expect(Rails.logger).to receive(:error) + end + + it 'the after export strategy is not called' do + expect(service).not_to receive(:execute_after_export_action) + end + end + end +end diff --git a/spec/services/projects/import_service_spec.rb b/spec/services/projects/import_service_spec.rb index bf7facaec99..30c89ebd821 100644 --- a/spec/services/projects/import_service_spec.rb +++ b/spec/services/projects/import_service_spec.rb @@ -156,7 +156,7 @@ describe Projects::ImportService do result = described_class.new(project, user).execute expect(result[:status]).to eq :error - expect(result[:message]).to end_with 'Blocked import URL.' + expect(result[:message]).to include('Requests to localhost are not allowed') end it 'fails with port 25' do @@ -165,7 +165,7 @@ describe Projects::ImportService do result = described_class.new(project, user).execute expect(result[:status]).to eq :error - expect(result[:message]).to end_with 'Blocked import URL.' + expect(result[:message]).to include('Only allowed ports are 22, 80, 443') end end diff --git a/spec/services/projects/move_access_service_spec.rb b/spec/services/projects/move_access_service_spec.rb new file mode 100644 index 00000000000..a820ebd91f4 --- /dev/null +++ b/spec/services/projects/move_access_service_spec.rb @@ -0,0 +1,114 @@ +require 'spec_helper' + +describe Projects::MoveAccessService do + let(:user) { create(:user) } + let(:group) { create(:group) } + let(:project_with_access) { create(:project, namespace: user.namespace) } + let(:master_user) { create(:user) } + let(:reporter_user) { create(:user) } + let(:developer_user) { create(:user) } + let(:master_group) { create(:group) } + let(:reporter_group) { create(:group) } + let(:developer_group) { create(:group) } + + before do + project_with_access.add_master(master_user) + project_with_access.add_developer(developer_user) + project_with_access.add_reporter(reporter_user) + project_with_access.project_group_links.create(group: master_group, group_access: Gitlab::Access::MASTER) + project_with_access.project_group_links.create(group: developer_group, group_access: Gitlab::Access::DEVELOPER) + project_with_access.project_group_links.create(group: reporter_group, group_access: Gitlab::Access::REPORTER) + end + + subject { described_class.new(target_project, user) } + + describe '#execute' do + shared_examples 'move the accesses' do + it do + expect(project_with_access.project_members.count).to eq 4 + expect(project_with_access.project_group_links.count).to eq 3 + expect(project_with_access.authorized_users.count).to eq 4 + + subject.execute(project_with_access) + + expect(project_with_access.project_members.count).to eq 0 + expect(project_with_access.project_group_links.count).to eq 0 + expect(project_with_access.authorized_users.count).to eq 1 + expect(target_project.project_members.count).to eq 4 + expect(target_project.project_group_links.count).to eq 3 + expect(target_project.authorized_users.count).to eq 4 + end + + it 'rollbacks if an exception is raised' do + allow(subject).to receive(:success).and_raise(StandardError) + + expect { subject.execute(project_with_groups) }.to raise_error(StandardError) + + expect(project_with_access.project_members.count).to eq 4 + expect(project_with_access.project_group_links.count).to eq 3 + expect(project_with_access.authorized_users.count).to eq 4 + end + end + + context 'when both projects are in the same namespace' do + let(:target_project) { create(:project, namespace: user.namespace) } + + it 'does not refresh project owner authorized projects' do + allow(project_with_access).to receive(:namespace).and_return(user.namespace) + expect(project_with_access.namespace).not_to receive(:refresh_project_authorizations) + expect(target_project.namespace).not_to receive(:refresh_project_authorizations) + + subject.execute(project_with_access) + end + + it_behaves_like 'move the accesses' + end + + context 'when projects are in different namespaces' do + let(:target_project) { create(:project, namespace: group) } + + before do + group.add_owner(user) + end + + it 'refreshes both project owner authorized projects' do + allow(project_with_access).to receive(:namespace).and_return(user.namespace) + expect(user.namespace).to receive(:refresh_project_authorizations).once + expect(group).to receive(:refresh_project_authorizations).once + + subject.execute(project_with_access) + end + + it_behaves_like 'move the accesses' + end + + context 'when remove_remaining_elements is false' do + let(:target_project) { create(:project, namespace: user.namespace) } + let(:options) { { remove_remaining_elements: false } } + + it 'does not remove remaining memberships' do + target_project.add_master(master_user) + + subject.execute(project_with_access, options) + + expect(project_with_access.project_members.count).not_to eq 0 + end + + it 'does not remove remaining group links' do + target_project.project_group_links.create(group: master_group, group_access: Gitlab::Access::MASTER) + + subject.execute(project_with_access, options) + + expect(project_with_access.project_group_links.count).not_to eq 0 + end + + it 'does not remove remaining authorizations' do + target_project.add_developer(developer_user) + + subject.execute(project_with_access, options) + + expect(project_with_access.project_authorizations.count).not_to eq 0 + end + end + end +end diff --git a/spec/services/projects/move_deploy_keys_projects_service_spec.rb b/spec/services/projects/move_deploy_keys_projects_service_spec.rb new file mode 100644 index 00000000000..c548edf39a8 --- /dev/null +++ b/spec/services/projects/move_deploy_keys_projects_service_spec.rb @@ -0,0 +1,58 @@ +require 'spec_helper' + +describe Projects::MoveDeployKeysProjectsService do + let!(:user) { create(:user) } + let!(:project_with_deploy_keys) { create(:project, namespace: user.namespace) } + let!(:target_project) { create(:project, namespace: user.namespace) } + + subject { described_class.new(target_project, user) } + + describe '#execute' do + before do + create_list(:deploy_keys_project, 2, project: project_with_deploy_keys) + end + + it 'moves the user\'s deploy keys from one project to another' do + expect(project_with_deploy_keys.deploy_keys_projects.count).to eq 2 + expect(target_project.deploy_keys_projects.count).to eq 0 + + subject.execute(project_with_deploy_keys) + + expect(project_with_deploy_keys.deploy_keys_projects.count).to eq 0 + expect(target_project.deploy_keys_projects.count).to eq 2 + end + + it 'does not link existent deploy_keys in the current project' do + target_project.deploy_keys << project_with_deploy_keys.deploy_keys.first + + expect(project_with_deploy_keys.deploy_keys_projects.count).to eq 2 + expect(target_project.deploy_keys_projects.count).to eq 1 + + subject.execute(project_with_deploy_keys) + + expect(project_with_deploy_keys.deploy_keys_projects.count).to eq 0 + expect(target_project.deploy_keys_projects.count).to eq 2 + end + + it 'rollbacks changes if transaction fails' do + allow(subject).to receive(:success).and_raise(StandardError) + + expect { subject.execute(project_with_deploy_keys) }.to raise_error(StandardError) + + expect(project_with_deploy_keys.deploy_keys_projects.count).to eq 2 + expect(target_project.deploy_keys_projects.count).to eq 0 + end + + context 'when remove_remaining_elements is false' do + let(:options) { { remove_remaining_elements: false } } + + it 'does not remove remaining deploy keys projects' do + target_project.deploy_keys << project_with_deploy_keys.deploy_keys.first + + subject.execute(project_with_deploy_keys, options) + + expect(project_with_deploy_keys.deploy_keys_projects.count).not_to eq 0 + end + end + end +end diff --git a/spec/services/projects/move_forks_service_spec.rb b/spec/services/projects/move_forks_service_spec.rb new file mode 100644 index 00000000000..f4a5a7f9fc2 --- /dev/null +++ b/spec/services/projects/move_forks_service_spec.rb @@ -0,0 +1,96 @@ +require 'spec_helper' + +describe Projects::MoveForksService do + include ProjectForksHelper + + let!(:user) { create(:user) } + let!(:project_with_forks) { create(:project, namespace: user.namespace) } + let!(:target_project) { create(:project, namespace: user.namespace) } + let!(:lvl1_forked_project_1) { fork_project(project_with_forks, user) } + let!(:lvl1_forked_project_2) { fork_project(project_with_forks, user) } + let!(:lvl2_forked_project_1_1) { fork_project(lvl1_forked_project_1, user) } + let!(:lvl2_forked_project_1_2) { fork_project(lvl1_forked_project_1, user) } + + subject { described_class.new(target_project, user) } + + describe '#execute' do + context 'when moving a root forked project' do + it 'moves the descendant forks' do + expect(project_with_forks.forks.count).to eq 2 + expect(target_project.forks.count).to eq 0 + + subject.execute(project_with_forks) + + expect(project_with_forks.forks.count).to eq 0 + expect(target_project.forks.count).to eq 2 + expect(lvl1_forked_project_1.forked_from_project).to eq target_project + expect(lvl1_forked_project_1.fork_network_member.forked_from_project).to eq target_project + expect(lvl1_forked_project_2.forked_from_project).to eq target_project + expect(lvl1_forked_project_2.fork_network_member.forked_from_project).to eq target_project + end + + it 'updates the fork network' do + expect(project_with_forks.fork_network.root_project).to eq project_with_forks + expect(project_with_forks.fork_network.fork_network_members.map(&:project)).to include project_with_forks + + subject.execute(project_with_forks) + + expect(target_project.reload.fork_network.root_project).to eq target_project + expect(target_project.fork_network.fork_network_members.map(&:project)).not_to include project_with_forks + end + end + + context 'when moving a intermediate forked project' do + it 'moves the descendant forks' do + expect(lvl1_forked_project_1.forks.count).to eq 2 + expect(target_project.forks.count).to eq 0 + + subject.execute(lvl1_forked_project_1) + + expect(lvl1_forked_project_1.forks.count).to eq 0 + expect(target_project.forks.count).to eq 2 + expect(lvl2_forked_project_1_1.forked_from_project).to eq target_project + expect(lvl2_forked_project_1_1.fork_network_member.forked_from_project).to eq target_project + expect(lvl2_forked_project_1_2.forked_from_project).to eq target_project + expect(lvl2_forked_project_1_2.fork_network_member.forked_from_project).to eq target_project + end + + it 'moves the ascendant fork' do + subject.execute(lvl1_forked_project_1) + + expect(target_project.forked_from_project).to eq project_with_forks + expect(target_project.fork_network_member.forked_from_project).to eq project_with_forks + end + + it 'does not update fork network' do + subject.execute(lvl1_forked_project_1) + + expect(target_project.reload.fork_network.root_project).to eq project_with_forks + end + end + + context 'when moving a leaf forked project' do + it 'moves the ascendant fork' do + subject.execute(lvl2_forked_project_1_1) + + expect(target_project.forked_from_project).to eq lvl1_forked_project_1 + expect(target_project.fork_network_member.forked_from_project).to eq lvl1_forked_project_1 + end + + it 'does not update fork network' do + subject.execute(lvl2_forked_project_1_1) + + expect(target_project.reload.fork_network.root_project).to eq project_with_forks + end + end + + it 'rollbacks changes if transaction fails' do + allow(subject).to receive(:success).and_raise(StandardError) + + expect { subject.execute(project_with_forks) }.to raise_error(StandardError) + + expect(project_with_forks.forks.count).to eq 2 + expect(target_project.forks.count).to eq 0 + end + end +end diff --git a/spec/services/projects/move_lfs_objects_projects_service_spec.rb b/spec/services/projects/move_lfs_objects_projects_service_spec.rb new file mode 100644 index 00000000000..517a24a982a --- /dev/null +++ b/spec/services/projects/move_lfs_objects_projects_service_spec.rb @@ -0,0 +1,55 @@ +require 'spec_helper' + +describe Projects::MoveLfsObjectsProjectsService do + let!(:user) { create(:user) } + let!(:project_with_lfs_objects) { create(:project, namespace: user.namespace) } + let!(:target_project) { create(:project, namespace: user.namespace) } + + subject { described_class.new(target_project, user) } + + before do + create_list(:lfs_objects_project, 3, project: project_with_lfs_objects) + end + + describe '#execute' do + it 'links the lfs objects from existent in source project' do + expect(target_project.lfs_objects.count).to eq 0 + + subject.execute(project_with_lfs_objects) + + expect(project_with_lfs_objects.reload.lfs_objects.count).to eq 0 + expect(target_project.reload.lfs_objects.count).to eq 3 + end + + it 'does not link existent lfs_object in the current project' do + target_project.lfs_objects << project_with_lfs_objects.lfs_objects.first(2) + + expect(target_project.lfs_objects.count).to eq 2 + + subject.execute(project_with_lfs_objects) + + expect(target_project.lfs_objects.count).to eq 3 + end + + it 'rollbacks changes if transaction fails' do + allow(subject).to receive(:success).and_raise(StandardError) + + expect { subject.execute(project_with_lfs_objects) }.to raise_error(StandardError) + + expect(project_with_lfs_objects.lfs_objects.count).to eq 3 + expect(target_project.lfs_objects.count).to eq 0 + end + + context 'when remove_remaining_elements is false' do + let(:options) { { remove_remaining_elements: false } } + + it 'does not remove remaining lfs objects' do + target_project.lfs_objects << project_with_lfs_objects.lfs_objects.first(2) + + subject.execute(project_with_lfs_objects, options) + + expect(project_with_lfs_objects.lfs_objects.count).not_to eq 0 + end + end + end +end diff --git a/spec/services/projects/move_notification_settings_service_spec.rb b/spec/services/projects/move_notification_settings_service_spec.rb new file mode 100644 index 00000000000..24d69eef86a --- /dev/null +++ b/spec/services/projects/move_notification_settings_service_spec.rb @@ -0,0 +1,56 @@ +require 'spec_helper' + +describe Projects::MoveNotificationSettingsService do + let(:user) { create(:user) } + let(:project_with_notifications) { create(:project, namespace: user.namespace) } + let(:target_project) { create(:project, namespace: user.namespace) } + + subject { described_class.new(target_project, user) } + + describe '#execute' do + context 'with notification settings' do + before do + create_list(:notification_setting, 2, source: project_with_notifications) + end + + it 'moves the user\'s notification settings from one project to another' do + expect(project_with_notifications.notification_settings.count).to eq 3 + expect(target_project.notification_settings.count).to eq 1 + + subject.execute(project_with_notifications) + + expect(project_with_notifications.notification_settings.count).to eq 0 + expect(target_project.notification_settings.count).to eq 3 + end + + it 'rollbacks changes if transaction fails' do + allow(subject).to receive(:success).and_raise(StandardError) + + expect { subject.execute(project_with_notifications) }.to raise_error(StandardError) + + expect(project_with_notifications.notification_settings.count).to eq 3 + expect(target_project.notification_settings.count).to eq 1 + end + end + + it 'does not move existent notification settings in the current project' do + expect(project_with_notifications.notification_settings.count).to eq 1 + expect(target_project.notification_settings.count).to eq 1 + expect(user.notification_settings.count).to eq 2 + + subject.execute(project_with_notifications) + + expect(user.notification_settings.count).to eq 1 + end + + context 'when remove_remaining_elements is false' do + let(:options) { { remove_remaining_elements: false } } + + it 'does not remove remaining notification settings' do + subject.execute(project_with_notifications, options) + + expect(project_with_notifications.notification_settings.count).not_to eq 0 + end + end + end +end diff --git a/spec/services/projects/move_project_authorizations_service_spec.rb b/spec/services/projects/move_project_authorizations_service_spec.rb new file mode 100644 index 00000000000..f7262b9b887 --- /dev/null +++ b/spec/services/projects/move_project_authorizations_service_spec.rb @@ -0,0 +1,56 @@ +require 'spec_helper' + +describe Projects::MoveProjectAuthorizationsService do + let!(:user) { create(:user) } + let(:project_with_users) { create(:project, namespace: user.namespace) } + let(:target_project) { create(:project, namespace: user.namespace) } + let(:master_user) { create(:user) } + let(:reporter_user) { create(:user) } + let(:developer_user) { create(:user) } + + subject { described_class.new(target_project, user) } + + describe '#execute' do + before do + project_with_users.add_master(master_user) + project_with_users.add_developer(developer_user) + project_with_users.add_reporter(reporter_user) + end + + it 'moves the authorizations from one project to another' do + expect(project_with_users.authorized_users.count).to eq 4 + expect(target_project.authorized_users.count).to eq 1 + + subject.execute(project_with_users) + + expect(project_with_users.authorized_users.count).to eq 0 + expect(target_project.authorized_users.count).to eq 4 + end + + it 'does not move existent authorizations to the current project' do + target_project.add_master(developer_user) + target_project.add_developer(reporter_user) + + expect(project_with_users.authorized_users.count).to eq 4 + expect(target_project.authorized_users.count).to eq 3 + + subject.execute(project_with_users) + + expect(project_with_users.authorized_users.count).to eq 0 + expect(target_project.authorized_users.count).to eq 4 + end + + context 'when remove_remaining_elements is false' do + let(:options) { { remove_remaining_elements: false } } + + it 'does not remove remaining project authorizations' do + target_project.add_master(developer_user) + target_project.add_developer(reporter_user) + + subject.execute(project_with_users, options) + + expect(project_with_users.project_authorizations.count).not_to eq 0 + end + end + end +end diff --git a/spec/services/projects/move_project_group_links_service_spec.rb b/spec/services/projects/move_project_group_links_service_spec.rb new file mode 100644 index 00000000000..e3d06e6d3d7 --- /dev/null +++ b/spec/services/projects/move_project_group_links_service_spec.rb @@ -0,0 +1,65 @@ +require 'spec_helper' + +describe Projects::MoveProjectGroupLinksService do + let!(:user) { create(:user) } + let(:project_with_groups) { create(:project, namespace: user.namespace) } + let(:target_project) { create(:project, namespace: user.namespace) } + let(:master_group) { create(:group) } + let(:reporter_group) { create(:group) } + let(:developer_group) { create(:group) } + + subject { described_class.new(target_project, user) } + + describe '#execute' do + before do + project_with_groups.project_group_links.create(group: master_group, group_access: Gitlab::Access::MASTER) + project_with_groups.project_group_links.create(group: developer_group, group_access: Gitlab::Access::DEVELOPER) + project_with_groups.project_group_links.create(group: reporter_group, group_access: Gitlab::Access::REPORTER) + end + + it 'moves the group links from one project to another' do + expect(project_with_groups.project_group_links.count).to eq 3 + expect(target_project.project_group_links.count).to eq 0 + + subject.execute(project_with_groups) + + expect(project_with_groups.project_group_links.count).to eq 0 + expect(target_project.project_group_links.count).to eq 3 + end + + it 'does not move existent group links in the current project' do + target_project.project_group_links.create(group: master_group, group_access: Gitlab::Access::MASTER) + target_project.project_group_links.create(group: developer_group, group_access: Gitlab::Access::DEVELOPER) + + expect(project_with_groups.project_group_links.count).to eq 3 + expect(target_project.project_group_links.count).to eq 2 + + subject.execute(project_with_groups) + + expect(project_with_groups.project_group_links.count).to eq 0 + expect(target_project.project_group_links.count).to eq 3 + end + + it 'rollbacks changes if transaction fails' do + allow(subject).to receive(:success).and_raise(StandardError) + + expect { subject.execute(project_with_groups) }.to raise_error(StandardError) + + expect(project_with_groups.project_group_links.count).to eq 3 + expect(target_project.project_group_links.count).to eq 0 + end + + context 'when remove_remaining_elements is false' do + let(:options) { { remove_remaining_elements: false } } + + it 'does not remove remaining project group links' do + target_project.project_group_links.create(group: master_group, group_access: Gitlab::Access::MASTER) + target_project.project_group_links.create(group: developer_group, group_access: Gitlab::Access::DEVELOPER) + + subject.execute(project_with_groups, options) + + expect(project_with_groups.project_group_links.count).not_to eq 0 + end + end + end +end diff --git a/spec/services/projects/move_project_members_service_spec.rb b/spec/services/projects/move_project_members_service_spec.rb new file mode 100644 index 00000000000..9c9a2d2fde1 --- /dev/null +++ b/spec/services/projects/move_project_members_service_spec.rb @@ -0,0 +1,65 @@ +require 'spec_helper' + +describe Projects::MoveProjectMembersService do + let!(:user) { create(:user) } + let(:project_with_users) { create(:project, namespace: user.namespace) } + let(:target_project) { create(:project, namespace: user.namespace) } + let(:master_user) { create(:user) } + let(:reporter_user) { create(:user) } + let(:developer_user) { create(:user) } + + subject { described_class.new(target_project, user) } + + describe '#execute' do + before do + project_with_users.add_master(master_user) + project_with_users.add_developer(developer_user) + project_with_users.add_reporter(reporter_user) + end + + it 'moves the members from one project to another' do + expect(project_with_users.project_members.count).to eq 4 + expect(target_project.project_members.count).to eq 1 + + subject.execute(project_with_users) + + expect(project_with_users.project_members.count).to eq 0 + expect(target_project.project_members.count).to eq 4 + end + + it 'does not move existent members to the current project' do + target_project.add_master(developer_user) + target_project.add_developer(reporter_user) + + expect(project_with_users.project_members.count).to eq 4 + expect(target_project.project_members.count).to eq 3 + + subject.execute(project_with_users) + + expect(project_with_users.project_members.count).to eq 0 + expect(target_project.project_members.count).to eq 4 + end + + it 'rollbacks changes if transaction fails' do + allow(subject).to receive(:success).and_raise(StandardError) + + expect { subject.execute(project_with_users) }.to raise_error(StandardError) + + expect(project_with_users.project_members.count).to eq 4 + expect(target_project.project_members.count).to eq 1 + end + + context 'when remove_remaining_elements is false' do + let(:options) { { remove_remaining_elements: false } } + + it 'does not remove remaining project members' do + target_project.add_master(developer_user) + target_project.add_developer(reporter_user) + + subject.execute(project_with_users, options) + + expect(project_with_users.project_members.count).not_to eq 0 + end + end + end +end diff --git a/spec/services/projects/move_users_star_projects_service_spec.rb b/spec/services/projects/move_users_star_projects_service_spec.rb new file mode 100644 index 00000000000..e0545c5a21b --- /dev/null +++ b/spec/services/projects/move_users_star_projects_service_spec.rb @@ -0,0 +1,42 @@ +require 'spec_helper' + +describe Projects::MoveUsersStarProjectsService do + let!(:user) { create(:user) } + let!(:project_with_stars) { create(:project, namespace: user.namespace) } + let!(:target_project) { create(:project, namespace: user.namespace) } + + subject { described_class.new(target_project, user) } + + describe '#execute' do + before do + create_list(:users_star_project, 2, project: project_with_stars) + end + + it 'moves the user\'s stars from one project to another' do + expect(project_with_stars.users_star_projects.count).to eq 2 + expect(project_with_stars.star_count).to eq 2 + expect(target_project.users_star_projects.count).to eq 0 + expect(target_project.star_count).to eq 0 + + subject.execute(project_with_stars) + project_with_stars.reload + target_project.reload + + expect(project_with_stars.users_star_projects.count).to eq 0 + expect(project_with_stars.star_count).to eq 0 + expect(target_project.users_star_projects.count).to eq 2 + expect(target_project.star_count).to eq 2 + end + + it 'rollbacks changes if transaction fails' do + allow(subject).to receive(:success).and_raise(StandardError) + + expect { subject.execute(project_with_stars) }.to raise_error(StandardError) + + expect(project_with_stars.users_star_projects.count).to eq 2 + expect(project_with_stars.star_count).to eq 2 + expect(target_project.users_star_projects.count).to eq 0 + expect(target_project.star_count).to eq 0 + end + end +end diff --git a/spec/services/projects/overwrite_project_service_spec.rb b/spec/services/projects/overwrite_project_service_spec.rb new file mode 100644 index 00000000000..252c61f4224 --- /dev/null +++ b/spec/services/projects/overwrite_project_service_spec.rb @@ -0,0 +1,198 @@ +require 'spec_helper' + +describe Projects::OverwriteProjectService do + include ProjectForksHelper + + let(:user) { create(:user) } + let(:project_from) { create(:project, namespace: user.namespace) } + let(:project_to) { create(:project, namespace: user.namespace) } + let!(:lvl1_forked_project_1) { fork_project(project_from, user) } + let!(:lvl1_forked_project_2) { fork_project(project_from, user) } + let!(:lvl2_forked_project_1_1) { fork_project(lvl1_forked_project_1, user) } + let!(:lvl2_forked_project_1_2) { fork_project(lvl1_forked_project_1, user) } + + subject { described_class.new(project_to, user) } + + before do + allow(project_to).to receive(:import_data).and_return(double(data: { 'original_path' => project_from.path })) + end + + describe '#execute' do + shared_examples 'overwrite actions' do + it 'moves deploy keys' do + deploy_keys_count = project_from.deploy_keys_projects.count + + subject.execute(project_from) + + expect(project_to.deploy_keys_projects.count).to eq deploy_keys_count + end + + it 'moves notification settings' do + notification_count = project_from.notification_settings.count + + subject.execute(project_from) + + expect(project_to.notification_settings.count).to eq notification_count + end + + it 'moves users stars' do + stars_count = project_from.users_star_projects.count + + subject.execute(project_from) + project_to.reload + + expect(project_to.users_star_projects.count).to eq stars_count + expect(project_to.star_count).to eq stars_count + end + + it 'moves project group links' do + group_links_count = project_from.project_group_links.count + + subject.execute(project_from) + + expect(project_to.project_group_links.count).to eq group_links_count + end + + it 'moves memberships and authorizations' do + members_count = project_from.project_members.count + project_authorizations = project_from.project_authorizations.count + + subject.execute(project_from) + + expect(project_to.project_members.count).to eq members_count + expect(project_to.project_authorizations.count).to eq project_authorizations + end + + context 'moves lfs objects relationships' do + before do + create_list(:lfs_objects_project, 3, project: project_from) + end + + it do + lfs_objects_count = project_from.lfs_objects.count + + subject.execute(project_from) + + expect(project_to.lfs_objects.count).to eq lfs_objects_count + end + end + + it 'removes the original project' do + subject.execute(project_from) + + expect { Project.find(project_from.id) }.to raise_error(ActiveRecord::RecordNotFound) + end + + it 'renames the project' do + subject.execute(project_from) + + expect(project_to.full_path).to eq project_from.full_path + end + end + + context 'when project does not have any relation' do + it_behaves_like 'overwrite actions' + end + + context 'when project with elements' do + it_behaves_like 'overwrite actions' do + let(:master_user) { create(:user) } + let(:reporter_user) { create(:user) } + let(:developer_user) { create(:user) } + let(:master_group) { create(:group) } + let(:reporter_group) { create(:group) } + let(:developer_group) { create(:group) } + + before do + create_list(:deploy_keys_project, 2, project: project_from) + create_list(:notification_setting, 2, source: project_from) + create_list(:users_star_project, 2, project: project_from) + project_from.project_group_links.create(group: master_group, group_access: Gitlab::Access::MASTER) + project_from.project_group_links.create(group: developer_group, group_access: Gitlab::Access::DEVELOPER) + project_from.project_group_links.create(group: reporter_group, group_access: Gitlab::Access::REPORTER) + project_from.add_master(master_user) + project_from.add_developer(developer_user) + project_from.add_reporter(reporter_user) + end + end + end + + context 'forks' do + context 'when moving a root forked project' do + it 'moves the descendant forks' do + expect(project_from.forks.count).to eq 2 + expect(project_to.forks.count).to eq 0 + + subject.execute(project_from) + + expect(project_from.forks.count).to eq 0 + expect(project_to.forks.count).to eq 2 + expect(lvl1_forked_project_1.forked_from_project).to eq project_to + expect(lvl1_forked_project_1.fork_network_member.forked_from_project).to eq project_to + expect(lvl1_forked_project_2.forked_from_project).to eq project_to + expect(lvl1_forked_project_2.fork_network_member.forked_from_project).to eq project_to + end + + it 'updates the fork network' do + expect(project_from.fork_network.root_project).to eq project_from + expect(project_from.fork_network.fork_network_members.map(&:project)).to include project_from + + subject.execute(project_from) + + expect(project_to.reload.fork_network.root_project).to eq project_to + expect(project_to.fork_network.fork_network_members.map(&:project)).not_to include project_from + end + end + context 'when moving a intermediate forked project' do + let(:project_to) { create(:project, namespace: lvl1_forked_project_1.namespace) } + + it 'moves the descendant forks' do + expect(lvl1_forked_project_1.forks.count).to eq 2 + expect(project_to.forks.count).to eq 0 + + subject.execute(lvl1_forked_project_1) + + expect(lvl1_forked_project_1.forks.count).to eq 0 + expect(project_to.forks.count).to eq 2 + expect(lvl2_forked_project_1_1.forked_from_project).to eq project_to + expect(lvl2_forked_project_1_1.fork_network_member.forked_from_project).to eq project_to + expect(lvl2_forked_project_1_2.forked_from_project).to eq project_to + expect(lvl2_forked_project_1_2.fork_network_member.forked_from_project).to eq project_to + end + + it 'moves the ascendant fork' do + subject.execute(lvl1_forked_project_1) + + expect(project_to.reload.forked_from_project).to eq project_from + expect(project_to.fork_network_member.forked_from_project).to eq project_from + end + + it 'does not update fork network' do + subject.execute(lvl1_forked_project_1) + + expect(project_to.reload.fork_network.root_project).to eq project_from + end + end + end + + context 'if an exception is raised' do + it 'rollbacks changes' do + updated_at = project_from.updated_at + + allow(subject).to receive(:rename_project).and_raise(StandardError) + + expect { subject.execute(project_from) }.to raise_error(StandardError) + expect(Project.find(project_from.id)).not_to be_nil + expect(project_from.reload.updated_at.change(usec: 0)).to eq updated_at.change(usec: 0) + end + + it 'tries to restore the original project repositories' do + allow(subject).to receive(:rename_project).and_raise(StandardError) + + expect(subject).to receive(:attempt_restore_repositories).with(project_from) + + expect { subject.execute(project_from) }.to raise_error(StandardError) + end + end + end +end diff --git a/spec/services/projects/transfer_service_spec.rb b/spec/services/projects/transfer_service_spec.rb index 95a6771c59d..ff9b2372a35 100644 --- a/spec/services/projects/transfer_service_spec.rb +++ b/spec/services/projects/transfer_service_spec.rb @@ -37,6 +37,12 @@ describe Projects::TransferService do transfer_project(project, user, group) end + it 'invalidates the user\'s personal_project_count cache' do + expect(user).to receive(:invalidate_personal_projects_count) + + transfer_project(project, user, group) + end + it 'executes system hooks' do transfer_project(project, user, group) do |service| expect(service).to receive(:execute_system_hooks) diff --git a/spec/services/projects/update_pages_service_spec.rb b/spec/services/projects/update_pages_service_spec.rb index 934106627a9..1b6caeab15d 100644 --- a/spec/services/projects/update_pages_service_spec.rb +++ b/spec/services/projects/update_pages_service_spec.rb @@ -21,75 +21,72 @@ describe Projects::UpdatePagesService do end context 'legacy artifacts' do - %w(tar.gz zip).each do |format| - let(:extension) { format } + let(:extension) { 'zip' } - context "for valid #{format}" do + before do + build.update_attributes(legacy_artifacts_file: file) + build.update_attributes(legacy_artifacts_metadata: metadata) + end + + describe 'pages artifacts' do + context 'with expiry date' do before do - build.update_attributes(legacy_artifacts_file: file) - build.update_attributes(legacy_artifacts_metadata: metadata) + build.artifacts_expire_in = "2 days" + build.save! end - describe 'pages artifacts' do - context 'with expiry date' do - before do - build.artifacts_expire_in = "2 days" - build.save! - end - - it "doesn't delete artifacts" do - expect(execute).to eq(:success) - - expect(build.reload.artifacts?).to eq(true) - end - end - - context 'without expiry date' do - it "does delete artifacts" do - expect(execute).to eq(:success) + it "doesn't delete artifacts" do + expect(execute).to eq(:success) - expect(build.reload.artifacts?).to eq(false) - end - end + expect(build.reload.artifacts?).to eq(true) end + end - it 'succeeds' do - expect(project.pages_deployed?).to be_falsey + context 'without expiry date' do + it "does delete artifacts" do expect(execute).to eq(:success) - expect(project.pages_deployed?).to be_truthy - # Check that all expected files are extracted - %w[index.html zero .hidden/file].each do |filename| - expect(File.exist?(File.join(project.public_pages_path, filename))).to be_truthy - end + expect(build.reload.artifacts?).to eq(false) end + end + end - it 'limits pages size' do - stub_application_setting(max_pages_size: 1) - expect(execute).not_to eq(:success) - end + it 'succeeds' do + expect(project.pages_deployed?).to be_falsey + expect(execute).to eq(:success) + expect(project.pages_deployed?).to be_truthy - it 'removes pages after destroy' do - expect(PagesWorker).to receive(:perform_in) - expect(project.pages_deployed?).to be_falsey - expect(execute).to eq(:success) - expect(project.pages_deployed?).to be_truthy - project.destroy - expect(project.pages_deployed?).to be_falsey - end + # Check that all expected files are extracted + %w[index.html zero .hidden/file].each do |filename| + expect(File.exist?(File.join(project.public_pages_path, filename))).to be_truthy + end + end - it 'fails if sha on branch is not latest' do - build.update_attributes(ref: 'feature') + it 'limits pages size' do + stub_application_setting(max_pages_size: 1) + expect(execute).not_to eq(:success) + end - expect(execute).not_to eq(:success) - end + it 'removes pages after destroy' do + expect(PagesWorker).to receive(:perform_in) + expect(project.pages_deployed?).to be_falsey + expect(execute).to eq(:success) + expect(project.pages_deployed?).to be_truthy + project.destroy + expect(project.pages_deployed?).to be_falsey + end - it 'fails for empty file fails' do - build.update_attributes(legacy_artifacts_file: empty_file) + it 'fails if sha on branch is not latest' do + build.update_attributes(ref: 'feature') - expect(execute).not_to eq(:success) - end - end + expect(execute).not_to eq(:success) + end + + it 'fails for empty file fails' do + build.update_attributes(legacy_artifacts_file: empty_file) + + expect { execute } + .to raise_error(Projects::UpdatePagesService::FailedToExtractError) end end @@ -159,7 +156,8 @@ describe Projects::UpdatePagesService do it 'fails for empty file fails' do build.job_artifacts_archive.update_attributes(file: empty_file) - expect(execute).not_to eq(:success) + expect { execute } + .to raise_error(Projects::UpdatePagesService::FailedToExtractError) end context 'when timeout happens by DNS error' do @@ -172,7 +170,39 @@ describe Projects::UpdatePagesService do expect { execute }.to raise_error(SocketError) build.reload - expect(build.artifacts?).to eq(true) + expect(deploy_status).to be_failed + expect(build.artifacts?).to be_truthy + end + end + + context 'when failed to extract zip artifacts' do + before do + allow_any_instance_of(described_class) + .to receive(:extract_zip_archive!) + .and_raise(Projects::UpdatePagesService::FailedToExtractError) + end + + it 'raises an error' do + expect { execute } + .to raise_error(Projects::UpdatePagesService::FailedToExtractError) + + build.reload + expect(deploy_status).to be_failed + expect(build.artifacts?).to be_truthy + end + end + + context 'when missing artifacts metadata' do + before do + allow(build).to receive(:artifacts_metadata?).and_return(false) + end + + it 'does not raise an error and remove artifacts as failed job' do + execute + + build.reload + expect(deploy_status).to be_failed + expect(build.artifacts?).to be_falsey end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e8cecf361ff..83664bae046 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -66,6 +66,7 @@ RSpec.configure do |config| config.include MigrationsHelpers, :migration config.include StubFeatureFlags config.include StubENV + config.include ExpectOffense config.infer_spec_type_from_file_location! @@ -108,7 +109,8 @@ RSpec.configure do |config| allow_any_instance_of(Gitlab::Git::GitlabProjects).to receive(:fork_repository).and_wrap_original do |m, *args| m.call(*args) - shard_path, repository_relative_path = args + shard_name, repository_relative_path = args + shard_path = Gitlab.config.repositories.storages.fetch(shard_name).legacy_disk_path # We can't leave the hooks in place after a fork, as those would fail in tests # The "internal" API is not available FileUtils.rm_rf(File.join(shard_path, repository_relative_path, 'hooks')) diff --git a/spec/support/commit_trailers_spec_helper.rb b/spec/support/commit_trailers_spec_helper.rb new file mode 100644 index 00000000000..add359946db --- /dev/null +++ b/spec/support/commit_trailers_spec_helper.rb @@ -0,0 +1,41 @@ +module CommitTrailersSpecHelper + extend ActiveSupport::Concern + + def expect_to_have_user_link_with_avatar(doc, user:, trailer:, email: nil) + wrapper = find_user_wrapper(doc, trailer) + + expect_to_have_links_with_url_and_avatar(wrapper, urls.user_url(user), email || user.email) + expect(wrapper.attribute('data-user').value).to eq user.id.to_s + end + + def expect_to_have_mailto_link(doc, email:, trailer:) + wrapper = find_user_wrapper(doc, trailer) + + expect_to_have_links_with_url_and_avatar(wrapper, "mailto:#{CGI.escape_html(email)}", email) + end + + def expect_to_have_links_with_url_and_avatar(doc, url, email) + expect(doc).not_to be_nil + expect(doc.xpath("a[position()<3 and @href='#{url}']").size).to eq 2 + expect(doc.xpath("a[position()=3 and @href='mailto:#{CGI.escape_html(email)}']").size).to eq 1 + expect(doc.css('img').size).to eq 1 + end + + def find_user_wrapper(doc, trailer) + doc.xpath("descendant-or-self::node()[@data-trailer='#{trailer}']").first + end + + def build_commit_message(trailer:, name:, email:) + message = trailer_line(trailer, name, email) + + [message, commit_html(message)] + end + + def trailer_line(trailer, name, email) + "#{trailer} #{name} <#{email}>" + end + + def commit_html(message) + "<pre>#{CGI.escape_html(message)}</pre>" + end +end diff --git a/spec/support/cookie_helper.rb b/spec/support/cookie_helper.rb index d72925e1838..5ff7b0b68c9 100644 --- a/spec/support/cookie_helper.rb +++ b/spec/support/cookie_helper.rb @@ -2,12 +2,25 @@ # module CookieHelper def set_cookie(name, value, options = {}) + case page.driver + when Capybara::RackTest::Driver + rack_set_cookie(name, value) + else + selenium_set_cookie(name, value, options) + end + end + + def selenium_set_cookie(name, value, options = {}) # Selenium driver will not set cookies for a given domain when the browser is at `about:blank`. # It also doesn't appear to allow overriding the cookie path. loading `/` is the most inclusive. visit options.fetch(:path, '/') unless on_a_page? page.driver.browser.manage.add_cookie(name: name, value: value, **options) end + def rack_set_cookie(name, value) + page.driver.browser.set_cookie("#{name}=#{value}") + end + def get_cookie(name) page.driver.browser.manage.cookie_named(name) end diff --git a/spec/support/features/discussion_comments_shared_example.rb b/spec/support/features/discussion_comments_shared_example.rb index c8662d41769..80604395adf 100644 --- a/spec/support/features/discussion_comments_shared_example.rb +++ b/spec/support/features/discussion_comments_shared_example.rb @@ -81,7 +81,10 @@ shared_examples 'discussion comments' do |resource_name| # on issues page, the menu closes when clicking anywhere, on other pages it will # remain open if clicking divider or menu padding, but should not change button action - if resource_name == 'issue' + # + # if dropdown menu is not toggled (and also not present), + # it's "issue-type" dropdown + if first(menu_selector).nil? expect(find(dropdown_selector)).to have_content 'Comment' find(toggle_selector).click @@ -107,8 +110,10 @@ shared_examples 'discussion comments' do |resource_name| end it 'updates the submit button text and closes the dropdown' do + button = find(submit_selector) + # on issues page, the submit input is a <button>, on other pages it is <input> - if resource_name == 'issue' + if button.tag_name == 'button' expect(find(submit_selector)).to have_content 'Start discussion' else expect(find(submit_selector).value).to eq 'Start discussion' @@ -132,6 +137,8 @@ shared_examples 'discussion comments' do |resource_name| describe 'creating a discussion' do before do find(submit_selector).click + wait_for_requests + find(comments_selector, match: :first) end @@ -197,11 +204,13 @@ shared_examples 'discussion comments' do |resource_name| end it 'updates the submit button text and closes the dropdown' do + button = find(submit_selector) + # on issues page, the submit input is a <button>, on other pages it is <input> - if resource_name == 'issue' - expect(find(submit_selector)).to have_content 'Comment' + if button.tag_name == 'button' + expect(button).to have_content 'Comment' else - expect(find(submit_selector).value).to eq 'Comment' + expect(button.value).to eq 'Comment' end expect(page).not_to have_selector menu_selector diff --git a/spec/support/features/issuable_slash_commands_shared_examples.rb b/spec/support/features/issuable_slash_commands_shared_examples.rb index f61469f673d..1bd6c25100e 100644 --- a/spec/support/features/issuable_slash_commands_shared_examples.rb +++ b/spec/support/features/issuable_slash_commands_shared_examples.rb @@ -2,7 +2,7 @@ # It takes a `issuable_type`, and expect an `issuable`. shared_examples 'issuable record that supports quick actions in its description and notes' do |issuable_type| - include QuickActionsHelpers + include Spec::Support::Helpers::Features::NotesHelpers let(:master) { create(:user) } let(:project) do @@ -61,7 +61,7 @@ shared_examples 'issuable record that supports quick actions in its description context 'with a note containing commands' do it 'creates a note without the commands and interpret the commands accordingly' do assignee = create(:user, username: 'bob') - write_note("Awesome!\n\n/assign @bob\n\n/label ~bug\n\n/milestone %\"ASAP\"") + add_note("Awesome!\n\n/assign @bob\n\n/label ~bug\n\n/milestone %\"ASAP\"") expect(page).to have_content 'Awesome!' expect(page).not_to have_content '/assign @bob' @@ -82,7 +82,7 @@ shared_examples 'issuable record that supports quick actions in its description context 'with a note containing only commands' do it 'does not create a note but interpret the commands accordingly' do assignee = create(:user, username: 'bob') - write_note("/assign @bob\n\n/label ~bug\n\n/milestone %\"ASAP\"") + add_note("/assign @bob\n\n/label ~bug\n\n/milestone %\"ASAP\"") expect(page).not_to have_content '/assign @bob' expect(page).not_to have_content '/label ~bug' @@ -105,7 +105,7 @@ shared_examples 'issuable record that supports quick actions in its description context "when current user can close #{issuable_type}" do it "closes the #{issuable_type}" do - write_note("/close") + add_note("/close") expect(page).not_to have_content '/close' expect(page).to have_content 'Commands applied' @@ -125,7 +125,7 @@ shared_examples 'issuable record that supports quick actions in its description end it "does not close the #{issuable_type}" do - write_note("/close") + add_note("/close") expect(page).not_to have_content 'Commands applied' @@ -142,7 +142,7 @@ shared_examples 'issuable record that supports quick actions in its description context "when current user can reopen #{issuable_type}" do it "reopens the #{issuable_type}" do - write_note("/reopen") + add_note("/reopen") expect(page).not_to have_content '/reopen' expect(page).to have_content 'Commands applied' @@ -162,7 +162,7 @@ shared_examples 'issuable record that supports quick actions in its description end it "does not reopen the #{issuable_type}" do - write_note("/reopen") + add_note("/reopen") expect(page).not_to have_content 'Commands applied' @@ -174,7 +174,7 @@ shared_examples 'issuable record that supports quick actions in its description context "with a note changing the #{issuable_type}'s title" do context "when current user can change title of #{issuable_type}" do it "reopens the #{issuable_type}" do - write_note("/title Awesome new title") + add_note("/title Awesome new title") expect(page).not_to have_content '/title' expect(page).to have_content 'Commands applied' @@ -194,7 +194,7 @@ shared_examples 'issuable record that supports quick actions in its description end it "does not change the #{issuable_type} title" do - write_note("/title Awesome new title") + add_note("/title Awesome new title") expect(page).not_to have_content 'Commands applied' @@ -205,7 +205,7 @@ shared_examples 'issuable record that supports quick actions in its description context "with a note marking the #{issuable_type} as todo" do it "creates a new todo for the #{issuable_type}" do - write_note("/todo") + add_note("/todo") expect(page).not_to have_content '/todo' expect(page).to have_content 'Commands applied' @@ -236,7 +236,7 @@ shared_examples 'issuable record that supports quick actions in its description expect(todo.author).to eq master expect(todo.user).to eq master - write_note("/done") + add_note("/done") expect(page).not_to have_content '/done' expect(page).to have_content 'Commands applied' @@ -249,7 +249,7 @@ shared_examples 'issuable record that supports quick actions in its description it "creates a new todo for the #{issuable_type}" do expect(issuable.subscribed?(master, project)).to be_falsy - write_note("/subscribe") + add_note("/subscribe") expect(page).not_to have_content '/subscribe' expect(page).to have_content 'Commands applied' @@ -266,7 +266,7 @@ shared_examples 'issuable record that supports quick actions in its description it "creates a new todo for the #{issuable_type}" do expect(issuable.subscribed?(master, project)).to be_truthy - write_note("/unsubscribe") + add_note("/unsubscribe") expect(page).not_to have_content '/unsubscribe' expect(page).to have_content 'Commands applied' @@ -277,7 +277,7 @@ shared_examples 'issuable record that supports quick actions in its description context "with a note assigning the #{issuable_type} to the current user" do it "assigns the #{issuable_type} to the current user" do - write_note("/assign me") + add_note("/assign me") expect(page).not_to have_content '/assign me' expect(page).to have_content 'Commands applied' diff --git a/spec/support/filtered_search_helpers.rb b/spec/support/filtered_search_helpers.rb index f3f96bd1f0a..5f42ff77fb2 100644 --- a/spec/support/filtered_search_helpers.rb +++ b/spec/support/filtered_search_helpers.rb @@ -21,6 +21,29 @@ module FilteredSearchHelpers end end + # Select a label clicking in the search dropdown instead + # of entering label names on the input. + def select_label_on_dropdown(label_title) + input_filtered_search("label:", submit: false) + + within('#js-dropdown-label') do + wait_for_requests + + find('li', text: label_title).click + end + + filtered_search.send_keys(:enter) + end + + def expect_issues_list_count(open_count, closed_count = 0) + all_count = open_count + closed_count + + expect(page).to have_issuable_counts(open: open_count, closed: closed_count, all: all_count) + page.within '.issues-list' do + expect(page).to have_selector('.issue', count: open_count) + end + end + # Enables input to be added character by character def input_filtered_search_keys(search_term) # Add an extra space to engage visual tokens diff --git a/spec/support/helpers/expect_offense.rb b/spec/support/helpers/expect_offense.rb new file mode 100644 index 00000000000..35718ba90c5 --- /dev/null +++ b/spec/support/helpers/expect_offense.rb @@ -0,0 +1,20 @@ +require 'rubocop/rspec/support' + +# https://github.com/backus/rubocop-rspec/blob/master/spec/support/expect_offense.rb +# rubocop-rspec gem extension of RuboCop's ExpectOffense module. +# +# This mixin is the same as rubocop's ExpectOffense except the default +# filename ends with `_spec.rb` +module ExpectOffense + include RuboCop::RSpec::ExpectOffense + + DEFAULT_FILENAME = 'example_spec.rb'.freeze + + def expect_offense(source, filename = DEFAULT_FILENAME) + super + end + + def expect_no_offenses(source, filename = DEFAULT_FILENAME) + super + end +end diff --git a/spec/support/helpers/features/notes_helpers.rb b/spec/support/helpers/features/notes_helpers.rb new file mode 100644 index 00000000000..1a1d5853a7a --- /dev/null +++ b/spec/support/helpers/features/notes_helpers.rb @@ -0,0 +1,27 @@ +# These helpers allow you to manipulate with notes. +# +# Usage: +# describe "..." do +# include Spec::Support::Helpers::Features::NotesHelpers +# ... +# +# add_note("Hello world!") +# +module Spec + module Support + module Helpers + module Features + module NotesHelpers + def add_note(text) + Sidekiq::Testing.fake! do + page.within(".js-main-target-form") do + fill_in("note[note]", with: text) + find(".js-comment-submit-button").click + end + end + end + end + end + end + end +end diff --git a/spec/support/helpers/features/sorting_helpers.rb b/spec/support/helpers/features/sorting_helpers.rb new file mode 100644 index 00000000000..50457b64745 --- /dev/null +++ b/spec/support/helpers/features/sorting_helpers.rb @@ -0,0 +1,26 @@ +# These helpers allow you to manipulate with sorting features. +# +# Usage: +# describe "..." do +# include Spec::Support::Helpers::Features::SortingHelpers +# ... +# +# sort_by("Last updated") +# +module Spec + module Support + module Helpers + module Features + module SortingHelpers + def sort_by(value) + find('button.dropdown-toggle').click + + page.within('.content ul.dropdown-menu.dropdown-menu-align-right li') do + click_link(value) + end + end + end + end + end + end +end diff --git a/spec/support/issuables_list_metadata_shared_examples.rb b/spec/support/issuables_list_metadata_shared_examples.rb index 75982432ab4..e61983c60b4 100644 --- a/spec/support/issuables_list_metadata_shared_examples.rb +++ b/spec/support/issuables_list_metadata_shared_examples.rb @@ -5,9 +5,9 @@ shared_examples 'issuables list meta-data' do |issuable_type, action = nil| %w[fix improve/awesome].each do |source_branch| issuable = if issuable_type == :issue - create(issuable_type, project: project) + create(issuable_type, project: project, author: project.creator) else - create(issuable_type, source_project: project, source_branch: source_branch) + create(issuable_type, source_project: project, source_branch: source_branch, author: project.creator) end @issuable_ids << issuable.id @@ -16,7 +16,7 @@ shared_examples 'issuables list meta-data' do |issuable_type, action = nil| it "creates indexed meta-data object for issuable notes and votes count" do if action - get action + get action, author_id: project.creator.id else get :index, namespace_id: project.namespace, project_id: project end @@ -35,7 +35,7 @@ shared_examples 'issuables list meta-data' do |issuable_type, action = nil| it "doesn't execute any queries with false conditions" do get_action = if action - proc { get action } + proc { get action, author_id: project.creator.id } else proc { get :index, namespace_id: project2.namespace, project_id: project2 } end diff --git a/spec/support/issuables_requiring_filter_shared_examples.rb b/spec/support/issuables_requiring_filter_shared_examples.rb new file mode 100644 index 00000000000..439ef5ed92e --- /dev/null +++ b/spec/support/issuables_requiring_filter_shared_examples.rb @@ -0,0 +1,15 @@ +shared_examples 'issuables requiring filter' do |action| + it "doesn't load any issuables if no filter is set" do + expect_any_instance_of(described_class).not_to receive(:issuables_collection) + + get action + + expect(response).to render_template(action) + end + + it "loads issuables if at least one filter is set" do + expect_any_instance_of(described_class).to receive(:issuables_collection).and_call_original + + get action, author_id: user.id + end +end diff --git a/spec/support/ldap_helpers.rb b/spec/support/ldap_helpers.rb index 081ce0ad7b7..0e87b3d359d 100644 --- a/spec/support/ldap_helpers.rb +++ b/spec/support/ldap_helpers.rb @@ -41,4 +41,9 @@ module LdapHelpers entry end + + def raise_ldap_connection_error + allow_any_instance_of(Gitlab::Auth::LDAP::Adapter) + .to receive(:ldap_search).and_raise(Gitlab::Auth::LDAP::LDAPConnectionError) + end end diff --git a/spec/support/login_helpers.rb b/spec/support/login_helpers.rb index d08183846a0..db34090e971 100644 --- a/spec/support/login_helpers.rb +++ b/spec/support/login_helpers.rb @@ -140,6 +140,10 @@ module LoginHelpers end allow(Gitlab::Auth::OAuth::Provider).to receive_messages(providers: [:saml], config_for: mock_saml_config) stub_omniauth_setting(messages) + stub_saml_authorize_path_helpers + end + + def stub_saml_authorize_path_helpers allow_any_instance_of(Object).to receive(:user_saml_omniauth_authorize_path).and_return('/users/auth/saml') allow_any_instance_of(Object).to receive(:omniauth_authorize_path).with(:user, "saml").and_return('/users/auth/saml') end diff --git a/spec/support/matchers/issuable_matchers.rb b/spec/support/matchers/issuable_matchers.rb new file mode 100644 index 00000000000..f5d9a97051a --- /dev/null +++ b/spec/support/matchers/issuable_matchers.rb @@ -0,0 +1,11 @@ +RSpec::Matchers.define :have_header_with_correct_id_and_link do |level, text, id, parent = ".wiki"| + match do |actual| + node = find("#{parent} h#{level} a#user-content-#{id}") + + expect(node[:href]).to end_with("##{id}") + + # Work around a weird Capybara behavior where calling `parent` on a node + # returns the whole document, not the node's actual parent element + expect(find(:xpath, "#{node.path}/..").text).to eq(text) + end +end diff --git a/spec/support/quick_actions_helpers.rb b/spec/support/quick_actions_helpers.rb deleted file mode 100644 index 361190aa352..00000000000 --- a/spec/support/quick_actions_helpers.rb +++ /dev/null @@ -1,10 +0,0 @@ -module QuickActionsHelpers - def write_note(text) - Sidekiq::Testing.fake! do - page.within('.js-main-target-form') do - fill_in 'note[note]', with: text - find('.js-comment-submit-button').click - end - end - end -end diff --git a/spec/support/reference_parser_helpers.rb b/spec/support/reference_parser_helpers.rb index 01689194eac..5d5e80851e6 100644 --- a/spec/support/reference_parser_helpers.rb +++ b/spec/support/reference_parser_helpers.rb @@ -2,4 +2,34 @@ module ReferenceParserHelpers def empty_html_link Nokogiri::HTML.fragment('<a></a>').children[0] end + + shared_examples 'no N+1 queries' do + it 'avoids N+1 queries in #nodes_visible_to_user', :request_store do + record_queries = lambda do |links| + ActiveRecord::QueryRecorder.new do + described_class.new(project, user).nodes_visible_to_user(user, links) + end + end + + control = record_queries.call(control_links) + actual = record_queries.call(actual_links) + + expect(actual.count).to be <= control.count + expect(actual.cached_count).to be <= control.cached_count + end + + it 'avoids N+1 queries in #records_for_nodes', :request_store do + record_queries = lambda do |links| + ActiveRecord::QueryRecorder.new do + described_class.new(project, user).records_for_nodes(links) + end + end + + control = record_queries.call(control_links) + actual = record_queries.call(actual_links) + + expect(actual.count).to be <= control.count + expect(actual.cached_count).to be <= control.cached_count + end + end end diff --git a/spec/support/shared_examples/serializers/note_entity_examples.rb b/spec/support/shared_examples/serializers/note_entity_examples.rb new file mode 100644 index 00000000000..9097c8e5513 --- /dev/null +++ b/spec/support/shared_examples/serializers/note_entity_examples.rb @@ -0,0 +1,42 @@ +shared_examples 'note entity' do + subject { entity.as_json } + + context 'basic note' do + it 'exposes correct elements' do + expect(subject).to include(:type, :author, :note, :note_html, :current_user, + :discussion_id, :emoji_awardable, :award_emoji, :report_abuse_path, :attachment) + end + + it 'does not expose elements for specific notes cases' do + expect(subject).not_to include(:last_edited_by, :last_edited_at, :system_note_icon_name) + end + + it 'exposes author correctly' do + expect(subject[:author]).to include(:id, :name, :username, :state, :avatar_url, :path) + end + + it 'does not expose web_url for author' do + expect(subject[:author]).not_to include(:web_url) + end + end + + context 'when note was edited' do + before do + note.update(updated_at: 1.minute.from_now, updated_by: user) + end + + it 'exposes last_edited_at and last_edited_by elements' do + expect(subject).to include(:last_edited_at, :last_edited_by) + end + end + + context 'when note is a system note' do + before do + note.update(system: true) + end + + it 'exposes system_note_icon_name element' do + expect(subject).to include(:system_note_icon_name) + end + end +end diff --git a/spec/support/shared_examples/services/boards/issues_move_service.rb b/spec/support/shared_examples/services/boards/issues_move_service.rb index 4a4fbaa3a0e..737863ea411 100644 --- a/spec/support/shared_examples/services/boards/issues_move_service.rb +++ b/spec/support/shared_examples/services/boards/issues_move_service.rb @@ -1,4 +1,4 @@ -shared_examples 'issues move service' do +shared_examples 'issues move service' do |group| context 'when moving an issue between lists' do let(:issue) { create(:labeled_issue, project: project, labels: [bug, development]) } let(:params) { { board_id: board1.id, from_list_id: list1.id, to_list_id: list2.id } } @@ -83,5 +83,18 @@ shared_examples 'issues move service' do expect(issue.relative_position).to be_between(issue1.relative_position, issue2.relative_position) end + + if group + context 'when on a group board' do + it 'sends the board_group_id parameter' do + params.merge!(move_after_id: issue1.id, move_before_id: issue2.id) + + match_params = { move_between_ids: [issue1.id, issue2.id], board_group_id: parent.id } + expect(Issues::UpdateService).to receive(:new).with(issue.project, user, match_params).and_return(double(execute: build(:issue))) + + described_class.new(parent, user, params).execute(issue) + end + end + end end end diff --git a/spec/support/slack_mattermost_notifications_shared_examples.rb b/spec/support/slack_mattermost_notifications_shared_examples.rb index 5e1ce19eafb..07bc3a51fd8 100644 --- a/spec/support/slack_mattermost_notifications_shared_examples.rb +++ b/spec/support/slack_mattermost_notifications_shared_examples.rb @@ -4,6 +4,11 @@ RSpec.shared_examples 'slack or mattermost notifications' do let(:chat_service) { described_class.new } let(:webhook_url) { 'https://example.gitlab.com/' } + def execute_with_options(options) + receive(:new).with(webhook_url, options) + .and_return(double(:slack_service).as_null_object) + end + describe "Associations" do it { is_expected.to belong_to :project } it { is_expected.to have_one :service_hook } @@ -33,6 +38,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do let(:project) { create(:project, :repository) } let(:username) { 'slack_username' } let(:channel) { 'slack_channel' } + let(:issue_service_options) { { title: 'Awesome issue', description: 'please fix' } } let(:push_sample_data) do Gitlab::DataBuilder::Push.build_sample(project, user) @@ -48,12 +54,7 @@ RSpec.shared_examples 'slack or mattermost notifications' do WebMock.stub_request(:post, webhook_url) - opts = { - title: 'Awesome issue', - description: 'please fix' - } - - issue_service = Issues::CreateService.new(project, user, opts) + issue_service = Issues::CreateService.new(project, user, issue_service_options) @issue = issue_service.execute @issues_sample_data = issue_service.hook_data(@issue, 'open') @@ -164,6 +165,26 @@ RSpec.shared_examples 'slack or mattermost notifications' do chat_service.execute(@issues_sample_data) end + context 'for confidential issues' do + let(:issue_service_options) { { title: 'Secret', confidential: true } } + + it "uses confidential issue channel" do + chat_service.update_attributes(confidential_issue_channel: 'confidential') + + expect(Slack::Notifier).to execute_with_options(channel: 'confidential') + + chat_service.execute(@issues_sample_data) + end + + it 'falls back to issue channel' do + chat_service.update_attributes(issue_channel: 'fallback_channel') + + expect(Slack::Notifier).to execute_with_options(channel: 'fallback_channel') + + chat_service.execute(@issues_sample_data) + end + end + it "uses the right channel for wiki event" do chat_service.update_attributes(wiki_page_channel: "random") @@ -194,6 +215,32 @@ RSpec.shared_examples 'slack or mattermost notifications' do chat_service.execute(note_data) end + + context 'for confidential notes' do + before do + issue_note.noteable.update!(confidential: true) + end + + it "uses confidential channel" do + chat_service.update_attributes(confidential_note_channel: "confidential") + + note_data = Gitlab::DataBuilder::Note.build(issue_note, user) + + expect(Slack::Notifier).to execute_with_options(channel: 'confidential') + + chat_service.execute(note_data) + end + + it 'falls back to note channel' do + chat_service.update_attributes(note_channel: "fallback_channel") + + note_data = Gitlab::DataBuilder::Note.build(issue_note, user) + + expect(Slack::Notifier).to execute_with_options(channel: 'fallback_channel') + + chat_service.execute(note_data) + end + end end end end @@ -248,8 +295,9 @@ RSpec.shared_examples 'slack or mattermost notifications' do create(:note_on_issue, project: project, note: "issue note") end + let(:data) { Gitlab::DataBuilder::Note.build(issue_note, user) } + it "calls Slack API for issue comment events" do - data = Gitlab::DataBuilder::Note.build(issue_note, user) chat_service.execute(data) expect(WebMock).to have_requested(:post, webhook_url).once diff --git a/spec/support/sorting_helper.rb b/spec/support/sorting_helper.rb deleted file mode 100644 index 577518d726c..00000000000 --- a/spec/support/sorting_helper.rb +++ /dev/null @@ -1,18 +0,0 @@ -# Helper allows you to sort items -# -# Params -# value - value for sorting -# -# Usage: -# include SortingHelper -# -# sorting_by('Oldest updated') -# -module SortingHelper - def sorting_by(value) - find('button.dropdown-toggle').click - page.within('.content ul.dropdown-menu.dropdown-menu-align-right li') do - click_link value - end - end -end diff --git a/spec/support/stub_configuration.rb b/spec/support/stub_configuration.rb index bad1d34df3a..a75a3eaefcb 100644 --- a/spec/support/stub_configuration.rb +++ b/spec/support/stub_configuration.rb @@ -45,6 +45,10 @@ module StubConfiguration allow(Gitlab.config.lfs).to receive_messages(to_settings(messages)) end + def stub_artifacts_setting(messages) + allow(Gitlab.config.artifacts).to receive_messages(to_settings(messages)) + end + def stub_storage_settings(messages) messages.deep_stringify_keys! diff --git a/spec/support/test_env.rb b/spec/support/test_env.rb index f14e69b1041..d87f265cdf0 100644 --- a/spec/support/test_env.rb +++ b/spec/support/test_env.rb @@ -62,6 +62,7 @@ module TestEnv }.freeze TMP_TEST_PATH = Rails.root.join('tmp', 'tests', '**') + REPOS_STORAGE = 'default'.freeze # Test environment # @@ -225,7 +226,7 @@ module TestEnv end def repos_path - Gitlab.config.repositories.storages.default.legacy_disk_path + Gitlab.config.repositories.storages[REPOS_STORAGE].legacy_disk_path end def backup_path diff --git a/spec/tasks/gitlab/uploads/migrate_rake_spec.rb b/spec/tasks/gitlab/uploads/migrate_rake_spec.rb index b778d26060d..6fcfae358ec 100644 --- a/spec/tasks/gitlab/uploads/migrate_rake_spec.rb +++ b/spec/tasks/gitlab/uploads/migrate_rake_spec.rb @@ -1,10 +1,9 @@ require 'rake_helper' describe 'gitlab:uploads:migrate rake tasks' do - let!(:projects) { create_list(:project, 10, :with_avatar) } - let(:model_class) { Project } - let(:uploader_class) { AvatarUploader } - let(:mounted_as) { :avatar } + let(:model_class) { nil } + let(:uploader_class) { nil } + let(:mounted_as) { nil } let(:batch_size) { 3 } before do @@ -20,9 +19,125 @@ describe 'gitlab:uploads:migrate rake tasks' do run_rake_task("gitlab:uploads:migrate", *args) end - it 'enqueue jobs in batch' do - expect(ObjectStorage::MigrateUploadsWorker).to receive(:enqueue!).exactly(4).times + shared_examples 'enqueue jobs in batch' do |batch:| + it do + expect(ObjectStorage::MigrateUploadsWorker) + .to receive(:perform_async).exactly(batch).times + .and_return("A fake job.") - run + run + end + end + + context "for AvatarUploader" do + let(:uploader_class) { AvatarUploader } + let(:mounted_as) { :avatar } + + context "for Project" do + let(:model_class) { Project } + let!(:projects) { create_list(:project, 10, :with_avatar) } + + it_behaves_like 'enqueue jobs in batch', batch: 4 + + context 'Upload has store = nil' do + before do + Upload.where(model: projects).update_all(store: nil) + end + + it_behaves_like 'enqueue jobs in batch', batch: 4 + end + end + + context "for Group" do + let(:model_class) { Group } + + before do + create_list(:group, 10, :with_avatar) + end + + it_behaves_like 'enqueue jobs in batch', batch: 4 + end + + context "for User" do + let(:model_class) { User } + + before do + create_list(:user, 10, :with_avatar) + end + + it_behaves_like 'enqueue jobs in batch', batch: 4 + end + end + + context "for AttachmentUploader" do + let(:uploader_class) { AttachmentUploader } + + context "for Note" do + let(:model_class) { Note } + let(:mounted_as) { :attachment } + + before do + create_list(:note, 10, :with_attachment) + end + + it_behaves_like 'enqueue jobs in batch', batch: 4 + end + + context "for Appearance" do + let(:model_class) { Appearance } + let(:mounted_as) { :logo } + + before do + create(:appearance, :with_logos) + end + + %i(logo header_logo).each do |mount| + it_behaves_like 'enqueue jobs in batch', batch: 1 do + let(:mounted_as) { mount } + end + end + end + end + + context "for FileUploader" do + let(:uploader_class) { FileUploader } + let(:model_class) { Project } + + before do + create_list(:project, 10) do |model| + uploader_class.new(model) + .store!(fixture_file_upload('spec/fixtures/doc_sample.txt')) + end + end + + it_behaves_like 'enqueue jobs in batch', batch: 4 + end + + context "for PersonalFileUploader" do + let(:uploader_class) { PersonalFileUploader } + let(:model_class) { PersonalSnippet } + + before do + create_list(:personal_snippet, 10) do |model| + uploader_class.new(model) + .store!(fixture_file_upload('spec/fixtures/doc_sample.txt')) + end + end + + it_behaves_like 'enqueue jobs in batch', batch: 4 + end + + context "for NamespaceFileUploader" do + let(:uploader_class) { NamespaceFileUploader } + let(:model_class) { Snippet } + + before do + create_list(:snippet, 10) do |model| + uploader_class.new(model) + .store!(fixture_file_upload('spec/fixtures/doc_sample.txt')) + end + end + + it_behaves_like 'enqueue jobs in batch', batch: 4 end end diff --git a/spec/uploaders/object_storage_spec.rb b/spec/uploaders/object_storage_spec.rb index 59e02fecbce..16455e2517b 100644 --- a/spec/uploaders/object_storage_spec.rb +++ b/spec/uploaders/object_storage_spec.rb @@ -62,10 +62,12 @@ describe ObjectStorage do end describe '#object_store' do + subject { uploader.object_store } + it "delegates to <mount>_store on model" do expect(object).to receive(:file_store) - uploader.object_store + subject end context 'when store is null' do @@ -73,8 +75,36 @@ describe ObjectStorage do expect(object).to receive(:file_store).and_return(nil) end - it "returns Store::LOCAL" do - expect(uploader.object_store).to eq(described_class::Store::LOCAL) + context 'when object storage is enabled' do + context 'when direct uploads are enabled' do + before do + stub_uploads_object_storage(uploader_class, enabled: true, direct_upload: true) + end + + it "uses Store::REMOTE" do + is_expected.to eq(described_class::Store::REMOTE) + end + end + + context 'when direct uploads are disabled' do + before do + stub_uploads_object_storage(uploader_class, enabled: true, direct_upload: false) + end + + it "uses Store::LOCAL" do + is_expected.to eq(described_class::Store::LOCAL) + end + end + end + + context 'when object storage is disabled' do + before do + stub_uploads_object_storage(uploader_class, enabled: false) + end + + it "uses Store::LOCAL" do + is_expected.to eq(described_class::Store::LOCAL) + end end end @@ -84,7 +114,7 @@ describe ObjectStorage do end it "returns the given value" do - expect(uploader.object_store).to eq(described_class::Store::REMOTE) + is_expected.to eq(described_class::Store::REMOTE) end end end @@ -486,108 +516,46 @@ describe ObjectStorage do end end - describe '#store_workhorse_file!' do + describe '#cache!' do subject do - uploader.store_workhorse_file!(params, :file) + uploader.cache!(uploaded_file) end context 'when local file is used' do context 'when valid file is used' do - let(:target_path) do - File.join(uploader_class.root, uploader_class::TMP_UPLOAD_PATH) - end - - before do - FileUtils.mkdir_p(target_path) + let(:uploaded_file) do + fixture_file_upload(Rails.root + 'spec/fixtures/rails_sample.jpg', 'image/jpg') end - context 'when no filename is specified' do - let(:params) do - { "file.path" => "test/file" } - end - - it 'raises an error' do - expect { subject }.to raise_error(uploader_class::RemoteStoreError, /Missing filename/) - end - end - - context 'when invalid file is specified' do - let(:file_path) do - File.join(target_path, "..", "test.file") - end - - before do - FileUtils.touch(file_path) - end - - let(:params) do - { "file.path" => file_path, - "file.name" => "my_file.txt" } - end - - it 'raises an error' do - expect { subject }.to raise_error(uploader_class::RemoteStoreError, /Bad file path/) - end - end - - context 'when filename is specified' do - let(:params) do - { "file.path" => tmp_file, - "file.name" => "my_file.txt" } - end - - let(:tmp_file) { Tempfile.new('filename', target_path) } + it "properly caches the file" do + subject - before do - FileUtils.touch(tmp_file) - end - - after do - FileUtils.rm_f(tmp_file) - end - - it 'succeeds' do - expect { subject }.not_to raise_error - - expect(uploader).to be_exists - end - - it 'proper path is being used' do - subject - - expect(uploader.path).to start_with(uploader_class.root) - expect(uploader.path).to end_with("my_file.txt") - end - - it 'source file to not exist' do - subject - - expect(File.exist?(tmp_file.path)).to be_falsey - end + expect(uploader).to be_exists + expect(uploader.path).to start_with(uploader_class.root) + expect(uploader.filename).to eq('rails_sample.jpg') end end end context 'when remote file is used' do + let(:temp_file) { Tempfile.new("test") } + let!(:fog_connection) do stub_uploads_object_storage(uploader_class) end - context 'when valid file is used' do - context 'when no filename is specified' do - let(:params) do - { "file.remote_id" => "test/123123" } - end + before do + FileUtils.touch(temp_file) + end - it 'raises an error' do - expect { subject }.to raise_error(uploader_class::RemoteStoreError, /Missing filename/) - end - end + after do + FileUtils.rm_f(temp_file) + end + context 'when valid file is used' do context 'when invalid file is specified' do - let(:params) do - { "file.remote_id" => "../test/123123", - "file.name" => "my_file.txt" } + let(:uploaded_file) do + UploadedFile.new(temp_file.path, remote_id: "../test/123123") end it 'raises an error' do @@ -596,9 +564,8 @@ describe ObjectStorage do end context 'when non existing file is specified' do - let(:params) do - { "file.remote_id" => "test/12312300", - "file.name" => "my_file.txt" } + let(:uploaded_file) do + UploadedFile.new(temp_file.path, remote_id: "test/123123") end it 'raises an error' do @@ -606,10 +573,9 @@ describe ObjectStorage do end end - context 'when filename is specified' do - let(:params) do - { "file.remote_id" => "test/123123", - "file.name" => "my_file.txt" } + context 'when valid file is specified' do + let(:uploaded_file) do + UploadedFile.new(temp_file.path, filename: "my_file.txt", remote_id: "test/123123") end let!(:fog_file) do @@ -619,36 +585,37 @@ describe ObjectStorage do ) end - it 'succeeds' do + it 'file to be cached and remote stored' do expect { subject }.not_to raise_error expect(uploader).to be_exists - end - - it 'path to not be temporary' do - subject - + expect(uploader).to be_cached expect(uploader.path).not_to be_nil - expect(uploader.path).not_to include('tmp/upload') - expect(uploader.url).to include('/my_file.txt') + expect(uploader.path).not_to include('tmp/cache') + expect(uploader.url).not_to be_nil + expect(uploader.path).not_to include('tmp/cache') + expect(uploader.object_store).to eq(described_class::Store::REMOTE) end - it 'url is used' do - subject + context 'when file is stored' do + subject do + uploader.store!(uploaded_file) + end - expect(uploader.url).not_to be_nil - expect(uploader.url).to include('/my_file.txt') + it 'file to be remotely stored in permament location' do + subject + + expect(uploader).to be_exists + expect(uploader).not_to be_cached + expect(uploader.path).not_to be_nil + expect(uploader.path).not_to include('tmp/upload') + expect(uploader.path).not_to include('tmp/cache') + expect(uploader.url).to include('/my_file.txt') + expect(uploader.object_store).to eq(described_class::Store::REMOTE) + end end end end end - - context 'when no file is used' do - let(:params) { {} } - - it 'raises an error' do - expect { subject }.to raise_error(uploader_class::RemoteStoreError, /Bad file/) - end - end end end diff --git a/spec/uploaders/workers/object_storage/background_move_worker_spec.rb b/spec/uploaders/workers/object_storage/background_move_worker_spec.rb new file mode 100644 index 00000000000..b34f427fd8a --- /dev/null +++ b/spec/uploaders/workers/object_storage/background_move_worker_spec.rb @@ -0,0 +1,146 @@ +require 'spec_helper' + +describe ObjectStorage::BackgroundMoveWorker do + let(:local) { ObjectStorage::Store::LOCAL } + let(:remote) { ObjectStorage::Store::REMOTE } + + def perform + described_class.perform_async(uploader_class.name, subject_class, file_field, subject_id) + end + + context 'for LFS' do + let!(:lfs_object) { create(:lfs_object, :with_file, file_store: local) } + let(:uploader_class) { LfsObjectUploader } + let(:subject_class) { LfsObject } + let(:file_field) { :file } + let(:subject_id) { lfs_object.id } + + context 'when object storage is enabled' do + before do + stub_lfs_object_storage(background_upload: true) + end + + it 'uploads object to storage' do + expect { perform }.to change { lfs_object.reload.file_store }.from(local).to(remote) + end + + context 'when background upload is disabled' do + before do + allow(Gitlab.config.lfs.object_store).to receive(:background_upload) { false } + end + + it 'is skipped' do + expect { perform }.not_to change { lfs_object.reload.file_store } + end + end + end + + context 'when object storage is disabled' do + before do + stub_lfs_object_storage(enabled: false) + end + + it "doesn't migrate files" do + perform + + expect(lfs_object.reload.file_store).to eq(local) + end + end + end + + context 'for legacy artifacts' do + let(:build) { create(:ci_build, :legacy_artifacts) } + let(:uploader_class) { LegacyArtifactUploader } + let(:subject_class) { Ci::Build } + let(:file_field) { :artifacts_file } + let(:subject_id) { build.id } + + context 'when local storage is used' do + let(:store) { local } + + context 'and remote storage is defined' do + before do + stub_artifacts_object_storage(background_upload: true) + end + + it "migrates file to remote storage" do + perform + + expect(build.reload.artifacts_file_store).to eq(remote) + end + + context 'for artifacts_metadata' do + let(:file_field) { :artifacts_metadata } + + it 'migrates metadata to remote storage' do + perform + + expect(build.reload.artifacts_metadata_store).to eq(remote) + end + end + end + end + end + + context 'for job artifacts' do + let(:artifact) { create(:ci_job_artifact, :archive) } + let(:uploader_class) { JobArtifactUploader } + let(:subject_class) { Ci::JobArtifact } + let(:file_field) { :file } + let(:subject_id) { artifact.id } + + context 'when local storage is used' do + let(:store) { local } + + context 'and remote storage is defined' do + before do + stub_artifacts_object_storage(background_upload: true) + end + + it "migrates file to remote storage" do + perform + + expect(artifact.reload.file_store).to eq(remote) + end + end + end + end + + context 'for uploads' do + let!(:project) { create(:project, :with_avatar) } + let(:uploader_class) { AvatarUploader } + let(:file_field) { :avatar } + + context 'when local storage is used' do + let(:store) { local } + + context 'and remote storage is defined' do + before do + stub_uploads_object_storage(uploader_class, background_upload: true) + end + + describe 'supports using the model' do + let(:subject_class) { project.class } + let(:subject_id) { project.id } + + it "migrates file to remote storage" do + perform + + expect(project.reload.avatar.file_storage?).to be_falsey + end + end + + describe 'supports using the Upload' do + let(:subject_class) { Upload } + let(:subject_id) { project.avatar.upload.id } + + it "migrates file to remote storage" do + perform + + expect(project.reload.avatar.file_storage?).to be_falsey + end + end + end + end + end +end diff --git a/spec/uploaders/workers/object_storage/migrate_uploads_worker_spec.rb b/spec/uploaders/workers/object_storage/migrate_uploads_worker_spec.rb new file mode 100644 index 00000000000..7a7dcb71680 --- /dev/null +++ b/spec/uploaders/workers/object_storage/migrate_uploads_worker_spec.rb @@ -0,0 +1,119 @@ +require 'spec_helper' + +describe ObjectStorage::MigrateUploadsWorker, :sidekiq do + shared_context 'sanity_check! fails' do + before do + expect(described_class).to receive(:sanity_check!).and_raise(described_class::SanityCheckError) + end + end + + let!(:projects) { create_list(:project, 10, :with_avatar) } + let(:uploads) { Upload.all } + let(:model_class) { Project } + let(:mounted_as) { :avatar } + let(:to_store) { ObjectStorage::Store::REMOTE } + + before do + stub_uploads_object_storage(AvatarUploader) + end + + describe '.enqueue!' do + def enqueue! + described_class.enqueue!(uploads, Project, mounted_as, to_store) + end + + it 'is guarded by .sanity_check!' do + expect(described_class).to receive(:perform_async) + expect(described_class).to receive(:sanity_check!) + + enqueue! + end + + context 'sanity_check! fails' do + include_context 'sanity_check! fails' + + it 'does not enqueue a job' do + expect(described_class).not_to receive(:perform_async) + + expect { enqueue! }.to raise_error(described_class::SanityCheckError) + end + end + end + + describe '.sanity_check!' do + shared_examples 'raises a SanityCheckError' do + let(:mount_point) { nil } + + it do + expect { described_class.sanity_check!(uploads, model_class, mount_point) } + .to raise_error(described_class::SanityCheckError) + end + end + + context 'uploader types mismatch' do + let!(:outlier) { create(:upload, uploader: 'FileUploader') } + + include_examples 'raises a SanityCheckError' + end + + context 'model types mismatch' do + let!(:outlier) { create(:upload, model_type: 'Potato') } + + include_examples 'raises a SanityCheckError' + end + + context 'mount point not found' do + include_examples 'raises a SanityCheckError' do + let(:mount_point) { :potato } + end + end + end + + describe '#perform' do + def perform + described_class.new.perform(uploads.ids, model_class.to_s, mounted_as, to_store) + rescue ObjectStorage::MigrateUploadsWorker::Report::MigrationFailures + # swallow + end + + shared_examples 'outputs correctly' do |success: 0, failures: 0| + total = success + failures + + if success > 0 + it 'outputs the reports' do + expect(Rails.logger).to receive(:info).with(%r{Migrated #{success}/#{total} files}) + + perform + end + end + + if failures > 0 + it 'outputs upload failures' do + expect(Rails.logger).to receive(:warn).with(/Error .* I am a teapot/) + + perform + end + end + end + + it_behaves_like 'outputs correctly', success: 10 + + it 'migrates files' do + perform + + aggregate_failures do + projects.each do |project| + expect(project.reload.avatar.upload.local?).to be_falsey + end + end + end + + context 'migration is unsuccessful' do + before do + allow_any_instance_of(ObjectStorage::Concern).to receive(:migrate!).and_raise(CarrierWave::UploadError, "I am a teapot.") + end + + it_behaves_like 'outputs correctly', failures: 10 + end + end +end diff --git a/spec/views/projects/jobs/show.html.haml_spec.rb b/spec/views/projects/jobs/show.html.haml_spec.rb index 6a67da79ec5..c93152b88e3 100644 --- a/spec/views/projects/jobs/show.html.haml_spec.rb +++ b/spec/views/projects/jobs/show.html.haml_spec.rb @@ -1,8 +1,10 @@ require 'spec_helper' describe 'projects/jobs/show' do + let(:user) { create(:user) } let(:project) { create(:project, :repository) } let(:build) { create(:ci_build, pipeline: pipeline) } + let(:builds) { project.builds.present(current_user: user) } let(:pipeline) do create(:ci_pipeline, project: project, sha: project.commit.id) @@ -11,6 +13,7 @@ describe 'projects/jobs/show' do before do assign(:build, build.present) assign(:project, project) + assign(:builds, builds) allow(view).to receive(:can?).and_return(true) end @@ -18,7 +21,7 @@ describe 'projects/jobs/show' do describe 'environment info in job view' do context 'job with latest deployment' do let(:build) do - create(:ci_build, :success, environment: 'staging') + create(:ci_build, :success, :trace_artifact, environment: 'staging') end before do @@ -37,11 +40,11 @@ describe 'projects/jobs/show' do context 'job with outdated deployment' do let(:build) do - create(:ci_build, :success, environment: 'staging', pipeline: pipeline) + create(:ci_build, :success, :trace_artifact, environment: 'staging', pipeline: pipeline) end let(:second_build) do - create(:ci_build, :success, environment: 'staging', pipeline: pipeline) + create(:ci_build, :success, :trace_artifact, environment: 'staging', pipeline: pipeline) end let(:environment) do @@ -67,7 +70,7 @@ describe 'projects/jobs/show' do context 'job failed to deploy' do let(:build) do - create(:ci_build, :failed, environment: 'staging', pipeline: pipeline) + create(:ci_build, :failed, :trace_artifact, environment: 'staging', pipeline: pipeline) end let!(:environment) do @@ -85,7 +88,7 @@ describe 'projects/jobs/show' do context 'job will deploy' do let(:build) do - create(:ci_build, :running, environment: 'staging', pipeline: pipeline) + create(:ci_build, :running, :trace_live, environment: 'staging', pipeline: pipeline) end context 'when environment exists' do @@ -133,7 +136,7 @@ describe 'projects/jobs/show' do context 'job that failed to deploy and environment has not been created' do let(:build) do - create(:ci_build, :failed, environment: 'staging', pipeline: pipeline) + create(:ci_build, :failed, :trace_artifact, environment: 'staging', pipeline: pipeline) end let!(:environment) do @@ -151,7 +154,7 @@ describe 'projects/jobs/show' do context 'job that will deploy and environment has not been created' do let(:build) do - create(:ci_build, :running, environment: 'staging', pipeline: pipeline) + create(:ci_build, :running, :trace_live, environment: 'staging', pipeline: pipeline) end let!(:environment) do @@ -171,8 +174,9 @@ describe 'projects/jobs/show' do end context 'when job is running' do + let(:build) { create(:ci_build, :trace_live, :running, pipeline: pipeline) } + before do - build.run! render end diff --git a/spec/views/projects/merge_requests/_commits.html.haml_spec.rb b/spec/views/projects/merge_requests/_commits.html.haml_spec.rb index 3ca67114558..b1c6565c08a 100644 --- a/spec/views/projects/merge_requests/_commits.html.haml_spec.rb +++ b/spec/views/projects/merge_requests/_commits.html.haml_spec.rb @@ -28,6 +28,6 @@ describe 'projects/merge_requests/_commits.html.haml' do commit = merge_request.commits.first # HEAD href = diffs_project_merge_request_path(target_project, merge_request, commit_id: commit) - expect(rendered).to have_link(Commit.truncate_sha(commit.sha), href: href) + expect(rendered).to have_link(href: href) end end diff --git a/spec/views/projects/pipelines_settings/_show.html.haml_spec.rb b/spec/views/projects/settings/ci_cd/_form.html.haml_spec.rb index 7b300150874..be9a4d9c57c 100644 --- a/spec/views/projects/pipelines_settings/_show.html.haml_spec.rb +++ b/spec/views/projects/settings/ci_cd/_form.html.haml_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'projects/pipelines_settings/_show' do +describe 'projects/settings/ci_cd/_form' do let(:project) { create(:project, :repository) } before do diff --git a/spec/workers/concerns/waitable_worker_spec.rb b/spec/workers/concerns/waitable_worker_spec.rb index 4af0de86ac9..54ab07981a4 100644 --- a/spec/workers/concerns/waitable_worker_spec.rb +++ b/spec/workers/concerns/waitable_worker_spec.rb @@ -14,6 +14,12 @@ describe WaitableWorker do include ApplicationWorker prepend WaitableWorker + # This is a workaround for a Ruby 2.3.7 bug. rspec-mocks cannot restore + # the visibility of prepended modules. See + # https://github.com/rspec/rspec-mocks/issues/1231 for more details. + def self.bulk_perform_inline(args_list) + end + def perform(i = 0) self.class.counter += i end diff --git a/spec/workers/project_export_worker_spec.rb b/spec/workers/project_export_worker_spec.rb new file mode 100644 index 00000000000..8899969c178 --- /dev/null +++ b/spec/workers/project_export_worker_spec.rb @@ -0,0 +1,28 @@ +require 'spec_helper' + +describe ProjectExportWorker do + let!(:user) { create(:user) } + let!(:project) { create(:project) } + + subject { described_class.new } + + describe '#perform' do + context 'when it succeeds' do + it 'calls the ExportService' do + expect_any_instance_of(::Projects::ImportExport::ExportService).to receive(:execute) + + subject.perform(user.id, project.id, { 'klass' => 'Gitlab::ImportExport::AfterExportStrategies::DownloadNotificationStrategy' }) + end + end + + context 'when it fails' do + it 'raises an exception when params are invalid' do + expect_any_instance_of(::Projects::ImportExport::ExportService).not_to receive(:execute) + + expect { subject.perform(1234, project.id, {}) }.to raise_exception(ActiveRecord::RecordNotFound) + expect { subject.perform(user.id, 1234, {}) }.to raise_exception(ActiveRecord::RecordNotFound) + expect { subject.perform(user.id, project.id, { 'klass' => 'Whatever' }) }.to raise_exception(Gitlab::ImportExport::AfterExportStrategyBuilder::StrategyNotFoundError) + end + end + end +end diff --git a/spec/workers/repository_fork_worker_spec.rb b/spec/workers/repository_fork_worker_spec.rb index 6c66658d8c3..4b3c1736ea0 100644 --- a/spec/workers/repository_fork_worker_spec.rb +++ b/spec/workers/repository_fork_worker_spec.rb @@ -9,70 +9,91 @@ describe RepositoryForkWorker do describe "#perform" do let(:project) { create(:project, :repository) } - let(:fork_project) { create(:project, :repository, :import_scheduled, forked_from_project: project) } let(:shell) { Gitlab::Shell.new } + let(:fork_project) { create(:project, :repository, :import_scheduled, forked_from_project: project) } - before do - allow(subject).to receive(:gitlab_shell).and_return(shell) - end + shared_examples 'RepositoryForkWorker performing' do + before do + allow(subject).to receive(:gitlab_shell).and_return(shell) + end - def perform! - subject.perform(fork_project.id, '/test/path', project.disk_path) - end + def expect_fork_repository + expect(shell).to receive(:fork_repository).with( + 'default', + project.disk_path, + fork_project.repository_storage, + fork_project.disk_path + ) + end - def expect_fork_repository - expect(shell).to receive(:fork_repository).with( - '/test/path', - project.disk_path, - fork_project.repository_storage_path, - fork_project.disk_path - ) - end + describe 'when a worker was reset without cleanup' do + let(:jid) { '12345678' } - describe 'when a worker was reset without cleanup' do - let(:jid) { '12345678' } + it 'creates a new repository from a fork' do + allow(subject).to receive(:jid).and_return(jid) - it 'creates a new repository from a fork' do - allow(subject).to receive(:jid).and_return(jid) + expect_fork_repository.and_return(true) + perform! + end + end + + it "creates a new repository from a fork" do expect_fork_repository.and_return(true) perform! end - end - it "creates a new repository from a fork" do - expect_fork_repository.and_return(true) + it 'protects the default branch' do + expect_fork_repository.and_return(true) - perform! - end + perform! + + expect(fork_project.protected_branches.first.name).to eq(fork_project.default_branch) + end + + it 'flushes various caches' do + expect_fork_repository.and_return(true) - it 'protects the default branch' do - expect_fork_repository.and_return(true) + expect_any_instance_of(Repository).to receive(:expire_emptiness_caches) + .and_call_original - perform! + expect_any_instance_of(Repository).to receive(:expire_exists_cache) + .and_call_original - expect(fork_project.protected_branches.first.name).to eq(fork_project.default_branch) - end + perform! + end + + it "handles bad fork" do + error_message = "Unable to fork project #{fork_project.id} for repository #{project.disk_path} -> #{fork_project.disk_path}" - it 'flushes various caches' do - expect_fork_repository.and_return(true) + expect_fork_repository.and_return(false) - expect_any_instance_of(Repository).to receive(:expire_emptiness_caches) - .and_call_original + expect { perform! }.to raise_error(StandardError, error_message) + end + end - expect_any_instance_of(Repository).to receive(:expire_exists_cache) - .and_call_original + context 'only project ID passed' do + def perform! + subject.perform(fork_project.id) + end - perform! + it_behaves_like 'RepositoryForkWorker performing' end - it "handles bad fork" do - error_message = "Unable to fork project #{fork_project.id} for repository #{project.disk_path} -> #{fork_project.disk_path}" + context 'project ID, storage and repo paths passed' do + def perform! + subject.perform(fork_project.id, TestEnv.repos_path, project.disk_path) + end - expect_fork_repository.and_return(false) + it_behaves_like 'RepositoryForkWorker performing' - expect { perform! }.to raise_error(StandardError, error_message) + it 'logs a message about forking with old-style arguments' do + allow(Rails.logger).to receive(:info).with(anything) # To compensate for other logs + expect(Rails.logger).to receive(:info).with("Project #{fork_project.id} is being forked using old-style arguments.") + + perform! + end end end end |