From 456a7247f9e88fc2518b69a1a00e905c6db6d775 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Fri, 7 Feb 2020 09:08:49 +0000 Subject: Add latest changes from gitlab-org/gitlab@master --- .../controllers/admin/spam_logs_controller_spec.rb | 2 +- spec/controllers/admin/users_controller_spec.rb | 2 +- spec/features/calendar_spec.rb | 34 ++++- spec/features/invites_spec.rb | 2 +- ...not_request_access_to_his_group_project_spec.rb | 2 +- ...er_cannot_request_access_to_his_project_spec.rb | 2 +- ...er_cannot_request_access_to_his_project_spec.rb | 2 +- spec/features/signed_commits_spec.rb | 4 +- .../environments/environments_store_spec.js | 163 +++++++++++++++++++++ spec/frontend/environments/mock_data.js | 59 +++++++- .../environments/environments_store_spec.js | 163 --------------------- spec/javascripts/environments/mock_data.js | 37 ----- .../clusters/applications/cert_manager_spec.rb | 2 +- spec/requests/api/users_spec.rb | 2 +- spec/spec_helper.rb | 3 + .../requests/api/notes_shared_examples.rb | 2 +- 16 files changed, 262 insertions(+), 219 deletions(-) create mode 100644 spec/frontend/environments/environments_store_spec.js delete mode 100644 spec/javascripts/environments/environments_store_spec.js (limited to 'spec') diff --git a/spec/controllers/admin/spam_logs_controller_spec.rb b/spec/controllers/admin/spam_logs_controller_spec.rb index 6716bb8b399..ec0d8c47660 100644 --- a/spec/controllers/admin/spam_logs_controller_spec.rb +++ b/spec/controllers/admin/spam_logs_controller_spec.rb @@ -27,7 +27,7 @@ describe Admin::SpamLogsController do expect(response).to have_gitlab_http_status(:ok) end - it 'removes user and his spam logs when removing the user', :sidekiq_might_not_need_inline do + it 'removes user and their spam logs when removing the user', :sidekiq_might_not_need_inline do delete :destroy, params: { id: first_spam.id, remove_user: true } expect(flash[:notice]).to eq "User #{user.username} was successfully removed." diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb index 2661f8c1519..a4ce510b413 100644 --- a/spec/controllers/admin/users_controller_spec.rb +++ b/spec/controllers/admin/users_controller_spec.rb @@ -270,7 +270,7 @@ describe Admin::UsersController do post :update, params: params end - context 'when the admin changes his own password' do + context 'when the admin changes their own password' do it 'updates the password' do expect { update_password(admin, 'AValidPassword1') } .to change { admin.reload.encrypted_password } diff --git a/spec/features/calendar_spec.rb b/spec/features/calendar_spec.rb index bac5c9f568e..acdc38038aa 100644 --- a/spec/features/calendar_spec.rb +++ b/spec/features/calendar_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' describe 'Contributions Calendar', :js do + include MobileHelpers + let(:user) { create(:user) } let(:contributed_project) { create(:project, :public, :repository) } let(:issue_note) { create(:note, project: contributed_project) } @@ -122,15 +124,15 @@ describe 'Contributions Calendar', :js do end end - describe 'calendar daily activities' do - shared_context 'visit user page' do - before do - visit user.username - page.find('.js-overview-tab a').click - wait_for_requests - end + shared_context 'visit user page' do + before do + visit user.username + page.find('.js-overview-tab a').click + wait_for_requests end + end + describe 'calendar daily activities' do shared_examples 'a day with activity' do |contribution_count:| include_context 'visit user page' @@ -199,4 +201,22 @@ describe 'Contributions Calendar', :js do end end end + + describe 'on smaller screens' do + shared_examples 'hidden activity calendar' do + include_context 'visit user page' + + it 'hides the activity calender' do + expect(find('#js-overview')).not_to have_css('.js-contrib-calendar') + end + end + + context 'size xs' do + before do + resize_screen_xs + end + + it_behaves_like 'hidden activity calendar' + end + end end diff --git a/spec/features/invites_spec.rb b/spec/features/invites_spec.rb index 0571ab007e9..7884a16c118 100644 --- a/spec/features/invites_spec.rb +++ b/spec/features/invites_spec.rb @@ -169,7 +169,7 @@ describe 'Invites' do end end - it "doesn't accept invitations until the user confirms his email" do + it "doesn't accept invitations until the user confirms their email" do fill_in_sign_up_form(new_user) sign_in(owner) diff --git a/spec/features/projects/members/group_member_cannot_request_access_to_his_group_project_spec.rb b/spec/features/projects/members/group_member_cannot_request_access_to_his_group_project_spec.rb index 1f4d555c6ae..cf9441bcd55 100644 --- a/spec/features/projects/members/group_member_cannot_request_access_to_his_group_project_spec.rb +++ b/spec/features/projects/members/group_member_cannot_request_access_to_his_group_project_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe 'Projects > Members > Group member cannot request access to his group project' do +describe 'Projects > Members > Group member cannot request access to their group project' do let(:user) { create(:user) } let(:group) { create(:group) } let(:project) { create(:project, namespace: group) } diff --git a/spec/features/projects/members/member_cannot_request_access_to_his_project_spec.rb b/spec/features/projects/members/member_cannot_request_access_to_his_project_spec.rb index 606444b36a2..e2b57472b2e 100644 --- a/spec/features/projects/members/member_cannot_request_access_to_his_project_spec.rb +++ b/spec/features/projects/members/member_cannot_request_access_to_his_project_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe 'Projects > Members > Member cannot request access to his project' do +describe 'Projects > Members > Member cannot request access to their project' do let(:member) { create(:user) } let(:project) { create(:project) } diff --git a/spec/features/projects/members/owner_cannot_request_access_to_his_project_spec.rb b/spec/features/projects/members/owner_cannot_request_access_to_his_project_spec.rb index 2fb76da36ad..5643a29b4e4 100644 --- a/spec/features/projects/members/owner_cannot_request_access_to_his_project_spec.rb +++ b/spec/features/projects/members/owner_cannot_request_access_to_his_project_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' -describe 'Projects > Members > Owner cannot request access to his project' do +describe 'Projects > Members > Owner cannot request access to their own project' do let(:project) { create(:project) } before do diff --git a/spec/features/signed_commits_spec.rb b/spec/features/signed_commits_spec.rb index f56bd055224..851e155480b 100644 --- a/spec/features/signed_commits_spec.rb +++ b/spec/features/signed_commits_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' describe 'GPG signed commits' do let(:project) { create(:project, :public, :repository) } - it 'changes from unverified to verified when the user changes his email to match the gpg key', :sidekiq_might_not_need_inline do + it 'changes from unverified to verified when the user changes their email to match the gpg key', :sidekiq_might_not_need_inline do ref = GpgHelpers::SIGNED_AND_AUTHORED_SHA user = create(:user, email: 'unrelated.user@example.org') @@ -18,7 +18,7 @@ describe 'GPG signed commits' do expect(page).to have_button 'Unverified' expect(page).not_to have_button 'Verified' - # user changes his email which makes the gpg key verified + # user changes their email which makes the gpg key verified perform_enqueued_jobs do user.skip_reconfirmation! user.update!(email: GpgHelpers::User1.emails.first) diff --git a/spec/frontend/environments/environments_store_spec.js b/spec/frontend/environments/environments_store_spec.js new file mode 100644 index 00000000000..8abdbcbbe54 --- /dev/null +++ b/spec/frontend/environments/environments_store_spec.js @@ -0,0 +1,163 @@ +import Store from '~/environments/stores/environments_store'; +import { environmentsList, serverData } from './mock_data'; + +describe('Store', () => { + let store; + + beforeEach(() => { + store = new Store(); + }); + + it('should start with a blank state', () => { + expect(store.state.environments.length).toEqual(0); + expect(store.state.stoppedCounter).toEqual(0); + expect(store.state.availableCounter).toEqual(0); + expect(store.state.paginationInformation).toEqual({}); + }); + + it('should store environments', () => { + store.storeEnvironments(serverData); + + expect(store.state.environments.length).toEqual(serverData.length); + expect(store.state.environments[0]).toEqual(environmentsList[0]); + }); + + it('should store available count', () => { + store.storeAvailableCount(2); + + expect(store.state.availableCounter).toEqual(2); + }); + + it('should store stopped count', () => { + store.storeStoppedCount(2); + + expect(store.state.stoppedCounter).toEqual(2); + }); + + it('should add folder keys when environment is a folder', () => { + const environment = { + name: 'bar', + size: 3, + id: 2, + }; + + store.storeEnvironments([environment]); + + expect(store.state.environments[0].isFolder).toEqual(true); + expect(store.state.environments[0].folderName).toEqual('bar'); + }); + + it('should extract content of `latest` key when provided', () => { + const environment = { + name: 'bar', + size: 3, + id: 2, + latest: { + last_deployment: {}, + isStoppable: true, + }, + }; + + store.storeEnvironments([environment]); + + expect(store.state.environments[0].last_deployment).toEqual({}); + expect(store.state.environments[0].isStoppable).toEqual(true); + }); + + it('should store latest.name when the environment is not a folder', () => { + store.storeEnvironments(serverData); + + expect(store.state.environments[0].name).toEqual(serverData[0].latest.name); + }); + + it('should store root level name when environment is a folder', () => { + store.storeEnvironments(serverData); + + expect(store.state.environments[1].folderName).toEqual(serverData[1].name); + }); + + describe('toggleFolder', () => { + it('should toggle folder', () => { + store.storeEnvironments(serverData); + + store.toggleFolder(store.state.environments[1]); + + expect(store.state.environments[1].isOpen).toEqual(true); + + store.toggleFolder(store.state.environments[1]); + + expect(store.state.environments[1].isOpen).toEqual(false); + }); + + it('should keep folder open when environments are updated', () => { + store.storeEnvironments(serverData); + + store.toggleFolder(store.state.environments[1]); + + expect(store.state.environments[1].isOpen).toEqual(true); + + store.storeEnvironments(serverData); + + expect(store.state.environments[1].isOpen).toEqual(true); + }); + }); + + describe('setfolderContent', () => { + it('should store folder content', () => { + store.storeEnvironments(serverData); + + store.setfolderContent(store.state.environments[1], serverData); + + expect(store.state.environments[1].children.length).toEqual(serverData.length); + expect(store.state.environments[1].children[0].isChildren).toEqual(true); + }); + + it('should keep folder content when environments are updated', () => { + store.storeEnvironments(serverData); + + store.setfolderContent(store.state.environments[1], serverData); + + expect(store.state.environments[1].children.length).toEqual(serverData.length); + // poll + store.storeEnvironments(serverData); + + expect(store.state.environments[1].children.length).toEqual(serverData.length); + }); + }); + + describe('store pagination', () => { + it('should store normalized and integer pagination information', () => { + const pagination = { + 'X-nExt-pAge': '2', + 'X-page': '1', + 'X-Per-Page': '1', + 'X-Prev-Page': '2', + 'X-TOTAL': '37', + 'X-Total-Pages': '2', + }; + + const expectedResult = { + perPage: 1, + page: 1, + total: 37, + totalPages: 2, + nextPage: 2, + previousPage: 2, + }; + + store.setPagination(pagination); + + expect(store.state.paginationInformation).toEqual(expectedResult); + }); + }); + + describe('getOpenFolders', () => { + it('should return open folder', () => { + store.storeEnvironments(serverData); + + store.toggleFolder(store.state.environments[1]); + + expect(store.getOpenFolders()[0]).toEqual(store.state.environments[1]); + }); + }); +}); diff --git a/spec/frontend/environments/mock_data.js b/spec/frontend/environments/mock_data.js index a2b581578d2..77c5dad0bbf 100644 --- a/spec/frontend/environments/mock_data.js +++ b/spec/frontend/environments/mock_data.js @@ -1,3 +1,31 @@ +const devProps = { + id: 7, + name: 'DEV', + state: 'available', + external_url: null, + environment_type: null, + last_deployment: null, + has_stop_action: false, + environment_path: '/root/review-app/environments/7', + stop_path: '/root/review-app/environments/7/stop', + created_at: '2017-01-31T10:53:46.894Z', + updated_at: '2017-01-31T10:53:46.894Z', +}; + +const buildProps = { + id: 12, + name: 'build/update-README', + state: 'available', + external_url: null, + environment_type: 'build', + last_deployment: null, + has_stop_action: false, + environment_path: '/root/review-app/environments/12', + stop_path: '/root/review-app/environments/12/stop', + created_at: '2017-02-01T19:42:18.400Z', + updated_at: '2017-02-01T19:42:18.400Z', +}; + const environment = { name: 'production', size: 1, @@ -66,6 +94,18 @@ const environment = { auto_stop_at: null, }; +const environmentsList = [ + { + size: 1, + ...devProps, + }, + { + folderName: 'build', + size: 5, + ...buildProps, + }, +]; + const folder = { name: 'review', folderName: 'review', @@ -78,6 +118,23 @@ const folder = { }, }; +const serverData = [ + { + name: 'DEV', + size: 1, + latest: { + ...devProps, + }, + }, + { + name: 'build', + size: 5, + latest: { + ...buildProps, + }, + }, +]; + const tableData = { name: { title: 'Environment', @@ -108,4 +165,4 @@ const tableData = { }, }; -export { environment, folder, tableData }; +export { environment, environmentsList, folder, serverData, tableData }; diff --git a/spec/javascripts/environments/environments_store_spec.js b/spec/javascripts/environments/environments_store_spec.js deleted file mode 100644 index 8abdbcbbe54..00000000000 --- a/spec/javascripts/environments/environments_store_spec.js +++ /dev/null @@ -1,163 +0,0 @@ -import Store from '~/environments/stores/environments_store'; -import { environmentsList, serverData } from './mock_data'; - -describe('Store', () => { - let store; - - beforeEach(() => { - store = new Store(); - }); - - it('should start with a blank state', () => { - expect(store.state.environments.length).toEqual(0); - expect(store.state.stoppedCounter).toEqual(0); - expect(store.state.availableCounter).toEqual(0); - expect(store.state.paginationInformation).toEqual({}); - }); - - it('should store environments', () => { - store.storeEnvironments(serverData); - - expect(store.state.environments.length).toEqual(serverData.length); - expect(store.state.environments[0]).toEqual(environmentsList[0]); - }); - - it('should store available count', () => { - store.storeAvailableCount(2); - - expect(store.state.availableCounter).toEqual(2); - }); - - it('should store stopped count', () => { - store.storeStoppedCount(2); - - expect(store.state.stoppedCounter).toEqual(2); - }); - - it('should add folder keys when environment is a folder', () => { - const environment = { - name: 'bar', - size: 3, - id: 2, - }; - - store.storeEnvironments([environment]); - - expect(store.state.environments[0].isFolder).toEqual(true); - expect(store.state.environments[0].folderName).toEqual('bar'); - }); - - it('should extract content of `latest` key when provided', () => { - const environment = { - name: 'bar', - size: 3, - id: 2, - latest: { - last_deployment: {}, - isStoppable: true, - }, - }; - - store.storeEnvironments([environment]); - - expect(store.state.environments[0].last_deployment).toEqual({}); - expect(store.state.environments[0].isStoppable).toEqual(true); - }); - - it('should store latest.name when the environment is not a folder', () => { - store.storeEnvironments(serverData); - - expect(store.state.environments[0].name).toEqual(serverData[0].latest.name); - }); - - it('should store root level name when environment is a folder', () => { - store.storeEnvironments(serverData); - - expect(store.state.environments[1].folderName).toEqual(serverData[1].name); - }); - - describe('toggleFolder', () => { - it('should toggle folder', () => { - store.storeEnvironments(serverData); - - store.toggleFolder(store.state.environments[1]); - - expect(store.state.environments[1].isOpen).toEqual(true); - - store.toggleFolder(store.state.environments[1]); - - expect(store.state.environments[1].isOpen).toEqual(false); - }); - - it('should keep folder open when environments are updated', () => { - store.storeEnvironments(serverData); - - store.toggleFolder(store.state.environments[1]); - - expect(store.state.environments[1].isOpen).toEqual(true); - - store.storeEnvironments(serverData); - - expect(store.state.environments[1].isOpen).toEqual(true); - }); - }); - - describe('setfolderContent', () => { - it('should store folder content', () => { - store.storeEnvironments(serverData); - - store.setfolderContent(store.state.environments[1], serverData); - - expect(store.state.environments[1].children.length).toEqual(serverData.length); - expect(store.state.environments[1].children[0].isChildren).toEqual(true); - }); - - it('should keep folder content when environments are updated', () => { - store.storeEnvironments(serverData); - - store.setfolderContent(store.state.environments[1], serverData); - - expect(store.state.environments[1].children.length).toEqual(serverData.length); - // poll - store.storeEnvironments(serverData); - - expect(store.state.environments[1].children.length).toEqual(serverData.length); - }); - }); - - describe('store pagination', () => { - it('should store normalized and integer pagination information', () => { - const pagination = { - 'X-nExt-pAge': '2', - 'X-page': '1', - 'X-Per-Page': '1', - 'X-Prev-Page': '2', - 'X-TOTAL': '37', - 'X-Total-Pages': '2', - }; - - const expectedResult = { - perPage: 1, - page: 1, - total: 37, - totalPages: 2, - nextPage: 2, - previousPage: 2, - }; - - store.setPagination(pagination); - - expect(store.state.paginationInformation).toEqual(expectedResult); - }); - }); - - describe('getOpenFolders', () => { - it('should return open folder', () => { - store.storeEnvironments(serverData); - - store.toggleFolder(store.state.environments[1]); - - expect(store.getOpenFolders()[0]).toEqual(store.state.environments[1]); - }); - }); -}); diff --git a/spec/javascripts/environments/mock_data.js b/spec/javascripts/environments/mock_data.js index 7bb57f938b8..a8be3706b79 100644 --- a/spec/javascripts/environments/mock_data.js +++ b/spec/javascripts/environments/mock_data.js @@ -30,43 +30,6 @@ export const environmentsList = [ }, ]; -export const serverData = [ - { - name: 'DEV', - size: 1, - latest: { - id: 7, - name: 'DEV', - state: 'available', - external_url: null, - environment_type: null, - last_deployment: null, - has_stop_action: false, - environment_path: '/root/review-app/environments/7', - stop_path: '/root/review-app/environments/7/stop', - created_at: '2017-01-31T10:53:46.894Z', - updated_at: '2017-01-31T10:53:46.894Z', - }, - }, - { - name: 'build', - size: 5, - latest: { - id: 12, - name: 'build/update-README', - state: 'available', - external_url: null, - environment_type: 'build', - last_deployment: null, - has_stop_action: false, - environment_path: '/root/review-app/environments/12', - stop_path: '/root/review-app/environments/12/stop', - created_at: '2017-02-01T19:42:18.400Z', - updated_at: '2017-02-01T19:42:18.400Z', - }, - }, -]; - export const environment = { name: 'DEV', size: 1, diff --git a/spec/models/clusters/applications/cert_manager_spec.rb b/spec/models/clusters/applications/cert_manager_spec.rb index 6b85f9bb127..31209a70018 100644 --- a/spec/models/clusters/applications/cert_manager_spec.rb +++ b/spec/models/clusters/applications/cert_manager_spec.rb @@ -65,7 +65,7 @@ describe Clusters::Applications::CertManager do cert_manager.email = cert_email end - it 'uses his/her email to register issuer with certificate provider' do + it 'uses their email to register issuer with certificate provider' do expect(subject.files).to eq(cert_manager.files.merge(cluster_issuer_file)) end end diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index aa8dd021707..d14baa49341 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -749,7 +749,7 @@ describe API::Users do expect(user.email).to eq('new@email.com') end - it 'updates user with his own username' do + it 'updates user with their own username' do put api("/users/#{user.id}", admin), params: { username: user.username } expect(response).to have_gitlab_http_status(200) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index ad15793f23b..35bf6846ab3 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -124,6 +124,9 @@ RSpec.configure do |config| if ENV['CI'] || ENV['RETRIES'] # This includes the first try, i.e. tests will be run 4 times before failing. config.default_retry_count = ENV.fetch('RETRIES', 3).to_i + 1 + end + + if ENV['FLAKY_RSPEC_GENERATE_REPORT'] config.reporter.register_listener( RspecFlaky::Listener.new, :example_passed, diff --git a/spec/support/shared_examples/requests/api/notes_shared_examples.rb b/spec/support/shared_examples/requests/api/notes_shared_examples.rb index 43bfeca93a2..0c52af43465 100644 --- a/spec/support/shared_examples/requests/api/notes_shared_examples.rb +++ b/spec/support/shared_examples/requests/api/notes_shared_examples.rb @@ -239,7 +239,7 @@ RSpec.shared_examples 'noteable API' do |parent_type, noteable_type, id_name| end end - context 'when the user is posting an award emoji on his/her own noteable' do + context 'when the user is posting an award emoji on their own noteable' do it 'creates a new note' do post api("/#{parent_type}/#{parent.id}/#{noteable_type}/#{noteable[id_name]}/notes", user), params: { body: ':+1:' } -- cgit v1.2.3