diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-15 00:06:30 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-10-15 00:06:30 +0300 |
commit | 565fa11a26c6824b1c6072d2dc5459979345ee57 (patch) | |
tree | 2668b631d925341e121c06b7b77cfe12954a015a /spec | |
parent | 8c30d396c5a789080345303330069981aa06e4af (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
8 files changed, 214 insertions, 29 deletions
diff --git a/spec/fixtures/api/schemas/public_api/v4/release.json b/spec/fixtures/api/schemas/public_api/v4/release.json index 3ca6167d0c6..2bdc8bc711c 100644 --- a/spec/fixtures/api/schemas/public_api/v4/release.json +++ b/spec/fixtures/api/schemas/public_api/v4/release.json @@ -36,6 +36,13 @@ } }, "additionalProperties": false + }, + "_links": { + "required": ["merge_requests_url", "issues_url"], + "properties": { + "merge_requests_url": { "type": "string" }, + "issues_url": { "type": "string" } + } } }, "additionalProperties": false diff --git a/spec/fixtures/api/schemas/public_api/v4/release/release_for_guest.json b/spec/fixtures/api/schemas/public_api/v4/release/release_for_guest.json index 57814b8bf73..bce74892059 100644 --- a/spec/fixtures/api/schemas/public_api/v4/release/release_for_guest.json +++ b/spec/fixtures/api/schemas/public_api/v4/release/release_for_guest.json @@ -24,6 +24,13 @@ "links": { "$ref": "../../../release/links.json" } }, "additionalProperties": false + }, + "_links": { + "required": ["merge_requests_url", "issues_url"], + "properties": { + "merge_requests_url": { "type": "string" }, + "issues_url": { "type": "string" } + } } }, "additionalProperties": false diff --git a/spec/frontend/create_cluster/eks_cluster/components/eks_cluster_configuration_form_spec.js b/spec/frontend/create_cluster/eks_cluster/components/eks_cluster_configuration_form_spec.js index df214442369..321dc5bd6ba 100644 --- a/spec/frontend/create_cluster/eks_cluster/components/eks_cluster_configuration_form_spec.js +++ b/spec/frontend/create_cluster/eks_cluster/components/eks_cluster_configuration_form_spec.js @@ -1,9 +1,10 @@ import { shallowMount, createLocalVue } from '@vue/test-utils'; import Vuex from 'vuex'; import Vue from 'vue'; +import { GlFormCheckbox } from '@gitlab/ui'; + import EksClusterConfigurationForm from '~/create_cluster/eks_cluster/components/eks_cluster_configuration_form.vue'; import RegionDropdown from '~/create_cluster/eks_cluster/components/region_dropdown.vue'; - import eksClusterFormState from '~/create_cluster/eks_cluster/store/state'; import clusterDropdownStoreState from '~/create_cluster/eks_cluster/store/cluster_dropdown/state'; @@ -19,21 +20,28 @@ describe('EksClusterConfigurationForm', () => { let vpcsState; let subnetsState; let keyPairsState; + let securityGroupsState; let vpcsActions; let rolesActions; let regionsActions; let subnetsActions; let keyPairsActions; + let securityGroupsActions; let vm; beforeEach(() => { state = eksClusterFormState(); actions = { + setClusterName: jest.fn(), + setEnvironmentScope: jest.fn(), + setKubernetesVersion: jest.fn(), setRegion: jest.fn(), setVpc: jest.fn(), setSubnet: jest.fn(), setRole: jest.fn(), setKeyPair: jest.fn(), + setSecurityGroup: jest.fn(), + setGitlabManagedCluster: jest.fn(), }; regionsActions = { fetchItems: jest.fn(), @@ -50,6 +58,9 @@ describe('EksClusterConfigurationForm', () => { rolesActions = { fetchItems: jest.fn(), }; + securityGroupsActions = { + fetchItems: jest.fn(), + }; rolesState = { ...clusterDropdownStoreState(), }; @@ -65,6 +76,9 @@ describe('EksClusterConfigurationForm', () => { keyPairsState = { ...clusterDropdownStoreState(), }; + securityGroupsState = { + ...clusterDropdownStoreState(), + }; store = new Vuex.Store({ state, actions, @@ -94,6 +108,11 @@ describe('EksClusterConfigurationForm', () => { state: keyPairsState, actions: keyPairsActions, }, + securityGroups: { + namespaced: true, + state: securityGroupsState, + actions: securityGroupsActions, + }, }, }); }); @@ -102,6 +121,9 @@ describe('EksClusterConfigurationForm', () => { vm = shallowMount(EksClusterConfigurationForm, { localVue, store, + propsData: { + gitlabManagedClusterHelpPath: '', + }, }); }); @@ -109,11 +131,16 @@ describe('EksClusterConfigurationForm', () => { vm.destroy(); }); + const findClusterNameInput = () => vm.find('[id=eks-cluster-name]'); + const findEnvironmentScopeInput = () => vm.find('[id=eks-environment-scope]'); + const findKubernetesVersionDropdown = () => vm.find('[field-id="eks-kubernetes-version"]'); const findRegionDropdown = () => vm.find(RegionDropdown); const findKeyPairDropdown = () => vm.find('[field-id="eks-key-pair"]'); const findVpcDropdown = () => vm.find('[field-id="eks-vpc"]'); const findSubnetDropdown = () => vm.find('[field-id="eks-subnet"]'); const findRoleDropdown = () => vm.find('[field-id="eks-role"]'); + const findSecurityGroupDropdown = () => vm.find('[field-id="eks-security-group"]'); + const findGitlabManagedClusterCheckbox = () => vm.find(GlFormCheckbox); describe('when mounted', () => { it('fetches available regions', () => { @@ -249,6 +276,36 @@ describe('EksClusterConfigurationForm', () => { expect(findSubnetDropdown().props('hasErrors')).toEqual(true); }); + it('disables SecurityGroupDropdown when no vpc is selected', () => { + expect(findSecurityGroupDropdown().props('disabled')).toBe(true); + }); + + it('enables SecurityGroupDropdown when a vpc is selected', () => { + state.selectedVpc = { name: 'vpc-1 ' }; + + return Vue.nextTick().then(() => { + expect(findSecurityGroupDropdown().props('disabled')).toBe(false); + }); + }); + + it('sets isLoadingSecurityGroups to SecurityGroupDropdown loading property', () => { + securityGroupsState.isLoadingItems = true; + + return Vue.nextTick().then(() => { + expect(findSecurityGroupDropdown().props('loading')).toBe(securityGroupsState.isLoadingItems); + }); + }); + + it('sets securityGroups to SecurityGroupDropdown items property', () => { + expect(findSecurityGroupDropdown().props('items')).toBe(securityGroupsState.items); + }); + + it('sets SecurityGroupDropdown hasErrors to true when loading security groups fails', () => { + securityGroupsState.loadingItemsError = new Error(); + + expect(findSecurityGroupDropdown().props('hasErrors')).toEqual(true); + }); + describe('when region is selected', () => { const region = { name: 'us-west-2' }; @@ -273,6 +330,54 @@ describe('EksClusterConfigurationForm', () => { }); }); + it('dispatches setClusterName when cluster name input changes', () => { + const clusterName = 'name'; + + findClusterNameInput().vm.$emit('input', clusterName); + + expect(actions.setClusterName).toHaveBeenCalledWith( + expect.anything(), + { clusterName }, + undefined, + ); + }); + + it('dispatches setEnvironmentScope when environment scope input changes', () => { + const environmentScope = 'production'; + + findEnvironmentScopeInput().vm.$emit('input', environmentScope); + + expect(actions.setEnvironmentScope).toHaveBeenCalledWith( + expect.anything(), + { environmentScope }, + undefined, + ); + }); + + it('dispatches setKubernetesVersion when kubernetes version dropdown changes', () => { + const kubernetesVersion = { name: '1.11' }; + + findKubernetesVersionDropdown().vm.$emit('input', kubernetesVersion); + + expect(actions.setKubernetesVersion).toHaveBeenCalledWith( + expect.anything(), + { kubernetesVersion }, + undefined, + ); + }); + + it('dispatches setGitlabManagedCluster when gitlab managed cluster input changes', () => { + const gitlabManagedCluster = false; + + findGitlabManagedClusterCheckbox().vm.$emit('input', gitlabManagedCluster); + + expect(actions.setGitlabManagedCluster).toHaveBeenCalledWith( + expect.anything(), + { gitlabManagedCluster }, + undefined, + ); + }); + describe('when vpc is selected', () => { const vpc = { name: 'vpc-1' }; @@ -287,6 +392,14 @@ describe('EksClusterConfigurationForm', () => { it('dispatches fetchSubnets action', () => { expect(subnetsActions.fetchItems).toHaveBeenCalledWith(expect.anything(), { vpc }, undefined); }); + + it('dispatches fetchSecurityGroups action', () => { + expect(securityGroupsActions.fetchItems).toHaveBeenCalledWith( + expect.anything(), + { vpc }, + undefined, + ); + }); }); describe('when a subnet is selected', () => { @@ -324,4 +437,20 @@ describe('EksClusterConfigurationForm', () => { expect(actions.setKeyPair).toHaveBeenCalledWith(expect.anything(), { keyPair }, undefined); }); }); + + describe('when security group is selected', () => { + const securityGroup = { name: 'default group' }; + + beforeEach(() => { + findSecurityGroupDropdown().vm.$emit('input', securityGroup); + }); + + it('dispatches setSecurityGroup action', () => { + expect(actions.setSecurityGroup).toHaveBeenCalledWith( + expect.anything(), + { securityGroup }, + undefined, + ); + }); + }); }); diff --git a/spec/frontend/create_cluster/eks_cluster/store/actions_spec.js b/spec/frontend/create_cluster/eks_cluster/store/actions_spec.js index aa7ced81e0d..1ed7f806804 100644 --- a/spec/frontend/create_cluster/eks_cluster/store/actions_spec.js +++ b/spec/frontend/create_cluster/eks_cluster/store/actions_spec.js @@ -3,35 +3,55 @@ import testAction from 'helpers/vuex_action_helper'; import createState from '~/create_cluster/eks_cluster/store/state'; import * as actions from '~/create_cluster/eks_cluster/store/actions'; import { + SET_CLUSTER_NAME, + SET_ENVIRONMENT_SCOPE, + SET_KUBERNETES_VERSION, SET_REGION, SET_VPC, SET_KEY_PAIR, SET_SUBNET, SET_ROLE, + SET_SECURITY_GROUP, + SET_GITLAB_MANAGED_CLUSTER, } from '~/create_cluster/eks_cluster/store/mutation_types'; describe('EKS Cluster Store Actions', () => { + let clusterName; + let environmentScope; + let kubernetesVersion; let region; let vpc; let subnet; let role; let keyPair; + let securityGroup; + let gitlabManagedCluster; beforeEach(() => { + clusterName = 'my cluster'; + environmentScope = 'production'; + kubernetesVersion = '11.1'; region = { name: 'regions-1' }; vpc = { name: 'vpc-1' }; subnet = { name: 'subnet-1' }; role = { name: 'role-1' }; keyPair = { name: 'key-pair-1' }; + securityGroup = { name: 'default group' }; + gitlabManagedCluster = true; }); it.each` - action | mutation | payload | payloadDescription - ${'setRole'} | ${SET_ROLE} | ${{ role }} | ${'role'} - ${'setRegion'} | ${SET_REGION} | ${{ region }} | ${'region'} - ${'setKeyPair'} | ${SET_KEY_PAIR} | ${{ keyPair }} | ${'key pair'} - ${'setVpc'} | ${SET_VPC} | ${{ vpc }} | ${'vpc'} - ${'setSubnet'} | ${SET_SUBNET} | ${{ subnet }} | ${'subnet'} + action | mutation | payload | payloadDescription + ${'setClusterName'} | ${SET_CLUSTER_NAME} | ${{ clusterName }} | ${'cluster name'} + ${'setEnvironmentScope'} | ${SET_ENVIRONMENT_SCOPE} | ${{ environmentScope }} | ${'environment scope'} + ${'setKubernetesVersion'} | ${SET_KUBERNETES_VERSION} | ${{ kubernetesVersion }} | ${'kubernetes version'} + ${'setRole'} | ${SET_ROLE} | ${{ role }} | ${'role'} + ${'setRegion'} | ${SET_REGION} | ${{ region }} | ${'region'} + ${'setKeyPair'} | ${SET_KEY_PAIR} | ${{ keyPair }} | ${'key pair'} + ${'setVpc'} | ${SET_VPC} | ${{ vpc }} | ${'vpc'} + ${'setSubnet'} | ${SET_SUBNET} | ${{ subnet }} | ${'subnet'} + ${'setSecurityGroup'} | ${SET_SECURITY_GROUP} | ${{ securityGroup }} | ${'securityGroup'} + ${'setGitlabManagedCluster'} | ${SET_GITLAB_MANAGED_CLUSTER} | ${gitlabManagedCluster} | ${'gitlab managed cluster'} `(`$action commits $mutation with $payloadDescription payload`, data => { const { action, mutation, payload } = data; diff --git a/spec/frontend/create_cluster/eks_cluster/store/mutations_spec.js b/spec/frontend/create_cluster/eks_cluster/store/mutations_spec.js index 966406386ac..81b65180fb5 100644 --- a/spec/frontend/create_cluster/eks_cluster/store/mutations_spec.js +++ b/spec/frontend/create_cluster/eks_cluster/store/mutations_spec.js @@ -1,38 +1,58 @@ import { + SET_CLUSTER_NAME, + SET_ENVIRONMENT_SCOPE, + SET_KUBERNETES_VERSION, SET_REGION, SET_VPC, SET_KEY_PAIR, SET_SUBNET, SET_ROLE, + SET_SECURITY_GROUP, + SET_GITLAB_MANAGED_CLUSTER, } from '~/create_cluster/eks_cluster/store/mutation_types'; import createState from '~/create_cluster/eks_cluster/store/state'; import mutations from '~/create_cluster/eks_cluster/store/mutations'; describe('Create EKS cluster store mutations', () => { + let clusterName; + let environmentScope; + let kubernetesVersion; let state; let region; let vpc; let subnet; let role; let keyPair; + let securityGroup; + let gitlabManagedCluster; beforeEach(() => { + clusterName = 'my cluster'; + environmentScope = 'production'; + kubernetesVersion = '11.1'; region = { name: 'regions-1' }; vpc = { name: 'vpc-1' }; subnet = { name: 'subnet-1' }; role = { name: 'role-1' }; keyPair = { name: 'key pair' }; + securityGroup = { name: 'default group' }; + gitlabManagedCluster = false; state = createState(); }); it.each` - mutation | mutatedProperty | payload | expectedValue | expectedValueDescription - ${SET_ROLE} | ${'selectedRole'} | ${{ role }} | ${role} | ${'selected role payload'} - ${SET_REGION} | ${'selectedRegion'} | ${{ region }} | ${region} | ${'selected region payload'} - ${SET_KEY_PAIR} | ${'selectedKeyPair'} | ${{ keyPair }} | ${keyPair} | ${'selected key pair payload'} - ${SET_VPC} | ${'selectedVpc'} | ${{ vpc }} | ${vpc} | ${'selected vpc payload'} - ${SET_SUBNET} | ${'selectedSubnet'} | ${{ subnet }} | ${subnet} | ${'selected sybnet payload'} + mutation | mutatedProperty | payload | expectedValue | expectedValueDescription + ${SET_CLUSTER_NAME} | ${'clusterName'} | ${{ clusterName }} | ${clusterName} | ${'cluster name'} + ${SET_ENVIRONMENT_SCOPE} | ${'environmentScope'} | ${{ environmentScope }} | ${environmentScope} | ${'environment scope'} + ${SET_KUBERNETES_VERSION} | ${'kubernetesVersion'} | ${{ kubernetesVersion }} | ${kubernetesVersion} | ${'kubernetes version'} + ${SET_ROLE} | ${'selectedRole'} | ${{ role }} | ${role} | ${'selected role payload'} + ${SET_REGION} | ${'selectedRegion'} | ${{ region }} | ${region} | ${'selected region payload'} + ${SET_KEY_PAIR} | ${'selectedKeyPair'} | ${{ keyPair }} | ${keyPair} | ${'selected key pair payload'} + ${SET_VPC} | ${'selectedVpc'} | ${{ vpc }} | ${vpc} | ${'selected vpc payload'} + ${SET_SUBNET} | ${'selectedSubnet'} | ${{ subnet }} | ${subnet} | ${'selected sybnet payload'} + ${SET_SECURITY_GROUP} | ${'selectedSecurityGroup'} | ${{ securityGroup }} | ${securityGroup} | ${'selected security group payload'} + ${SET_GITLAB_MANAGED_CLUSTER} | ${'gitlabManagedCluster'} | ${{ gitlabManagedCluster }} | ${gitlabManagedCluster} | ${'gitlab managed cluster'} `(`$mutation sets $mutatedProperty to $expectedValueDescription`, data => { const { mutation, mutatedProperty, payload, expectedValue } = data; diff --git a/spec/helpers/releases_helper_spec.rb b/spec/helpers/releases_helper_spec.rb index ff820b3cc95..3b4973677ef 100644 --- a/spec/helpers/releases_helper_spec.rb +++ b/spec/helpers/releases_helper_spec.rb @@ -22,23 +22,9 @@ describe ReleasesHelper do helper.instance_variable_set(:@project, project) end - describe '#url_for_merge_requests' do - it 'returns the the correct link with the correct parameters' do - path = "#{project.group.path}/#{project.path}/merge_requests?scope=all&state=opened" - expect(helper.url_for_merge_requests).to include(path) - end - end - - describe '#url_for_issues' do - it 'returns the the correct link with the correct parameters' do - path = "#{project.group.path}/#{project.path}/issues?scope=all&state=opened" - expect(helper.url_for_issues).to include(path) - end - end - describe '#data_for_releases_page' do it 'has the needed data to display release blocks' do - keys = %i(project_id illustration_path documentation_path merge_requests_url issues_url) + keys = %i(project_id illustration_path documentation_path) expect(helper.data_for_releases_page.keys).to eq(keys) end end diff --git a/spec/lib/gitlab/path_regex_spec.rb b/spec/lib/gitlab/path_regex_spec.rb index 0829a2b4334..3cbcae4cdeb 100644 --- a/spec/lib/gitlab/path_regex_spec.rb +++ b/spec/lib/gitlab/path_regex_spec.rb @@ -108,7 +108,7 @@ describe Gitlab::PathRegex do git = Gitlab.config.git.bin_path tracked = `cd #{Rails.root} && #{git} ls-files public` .split("\n") - .map { |entry| entry.gsub('public/', '') } + .map { |entry| entry.start_with?('public/-/') ? '-' : entry.gsub('public/', '') } .uniq tracked + %w(assets uploads) end diff --git a/spec/requests/api/releases_spec.rb b/spec/requests/api/releases_spec.rb index 0bb238d08c0..99d0ceee76b 100644 --- a/spec/requests/api/releases_spec.rb +++ b/spec/requests/api/releases_spec.rb @@ -63,6 +63,22 @@ describe API::Releases do expect(json_response.second['commit_path']).to eq("/#{release_1.project.full_path}/commit/#{release_1.commit.id}") expect(json_response.second['tag_path']).to eq("/#{release_1.project.full_path}/-/tags/#{release_1.tag}") end + + it 'returns the merge requests and issues links, with correct query' do + get api("/projects/#{project.id}/releases", maintainer) + + links = json_response.first['_links'] + release = json_response.first['tag_name'] + expected_query = "release_tag=#{release}&scope=all&state=opened" + path_base = "/#{project.namespace.path}/#{project.path}" + mr_uri = URI.parse(links['merge_requests_url']) + issue_uri = URI.parse(links['issues_url']) + + expect(mr_uri.path).to eq("#{path_base}/merge_requests") + expect(issue_uri.path).to eq("#{path_base}/issues") + expect(mr_uri.query).to eq(expected_query) + expect(issue_uri.query).to eq(expected_query) + end end it 'returns an upcoming_release status for a future release' do |