diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-14 03:08:27 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-14 03:08:27 +0300 |
commit | b7d58ff8b17623f64ac7835a590e79d916e758ac (patch) | |
tree | 4f75a8f9e0e30cf8c7e944ea2c4461be396c0d5f /spec | |
parent | 0e2fc1701bd0c87cc458cbbb34c618b0e0dc5a14 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/autocomplete_controller_spec.rb | 21 | ||||
-rw-r--r-- | spec/features/admin/admin_groups_spec.rb | 8 | ||||
-rw-r--r-- | spec/fixtures/api/schemas/entities/merge_request_noteable.json | 10 | ||||
-rw-r--r-- | spec/frontend/monitoring/panel_type_spec.js | 76 | ||||
-rw-r--r-- | spec/frontend/sidebar/components/assignees/assignee_avatar_link_spec.js | 6 | ||||
-rw-r--r-- | spec/frontend/sidebar/user_data_mock.js | 6 | ||||
-rw-r--r-- | spec/serializers/issue_entity_spec.rb | 32 | ||||
-rw-r--r-- | spec/serializers/merge_request_serializer_spec.rb | 19 |
8 files changed, 135 insertions, 43 deletions
diff --git a/spec/controllers/autocomplete_controller_spec.rb b/spec/controllers/autocomplete_controller_spec.rb index 56c27b4e5eb..4227a4453a3 100644 --- a/spec/controllers/autocomplete_controller_spec.rb +++ b/spec/controllers/autocomplete_controller_spec.rb @@ -391,13 +391,24 @@ describe AutocompleteController do end context 'user with an accessible merge request but no scope' do - it 'returns an error' do - sign_in(user) + where( + params: [ + {}, + { group_id: ' ' }, + { project_id: ' ' }, + { group_id: ' ', project_id: ' ' } + ] + ) + + with_them do + it 'returns an error' do + sign_in(user) - get :merge_request_target_branches + get :merge_request_target_branches, params: params - expect(response).to have_gitlab_http_status(400) - expect(json_response).to eq({ 'error' => 'At least one of group_id or project_id must be specified' }) + expect(response).to have_gitlab_http_status(400) + expect(json_response).to eq({ 'error' => 'At least one of group_id or project_id must be specified' }) + end end end diff --git a/spec/features/admin/admin_groups_spec.rb b/spec/features/admin/admin_groups_spec.rb index 34356a2ee90..257e5cb8bf0 100644 --- a/spec/features/admin/admin_groups_spec.rb +++ b/spec/features/admin/admin_groups_spec.rb @@ -94,6 +94,14 @@ describe 'Admin Groups' do expect(page).to have_content("Group: #{group.name}") expect(page).to have_content("ID: #{group.id}") end + + it 'has a link to the group' do + group = create(:group, :private) + + visit admin_group_path(group) + + expect(page).to have_link(group.name, href: group_path(group)) + end end describe 'group edit' do diff --git a/spec/fixtures/api/schemas/entities/merge_request_noteable.json b/spec/fixtures/api/schemas/entities/merge_request_noteable.json index d37f5b864d7..c0eb320e67f 100644 --- a/spec/fixtures/api/schemas/entities/merge_request_noteable.json +++ b/spec/fixtures/api/schemas/entities/merge_request_noteable.json @@ -1,6 +1,9 @@ { "type": "object", - "properties" : { + "required": ["id", "iid", "title", "description", "merge_params", "state", "source_branch", "target_branch", + "diff_head_sha", "create_note_path", "preview_note_path", "can_receive_suggestion", "create_issue_to_resolve_discussions_path", + "new_blob_path", "current_user", "is_project_archived"], + "properties": { "id": { "type": "integer" }, "iid": { "type": "integer" }, "title": { "type": "string" }, @@ -26,7 +29,10 @@ "can_update": { "type": "boolean" } }, "additionalProperties": false - } + }, + "is_project_archived": { "type": "boolean" }, + "locked_discussion_docs_path": { "type": "string" }, + "archived_project_docs_path": { "type": "string" } }, "additionalProperties": false } diff --git a/spec/frontend/monitoring/panel_type_spec.js b/spec/frontend/monitoring/panel_type_spec.js index 7adecc56d18..c869d77673e 100644 --- a/spec/frontend/monitoring/panel_type_spec.js +++ b/spec/frontend/monitoring/panel_type_spec.js @@ -20,6 +20,16 @@ describe('Panel Type component', () => { const dashboardWidth = 100; const exampleText = 'example_text'; + const createWrapper = props => + shallowMount(PanelType, { + propsData: { + ...props, + }, + store, + sync: false, + attachToDocument: true, + }); + beforeEach(() => { setTestTimeout(1000); axiosMock = new AxiosMockAdapter(axios); @@ -36,14 +46,9 @@ describe('Panel Type component', () => { graphDataNoResult.metrics[0].result = []; beforeEach(() => { - panelType = shallowMount(PanelType, { - propsData: { - clipboardText: 'dashboard_link', - dashboardWidth, - graphData: graphDataNoResult, - }, - sync: false, - attachToDocument: true, + panelType = createWrapper({ + dashboardWidth, + graphData: graphDataNoResult, }); }); @@ -68,41 +73,30 @@ describe('Panel Type component', () => { }); }); - describe('when Graph data is available', () => { - const propsData = { - clipboardText: exampleText, - dashboardWidth, - graphData: graphDataPrometheusQueryRange, - }; - - beforeEach(done => { + describe('when graph data is available', () => { + beforeEach(() => { store = createStore(); - panelType = shallowMount(PanelType, { - propsData, - store, - sync: false, - attachToDocument: true, + panelType = createWrapper({ + dashboardWidth, + graphData: graphDataPrometheusQueryRange, }); - panelType.vm.$nextTick(done); }); afterEach(() => { panelType.destroy(); }); + it('sets no clipboard copy link on dropdown by default', () => { + const link = () => panelType.find('.js-chart-link'); + expect(link().exists()).toBe(false); + }); + describe('Time Series Chart panel type', () => { it('is rendered', () => { expect(panelType.find(TimeSeriesChart).isVueInstance()).toBe(true); expect(panelType.find(TimeSeriesChart).exists()).toBe(true); }); - it('sets clipboard text on the dropdown', () => { - const link = () => panelType.find('.js-chart-link'); - const clipboardText = () => link().element.dataset.clipboardText; - - expect(clipboardText()).toBe(exampleText); - }); - it('includes a default group id', () => { expect(panelType.vm.groupId).toBe('panel-type-chart'); }); @@ -123,6 +117,30 @@ describe('Panel Type component', () => { }); }); + describe('when cliboard data is available', () => { + const clipboardText = 'A value to copy.'; + + beforeEach(() => { + store = createStore(); + panelType = createWrapper({ + clipboardText, + dashboardWidth, + graphData: graphDataPrometheusQueryRange, + }); + }); + + afterEach(() => { + panelType.destroy(); + }); + + it('sets clipboard text on the dropdown', () => { + const link = () => panelType.find('.js-chart-link'); + + expect(link().exists()).toBe(true); + expect(link().element.dataset.clipboardText).toBe(clipboardText); + }); + }); + describe('when downloading metrics data as CSV', () => { beforeEach(done => { graphDataPrometheusQueryRange.y_label = 'metric'; diff --git a/spec/frontend/sidebar/components/assignees/assignee_avatar_link_spec.js b/spec/frontend/sidebar/components/assignees/assignee_avatar_link_spec.js index d800649bc1d..9b2e2e38366 100644 --- a/spec/frontend/sidebar/components/assignees/assignee_avatar_link_spec.js +++ b/spec/frontend/sidebar/components/assignees/assignee_avatar_link_spec.js @@ -1,12 +1,11 @@ import { shallowMount } from '@vue/test-utils'; import { TEST_HOST } from 'helpers/test_constants'; -import { joinPaths } from '~/lib/utils/url_utility'; import AssigneeAvatarLink from '~/sidebar/components/assignees/assignee_avatar_link.vue'; import AssigneeAvatar from '~/sidebar/components/assignees/assignee_avatar.vue'; import userDataMock from '../../user_data_mock'; const TOOLTIP_PLACEMENT = 'bottom'; -const { name: USER_NAME, username: USER_USERNAME } = userDataMock(); +const { name: USER_NAME } = userDataMock(); const TEST_ISSUABLE_TYPE = 'merge_request'; describe('AssigneeAvatarLink component', () => { @@ -38,9 +37,8 @@ describe('AssigneeAvatarLink component', () => { it('has the root url present in the assigneeUrl method', () => { createComponent(); - const assigneeUrl = joinPaths(TEST_HOST, USER_USERNAME); - expect(wrapper.attributes().href).toEqual(assigneeUrl); + expect(wrapper.attributes().href).toEqual(userDataMock().web_url); }); it('renders assignee avatar', () => { diff --git a/spec/frontend/sidebar/user_data_mock.js b/spec/frontend/sidebar/user_data_mock.js index 8ad70bb3499..df90a65f6f9 100644 --- a/spec/frontend/sidebar/user_data_mock.js +++ b/spec/frontend/sidebar/user_data_mock.js @@ -1,9 +1,11 @@ +import { TEST_HOST } from 'helpers/test_constants'; + export default () => ({ - avatar_url: 'mock_path', + avatar_url: `${TEST_HOST}/avatar/root.png`, id: 1, name: 'Root', state: 'active', username: 'root', - web_url: '', + web_url: `${TEST_HOST}/root`, can_merge: true, }); diff --git a/spec/serializers/issue_entity_spec.rb b/spec/serializers/issue_entity_spec.rb index 224ed0b402f..a1868b2631b 100644 --- a/spec/serializers/issue_entity_spec.rb +++ b/spec/serializers/issue_entity_spec.rb @@ -92,4 +92,36 @@ describe IssueEntity do end end end + + context 'when issuable in active or archived project' do + before do + project.add_developer(user) + end + + context 'when project is active' do + it 'returns archived false' do + expect(subject[:is_project_archived]).to eq(false) + end + + it 'returns nil for archived project doc' do + response = described_class.new(resource, request: request).as_json + + expect(response[:archived_project_docs_path]).to be nil + end + end + + context 'when project is archived' do + before do + project.update(archived: true) + end + + it 'returns archived true' do + expect(subject[:is_project_archived]).to eq(true) + end + + it 'returns archived project doc' do + expect(subject[:archived_project_docs_path]).to eq('/help/user/project/settings/index.md#archiving-a-project') + end + end + end end diff --git a/spec/serializers/merge_request_serializer_spec.rb b/spec/serializers/merge_request_serializer_spec.rb index a99f11168c0..9297df31842 100644 --- a/spec/serializers/merge_request_serializer_spec.rb +++ b/spec/serializers/merge_request_serializer_spec.rb @@ -48,7 +48,24 @@ describe MergeRequestSerializer do let(:serializer) { 'noteable' } it 'matches noteable merge request json schema' do - expect(json_entity).to match_schema('entities/merge_request_noteable', strict: true) + expect(json_entity).to match_schema('entities/merge_request_noteable') + end + + context 'when merge_request is locked' do + let(:resource) { create(:merge_request, :locked, description: "Description") } + + it 'matches noteable merge request json schema' do + expect(json_entity).to match_schema('entities/merge_request_noteable') + end + end + + context 'when project is archived' do + let(:project) { create(:project, :archived, :repository) } + let(:resource) { create(:merge_request, source_project: project, target_project: project, description: "Description") } + + it 'matches noteable merge request json schema' do + expect(json_entity).to match_schema('entities/merge_request_noteable') + end end end |