summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/db/schema_spec.rb1
-rw-r--r--spec/features/merge_request/user_sees_merge_widget_spec.rb22
-rw-r--r--spec/frontend/ci_variable_list/components/ci_variable_modal_spec.js18
-rw-r--r--spec/frontend/ci_variable_list/components/ci_variable_popover_spec.js48
-rw-r--r--spec/frontend/ci_variable_list/components/ci_variable_table_spec.js7
-rw-r--r--spec/frontend/ci_variable_list/services/mock_data.js27
-rw-r--r--spec/frontend/ci_variable_list/store/mutations_spec.js4
-rw-r--r--spec/frontend/ci_variable_list/store/utils_spec.js2
-rw-r--r--spec/frontend/contributors/store/getters_spec.js32
-rw-r--r--spec/frontend/reports/store/utils_spec.js34
-rw-r--r--spec/frontend/sidebar/mock_data.js2
-rw-r--r--spec/javascripts/reports/components/grouped_test_reports_app_spec.js20
-rw-r--r--spec/lib/gitlab/git/repository_spec.rb4
-rw-r--r--spec/lib/gitlab/import_export/fast_hash_serializer_spec.rb10
-rw-r--r--spec/models/concerns/ci/has_ref_spec.rb (renamed from spec/models/concerns/has_ref_spec.rb)2
-rw-r--r--spec/requests/api/pipelines_spec.rb4
-rw-r--r--spec/rubocop/cop/migration/with_lock_retries_with_change_spec.rb43
-rw-r--r--spec/serializers/group_variable_entity_spec.rb2
-rw-r--r--spec/support/matchers/exceed_query_limit.rb10
-rw-r--r--spec/support_specs/matchers/exceed_query_limit_helpers_spec.rb34
20 files changed, 235 insertions, 91 deletions
diff --git a/spec/db/schema_spec.rb b/spec/db/schema_spec.rb
index f2f7d6cbafc..c6c842ce1a1 100644
--- a/spec/db/schema_spec.rb
+++ b/spec/db/schema_spec.rb
@@ -60,6 +60,7 @@ describe 'Database schema' do
oauth_access_grants: %w[resource_owner_id application_id],
oauth_access_tokens: %w[resource_owner_id application_id],
oauth_applications: %w[owner_id],
+ open_project_tracker_data: %w[closed_status_id],
project_group_links: %w[group_id],
project_statistics: %w[namespace_id],
projects: %w[creator_id namespace_id ci_id mirror_user_id],
diff --git a/spec/features/merge_request/user_sees_merge_widget_spec.rb b/spec/features/merge_request/user_sees_merge_widget_spec.rb
index 94f57cdda74..eca011bc786 100644
--- a/spec/features/merge_request/user_sees_merge_widget_spec.rb
+++ b/spec/features/merge_request/user_sees_merge_widget_spec.rb
@@ -585,10 +585,10 @@ describe 'Merge request > User sees merge widget', :js do
within(".js-reports-container") do
click_button 'Expand'
- expect(page).to have_content('Test summary contained 1 failed/error test result out of 2 total tests')
+ expect(page).to have_content('Test summary contained 1 failed out of 2 total tests')
within(".js-report-section-container") do
expect(page).to have_content('rspec found no changed test results out of 1 total test')
- expect(page).to have_content('junit found 1 failed/error test result out of 1 total test')
+ expect(page).to have_content('junit found 1 failed out of 1 total test')
expect(page).to have_content('New')
expect(page).to have_content('addTest')
end
@@ -630,9 +630,9 @@ describe 'Merge request > User sees merge widget', :js do
within(".js-reports-container") do
click_button 'Expand'
- expect(page).to have_content('Test summary contained 1 failed/error test result out of 2 total tests')
+ expect(page).to have_content('Test summary contained 1 failed out of 2 total tests')
within(".js-report-section-container") do
- expect(page).to have_content('rspec found 1 failed/error test result out of 1 total test')
+ expect(page).to have_content('rspec found 1 failed out of 1 total test')
expect(page).to have_content('junit found no changed test results out of 1 total test')
expect(page).not_to have_content('New')
expect(page).to have_content('Test#sum when a is 1 and b is 3 returns summary')
@@ -718,10 +718,10 @@ describe 'Merge request > User sees merge widget', :js do
within(".js-reports-container") do
click_button 'Expand'
- expect(page).to have_content('Test summary contained 1 failed/error test result out of 2 total tests')
+ expect(page).to have_content('Test summary contained 1 error out of 2 total tests')
within(".js-report-section-container") do
expect(page).to have_content('rspec found no changed test results out of 1 total test')
- expect(page).to have_content('junit found 1 failed/error test result out of 1 total test')
+ expect(page).to have_content('junit found 1 error out of 1 total test')
expect(page).to have_content('New')
expect(page).to have_content('addTest')
end
@@ -762,9 +762,9 @@ describe 'Merge request > User sees merge widget', :js do
within(".js-reports-container") do
click_button 'Expand'
- expect(page).to have_content('Test summary contained 1 failed/error test result out of 2 total tests')
+ expect(page).to have_content('Test summary contained 1 error out of 2 total tests')
within(".js-report-section-container") do
- expect(page).to have_content('rspec found 1 failed/error test result out of 1 total test')
+ expect(page).to have_content('rspec found 1 error out of 1 total test')
expect(page).to have_content('junit found no changed test results out of 1 total test')
expect(page).not_to have_content('New')
expect(page).to have_content('Test#sum when a is 4 and b is 4 returns summary')
@@ -857,10 +857,10 @@ describe 'Merge request > User sees merge widget', :js do
within(".js-reports-container") do
click_button 'Expand'
- expect(page).to have_content('Test summary contained 20 failed/error test results out of 20 total tests')
+ expect(page).to have_content('Test summary contained 20 failed out of 20 total tests')
within(".js-report-section-container") do
- expect(page).to have_content('rspec found 10 failed/error test results out of 10 total tests')
- expect(page).to have_content('junit found 10 failed/error test results out of 10 total tests')
+ expect(page).to have_content('rspec found 10 failed out of 10 total tests')
+ expect(page).to have_content('junit found 10 failed out of 10 total tests')
expect(page).to have_content('Test#sum when a is 1 and b is 3 returns summary', count: 2)
end
diff --git a/spec/frontend/ci_variable_list/components/ci_variable_modal_spec.js b/spec/frontend/ci_variable_list/components/ci_variable_modal_spec.js
index be2c017cc7e..8db6626fca3 100644
--- a/spec/frontend/ci_variable_list/components/ci_variable_modal_spec.js
+++ b/spec/frontend/ci_variable_list/components/ci_variable_modal_spec.js
@@ -35,10 +35,6 @@ describe('Ci variable modal', () => {
expect(findModal().props('actionPrimary').attributes.disabled).toBeTruthy();
});
- it('masked checkbox is disabled when value does not meet regex requirements', () => {
- expect(wrapper.find({ ref: 'masked-ci-variable' }).attributes('disabled')).toBeTruthy();
- });
-
describe('Adding a new variable', () => {
beforeEach(() => {
const [variable] = mockData.mockVariables;
@@ -49,13 +45,6 @@ describe('Ci variable modal', () => {
expect(findModal().props('actionPrimary').attributes.disabled).toBeFalsy();
});
- it('masked checkbox is enabled when value meets regex requirements', () => {
- store.state.maskableRegex = '^[a-zA-Z0-9_+=/@:-]{8,}$';
- return wrapper.vm.$nextTick(() => {
- expect(wrapper.find({ ref: 'masked-ci-variable' }).attributes('disabled')).toBeFalsy();
- });
- });
-
it('Add variable button dispatches addVariable action', () => {
findModal().vm.$emit('ok');
expect(store.dispatch).toHaveBeenCalledWith('addVariable');
@@ -74,7 +63,7 @@ describe('Ci variable modal', () => {
});
it('button text is Update variable when updating', () => {
- expect(wrapper.vm.modalActionText).toBe('Update Variable');
+ expect(wrapper.vm.modalActionText).toBe('Update variable');
});
it('Update variable button dispatches updateVariable with correct variable', () => {
@@ -89,5 +78,10 @@ describe('Ci variable modal', () => {
findModal().vm.$emit('hidden');
expect(store.dispatch).toHaveBeenCalledWith('resetEditing');
});
+
+ it('dispatches deleteVariable with correct variable to delete', () => {
+ findModal().vm.$emit('secondary');
+ expect(store.dispatch).toHaveBeenCalledWith('deleteVariable', mockData.mockVariables[0]);
+ });
});
});
diff --git a/spec/frontend/ci_variable_list/components/ci_variable_popover_spec.js b/spec/frontend/ci_variable_list/components/ci_variable_popover_spec.js
new file mode 100644
index 00000000000..5d37f059161
--- /dev/null
+++ b/spec/frontend/ci_variable_list/components/ci_variable_popover_spec.js
@@ -0,0 +1,48 @@
+import { shallowMount } from '@vue/test-utils';
+import { GlButton } from '@gitlab/ui';
+import CiVariablePopover from '~/ci_variable_list/components/ci_variable_popover.vue';
+import mockData from '../services/mock_data';
+
+describe('Ci Variable Popover', () => {
+ let wrapper;
+
+ const defaultProps = {
+ target: 'ci-variable-value-22',
+ value: mockData.mockPemCert,
+ tooltipText: 'Copy value',
+ };
+
+ const createComponent = (props = defaultProps) => {
+ wrapper = shallowMount(CiVariablePopover, {
+ propsData: { ...props },
+ });
+ };
+
+ const findButton = () => wrapper.find(GlButton);
+
+ beforeEach(() => {
+ createComponent();
+ });
+
+ afterEach(() => {
+ wrapper.destroy();
+ wrapper = null;
+ });
+
+ it('displays max count plus ... when character count is over 95', () => {
+ expect(wrapper.text()).toHaveLength(98);
+ });
+
+ it('copies full value to clipboard', () => {
+ expect(findButton().attributes('data-clipboard-text')).toEqual(mockData.mockPemCert);
+ });
+
+ it('displays full value when count is less than max count', () => {
+ createComponent({
+ target: 'ci-variable-value-22',
+ value: 'test_variable_value',
+ tooltipText: 'Copy value',
+ });
+ expect(wrapper.text()).toEqual('test_variable_value');
+ });
+});
diff --git a/spec/frontend/ci_variable_list/components/ci_variable_table_spec.js b/spec/frontend/ci_variable_list/components/ci_variable_table_spec.js
index 973a9c51f16..36aeffe7798 100644
--- a/spec/frontend/ci_variable_list/components/ci_variable_table_spec.js
+++ b/spec/frontend/ci_variable_list/components/ci_variable_table_spec.js
@@ -17,12 +17,12 @@ describe('Ci variable table', () => {
store.state.isGroup = true;
jest.spyOn(store, 'dispatch').mockImplementation();
wrapper = mount(CiVariableTable, {
+ attachToDocument: true,
localVue,
store,
});
};
- const findDeleteButton = () => wrapper.find({ ref: 'delete-ci-variable' });
const findRevealButton = () => wrapper.find({ ref: 'secret-value-reveal-button' });
const findEditButton = () => wrapper.find({ ref: 'edit-ci-variable' });
const findEmptyVariablesPlaceholder = () => wrapper.find({ ref: 'empty-variables' });
@@ -71,11 +71,6 @@ describe('Ci variable table', () => {
store.state.variables = mockData.mockVariables;
});
- it('dispatches deleteVariable with correct variable to delete', () => {
- findDeleteButton().trigger('click');
- expect(store.dispatch).toHaveBeenCalledWith('deleteVariable', mockData.mockVariables[0]);
- });
-
it('reveals secret values when button is clicked', () => {
findRevealButton().trigger('click');
expect(store.dispatch).toHaveBeenCalledWith('toggleValues', false);
diff --git a/spec/frontend/ci_variable_list/services/mock_data.js b/spec/frontend/ci_variable_list/services/mock_data.js
index b04cd223d42..5e0fa55a20c 100644
--- a/spec/frontend/ci_variable_list/services/mock_data.js
+++ b/spec/frontend/ci_variable_list/services/mock_data.js
@@ -6,8 +6,9 @@ export default {
key: 'test_var',
masked: false,
protected: false,
+ secret_value: 'test_val',
value: 'test_val',
- variable_type: 'Variable',
+ variable_type: 'Var',
},
],
@@ -18,6 +19,7 @@ export default {
key: 'test_var',
masked: false,
protected: false,
+ secret_value: 'test_val',
value: 'test_val',
variable_type: 'env_var',
},
@@ -27,6 +29,7 @@ export default {
key: 'test_var_2',
masked: false,
protected: false,
+ secret_value: 'test_val_2',
value: 'test_val_2',
variable_type: 'file',
},
@@ -34,20 +37,22 @@ export default {
mockVariablesDisplay: [
{
- environment_scope: 'All environments',
+ environment_scope: 'All',
id: 113,
key: 'test_var',
masked: false,
protected: false,
+ secret_value: 'test_val',
value: 'test_val',
- variable_type: 'Variable',
+ variable_type: 'Var',
},
{
- environment_scope: 'All environments',
+ environment_scope: 'All',
id: 114,
key: 'test_var_2',
masked: false,
protected: false,
+ secret_value: 'test_val_2',
value: 'test_val_2',
variable_type: 'File',
},
@@ -69,4 +74,18 @@ export default {
state: 'available',
},
],
+
+ mockPemCert: `-----BEGIN CERTIFICATE REQUEST-----
+ MIIB9TCCAWACAQAwgbgxGTAXBgNVBAoMEFF1b1ZhZGlzIExpbWl0ZWQxHDAaBgNV
+ BAsME0RvY3VtZW50IERlcGFydG1lbnQxOTA3BgNVBAMMMFdoeSBhcmUgeW91IGRl
+ Y29kaW5nIG1lPyAgVGhpcyBpcyBvbmx5IGEgdGVzdCEhITERMA8GA1UEBwwISGFt
+ aWx0b24xETAPBgNVBAgMCFBlbWJyb2tlMQswCQYDVQQGEwJCTTEPMA0GCSqGSIb3
+ DQEJARYAMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCJ9WRanG/fUvcfKiGl
+ EL4aRLjGt537mZ28UU9/3eiJeJznNSOuNLnF+hmabAu7H0LT4K7EdqfF+XUZW/2j
+ RKRYcvOUDGF9A7OjW7UfKk1In3+6QDCi7X34RE161jqoaJjrm/T18TOKcgkkhRzE
+ apQnIDm0Ea/HVzX/PiSOGuertwIDAQABMAsGCSqGSIb3DQEBBQOBgQBzMJdAV4QP
+ Awel8LzGx5uMOshezF/KfP67wJ93UW+N7zXY6AwPgoLj4Kjw+WtU684JL8Dtr9FX
+ ozakE+8p06BpxegR4BR3FMHf6p+0jQxUEAkAyb/mVgm66TyghDGC6/YkiKoZptXQ
+ 98TwDIK/39WEB/V607As+KoYazQG8drorw==
+ -----END CERTIFICATE REQUEST-----`,
};
diff --git a/spec/frontend/ci_variable_list/store/mutations_spec.js b/spec/frontend/ci_variable_list/store/mutations_spec.js
index 1bb34e88cf5..05513edff7b 100644
--- a/spec/frontend/ci_variable_list/store/mutations_spec.js
+++ b/spec/frontend/ci_variable_list/store/mutations_spec.js
@@ -48,12 +48,12 @@ describe('CI variable list mutations', () => {
describe('CLEAR_MODAL', () => {
it('should clear modal state ', () => {
const modalState = {
- variable_type: 'Variable',
+ variable_type: 'Var',
key: '',
secret_value: '',
protected: false,
masked: false,
- environment_scope: 'All environments',
+ environment_scope: 'All',
};
mutations[types.CLEAR_MODAL](stateCopy);
diff --git a/spec/frontend/ci_variable_list/store/utils_spec.js b/spec/frontend/ci_variable_list/store/utils_spec.js
index 070bc996d75..5b10370324a 100644
--- a/spec/frontend/ci_variable_list/store/utils_spec.js
+++ b/spec/frontend/ci_variable_list/store/utils_spec.js
@@ -19,6 +19,7 @@ describe('CI variables store utils', () => {
key: 'test_var',
masked: 'false',
protected: 'false',
+ secret_value: 'test_val',
value: 'test_val',
variable_type: 'env_var',
});
@@ -29,6 +30,7 @@ describe('CI variables store utils', () => {
key: 'test_var_2',
masked: 'false',
protected: 'false',
+ secret_value: 'test_val_2',
value: 'test_val_2',
variable_type: 'file',
});
diff --git a/spec/frontend/contributors/store/getters_spec.js b/spec/frontend/contributors/store/getters_spec.js
index 62ae9b36f87..e6342a669b7 100644
--- a/spec/frontend/contributors/store/getters_spec.js
+++ b/spec/frontend/contributors/store/getters_spec.js
@@ -29,33 +29,39 @@ describe('Contributors Store Getters', () => {
beforeAll(() => {
state.chartData = [
+ { author_name: 'John Smith', author_email: 'jawnnypoo@gmail.com', date: '2019-05-05' },
{ author_name: 'John', author_email: 'jawnnypoo@gmail.com', date: '2019-05-05' },
- { author_name: 'John', author_email: 'jawnnypoo@gmail.com', date: '2019-05-05' },
- { author_name: 'Carlson', author_email: 'jawnnypoo@gmail.com', date: '2019-03-03' },
- { author_name: 'Carlson', author_email: 'jawnnypoo@gmail.com', date: '2019-05-05' },
- { author_name: 'John', author_email: 'jawnnypoo@gmail.com', date: '2019-04-04' },
+ { author_name: 'Carlson', author_email: 'carlson123@gitlab.com', date: '2019-03-03' },
+ { author_name: 'Carlson', author_email: 'carlson123@gmail.com', date: '2019-05-05' },
{ author_name: 'John', author_email: 'jawnnypoo@gmail.com', date: '2019-04-04' },
+ { author_name: 'Johan', author_email: 'jawnnypoo@gmail.com', date: '2019-04-04' },
{ author_name: 'John', author_email: 'jawnnypoo@gmail.com', date: '2019-03-03' },
];
parsed = getters.parsedData(state);
});
- it('should group contributions by date ', () => {
+ it('should group contributions by date', () => {
expect(parsed.total).toMatchObject({ '2019-05-05': 3, '2019-03-03': 2, '2019-04-04': 2 });
});
- it('should group contributions by author ', () => {
- expect(parsed.byAuthor).toMatchObject({
- Carlson: {
- email: 'jawnnypoo@gmail.com',
- commits: 2,
+ it('should group contributions by email and use most recent name', () => {
+ expect(parsed.byAuthorEmail).toMatchObject({
+ 'carlson123@gmail.com': {
+ name: 'Carlson',
+ commits: 1,
dates: {
- '2019-03-03': 1,
'2019-05-05': 1,
},
},
- John: {
- email: 'jawnnypoo@gmail.com',
+ 'carlson123@gitlab.com': {
+ name: 'Carlson',
+ commits: 1,
+ dates: {
+ '2019-03-03': 1,
+ },
+ },
+ 'jawnnypoo@gmail.com': {
+ name: 'John Smith',
commits: 5,
dates: {
'2019-03-03': 1,
diff --git a/spec/frontend/reports/store/utils_spec.js b/spec/frontend/reports/store/utils_spec.js
index 0d9a8dd4585..9ae456658dc 100644
--- a/spec/frontend/reports/store/utils_spec.js
+++ b/spec/frontend/reports/store/utils_spec.js
@@ -30,9 +30,7 @@ describe('Reports store utils', () => {
const data = { failed: 3, total: 10 };
const result = utils.summaryTextBuilder(name, data);
- expect(result).toBe(
- 'Test summary contained 3 failed/error test results out of 10 total tests',
- );
+ expect(result).toBe('Test summary contained 3 failed out of 10 total tests');
});
it('should render text for multiple errored results', () => {
@@ -40,9 +38,7 @@ describe('Reports store utils', () => {
const data = { errored: 7, total: 10 };
const result = utils.summaryTextBuilder(name, data);
- expect(result).toBe(
- 'Test summary contained 7 failed/error test results out of 10 total tests',
- );
+ expect(result).toBe('Test summary contained 7 errors out of 10 total tests');
});
it('should render text for multiple fixed results', () => {
@@ -59,7 +55,7 @@ describe('Reports store utils', () => {
const result = utils.summaryTextBuilder(name, data);
expect(result).toBe(
- 'Test summary contained 3 failed/error test results and 4 fixed test results out of 10 total tests',
+ 'Test summary contained 3 failed and 4 fixed test results out of 10 total tests',
);
});
@@ -69,18 +65,17 @@ describe('Reports store utils', () => {
const result = utils.summaryTextBuilder(name, data);
expect(result).toBe(
- 'Test summary contained 1 failed/error test result and 1 fixed test result out of 10 total tests',
+ 'Test summary contained 1 failed and 1 fixed test result out of 10 total tests',
);
});
it('should render text for singular failed, errored, and fixed results', () => {
- // these will be singular when the copy is updated
const name = 'Test summary';
const data = { failed: 1, errored: 1, resolved: 1, total: 10 };
const result = utils.summaryTextBuilder(name, data);
expect(result).toBe(
- 'Test summary contained 2 failed/error test results and 1 fixed test result out of 10 total tests',
+ 'Test summary contained 1 failed, 1 error and 1 fixed test result out of 10 total tests',
);
});
@@ -90,7 +85,7 @@ describe('Reports store utils', () => {
const result = utils.summaryTextBuilder(name, data);
expect(result).toBe(
- 'Test summary contained 5 failed/error test results and 4 fixed test results out of 10 total tests',
+ 'Test summary contained 2 failed, 3 errors and 4 fixed test results out of 10 total tests',
);
});
});
@@ -117,7 +112,7 @@ describe('Reports store utils', () => {
const data = { failed: 3, total: 10 };
const result = utils.reportTextBuilder(name, data);
- expect(result).toBe('Rspec found 3 failed/error test results out of 10 total tests');
+ expect(result).toBe('Rspec found 3 failed out of 10 total tests');
});
it('should render text for multiple errored results', () => {
@@ -125,7 +120,7 @@ describe('Reports store utils', () => {
const data = { errored: 7, total: 10 };
const result = utils.reportTextBuilder(name, data);
- expect(result).toBe('Rspec found 7 failed/error test results out of 10 total tests');
+ expect(result).toBe('Rspec found 7 errors out of 10 total tests');
});
it('should render text for multiple fixed results', () => {
@@ -141,9 +136,7 @@ describe('Reports store utils', () => {
const data = { failed: 3, resolved: 4, total: 10 };
const result = utils.reportTextBuilder(name, data);
- expect(result).toBe(
- 'Rspec found 3 failed/error test results and 4 fixed test results out of 10 total tests',
- );
+ expect(result).toBe('Rspec found 3 failed and 4 fixed test results out of 10 total tests');
});
it('should render text for a singular fixed, and a singular failed result', () => {
@@ -151,19 +144,16 @@ describe('Reports store utils', () => {
const data = { failed: 1, resolved: 1, total: 10 };
const result = utils.reportTextBuilder(name, data);
- expect(result).toBe(
- 'Rspec found 1 failed/error test result and 1 fixed test result out of 10 total tests',
- );
+ expect(result).toBe('Rspec found 1 failed and 1 fixed test result out of 10 total tests');
});
it('should render text for singular failed, errored, and fixed results', () => {
- // these will be singular when the copy is updated
const name = 'Rspec';
const data = { failed: 1, errored: 1, resolved: 1, total: 10 };
const result = utils.reportTextBuilder(name, data);
expect(result).toBe(
- 'Rspec found 2 failed/error test results and 1 fixed test result out of 10 total tests',
+ 'Rspec found 1 failed, 1 error and 1 fixed test result out of 10 total tests',
);
});
@@ -173,7 +163,7 @@ describe('Reports store utils', () => {
const result = utils.reportTextBuilder(name, data);
expect(result).toBe(
- 'Rspec found 5 failed/error test results and 4 fixed test results out of 10 total tests',
+ 'Rspec found 2 failed, 3 errors and 4 fixed test results out of 10 total tests',
);
});
});
diff --git a/spec/frontend/sidebar/mock_data.js b/spec/frontend/sidebar/mock_data.js
index c7e52eae9bd..3dde40260eb 100644
--- a/spec/frontend/sidebar/mock_data.js
+++ b/spec/frontend/sidebar/mock_data.js
@@ -204,7 +204,7 @@ const mockData = {
},
rootPath: '/',
fullPath: '/gitlab-org/gitlab-shell',
- id: 1,
+ iid: 1,
},
time: {
time_estimate: 3600,
diff --git a/spec/javascripts/reports/components/grouped_test_reports_app_spec.js b/spec/javascripts/reports/components/grouped_test_reports_app_spec.js
index 154aa881d2d..bafc47c952a 100644
--- a/spec/javascripts/reports/components/grouped_test_reports_app_spec.js
+++ b/spec/javascripts/reports/components/grouped_test_reports_app_spec.js
@@ -84,12 +84,10 @@ describe('Grouped Test Reports App', () => {
setTimeout(() => {
expect(vm.$el.querySelector('.gl-spinner')).toBeNull();
expect(vm.$el.querySelector('.js-code-text').textContent.trim()).toEqual(
- 'Test summary contained 2 failed/error test results out of 11 total tests',
+ 'Test summary contained 2 failed out of 11 total tests',
);
- expect(vm.$el.textContent).toContain(
- 'rspec:pg found 2 failed/error test results out of 8 total tests',
- );
+ expect(vm.$el.textContent).toContain('rspec:pg found 2 failed out of 8 total tests');
expect(vm.$el.textContent).toContain('New');
expect(vm.$el.textContent).toContain(
@@ -112,12 +110,10 @@ describe('Grouped Test Reports App', () => {
setTimeout(() => {
expect(vm.$el.querySelector('.gl-spinner')).toBeNull();
expect(vm.$el.querySelector('.js-code-text').textContent.trim()).toEqual(
- 'Test summary contained 2 failed/error test results out of 11 total tests',
+ 'Test summary contained 2 errors out of 11 total tests',
);
- expect(vm.$el.textContent).toContain(
- 'karma found 2 failed/error test results out of 3 total tests',
- );
+ expect(vm.$el.textContent).toContain('karma found 2 errors out of 3 total tests');
expect(vm.$el.textContent).toContain('New');
expect(vm.$el.textContent).toContain(
@@ -140,17 +136,15 @@ describe('Grouped Test Reports App', () => {
setTimeout(() => {
expect(vm.$el.querySelector('.gl-spinner')).toBeNull();
expect(vm.$el.querySelector('.js-code-text').textContent.trim()).toEqual(
- 'Test summary contained 2 failed/error test results and 2 fixed test results out of 11 total tests',
+ 'Test summary contained 2 failed and 2 fixed test results out of 11 total tests',
);
expect(vm.$el.textContent).toContain(
- 'rspec:pg found 1 failed/error test result and 2 fixed test results out of 8 total tests',
+ 'rspec:pg found 1 failed and 2 fixed test results out of 8 total tests',
);
expect(vm.$el.textContent).toContain('New');
- expect(vm.$el.textContent).toContain(
- ' java ant found 1 failed/error test result out of 3 total tests',
- );
+ expect(vm.$el.textContent).toContain(' java ant found 1 failed out of 3 total tests');
done();
}, 0);
});
diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb
index cfe73ead9cc..a2326728679 100644
--- a/spec/lib/gitlab/git/repository_spec.rb
+++ b/spec/lib/gitlab/git/repository_spec.rb
@@ -2151,11 +2151,11 @@ describe Gitlab::Git::Repository, :seed_helper do
'gitaly_address' => Gitlab.config.repositories.storages.default.gitaly_address,
'path' => TestEnv::SECOND_STORAGE_PATH
})
- Gitlab::Shell.new.create_repository('test_second_storage', TEST_REPO_PATH, 'group/project')
+ new_repository.create_repository
end
after do
- Gitlab::Shell.new.remove_repository('test_second_storage', TEST_REPO_PATH)
+ new_repository.remove
end
it 'mirrors the source repository' do
diff --git a/spec/lib/gitlab/import_export/fast_hash_serializer_spec.rb b/spec/lib/gitlab/import_export/fast_hash_serializer_spec.rb
index 56ec6ec0f59..15058684229 100644
--- a/spec/lib/gitlab/import_export/fast_hash_serializer_spec.rb
+++ b/spec/lib/gitlab/import_export/fast_hash_serializer_spec.rb
@@ -215,6 +215,14 @@ describe Gitlab::ImportExport::FastHashSerializer do
expect(subject['boards'].first['lists']).not_to be_empty
end
+ context 'relation ordering' do
+ it 'orders exported pipelines by primary key' do
+ expected_order = project.ci_pipelines.reorder(:id).ids
+
+ expect(subject['ci_pipelines'].pluck('id')).to eq(expected_order)
+ end
+ end
+
def setup_project
release = create(:release)
group = create(:group)
@@ -246,6 +254,8 @@ describe Gitlab::ImportExport::FastHashSerializer do
ci_build.pipeline.update(project: project)
create(:commit_status, project: project, pipeline: ci_build.pipeline)
+ create_list(:ci_pipeline, 5, :success, project: project)
+
create(:milestone, project: project)
create(:discussion_note, noteable: issue, project: project)
create(:note, noteable: merge_request, project: project)
diff --git a/spec/models/concerns/has_ref_spec.rb b/spec/models/concerns/ci/has_ref_spec.rb
index 66b25c77430..b98f915018b 100644
--- a/spec/models/concerns/has_ref_spec.rb
+++ b/spec/models/concerns/ci/has_ref_spec.rb
@@ -2,7 +2,7 @@
require 'spec_helper'
-describe HasRef do
+describe Ci::HasRef do
describe '#branch?' do
let(:build) { create(:ci_build) }
diff --git a/spec/requests/api/pipelines_spec.rb b/spec/requests/api/pipelines_spec.rb
index b38b92af139..6b824690e6c 100644
--- a/spec/requests/api/pipelines_spec.rb
+++ b/spec/requests/api/pipelines_spec.rb
@@ -254,7 +254,9 @@ describe API::Pipelines do
context 'when order_by and sort are specified' do
context 'when order_by user_id' do
before do
- create_list(:ci_pipeline, 3, project: project, user: create(:user))
+ create_list(:user, 3).each do |some_user|
+ create(:ci_pipeline, project: project, user: some_user)
+ end
end
context 'when sort parameter is valid' do
diff --git a/spec/rubocop/cop/migration/with_lock_retries_with_change_spec.rb b/spec/rubocop/cop/migration/with_lock_retries_with_change_spec.rb
new file mode 100644
index 00000000000..75a1f939a9f
--- /dev/null
+++ b/spec/rubocop/cop/migration/with_lock_retries_with_change_spec.rb
@@ -0,0 +1,43 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+require 'rubocop'
+require 'rubocop/rspec/support'
+
+require_relative '../../../../rubocop/cop/migration/with_lock_retries_with_change'
+
+describe RuboCop::Cop::Migration::WithLockRetriesWithChange do
+ include CopHelper
+
+ subject(:cop) { described_class.new }
+
+ context 'in migration' do
+ before do
+ allow(cop).to receive(:in_migration?).and_return(true)
+ end
+
+ it 'registers an offense when `with_lock_retries` is used inside a `change` method' do
+ inspect_source('def change; with_lock_retries {}; end')
+
+ aggregate_failures do
+ expect(cop.offenses.size).to eq(1)
+ expect(cop.offenses.map(&:line)).to eq([1])
+ end
+ end
+
+ it 'registers no offense when `with_lock_retries` is used inside an `up` method' do
+ inspect_source('def up; with_lock_retries {}; end')
+
+ expect(cop.offenses.size).to eq(0)
+ end
+ end
+
+ context 'outside of migration' do
+ it 'registers no offense' do
+ inspect_source('def change; with_lock_retries {}; end')
+
+ expect(cop.offenses.size).to eq(0)
+ end
+ end
+end
diff --git a/spec/serializers/group_variable_entity_spec.rb b/spec/serializers/group_variable_entity_spec.rb
index 22c98b418dd..e6b51e0d626 100644
--- a/spec/serializers/group_variable_entity_spec.rb
+++ b/spec/serializers/group_variable_entity_spec.rb
@@ -10,7 +10,7 @@ describe GroupVariableEntity do
subject { entity.as_json }
it 'contains required fields' do
- expect(subject).to include(:id, :key, :value, :protected)
+ expect(subject).to include(:id, :key, :value, :protected, :variable_type)
end
end
end
diff --git a/spec/support/matchers/exceed_query_limit.rb b/spec/support/matchers/exceed_query_limit.rb
index 40cf85eb8e5..f38ae44a577 100644
--- a/spec/support/matchers/exceed_query_limit.rb
+++ b/spec/support/matchers/exceed_query_limit.rb
@@ -1,6 +1,8 @@
# frozen_string_literal: true
module ExceedQueryLimitHelpers
+ MARGINALIA_ANNOTATION_REGEX = %r{\s*\/\*.*\*\/}.freeze
+
def with_threshold(threshold)
@threshold = threshold
self
@@ -41,8 +43,8 @@ module ExceedQueryLimitHelpers
def log_message
if expected.is_a?(ActiveRecord::QueryRecorder)
- counts = count_queries(expected.log)
- extra_queries = @recorder.log.reject { |query| counts[query] -= 1 unless counts[query].zero? }
+ counts = count_queries(strip_marginalia_annotations(expected.log))
+ extra_queries = strip_marginalia_annotations(@recorder.log).reject { |query| counts[query] -= 1 unless counts[query].zero? }
extra_queries_display = count_queries(extra_queries).map { |query, count| "[#{count}] #{query}" }
(['Extra queries:'] + extra_queries_display).join("\n\n")
@@ -65,6 +67,10 @@ module ExceedQueryLimitHelpers
counts = "#{expected_count}#{threshold_message}"
"Expected a maximum of #{counts} queries, got #{actual_count}:\n\n#{log_message}"
end
+
+ def strip_marginalia_annotations(logs)
+ logs.map { |log| log.sub(MARGINALIA_ANNOTATION_REGEX, '') }
+ end
end
RSpec::Matchers.define :exceed_all_query_limit do |expected|
diff --git a/spec/support_specs/matchers/exceed_query_limit_helpers_spec.rb b/spec/support_specs/matchers/exceed_query_limit_helpers_spec.rb
new file mode 100644
index 00000000000..3b15d804d7c
--- /dev/null
+++ b/spec/support_specs/matchers/exceed_query_limit_helpers_spec.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe ExceedQueryLimitHelpers do
+ class TestQueries < ActiveRecord::Base
+ self.table_name = 'schema_migrations'
+ end
+
+ class TestMatcher
+ include ExceedQueryLimitHelpers
+
+ def expected
+ ActiveRecord::QueryRecorder.new do
+ 2.times { TestQueries.count }
+ end
+ end
+ end
+
+ it 'does not contain marginalia annotations' do
+ test_matcher = TestMatcher.new
+ test_matcher.verify_count do
+ 2.times { TestQueries.count }
+ TestQueries.first
+ end
+
+ aggregate_failures do
+ expect(test_matcher.log_message)
+ .to match(%r{ORDER BY.*#{TestQueries.table_name}.*LIMIT 1})
+ expect(test_matcher.log_message)
+ .not_to match(%r{\/\*.*correlation_id.*\*\/})
+ end
+ end
+end