From 07365e518330289149dd2135424c49fad19f401d Mon Sep 17 00:00:00 2001 From: Keith Pope Date: Fri, 5 Aug 2016 10:29:09 +0100 Subject: Add config option to project to allow custom .gitlab-ci.yml location --- spec/models/ci/pipeline_spec.rb | 30 ++++++++++++++++++++++++++++++ spec/models/project_spec.rb | 1 + spec/requests/api/projects_spec.rb | 4 +++- 3 files changed, 34 insertions(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index 550a890797e..8d774666d2b 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -403,6 +403,36 @@ describe Ci::Pipeline, models: true do end end + describe 'yaml config file resolution' do + let(:project) { FactoryGirl.build(:project) } + + let(:pipeline) { create(:ci_empty_pipeline, project: project) } + it 'uses custom ci config file path when present' do + allow(project).to receive(:ci_config_file) { 'custom/path' } + expect(pipeline.ci_yaml_file_path).to eq('custom/path/.gitlab-ci.yml') + end + it 'uses root when custom path is nil' do + allow(project).to receive(:ci_config_file) { nil } + expect(pipeline.ci_yaml_file_path).to eq('.gitlab-ci.yml') + end + it 'uses root when custom path is empty' do + allow(project).to receive(:ci_config_file) { '' } + expect(pipeline.ci_yaml_file_path).to eq('.gitlab-ci.yml') + end + it 'allows custom filename' do + allow(project).to receive(:ci_config_file) { 'custom/path/.my-config.yml' } + expect(pipeline.ci_yaml_file_path).to eq('custom/path/.my-config.yml') + end + it 'custom filename must be yml' do + allow(project).to receive(:ci_config_file) { 'custom/path/.my-config.cnf' } + expect(pipeline.ci_yaml_file_path).to eq('custom/path/.my-config.cnf/.gitlab-ci.yml') + end + it 'reports error if the file is not found' do + pipeline.ci_yaml_file + expect(pipeline.yaml_errors).to eq('Failed to load CI config file') + end + end + describe '#execute_hooks' do let!(:build_a) { create_build('a', 0) } let!(:build_b) { create_build('b', 1) } diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 8aadfcb439b..363b5ff1913 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -118,6 +118,7 @@ describe Project, models: true do it { is_expected.to validate_uniqueness_of(:path).scoped_to(:namespace_id) } it { is_expected.to validate_length_of(:path).is_within(0..255) } it { is_expected.to validate_length_of(:description).is_within(0..2000) } + it { is_expected.to validate_length_of(:ci_config_file).is_within(0..255) } it { is_expected.to validate_presence_of(:creator) } it { is_expected.to validate_presence_of(:namespace) } it { is_expected.to validate_presence_of(:repository_storage) } diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 5f19638b460..80e5deb7f92 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -256,7 +256,8 @@ describe API::API, api: true do merge_requests_enabled: false, wiki_enabled: false, only_allow_merge_if_build_succeeds: false, - request_access_enabled: true + request_access_enabled: true, + ci_config_file: 'a/custom/path' }) post api('/projects', user), project @@ -503,6 +504,7 @@ describe API::API, api: true do expect(json_response['star_count']).to be_present expect(json_response['forks_count']).to be_present expect(json_response['public_builds']).to be_present + expect(json_response['ci_config_file']).to be_nil expect(json_response['shared_with_groups']).to be_an Array expect(json_response['shared_with_groups'].length).to eq(1) expect(json_response['shared_with_groups'][0]['group_id']).to eq(group.id) -- cgit v1.2.3 From 07a65da1d96a71474f6997aed95bac6290d81a42 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Fri, 16 Jun 2017 22:15:40 +0800 Subject: Generate KUBECONFIG in KubernetesService#predefined_variables --- spec/fixtures/config/kubeconfig-without-ca.yml | 18 ++++++++++ spec/fixtures/config/kubeconfig.yml | 19 ++++++++++ spec/lib/gitlab/kubernetes_spec.rb | 24 +++++++++++++ .../project_services/kubernetes_service_spec.rb | 40 ++++++++++++++-------- 4 files changed, 86 insertions(+), 15 deletions(-) create mode 100644 spec/fixtures/config/kubeconfig-without-ca.yml create mode 100644 spec/fixtures/config/kubeconfig.yml (limited to 'spec') diff --git a/spec/fixtures/config/kubeconfig-without-ca.yml b/spec/fixtures/config/kubeconfig-without-ca.yml new file mode 100644 index 00000000000..b2cb989d548 --- /dev/null +++ b/spec/fixtures/config/kubeconfig-without-ca.yml @@ -0,0 +1,18 @@ +--- +apiVersion: v1 +clusters: +- name: gitlab-deploy + cluster: + server: https://kube.domain.com +contexts: +- name: gitlab-deploy + context: + cluster: gitlab-deploy + namespace: NAMESPACE + user: gitlab-deploy +current-context: gitlab-deploy +kind: Config +users: +- name: gitlab-deploy + user: + token: TOKEN diff --git a/spec/fixtures/config/kubeconfig.yml b/spec/fixtures/config/kubeconfig.yml new file mode 100644 index 00000000000..4fa52818fee --- /dev/null +++ b/spec/fixtures/config/kubeconfig.yml @@ -0,0 +1,19 @@ +--- +apiVersion: v1 +clusters: +- name: gitlab-deploy + cluster: + server: https://kube.domain.com + certificate-authority-data: PEM +contexts: +- name: gitlab-deploy + context: + cluster: gitlab-deploy + namespace: NAMESPACE + user: gitlab-deploy +current-context: gitlab-deploy +kind: Config +users: +- name: gitlab-deploy + user: + token: TOKEN diff --git a/spec/lib/gitlab/kubernetes_spec.rb b/spec/lib/gitlab/kubernetes_spec.rb index e8c599a95ee..34b33772578 100644 --- a/spec/lib/gitlab/kubernetes_spec.rb +++ b/spec/lib/gitlab/kubernetes_spec.rb @@ -46,4 +46,28 @@ describe Gitlab::Kubernetes do expect(filter_by_label(items, app: 'foo')).to eq(matching_items) end end + + describe '#to_kubeconfig' do + subject do + to_kubeconfig( + url: 'https://kube.domain.com', + namespace: 'NAMESPACE', + token: 'TOKEN', + ca_pem: ca_pem) + end + + context 'when CA PEM is provided' do + let(:ca_pem) { 'PEM' } + let(:path) { expand_fixture_path('config/kubeconfig.yml') } + + it { is_expected.to eq(YAML.load_file(path)) } + end + + context 'when CA PEM is not provided' do + let(:ca_pem) { nil } + let(:path) { expand_fixture_path('config/kubeconfig-without-ca.yml') } + + it { is_expected.to eq(YAML.load_file(path)) } + end + end end diff --git a/spec/models/project_services/kubernetes_service_spec.rb b/spec/models/project_services/kubernetes_service_spec.rb index 858ad595dbf..f69e273cd7c 100644 --- a/spec/models/project_services/kubernetes_service_spec.rb +++ b/spec/models/project_services/kubernetes_service_spec.rb @@ -129,7 +129,7 @@ describe KubernetesService, models: true, caching: true do it "returns the default namespace" do is_expected.to eq(service.send(:default_namespace)) end - + context 'when namespace is specified' do before do service.namespace = 'my-namespace' @@ -201,6 +201,13 @@ describe KubernetesService, models: true, caching: true do end describe '#predefined_variables' do + let(:kubeconfig) do + File.read(expand_fixture_path('config/kubeconfig.yml')) + .gsub('TOKEN', 'token') + .gsub('PEM', 'CA PEM DATA') + .gsub('NAMESPACE', namespace) + end + before do subject.api_url = 'https://kube.domain.com' subject.token = 'token' @@ -208,32 +215,35 @@ describe KubernetesService, models: true, caching: true do subject.project = project end - context 'namespace is provided' do - before do - subject.namespace = 'my-project' - end - + shared_examples 'setting variables' do it 'sets the variables' do expect(subject.predefined_variables).to include( { key: 'KUBE_URL', value: 'https://kube.domain.com', public: true }, { key: 'KUBE_TOKEN', value: 'token', public: false }, - { key: 'KUBE_NAMESPACE', value: 'my-project', public: true }, + { key: 'KUBE_NAMESPACE', value: namespace, public: true }, + { key: 'KUBECONFIG', value: kubeconfig, public: false }, + { key: 'KUBECONFIG_FILE', value: kubeconfig, public: false, file: true }, { key: 'KUBE_CA_PEM', value: 'CA PEM DATA', public: true }, { key: 'KUBE_CA_PEM_FILE', value: 'CA PEM DATA', public: true, file: true } ) end end - context 'no namespace provided' do - it 'sets the variables' do - expect(subject.predefined_variables).to include( - { key: 'KUBE_URL', value: 'https://kube.domain.com', public: true }, - { key: 'KUBE_TOKEN', value: 'token', public: false }, - { key: 'KUBE_CA_PEM', value: 'CA PEM DATA', public: true }, - { key: 'KUBE_CA_PEM_FILE', value: 'CA PEM DATA', public: true, file: true } - ) + context 'namespace is provided' do + let(:namespace) { 'my-project' } + + before do + subject.namespace = namespace end + it_behaves_like 'setting variables' + end + + context 'no namespace provided' do + let(:namespace) { subject.actual_namespace } + + it_behaves_like 'setting variables' + it 'sets the KUBE_NAMESPACE' do kube_namespace = subject.predefined_variables.find { |h| h[:key] == 'KUBE_NAMESPACE' } -- cgit v1.2.3 From 6eaec942e6ae89818ea1ba0da5ff00daea633c41 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Fri, 16 Jun 2017 22:26:40 +0800 Subject: Changelog entry, doc, and only pass KUBECONFIG_FILE --- spec/models/project_services/kubernetes_service_spec.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'spec') diff --git a/spec/models/project_services/kubernetes_service_spec.rb b/spec/models/project_services/kubernetes_service_spec.rb index f69e273cd7c..d4feae231bc 100644 --- a/spec/models/project_services/kubernetes_service_spec.rb +++ b/spec/models/project_services/kubernetes_service_spec.rb @@ -221,7 +221,6 @@ describe KubernetesService, models: true, caching: true do { key: 'KUBE_URL', value: 'https://kube.domain.com', public: true }, { key: 'KUBE_TOKEN', value: 'token', public: false }, { key: 'KUBE_NAMESPACE', value: namespace, public: true }, - { key: 'KUBECONFIG', value: kubeconfig, public: false }, { key: 'KUBECONFIG_FILE', value: kubeconfig, public: false, file: true }, { key: 'KUBE_CA_PEM', value: 'CA PEM DATA', public: true }, { key: 'KUBE_CA_PEM_FILE', value: 'CA PEM DATA', public: true, file: true } -- cgit v1.2.3 From e02ca5fdb7f9b9a7e52d0e6edfb3be65860818a5 Mon Sep 17 00:00:00 2001 From: Stefan Hanreich Date: Thu, 11 May 2017 20:04:36 +0200 Subject: Updated spec for build to include new ref_slug invariants --- spec/models/ci/build_spec.rb | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'spec') diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 3816422fec6..a54261667bd 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -1033,19 +1033,27 @@ describe Ci::Build, :models do end describe '#ref_slug' do + let(:build) { build(:ci_build, ref: "'100%") } + subject { build.ref_slug } + + it { is_expected.not_to start_with('-') } + it { is_expected.not_to end_with('-') } + { - 'master' => 'master', - '1-foo' => '1-foo', - 'fix/1-foo' => 'fix-1-foo', - 'fix-1-foo' => 'fix-1-foo', - 'a' * 63 => 'a' * 63, - 'a' * 64 => 'a' * 63, - 'FOO' => 'foo' + 'master' => 'master', + '1-foo' => '1-foo', + 'fix/1-foo' => 'fix-1-foo', + 'fix-1-foo' => 'fix-1-foo', + 'a' * 63 => 'a' * 63, + 'a' * 64 => 'a' * 63, + 'FOO' => 'foo', + '-' + 'a' * 61 + '-' => 'a' * 61, + 'a' * 62 + ' ' => 'a' * 62, }.each do |ref, slug| it "transforms #{ref} to #{slug}" do build.ref = ref - expect(build.ref_slug).to eq(slug) + is_expected.to eq(slug) end end end -- cgit v1.2.3 From 6394d560ada1bc8b70bcd338343fe978916f84a4 Mon Sep 17 00:00:00 2001 From: Stefan Hanreich Date: Thu, 11 May 2017 20:50:59 +0200 Subject: removed superfluos tests --- spec/models/ci/build_spec.rb | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'spec') diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index a54261667bd..855e55dd489 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -1033,12 +1033,6 @@ describe Ci::Build, :models do end describe '#ref_slug' do - let(:build) { build(:ci_build, ref: "'100%") } - subject { build.ref_slug } - - it { is_expected.not_to start_with('-') } - it { is_expected.not_to end_with('-') } - { 'master' => 'master', '1-foo' => '1-foo', @@ -1053,7 +1047,7 @@ describe Ci::Build, :models do it "transforms #{ref} to #{slug}" do build.ref = ref - is_expected.to eq(slug) + expected(build.ref_slug).to eq(slug) end end end -- cgit v1.2.3 From fde8f9d736b058e1688c87ed4d3ac835d1603937 Mon Sep 17 00:00:00 2001 From: Stefan Hanreich Date: Thu, 11 May 2017 20:54:41 +0200 Subject: fix typo --- spec/models/ci/build_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 855e55dd489..4bf1f296803 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -1047,7 +1047,7 @@ describe Ci::Build, :models do it "transforms #{ref} to #{slug}" do build.ref = ref - expected(build.ref_slug).to eq(slug) + expect(build.ref_slug).to eq(slug) end end end -- cgit v1.2.3 From d60a59b067f7914ddcd7d28300f025cf125b586d Mon Sep 17 00:00:00 2001 From: Stefan Hanreich Date: Thu, 11 May 2017 21:42:39 +0200 Subject: remove trailing comma --- spec/models/ci/build_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 4bf1f296803..7ec06b6d6be 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -1042,7 +1042,7 @@ describe Ci::Build, :models do 'a' * 64 => 'a' * 63, 'FOO' => 'foo', '-' + 'a' * 61 + '-' => 'a' * 61, - 'a' * 62 + ' ' => 'a' * 62, + 'a' * 62 + ' ' => 'a' * 62 }.each do |ref, slug| it "transforms #{ref} to #{slug}" do build.ref = ref -- cgit v1.2.3 From c701ea945a9af4d1332357b9274d36fffd98c345 Mon Sep 17 00:00:00 2001 From: Stefan Hanreich Date: Sun, 18 Jun 2017 23:49:04 +0200 Subject: added additional test case --- spec/models/ci/build_spec.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'spec') diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 7ec06b6d6be..7033623d413 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -1042,6 +1042,7 @@ describe Ci::Build, :models do 'a' * 64 => 'a' * 63, 'FOO' => 'foo', '-' + 'a' * 61 + '-' => 'a' * 61, + '-' + 'a' * 63 + '-' => 'a' * 63, 'a' * 62 + ' ' => 'a' * 62 }.each do |ref, slug| it "transforms #{ref} to #{slug}" do -- cgit v1.2.3 From da737f13a963075ffc952756cfd6da2997d1a348 Mon Sep 17 00:00:00 2001 From: Stefan Hanreich Date: Mon, 19 Jun 2017 14:13:46 +0200 Subject: fixed incorrect test case --- spec/models/ci/build_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 7033623d413..523650eb506 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -1042,7 +1042,7 @@ describe Ci::Build, :models do 'a' * 64 => 'a' * 63, 'FOO' => 'foo', '-' + 'a' * 61 + '-' => 'a' * 61, - '-' + 'a' * 63 + '-' => 'a' * 63, + '-' + 'a' * 63 => 'a' * 63, 'a' * 62 + ' ' => 'a' * 62 }.each do |ref, slug| it "transforms #{ref} to #{slug}" do -- cgit v1.2.3 From 071603a0a59ff315b1d6b1ee2996b37a37cb3c75 Mon Sep 17 00:00:00 2001 From: Stefan Hanreich Date: Mon, 19 Jun 2017 14:16:41 +0200 Subject: fixed incorrect test case (for real), added another one --- spec/models/ci/build_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 523650eb506..dec105d13ec 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -1042,7 +1042,8 @@ describe Ci::Build, :models do 'a' * 64 => 'a' * 63, 'FOO' => 'foo', '-' + 'a' * 61 + '-' => 'a' * 61, - '-' + 'a' * 63 => 'a' * 63, + '-' + 'a' * 62 + '-' => 'a' * 62, + '-' + 'a' * 63 + '-' => 'a' * 62, 'a' * 62 + ' ' => 'a' * 62 }.each do |ref, slug| it "transforms #{ref} to #{slug}" do -- cgit v1.2.3 From 91c58ed14d13dcefd7ca2834d6157a9fa630a9af Mon Sep 17 00:00:00 2001 From: Toon Claes Date: Wed, 31 May 2017 15:59:01 +0200 Subject: FormHelper#issue_assignees_dropdown_options never has multiple assignees Only EE supports multiple issue assignees, so this CE code should not contain code to have multiple assignees. EE will override the multiple issue assignees feature by overriding this method. --- spec/features/issues/form_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'spec') diff --git a/spec/features/issues/form_spec.rb b/spec/features/issues/form_spec.rb index b369ef1ff79..58f6bd277e4 100644 --- a/spec/features/issues/form_spec.rb +++ b/spec/features/issues/form_spec.rb @@ -31,8 +31,8 @@ describe 'New/edit issue', :feature, :js do # the original method, resulting in infinite recurison when called. # This is likely a bug with helper modules included into dynamically generated view classes. # To work around this, we have to hold on to and call to the original implementation manually. - original_issue_dropdown_options = FormHelper.instance_method(:issue_dropdown_options) - allow_any_instance_of(FormHelper).to receive(:issue_dropdown_options).and_wrap_original do |original, *args| + original_issue_dropdown_options = FormHelper.instance_method(:issue_assignees_dropdown_options) + allow_any_instance_of(FormHelper).to receive(:issue_assignees_dropdown_options).and_wrap_original do |original, *args| options = original_issue_dropdown_options.bind(original.receiver).call(*args) options[:data][:per_page] = 2 -- cgit v1.2.3 From fcd46c1af4ceeec7813a91111dfce5e492695119 Mon Sep 17 00:00:00 2001 From: Toon Claes Date: Tue, 20 Jun 2017 15:03:25 +0200 Subject: Backport /reassign quick command The /reassign quick command works even when no multiple assignees are allowed of there isn't any assignee yet. So for consistency, it's also be backported to CE. But it functions the same as the /assign quick action. --- spec/services/quick_actions/interpret_service_spec.rb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/services/quick_actions/interpret_service_spec.rb b/spec/services/quick_actions/interpret_service_spec.rb index c9e63efbc14..b1997e64557 100644 --- a/spec/services/quick_actions/interpret_service_spec.rb +++ b/spec/services/quick_actions/interpret_service_spec.rb @@ -362,7 +362,7 @@ describe QuickActions::InterpretService, services: true do it 'fetches assignee and populates assignee_id if content contains /assign' do _, updates = service.execute(content, issue) - expect(updates).to eq(assignee_ids: [developer.id]) + expect(updates[:assignee_ids]).to match_array([developer.id]) end end @@ -431,6 +431,22 @@ describe QuickActions::InterpretService, services: true do end end + context 'reassign command' do + let(:content) { '/reassign' } + + context 'Issue' do + it 'reassigns user if content contains /reassign @user' do + user = create(:user) + + issue.update(assignee_ids: [developer.id]) + + _, updates = service.execute("/reassign @#{user.username}", issue) + + expect(updates).to eq(assignee_ids: [user.id]) + end + end + end + it_behaves_like 'milestone command' do let(:content) { "/milestone %#{milestone.title}" } let(:issuable) { issue } -- cgit v1.2.3 From 451e25532ff43de8151b71ced8246f709c08bf92 Mon Sep 17 00:00:00 2001 From: Toon Claes Date: Tue, 20 Jun 2017 21:32:49 +0200 Subject: Make MergeRequest respond to assignee_ids & assignee_ids= To make it simpler to assign users to an Issuable, make MergeRequest support the attribute `assignee_ids`. --- spec/models/merge_request_spec.rb | 16 ++++++++++++++++ spec/services/quick_actions/interpret_service_spec.rb | 18 +++++++++--------- 2 files changed, 25 insertions(+), 9 deletions(-) (limited to 'spec') diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index a56bc524a98..945189b922b 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -105,6 +105,22 @@ describe MergeRequest, models: true do end end + describe '#assignee_ids' do + it 'returns an array of the assigned user id' do + subject.assignee_id = 123 + + expect(subject.assignee_ids).to eq([123]) + end + end + + describe '#assignee_ids=' do + it 'sets assignee_id to the last id in the array' do + subject.assignee_ids = [123, 456] + + expect(subject.assignee_id).to eq(456) + end + end + describe '#assignee_or_author?' do let(:user) { create(:user) } diff --git a/spec/services/quick_actions/interpret_service_spec.rb b/spec/services/quick_actions/interpret_service_spec.rb index b1997e64557..35373675894 100644 --- a/spec/services/quick_actions/interpret_service_spec.rb +++ b/spec/services/quick_actions/interpret_service_spec.rb @@ -359,7 +359,7 @@ describe QuickActions::InterpretService, services: true do let(:content) { "/assign @#{developer.username}" } context 'Issue' do - it 'fetches assignee and populates assignee_id if content contains /assign' do + it 'fetches assignee and populates assignee_ids if content contains /assign' do _, updates = service.execute(content, issue) expect(updates[:assignee_ids]).to match_array([developer.id]) @@ -367,10 +367,10 @@ describe QuickActions::InterpretService, services: true do end context 'Merge Request' do - it 'fetches assignee and populates assignee_id if content contains /assign' do + it 'fetches assignee and populates assignee_ids if content contains /assign' do _, updates = service.execute(content, merge_request) - expect(updates).to eq(assignee_id: developer.id) + expect(updates).to eq(assignee_ids: [developer.id]) end end end @@ -383,7 +383,7 @@ describe QuickActions::InterpretService, services: true do end context 'Issue' do - it 'fetches assignee and populates assignee_id if content contains /assign' do + it 'fetches assignee and populates assignee_ids if content contains /assign' do _, updates = service.execute(content, issue) expect(updates[:assignee_ids]).to match_array([developer.id]) @@ -391,10 +391,10 @@ describe QuickActions::InterpretService, services: true do end context 'Merge Request' do - it 'fetches assignee and populates assignee_id if content contains /assign' do + it 'fetches assignee and populates assignee_ids if content contains /assign' do _, updates = service.execute(content, merge_request) - expect(updates).to eq(assignee_id: developer.id) + expect(updates).to eq(assignee_ids: [developer.id]) end end end @@ -422,11 +422,11 @@ describe QuickActions::InterpretService, services: true do end context 'Merge Request' do - it 'populates assignee_id: nil if content contains /unassign' do - merge_request.update(assignee_id: developer.id) + it 'populates assignee_ids: [] if content contains /unassign' do + merge_request.update(assignee_ids: [developer.id]) _, updates = service.execute(content, merge_request) - expect(updates).to eq(assignee_id: nil) + expect(updates).to eq(assignee_ids: []) end end end -- cgit v1.2.3 From d9ad56f3c5a7fc5e682ec96731b0578719934122 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Wed, 21 Jun 2017 17:30:12 +0000 Subject: Add environment_scope column to ci_variables table This is merely to make CE and EE more compatible. See the EE merge request at: https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/2112 --- spec/models/ci/variable_spec.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'spec') diff --git a/spec/models/ci/variable_spec.rb b/spec/models/ci/variable_spec.rb index 83494af24ba..ad3aa660b96 100644 --- a/spec/models/ci/variable_spec.rb +++ b/spec/models/ci/variable_spec.rb @@ -5,12 +5,14 @@ describe Ci::Variable, models: true do let(:secret_value) { 'secret' } - it { is_expected.to validate_presence_of(:key) } - it { is_expected.to validate_uniqueness_of(:key).scoped_to(:project_id) } - it { is_expected.to validate_length_of(:key).is_at_most(255) } - it { is_expected.to allow_value('foo').for(:key) } - it { is_expected.not_to allow_value('foo bar').for(:key) } - it { is_expected.not_to allow_value('foo/bar').for(:key) } + describe 'validations' do + it { is_expected.to validate_presence_of(:key) } + it { is_expected.to validate_uniqueness_of(:key).scoped_to(:project_id, :environment_scope) } + it { is_expected.to validate_length_of(:key).is_at_most(255) } + it { is_expected.to allow_value('foo').for(:key) } + it { is_expected.not_to allow_value('foo bar').for(:key) } + it { is_expected.not_to allow_value('foo/bar').for(:key) } + end describe '.unprotected' do subject { described_class.unprotected } -- cgit v1.2.3 From 5725b3769fdfbffc86bcea72d26197391f538759 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Thu, 22 Jun 2017 15:54:23 +0000 Subject: Remove duplicated records and add unique constraint --- spec/migrations/remove_duplicated_variable_spec.rb | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 spec/migrations/remove_duplicated_variable_spec.rb (limited to 'spec') diff --git a/spec/migrations/remove_duplicated_variable_spec.rb b/spec/migrations/remove_duplicated_variable_spec.rb new file mode 100644 index 00000000000..9a521a7d980 --- /dev/null +++ b/spec/migrations/remove_duplicated_variable_spec.rb @@ -0,0 +1,25 @@ +require 'spec_helper' +require Rails.root.join('db', 'migrate', '20170622135451_remove_duplicated_variable.rb') + +describe RemoveDuplicatedVariable, :migration do + let(:variables) { table(:ci_variables) } + let(:projects) { table(:projects) } + + before do + projects.create!(id: 1) + variables.create!(id: 1, key: 'key1', project_id: 1) + variables.create!(id: 2, key: 'key2', project_id: 1) + variables.create!(id: 3, key: 'keyX', project_id: 1) + variables.create!(id: 4, key: 'keyX', project_id: 1) + variables.create!(id: 5, key: 'keyY', project_id: 1) + variables.create!(id: 6, key: 'keyX', project_id: 1) + variables.create!(id: 7, key: 'key7', project_id: 1) + variables.create!(id: 8, key: 'keyY', project_id: 1) + end + + it 'correctly remove duplicated records with smaller id' do + migrate! + + expect(variables.pluck(:id)).to contain_exactly(1, 2, 6, 7, 8) + end +end -- cgit v1.2.3 From 20f679d620380b5b5e662b790c76caf256867b01 Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Mon, 26 Jun 2017 07:20:30 +0000 Subject: Allow unauthenticated access to the `/api/v4/users` API. - The issue filtering frontend code needs access to this API for non-logged-in users + public projects. It uses the API to fetch information for a user by username. - We don't authenticate this API anymore, but instead - if the `current_user` is not present: - Verify that the `username` parameter has been passed. This disallows an unauthenticated user from grabbing a list of all users on the instance. The `UsersFinder` class performs an exact match on the `username`, so we are guaranteed to get 0 or 1 users. - Verify that the resulting user (if any) is accessible to be viewed publicly by calling `can?(current_user, :read_user, user)` --- spec/requests/api/users_spec.rb | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'spec') diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index 18000d91795..01541901330 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -13,9 +13,40 @@ describe API::Users do describe 'GET /users' do context "when unauthenticated" do - it "returns authentication error" do + it "returns authorization error when the `username` parameter is not passed" do get api("/users") - expect(response).to have_http_status(401) + + expect(response).to have_http_status(403) + end + + it "returns the user when a valid `username` parameter is passed" do + user = create(:user) + + get api("/users"), username: user.username + + expect(response).to have_http_status(200) + expect(json_response).to be_an Array + expect(json_response.size).to eq(1) + expect(json_response[0]['id']).to eq(user.id) + expect(json_response[0]['username']).to eq(user.username) + end + + it "returns authorization error when the `username` parameter refers to an inaccessible user" do + user = create(:user) + + expect(Ability).to receive(:allowed?).with(nil, :read_user, user).and_return(false) + + get api("/users"), username: user.username + + expect(response).to have_http_status(403) + end + + it "returns an empty response when an invalid `username` parameter is passed" do + get api("/users"), username: 'invalid' + + expect(response).to have_http_status(200) + expect(json_response).to be_an Array + expect(json_response.size).to eq(0) end end -- cgit v1.2.3 From 175b7834c398546550a75b545fa42828302d656c Mon Sep 17 00:00:00 2001 From: Takuya Noguchi Date: Thu, 22 Jun 2017 16:19:43 +0900 Subject: Add tests for MilestonesHelper#milestones_filter_dropdown_path --- spec/helpers/milestones_helper_spec.rb | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'spec') diff --git a/spec/helpers/milestones_helper_spec.rb b/spec/helpers/milestones_helper_spec.rb index 3cb809d42b5..24d4f1b4938 100644 --- a/spec/helpers/milestones_helper_spec.rb +++ b/spec/helpers/milestones_helper_spec.rb @@ -1,6 +1,42 @@ require 'spec_helper' describe MilestonesHelper do + describe '#milestones_filter_dropdown_path' do + let(:project) { create(:empty_project) } + let(:project2) { create(:empty_project) } + let(:group) { create(:group) } + + context 'when @project present' do + it 'returns project milestones JSON URL' do + assign(:project, project) + + expect(helper.milestones_filter_dropdown_path).to eq(namespace_project_milestones_path(project.namespace, project, :json)) + end + end + + context 'when @target_project present' do + it 'returns targeted project milestones JSON URL' do + assign(:target_project, project2) + + expect(helper.milestones_filter_dropdown_path).to eq(namespace_project_milestones_path(project2.namespace, project2, :json)) + end + end + + context 'when @group present' do + it 'returns group milestones JSON URL' do + assign(:group, group) + + expect(helper.milestones_filter_dropdown_path).to eq(group_milestones_path(group, :json)) + end + end + + context 'when neither of @project/@target_project/@group present' do + it 'returns dashboard milestones JSON URL' do + expect(helper.milestones_filter_dropdown_path).to eq(dashboard_milestones_path(:json)) + end + end + end + describe "#milestone_date_range" do def result_for(*args) milestone_date_range(build(:milestone, *args)) -- cgit v1.2.3 From 5d4ec03687852564b44ce1befccb292e11f1504b Mon Sep 17 00:00:00 2001 From: Takuya Noguchi Date: Fri, 23 Jun 2017 09:29:08 +0900 Subject: Add tests for Groups::MilestonesController#index --- spec/controllers/groups/milestones_controller_spec.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'spec') diff --git a/spec/controllers/groups/milestones_controller_spec.rb b/spec/controllers/groups/milestones_controller_spec.rb index f3263bc177d..c6e5fb61cf9 100644 --- a/spec/controllers/groups/milestones_controller_spec.rb +++ b/spec/controllers/groups/milestones_controller_spec.rb @@ -23,6 +23,21 @@ describe Groups::MilestonesController do project.team << [user, :master] end + describe "#index" do + it 'shows group milestones page' do + get :index, group_id: group.to_param + + expect(response).to have_http_status(200) + end + + it 'shows group milestones JSON' do + get :index, group_id: group.to_param, format: :json + + expect(response).to have_http_status(200) + expect(response.content_type).to eq 'application/json' + end + end + it_behaves_like 'milestone tabs' describe "#create" do -- cgit v1.2.3 From 10e732d2bb1afff22a0549c74636641859cc3bde Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Tue, 27 Jun 2017 17:46:45 +0800 Subject: Rename instead of delete, feedback: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/12363#note_33449374 --- spec/migrations/remove_duplicated_variable_spec.rb | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'spec') diff --git a/spec/migrations/remove_duplicated_variable_spec.rb b/spec/migrations/remove_duplicated_variable_spec.rb index 9a521a7d980..11096564dfa 100644 --- a/spec/migrations/remove_duplicated_variable_spec.rb +++ b/spec/migrations/remove_duplicated_variable_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' -require Rails.root.join('db', 'migrate', '20170622135451_remove_duplicated_variable.rb') +require Rails.root.join('db', 'migrate', '20170622135451_rename_duplicated_variable_key.rb') -describe RemoveDuplicatedVariable, :migration do +describe RenameDuplicatedVariableKey, :migration do let(:variables) { table(:ci_variables) } let(:projects) { table(:projects) } @@ -20,6 +20,15 @@ describe RemoveDuplicatedVariable, :migration do it 'correctly remove duplicated records with smaller id' do migrate! - expect(variables.pluck(:id)).to contain_exactly(1, 2, 6, 7, 8) + expect(variables.pluck(:id, :key)).to contain_exactly( + [1, 'key1'], + [2, 'key2'], + [3, 'keyX_3'], + [4, 'keyX_4'], + [5, 'keyY_5'], + [6, 'keyX'], + [7, 'key7'], + [8, 'keyY'] + ) end end -- cgit v1.2.3 From 7f3f053a7d2c720eb946c07a4b4bd09a54a72bbe Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Tue, 27 Jun 2017 18:29:23 +0800 Subject: Rename the migration test to match the migration path --- spec/migrations/remove_duplicated_variable_spec.rb | 34 ---------------------- .../rename_duplicated_variable_key_spec.rb | 34 ++++++++++++++++++++++ 2 files changed, 34 insertions(+), 34 deletions(-) delete mode 100644 spec/migrations/remove_duplicated_variable_spec.rb create mode 100644 spec/migrations/rename_duplicated_variable_key_spec.rb (limited to 'spec') diff --git a/spec/migrations/remove_duplicated_variable_spec.rb b/spec/migrations/remove_duplicated_variable_spec.rb deleted file mode 100644 index 11096564dfa..00000000000 --- a/spec/migrations/remove_duplicated_variable_spec.rb +++ /dev/null @@ -1,34 +0,0 @@ -require 'spec_helper' -require Rails.root.join('db', 'migrate', '20170622135451_rename_duplicated_variable_key.rb') - -describe RenameDuplicatedVariableKey, :migration do - let(:variables) { table(:ci_variables) } - let(:projects) { table(:projects) } - - before do - projects.create!(id: 1) - variables.create!(id: 1, key: 'key1', project_id: 1) - variables.create!(id: 2, key: 'key2', project_id: 1) - variables.create!(id: 3, key: 'keyX', project_id: 1) - variables.create!(id: 4, key: 'keyX', project_id: 1) - variables.create!(id: 5, key: 'keyY', project_id: 1) - variables.create!(id: 6, key: 'keyX', project_id: 1) - variables.create!(id: 7, key: 'key7', project_id: 1) - variables.create!(id: 8, key: 'keyY', project_id: 1) - end - - it 'correctly remove duplicated records with smaller id' do - migrate! - - expect(variables.pluck(:id, :key)).to contain_exactly( - [1, 'key1'], - [2, 'key2'], - [3, 'keyX_3'], - [4, 'keyX_4'], - [5, 'keyY_5'], - [6, 'keyX'], - [7, 'key7'], - [8, 'keyY'] - ) - end -end diff --git a/spec/migrations/rename_duplicated_variable_key_spec.rb b/spec/migrations/rename_duplicated_variable_key_spec.rb new file mode 100644 index 00000000000..11096564dfa --- /dev/null +++ b/spec/migrations/rename_duplicated_variable_key_spec.rb @@ -0,0 +1,34 @@ +require 'spec_helper' +require Rails.root.join('db', 'migrate', '20170622135451_rename_duplicated_variable_key.rb') + +describe RenameDuplicatedVariableKey, :migration do + let(:variables) { table(:ci_variables) } + let(:projects) { table(:projects) } + + before do + projects.create!(id: 1) + variables.create!(id: 1, key: 'key1', project_id: 1) + variables.create!(id: 2, key: 'key2', project_id: 1) + variables.create!(id: 3, key: 'keyX', project_id: 1) + variables.create!(id: 4, key: 'keyX', project_id: 1) + variables.create!(id: 5, key: 'keyY', project_id: 1) + variables.create!(id: 6, key: 'keyX', project_id: 1) + variables.create!(id: 7, key: 'key7', project_id: 1) + variables.create!(id: 8, key: 'keyY', project_id: 1) + end + + it 'correctly remove duplicated records with smaller id' do + migrate! + + expect(variables.pluck(:id, :key)).to contain_exactly( + [1, 'key1'], + [2, 'key2'], + [3, 'keyX_3'], + [4, 'keyX_4'], + [5, 'keyY_5'], + [6, 'keyX'], + [7, 'key7'], + [8, 'keyY'] + ) + end +end -- cgit v1.2.3 From b4d325c80c63ee9ee2676a57a42fac472b5b20d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Wed, 21 Jun 2017 16:49:51 +0200 Subject: Allow the feature flags to be enabled/disabled with more granularity MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This allows to enable/disable a feature flag for a given user, or a given Flipper group (must be declared statically in the `flipper.rb` initializer beforehand). Signed-off-by: Rémy Coutable --- spec/models/user_spec.rb | 14 +++ spec/requests/api/features_spec.rb | 178 ++++++++++++++++++++++++++++++++----- 2 files changed, 170 insertions(+), 22 deletions(-) (limited to 'spec') diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 8e895ec6634..05ba887c51f 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -430,6 +430,20 @@ describe User, models: true do end end + describe '#flipper_id' do + context 'when user is not persisted' do + let(:user) { build(:user) } + + it { expect(user.flipper_id).to be_nil } + end + + context 'when user is persisted' do + let(:user) { create(:user) } + + it { expect(user.flipper_id).to eq "User:#{user.id}" } + end + end + describe '#generate_password' do it "does not generate password by default" do user = create(:user, password: 'abcdefghe') diff --git a/spec/requests/api/features_spec.rb b/spec/requests/api/features_spec.rb index f169e6661d1..0ee0749c7a1 100644 --- a/spec/requests/api/features_spec.rb +++ b/spec/requests/api/features_spec.rb @@ -4,6 +4,13 @@ describe API::Features do let(:user) { create(:user) } let(:admin) { create(:admin) } + before do + Flipper.unregister_groups + Flipper.register(:perf_team) do |actor| + actor.respond_to?(:admin) && actor.admin? + end + end + describe 'GET /features' do let(:expected_features) do [ @@ -16,6 +23,14 @@ describe API::Features do 'name' => 'feature_2', 'state' => 'off', 'gates' => [{ 'key' => 'boolean', 'value' => false }] + }, + { + 'name' => 'feature_3', + 'state' => 'conditional', + 'gates' => [ + { 'key' => 'boolean', 'value' => false }, + { 'key' => 'groups', 'value' => ['perf_team'] } + ] } ] end @@ -23,6 +38,7 @@ describe API::Features do before do Feature.get('feature_1').enable Feature.get('feature_2').disable + Feature.get('feature_3').enable Feature.group(:perf_team) end it 'returns a 401 for anonymous users' do @@ -47,30 +63,70 @@ describe API::Features do describe 'POST /feature' do let(:feature_name) { 'my_feature' } - it 'returns a 401 for anonymous users' do - post api("/features/#{feature_name}") - expect(response).to have_http_status(401) - end + context 'when the feature does not exist' do + it 'returns a 401 for anonymous users' do + post api("/features/#{feature_name}") - it 'returns a 403 for users' do - post api("/features/#{feature_name}", user) + expect(response).to have_http_status(401) + end - expect(response).to have_http_status(403) - end + it 'returns a 403 for users' do + post api("/features/#{feature_name}", user) - it 'creates an enabled feature if passed true' do - post api("/features/#{feature_name}", admin), value: 'true' + expect(response).to have_http_status(403) + end - expect(response).to have_http_status(201) - expect(Feature.get(feature_name)).to be_enabled - end + context 'when passed value=true' do + it 'creates an enabled feature' do + post api("/features/#{feature_name}", admin), value: 'true' - it 'creates a feature with the given percentage if passed an integer' do - post api("/features/#{feature_name}", admin), value: '50' + expect(response).to have_http_status(201) + expect(json_response).to eq( + 'name' => 'my_feature', + 'state' => 'on', + 'gates' => [{ 'key' => 'boolean', 'value' => true }]) + end + + it 'creates an enabled feature for the given Flipper group when passed flipper_group=perf_team' do + post api("/features/#{feature_name}", admin), value: 'true', flipper_group: 'perf_team' + + expect(response).to have_http_status(201) + expect(json_response).to eq( + 'name' => 'my_feature', + 'state' => 'conditional', + 'gates' => [ + { 'key' => 'boolean', 'value' => false }, + { 'key' => 'groups', 'value' => ['perf_team'] } + ]) + end + + it 'creates an enabled feature for the given user when passed user=username' do + post api("/features/#{feature_name}", admin), value: 'true', user: user.username - expect(response).to have_http_status(201) - expect(Feature.get(feature_name).percentage_of_time_value).to be(50) + expect(response).to have_http_status(201) + expect(json_response).to eq( + 'name' => 'my_feature', + 'state' => 'conditional', + 'gates' => [ + { 'key' => 'boolean', 'value' => false }, + { 'key' => 'actors', 'value' => ["User:#{user.id}"] } + ]) + end + end + + it 'creates a feature with the given percentage if passed an integer' do + post api("/features/#{feature_name}", admin), value: '50' + + expect(response).to have_http_status(201) + expect(json_response).to eq( + 'name' => 'my_feature', + 'state' => 'conditional', + 'gates' => [ + { 'key' => 'boolean', 'value' => false }, + { 'key' => 'percentage_of_time', 'value' => 50 } + ]) + end end context 'when the feature exists' do @@ -80,11 +136,83 @@ describe API::Features do feature.disable # This also persists the feature on the DB end - it 'enables the feature if passed true' do - post api("/features/#{feature_name}", admin), value: 'true' + context 'when passed value=true' do + it 'enables the feature' do + post api("/features/#{feature_name}", admin), value: 'true' - expect(response).to have_http_status(201) - expect(feature).to be_enabled + expect(response).to have_http_status(201) + expect(json_response).to eq( + 'name' => 'my_feature', + 'state' => 'on', + 'gates' => [{ 'key' => 'boolean', 'value' => true }]) + end + + it 'enables the feature for the given Flipper group when passed flipper_group=perf_team' do + post api("/features/#{feature_name}", admin), value: 'true', flipper_group: 'perf_team' + + expect(response).to have_http_status(201) + expect(json_response).to eq( + 'name' => 'my_feature', + 'state' => 'conditional', + 'gates' => [ + { 'key' => 'boolean', 'value' => false }, + { 'key' => 'groups', 'value' => ['perf_team'] } + ]) + end + + it 'enables the feature for the given user when passed user=username' do + post api("/features/#{feature_name}", admin), value: 'true', user: user.username + + expect(response).to have_http_status(201) + expect(json_response).to eq( + 'name' => 'my_feature', + 'state' => 'conditional', + 'gates' => [ + { 'key' => 'boolean', 'value' => false }, + { 'key' => 'actors', 'value' => ["User:#{user.id}"] } + ]) + end + end + + context 'when feature is enabled and value=false is passed' do + it 'disables the feature' do + feature.enable + expect(feature).to be_enabled + + post api("/features/#{feature_name}", admin), value: 'false' + + expect(response).to have_http_status(201) + expect(json_response).to eq( + 'name' => 'my_feature', + 'state' => 'off', + 'gates' => [{ 'key' => 'boolean', 'value' => false }]) + end + + it 'disables the feature for the given Flipper group when passed flipper_group=perf_team' do + feature.enable(Feature.group(:perf_team)) + expect(Feature.get(feature_name).enabled?(admin)).to be_truthy + + post api("/features/#{feature_name}", admin), value: 'false', flipper_group: 'perf_team' + + expect(response).to have_http_status(201) + expect(json_response).to eq( + 'name' => 'my_feature', + 'state' => 'off', + 'gates' => [{ 'key' => 'boolean', 'value' => false }]) + end + + it 'disables the feature for the given user when passed user=username' do + feature.enable(user) + expect(Feature.get(feature_name).enabled?(user)).to be_truthy + + post api("/features/#{feature_name}", admin), value: 'false', user: user.username + + expect(response).to have_http_status(201) + expect(json_response).to eq( + 'name' => 'my_feature', + 'state' => 'off', + 'gates' => [{ 'key' => 'boolean', 'value' => false }]) + end end context 'with a pre-existing percentage value' do @@ -96,7 +224,13 @@ describe API::Features do post api("/features/#{feature_name}", admin), value: '30' expect(response).to have_http_status(201) - expect(Feature.get(feature_name).percentage_of_time_value).to be(30) + expect(json_response).to eq( + 'name' => 'my_feature', + 'state' => 'conditional', + 'gates' => [ + { 'key' => 'boolean', 'value' => false }, + { 'key' => 'percentage_of_time', 'value' => 30 } + ]) end end end -- cgit v1.2.3 From 5fa9d6a17dac86e9976946ded7857e1392403136 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Tue, 27 Jun 2017 18:58:56 +0200 Subject: Rename FLippable to FeatureGate and make `flipper_group` and `user` mutually exclusive MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- spec/models/concerns/feature_gate_spec.rb | 19 +++++++++++++++++++ spec/models/user_spec.rb | 14 -------------- 2 files changed, 19 insertions(+), 14 deletions(-) create mode 100644 spec/models/concerns/feature_gate_spec.rb (limited to 'spec') diff --git a/spec/models/concerns/feature_gate_spec.rb b/spec/models/concerns/feature_gate_spec.rb new file mode 100644 index 00000000000..3f601243245 --- /dev/null +++ b/spec/models/concerns/feature_gate_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper' + +describe FeatureGate do + describe 'User' do + describe '#flipper_id' do + context 'when user is not persisted' do + let(:user) { build(:user) } + + it { expect(user.flipper_id).to be_nil } + end + + context 'when user is persisted' do + let(:user) { create(:user) } + + it { expect(user.flipper_id).to eq "User:#{user.id}" } + end + end + end +end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 05ba887c51f..8e895ec6634 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -430,20 +430,6 @@ describe User, models: true do end end - describe '#flipper_id' do - context 'when user is not persisted' do - let(:user) { build(:user) } - - it { expect(user.flipper_id).to be_nil } - end - - context 'when user is persisted' do - let(:user) { create(:user) } - - it { expect(user.flipper_id).to eq "User:#{user.id}" } - end - end - describe '#generate_password' do it "does not generate password by default" do user = create(:user, password: 'abcdefghe') -- cgit v1.2.3 From 502bd6c033aaf05eba23122681852b63a90ad4a6 Mon Sep 17 00:00:00 2001 From: Jose Ivan Vargas Date: Tue, 27 Jun 2017 12:35:13 -0500 Subject: Fixed sidebar not collapsing on merge request in mobile screens --- spec/features/issues/issue_sidebar_spec.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'spec') diff --git a/spec/features/issues/issue_sidebar_spec.rb b/spec/features/issues/issue_sidebar_spec.rb index 163bc4bb32f..cd06b5af675 100644 --- a/spec/features/issues/issue_sidebar_spec.rb +++ b/spec/features/issues/issue_sidebar_spec.rb @@ -6,6 +6,7 @@ feature 'Issue Sidebar', feature: true do let(:group) { create(:group, :nested) } let(:project) { create(:project, :public, namespace: group) } let(:issue) { create(:issue, project: project) } + let(:merge_request) { create(:merge_request, source_project: project) } let!(:user) { create(:user)} let!(:label) { create(:label, project: project, title: 'bug') } @@ -158,11 +159,13 @@ feature 'Issue Sidebar', feature: true do before do project.team << [user, :developer] resize_screen_xs - visit_issue(project, issue) end context 'mobile sidebar' do - it 'collapses the sidebar for small screens' do + it 'collapses the sidebar for small screens on an issue/merge_request' do + visit_issue(project, issue) + expect(page).not_to have_css('aside.right-sidebar.right-sidebar-collapsed') + visit namespace_project_merge_request_path(merge_request.project.namespace, merge_request.project, merge_request) expect(page).not_to have_css('aside.right-sidebar.right-sidebar-collapsed') end end -- cgit v1.2.3 From 6f1922500bc9e2c6d53c46dfcbd420687dfe6e6b Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Tue, 20 Jun 2017 07:40:24 +0000 Subject: Initial attempt at refactoring API scope declarations. - Declaring an endpoint's scopes in a `before` block has proved to be unreliable. For example, if we're accessing the `API::Users` endpoint - code in a `before` block in `API::API` wouldn't be able to see the scopes set in `API::Users` since the `API::API` `before` block runs first. - This commit moves these declarations to the class level, since they don't need to change once set. --- spec/requests/api/users_spec.rb | 22 ++++++++++++++++++++++ spec/support/api_helpers.rb | 6 ++++-- 2 files changed, 26 insertions(+), 2 deletions(-) (limited to 'spec') diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index c0174b304c8..c8e22799ba4 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -50,6 +50,28 @@ describe API::Users do end['username']).to eq(username) end + context "scopes" do + context 'when the requesting token has the "read_user" scope' do + let(:token) { create(:personal_access_token, scopes: ['read_user']) } + + it 'returns a "200" response' do + get api("/users", user, personal_access_token: token) + + expect(response).to have_http_status(200) + end + end + + context 'when the requesting token does not have any required scope' do + let(:token) { create(:personal_access_token, scopes: ['read_registry']) } + + it 'returns a "401" response' do + get api("/users", user, personal_access_token: token) + + expect(response).to have_http_status(401) + end + end + end + it "returns an array of blocked users" do ldap_blocked_user create(:user, state: 'blocked') diff --git a/spec/support/api_helpers.rb b/spec/support/api_helpers.rb index 35d1e1cfc7d..163979a2a28 100644 --- a/spec/support/api_helpers.rb +++ b/spec/support/api_helpers.rb @@ -17,14 +17,16 @@ module ApiHelpers # => "/api/v2/issues?foo=bar&private_token=..." # # Returns the relative path to the requested API resource - def api(path, user = nil, version: API::API.version) + def api(path, user = nil, version: API::API.version, personal_access_token: nil) "/api/#{version}#{path}" + # Normalize query string (path.index('?') ? '' : '?') + + if personal_access_token.present? + "&private_token=#{personal_access_token.token}" # Append private_token if given a User object - if user.respond_to?(:private_token) + elsif user.respond_to?(:private_token) "&private_token=#{user.private_token}" else '' -- cgit v1.2.3 From 80c1ebaa83f346e45346baac584f21878652c350 Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Tue, 20 Jun 2017 08:27:45 +0000 Subject: Allow API scope declarations to be applied conditionally. - Scope declarations of the form: allow_access_with_scope :read_user, if: -> (request) { request.get? } will only apply for `GET` requests - Add a negative test to a `POST` endpoint in the `users` API to test this. Also test for this case in the `AccessTokenValidationService` unit tests. --- spec/requests/api/helpers_spec.rb | 3 +- spec/requests/api/users_spec.rb | 10 ++++++ .../access_token_validation_service_spec.rb | 36 ++++++++++++++++++---- 3 files changed, 42 insertions(+), 7 deletions(-) (limited to 'spec') diff --git a/spec/requests/api/helpers_spec.rb b/spec/requests/api/helpers_spec.rb index 191c60aba31..87d6f46533e 100644 --- a/spec/requests/api/helpers_spec.rb +++ b/spec/requests/api/helpers_spec.rb @@ -14,6 +14,8 @@ describe API::Helpers do let(:request) { Rack::Request.new(env) } let(:header) { } + before { allow_any_instance_of(self.class).to receive(:options).and_return({}) } + def set_env(user_or_token, identifier) clear_env clear_param @@ -167,7 +169,6 @@ describe API::Helpers do it "returns nil for a token without the appropriate scope" do personal_access_token = create(:personal_access_token, user: user, scopes: ['read_user']) env[API::APIGuard::PRIVATE_TOKEN_HEADER] = personal_access_token.token - allow_access_with_scope('write_user') expect(current_user).to be_nil end diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index c8e22799ba4..982c1a50e3b 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -321,6 +321,16 @@ describe API::Users do .to eq([Gitlab::PathRegex.namespace_format_message]) end + context 'when the requesting token has the "read_user" scope' do + let(:token) { create(:personal_access_token, scopes: ['read_user'], user: admin) } + + it 'returns a "401" response' do + post api("/users", admin, personal_access_token: token), attributes_for(:user, projects_limit: 3) + + expect(response).to have_http_status(401) + end + end + it "is not available for non admin users" do post api("/users", user), attributes_for(:user) expect(response).to have_http_status(403) diff --git a/spec/services/access_token_validation_service_spec.rb b/spec/services/access_token_validation_service_spec.rb index 87f093ee8ce..0023678dc3b 100644 --- a/spec/services/access_token_validation_service_spec.rb +++ b/spec/services/access_token_validation_service_spec.rb @@ -2,40 +2,64 @@ require 'spec_helper' describe AccessTokenValidationService, services: true do describe ".include_any_scope?" do + let(:request) { double("request") } + it "returns true if the required scope is present in the token's scopes" do token = double("token", scopes: [:api, :read_user]) - expect(described_class.new(token).include_any_scope?([:api])).to be(true) + expect(described_class.new(token, request).include_any_scope?([{ name: :api }])).to be(true) end it "returns true if more than one of the required scopes is present in the token's scopes" do token = double("token", scopes: [:api, :read_user, :other_scope]) - expect(described_class.new(token).include_any_scope?([:api, :other_scope])).to be(true) + expect(described_class.new(token, request).include_any_scope?([{ name: :api }, { name: :other_scope }])).to be(true) end it "returns true if the list of required scopes is an exact match for the token's scopes" do token = double("token", scopes: [:api, :read_user, :other_scope]) - expect(described_class.new(token).include_any_scope?([:api, :read_user, :other_scope])).to be(true) + expect(described_class.new(token, request).include_any_scope?([{ name: :api }, { name: :read_user }, { name: :other_scope }])).to be(true) end it "returns true if the list of required scopes contains all of the token's scopes, in addition to others" do token = double("token", scopes: [:api, :read_user]) - expect(described_class.new(token).include_any_scope?([:api, :read_user, :other_scope])).to be(true) + expect(described_class.new(token, request).include_any_scope?([{ name: :api }, { name: :read_user }, { name: :other_scope }])).to be(true) end it 'returns true if the list of required scopes is blank' do token = double("token", scopes: []) - expect(described_class.new(token).include_any_scope?([])).to be(true) + expect(described_class.new(token, request).include_any_scope?([])).to be(true) end it "returns false if there are no scopes in common between the required scopes and the token scopes" do token = double("token", scopes: [:api, :read_user]) - expect(described_class.new(token).include_any_scope?([:other_scope])).to be(false) + expect(described_class.new(token, request).include_any_scope?([{ name: :other_scope }])).to be(false) + end + + context "conditions" do + context "if" do + it "ignores any scopes whose `if` condition returns false" do + token = double("token", scopes: [:api, :read_user]) + + expect(described_class.new(token, request).include_any_scope?([{ name: :api, if: ->(_) { false } }])).to be(false) + end + + it "does not ignore scopes whose `if` condition is not set" do + token = double("token", scopes: [:api, :read_user]) + + expect(described_class.new(token, request).include_any_scope?([{ name: :api, if: ->(_) { false } }, { name: :read_user }])).to be(true) + end + + it "does not ignore scopes whose `if` condition returns true" do + token = double("token", scopes: [:api, :read_user]) + + expect(described_class.new(token, request).include_any_scope?([{ name: :api, if: ->(_) { true } }, { name: :read_user, if: ->(_) { false } }])).to be(true) + end + end end end end -- cgit v1.2.3 From 157c05f49da1d6992d6b491e4fba8d90a7d821c8 Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Tue, 20 Jun 2017 09:35:59 +0000 Subject: Test `/users` endpoints for the `read_user` scope. - Test `GET` endpoints to check that the scope is allowed. - Test `POST` endpoints to check that the scope is disallowed. - Test both `v3` and `v4` endpoints. --- spec/requests/api/users_spec.rb | 54 +++++++++------------- spec/requests/api/v3/users_spec.rb | 21 +++++++++ .../api/scopes/read_user_shared_examples.rb | 33 +++++++++++++ spec/support/api_helpers.rb | 4 +- 4 files changed, 78 insertions(+), 34 deletions(-) create mode 100644 spec/support/api/scopes/read_user_shared_examples.rb (limited to 'spec') diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index 982c1a50e3b..f0edc06cd0b 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -50,28 +50,6 @@ describe API::Users do end['username']).to eq(username) end - context "scopes" do - context 'when the requesting token has the "read_user" scope' do - let(:token) { create(:personal_access_token, scopes: ['read_user']) } - - it 'returns a "200" response' do - get api("/users", user, personal_access_token: token) - - expect(response).to have_http_status(200) - end - end - - context 'when the requesting token does not have any required scope' do - let(:token) { create(:personal_access_token, scopes: ['read_registry']) } - - it 'returns a "401" response' do - get api("/users", user, personal_access_token: token) - - expect(response).to have_http_status(401) - end - end - end - it "returns an array of blocked users" do ldap_blocked_user create(:user, state: 'blocked') @@ -104,6 +82,13 @@ describe API::Users do expect(json_response.first.keys).not_to include 'is_admin' end + + context "scopes" do + let(:path) { "/users" } + let(:api_call) { method(:api) } + + include_examples 'allows the "read_user" scope' + end end context "when admin" do @@ -186,6 +171,13 @@ describe API::Users do expect(response).to have_http_status(404) end + + context "scopes" do + let(:path) { "/users/#{user.id}" } + let(:api_call) { method(:api) } + + include_examples 'allows the "read_user" scope' + end end describe "POST /users" do @@ -321,16 +313,6 @@ describe API::Users do .to eq([Gitlab::PathRegex.namespace_format_message]) end - context 'when the requesting token has the "read_user" scope' do - let(:token) { create(:personal_access_token, scopes: ['read_user'], user: admin) } - - it 'returns a "401" response' do - post api("/users", admin, personal_access_token: token), attributes_for(:user, projects_limit: 3) - - expect(response).to have_http_status(401) - end - end - it "is not available for non admin users" do post api("/users", user), attributes_for(:user) expect(response).to have_http_status(403) @@ -377,6 +359,14 @@ describe API::Users do expect(json_response['identities'].first['provider']).to eq('github') end end + + context "scopes" do + let(:user) { admin } + let(:path) { '/users' } + let(:api_call) { method(:api) } + + include_examples 'does not allow the "read_user" scope' + end end describe "GET /users/sign_up" do diff --git a/spec/requests/api/v3/users_spec.rb b/spec/requests/api/v3/users_spec.rb index 6d7401f9764..b2c5003c97a 100644 --- a/spec/requests/api/v3/users_spec.rb +++ b/spec/requests/api/v3/users_spec.rb @@ -67,6 +67,19 @@ describe API::V3::Users do expect(json_response.first['title']).to eq(key.title) end end + + context "scopes" do + let(:user) { admin } + let(:path) { "/users/#{user.id}/keys" } + let(:api_call) { method(:v3_api) } + + before do + user.keys << key + user.save + end + + include_examples 'allows the "read_user" scope' + end end describe 'GET /user/:id/emails' do @@ -312,5 +325,13 @@ describe API::V3::Users do expect(json_response['is_admin']).to be_nil end + + context "scopes" do + let(:user) { admin } + let(:path) { '/users' } + let(:api_call) { method(:v3_api) } + + include_examples 'does not allow the "read_user" scope' + end end end diff --git a/spec/support/api/scopes/read_user_shared_examples.rb b/spec/support/api/scopes/read_user_shared_examples.rb new file mode 100644 index 00000000000..bb5f493f3fd --- /dev/null +++ b/spec/support/api/scopes/read_user_shared_examples.rb @@ -0,0 +1,33 @@ +shared_examples_for 'allows the "read_user" scope' do + describe 'when the requesting token has the "read_user" scope' do + let(:token) { create(:personal_access_token, scopes: ['read_user'], user: user) } + + it 'returns a "200" response' do + get api_call.call(path, user, personal_access_token: token) + + expect(response).to have_http_status(200) + end + end + + describe 'when the requesting token does not have any required scope' do + let(:token) { create(:personal_access_token, scopes: ['read_registry'], user: user) } + + it 'returns a "401" response' do + get api_call.call(path, user, personal_access_token: token) + + expect(response).to have_http_status(401) + end + end +end + +shared_examples_for 'does not allow the "read_user" scope' do + context 'when the requesting token has the "read_user" scope' do + let(:token) { create(:personal_access_token, scopes: ['read_user'], user: user) } + + it 'returns a "401" response' do + post api_call.call(path, user, personal_access_token: token), attributes_for(:user, projects_limit: 3) + + expect(response).to have_http_status(401) + end + end +end diff --git a/spec/support/api_helpers.rb b/spec/support/api_helpers.rb index 163979a2a28..1becd302d77 100644 --- a/spec/support/api_helpers.rb +++ b/spec/support/api_helpers.rb @@ -34,8 +34,8 @@ module ApiHelpers end # Temporary helper method for simplifying V3 exclusive API specs - def v3_api(path, user = nil) - api(path, user, version: 'v3') + def v3_api(path, user = nil, personal_access_token: nil) + api(path, user, version: 'v3', personal_access_token: personal_access_token) end def ci_api(path, user = nil) -- cgit v1.2.3 From 0ff1d161920a083e07b5f1629aa395642609b251 Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Tue, 20 Jun 2017 12:02:25 +0000 Subject: Test OAuth token scope verification in the `API::Users` endpoint --- spec/requests/api/helpers_spec.rb | 4 +- .../api/scopes/read_user_shared_examples.rb | 67 ++++++++++++++++++---- spec/support/api_helpers.rb | 14 ++++- 3 files changed, 71 insertions(+), 14 deletions(-) (limited to 'spec') diff --git a/spec/requests/api/helpers_spec.rb b/spec/requests/api/helpers_spec.rb index 87d6f46533e..25ec44fa036 100644 --- a/spec/requests/api/helpers_spec.rb +++ b/spec/requests/api/helpers_spec.rb @@ -14,7 +14,9 @@ describe API::Helpers do let(:request) { Rack::Request.new(env) } let(:header) { } - before { allow_any_instance_of(self.class).to receive(:options).and_return({}) } + before do + allow_any_instance_of(self.class).to receive(:options).and_return({}) + end def set_env(user_or_token, identifier) clear_env diff --git a/spec/support/api/scopes/read_user_shared_examples.rb b/spec/support/api/scopes/read_user_shared_examples.rb index bb5f493f3fd..cae6099a0c2 100644 --- a/spec/support/api/scopes/read_user_shared_examples.rb +++ b/spec/support/api/scopes/read_user_shared_examples.rb @@ -1,21 +1,68 @@ shared_examples_for 'allows the "read_user" scope' do - describe 'when the requesting token has the "read_user" scope' do - let(:token) { create(:personal_access_token, scopes: ['read_user'], user: user) } + context 'for personal access tokens' do + context 'when the requesting token has the "api" scope' do + let(:token) { create(:personal_access_token, scopes: ['api'], user: user) } + + it 'returns a "200" response' do + get api_call.call(path, user, personal_access_token: token) + + expect(response).to have_http_status(200) + end + end + + context 'when the requesting token has the "read_user" scope' do + let(:token) { create(:personal_access_token, scopes: ['read_user'], user: user) } - it 'returns a "200" response' do - get api_call.call(path, user, personal_access_token: token) + it 'returns a "200" response' do + get api_call.call(path, user, personal_access_token: token) - expect(response).to have_http_status(200) + expect(response).to have_http_status(200) + end + end + + context 'when the requesting token does not have any required scope' do + let(:token) { create(:personal_access_token, scopes: ['read_registry'], user: user) } + + it 'returns a "401" response' do + get api_call.call(path, user, personal_access_token: token) + + expect(response).to have_http_status(401) + end end end - describe 'when the requesting token does not have any required scope' do - let(:token) { create(:personal_access_token, scopes: ['read_registry'], user: user) } + context 'for doorkeeper (OAuth) tokens' do + let!(:user) {create(:user)} + let!(:application) { Doorkeeper::Application.create!(name: "MyApp", redirect_uri: "https://app.com", owner: user) } - it 'returns a "401" response' do - get api_call.call(path, user, personal_access_token: token) + context 'when the requesting token has the "api" scope' do + let!(:token) { Doorkeeper::AccessToken.create! application_id: application.id, resource_owner_id: user.id, scopes: "api" } - expect(response).to have_http_status(401) + it 'returns a "200" response' do + get api_call.call(path, user, oauth_access_token: token) + + expect(response).to have_http_status(200) + end + end + + context 'when the requesting token has the "read_user" scope' do + let!(:token) { Doorkeeper::AccessToken.create! application_id: application.id, resource_owner_id: user.id, scopes: "read_user" } + + it 'returns a "200" response' do + get api_call.call(path, user, oauth_access_token: token) + + expect(response).to have_http_status(200) + end + end + + context 'when the requesting token does not have any required scope' do + let!(:token) { Doorkeeper::AccessToken.create! application_id: application.id, resource_owner_id: user.id, scopes: "invalid" } + + it 'returns a "403" response' do + get api_call.call(path, user, oauth_access_token: token) + + expect(response).to have_http_status(403) + end end end end diff --git a/spec/support/api_helpers.rb b/spec/support/api_helpers.rb index 1becd302d77..ac0aaa524b7 100644 --- a/spec/support/api_helpers.rb +++ b/spec/support/api_helpers.rb @@ -17,7 +17,7 @@ module ApiHelpers # => "/api/v2/issues?foo=bar&private_token=..." # # Returns the relative path to the requested API resource - def api(path, user = nil, version: API::API.version, personal_access_token: nil) + def api(path, user = nil, version: API::API.version, personal_access_token: nil, oauth_access_token: nil) "/api/#{version}#{path}" + # Normalize query string @@ -25,6 +25,8 @@ module ApiHelpers if personal_access_token.present? "&private_token=#{personal_access_token.token}" + elsif oauth_access_token.present? + "&access_token=#{oauth_access_token.token}" # Append private_token if given a User object elsif user.respond_to?(:private_token) "&private_token=#{user.private_token}" @@ -34,8 +36,14 @@ module ApiHelpers end # Temporary helper method for simplifying V3 exclusive API specs - def v3_api(path, user = nil, personal_access_token: nil) - api(path, user, version: 'v3', personal_access_token: personal_access_token) + def v3_api(path, user = nil, personal_access_token: nil, oauth_access_token: nil) + api( + path, + user, + version: 'v3', + personal_access_token: personal_access_token, + oauth_access_token: oauth_access_token + ) end def ci_api(path, user = nil) -- cgit v1.2.3 From 1b8223dd51345f6075172a92dab610f9dee89d84 Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Wed, 21 Jun 2017 09:22:39 +0000 Subject: Fix remaining spec failures for !12300. 1. Get the spec for `lib/gitlab/auth.rb` passing. - Make the `request` argument to `AccessTokenValidationService` optional - `auth.rb` doesn't need to pass in a request. - Pass in scopes in the format `[{ name: 'api' }]` rather than `['api']`, which is what `AccessTokenValidationService` now expects. 2. Get the spec for `API::V3::Users` passing 2. Get the spec for `AccessTokenValidationService` passing --- spec/requests/api/v3/users_spec.rb | 2 +- spec/services/access_token_validation_service_spec.rb | 18 +++++++++--------- spec/support/api/scopes/read_user_shared_examples.rb | 1 - 3 files changed, 10 insertions(+), 11 deletions(-) (limited to 'spec') diff --git a/spec/requests/api/v3/users_spec.rb b/spec/requests/api/v3/users_spec.rb index b2c5003c97a..de7499a4e43 100644 --- a/spec/requests/api/v3/users_spec.rb +++ b/spec/requests/api/v3/users_spec.rb @@ -300,7 +300,7 @@ describe API::V3::Users do end it 'returns a 404 error if not found' do - get v3_api('/users/42/events', user) + get v3_api('/users/420/events', user) expect(response).to have_http_status(404) expect(json_response['message']).to eq('404 User Not Found') diff --git a/spec/services/access_token_validation_service_spec.rb b/spec/services/access_token_validation_service_spec.rb index 0023678dc3b..eff4269a4d5 100644 --- a/spec/services/access_token_validation_service_spec.rb +++ b/spec/services/access_token_validation_service_spec.rb @@ -7,37 +7,37 @@ describe AccessTokenValidationService, services: true do it "returns true if the required scope is present in the token's scopes" do token = double("token", scopes: [:api, :read_user]) - expect(described_class.new(token, request).include_any_scope?([{ name: :api }])).to be(true) + expect(described_class.new(token, request: request).include_any_scope?([{ name: :api }])).to be(true) end it "returns true if more than one of the required scopes is present in the token's scopes" do token = double("token", scopes: [:api, :read_user, :other_scope]) - expect(described_class.new(token, request).include_any_scope?([{ name: :api }, { name: :other_scope }])).to be(true) + expect(described_class.new(token, request: request).include_any_scope?([{ name: :api }, { name: :other_scope }])).to be(true) end it "returns true if the list of required scopes is an exact match for the token's scopes" do token = double("token", scopes: [:api, :read_user, :other_scope]) - expect(described_class.new(token, request).include_any_scope?([{ name: :api }, { name: :read_user }, { name: :other_scope }])).to be(true) + expect(described_class.new(token, request: request).include_any_scope?([{ name: :api }, { name: :read_user }, { name: :other_scope }])).to be(true) end it "returns true if the list of required scopes contains all of the token's scopes, in addition to others" do token = double("token", scopes: [:api, :read_user]) - expect(described_class.new(token, request).include_any_scope?([{ name: :api }, { name: :read_user }, { name: :other_scope }])).to be(true) + expect(described_class.new(token, request: request).include_any_scope?([{ name: :api }, { name: :read_user }, { name: :other_scope }])).to be(true) end it 'returns true if the list of required scopes is blank' do token = double("token", scopes: []) - expect(described_class.new(token, request).include_any_scope?([])).to be(true) + expect(described_class.new(token, request: request).include_any_scope?([])).to be(true) end it "returns false if there are no scopes in common between the required scopes and the token scopes" do token = double("token", scopes: [:api, :read_user]) - expect(described_class.new(token, request).include_any_scope?([{ name: :other_scope }])).to be(false) + expect(described_class.new(token, request: request).include_any_scope?([{ name: :other_scope }])).to be(false) end context "conditions" do @@ -45,19 +45,19 @@ describe AccessTokenValidationService, services: true do it "ignores any scopes whose `if` condition returns false" do token = double("token", scopes: [:api, :read_user]) - expect(described_class.new(token, request).include_any_scope?([{ name: :api, if: ->(_) { false } }])).to be(false) + expect(described_class.new(token, request: request).include_any_scope?([{ name: :api, if: ->(_) { false } }])).to be(false) end it "does not ignore scopes whose `if` condition is not set" do token = double("token", scopes: [:api, :read_user]) - expect(described_class.new(token, request).include_any_scope?([{ name: :api, if: ->(_) { false } }, { name: :read_user }])).to be(true) + expect(described_class.new(token, request: request).include_any_scope?([{ name: :api, if: ->(_) { false } }, { name: :read_user }])).to be(true) end it "does not ignore scopes whose `if` condition returns true" do token = double("token", scopes: [:api, :read_user]) - expect(described_class.new(token, request).include_any_scope?([{ name: :api, if: ->(_) { true } }, { name: :read_user, if: ->(_) { false } }])).to be(true) + expect(described_class.new(token, request: request).include_any_scope?([{ name: :api, if: ->(_) { true } }, { name: :read_user, if: ->(_) { false } }])).to be(true) end end end diff --git a/spec/support/api/scopes/read_user_shared_examples.rb b/spec/support/api/scopes/read_user_shared_examples.rb index cae6099a0c2..3bd589d64b9 100644 --- a/spec/support/api/scopes/read_user_shared_examples.rb +++ b/spec/support/api/scopes/read_user_shared_examples.rb @@ -32,7 +32,6 @@ shared_examples_for 'allows the "read_user" scope' do end context 'for doorkeeper (OAuth) tokens' do - let!(:user) {create(:user)} let!(:application) { Doorkeeper::Application.create!(name: "MyApp", redirect_uri: "https://app.com", owner: user) } context 'when the requesting token has the "api" scope' do -- cgit v1.2.3 From 4dbfa14e160e0d9bca11941adcf04b3d272aa1a2 Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Fri, 23 Jun 2017 11:18:44 +0000 Subject: Implement review comments from @dbalexandre for !12300. --- .../access_token_validation_service_spec.rb | 24 ++++++++++------------ 1 file changed, 11 insertions(+), 13 deletions(-) (limited to 'spec') diff --git a/spec/services/access_token_validation_service_spec.rb b/spec/services/access_token_validation_service_spec.rb index eff4269a4d5..c8189aa14d8 100644 --- a/spec/services/access_token_validation_service_spec.rb +++ b/spec/services/access_token_validation_service_spec.rb @@ -41,24 +41,22 @@ describe AccessTokenValidationService, services: true do end context "conditions" do - context "if" do - it "ignores any scopes whose `if` condition returns false" do - token = double("token", scopes: [:api, :read_user]) + it "ignores any scopes whose `if` condition returns false" do + token = double("token", scopes: [:api, :read_user]) - expect(described_class.new(token, request: request).include_any_scope?([{ name: :api, if: ->(_) { false } }])).to be(false) - end + expect(described_class.new(token, request: request).include_any_scope?([{ name: :api, if: ->(_) { false } }])).to be(false) + end - it "does not ignore scopes whose `if` condition is not set" do - token = double("token", scopes: [:api, :read_user]) + it "does not ignore scopes whose `if` condition is not set" do + token = double("token", scopes: [:api, :read_user]) - expect(described_class.new(token, request: request).include_any_scope?([{ name: :api, if: ->(_) { false } }, { name: :read_user }])).to be(true) - end + expect(described_class.new(token, request: request).include_any_scope?([{ name: :api, if: ->(_) { false } }, { name: :read_user }])).to be(true) + end - it "does not ignore scopes whose `if` condition returns true" do - token = double("token", scopes: [:api, :read_user]) + it "does not ignore scopes whose `if` condition returns true" do + token = double("token", scopes: [:api, :read_user]) - expect(described_class.new(token, request: request).include_any_scope?([{ name: :api, if: ->(_) { true } }, { name: :read_user, if: ->(_) { false } }])).to be(true) - end + expect(described_class.new(token, request: request).include_any_scope?([{ name: :api, if: ->(_) { true } }, { name: :read_user, if: ->(_) { false } }])).to be(true) end end end -- cgit v1.2.3 From c1fcd730cc9dbee5b41ce2a6a12f8d84416b1a4a Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Mon, 26 Jun 2017 04:14:10 +0000 Subject: Implement review comments from @DouweM for !12300. - Use a struct for scopes, so we can call `scope.if` instead of `scope[:if]` - Refactor the "remove scopes whose :if condition returns false" logic to use a `select` rather than a `reject`. --- .../access_token_validation_service_spec.rb | 31 +++++++++++++++------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'spec') diff --git a/spec/services/access_token_validation_service_spec.rb b/spec/services/access_token_validation_service_spec.rb index c8189aa14d8..279f4ed93ac 100644 --- a/spec/services/access_token_validation_service_spec.rb +++ b/spec/services/access_token_validation_service_spec.rb @@ -1,62 +1,75 @@ require 'spec_helper' describe AccessTokenValidationService, services: true do + def scope(data) + OpenStruct.new(data) + end + describe ".include_any_scope?" do let(:request) { double("request") } it "returns true if the required scope is present in the token's scopes" do token = double("token", scopes: [:api, :read_user]) + scopes = [scope({ name: :api })] - expect(described_class.new(token, request: request).include_any_scope?([{ name: :api }])).to be(true) + expect(described_class.new(token, request: request).include_any_scope?(scopes)).to be(true) end it "returns true if more than one of the required scopes is present in the token's scopes" do token = double("token", scopes: [:api, :read_user, :other_scope]) + scopes = [scope({ name: :api }), scope({ name: :other_scope })] - expect(described_class.new(token, request: request).include_any_scope?([{ name: :api }, { name: :other_scope }])).to be(true) + expect(described_class.new(token, request: request).include_any_scope?(scopes)).to be(true) end it "returns true if the list of required scopes is an exact match for the token's scopes" do token = double("token", scopes: [:api, :read_user, :other_scope]) + scopes = [scope({ name: :api }), scope({ name: :read_user }), scope({ name: :other_scope })] - expect(described_class.new(token, request: request).include_any_scope?([{ name: :api }, { name: :read_user }, { name: :other_scope }])).to be(true) + expect(described_class.new(token, request: request).include_any_scope?(scopes)).to be(true) end it "returns true if the list of required scopes contains all of the token's scopes, in addition to others" do token = double("token", scopes: [:api, :read_user]) + scopes = [scope({ name: :api }), scope({ name: :read_user }), scope({ name: :other_scope })] - expect(described_class.new(token, request: request).include_any_scope?([{ name: :api }, { name: :read_user }, { name: :other_scope }])).to be(true) + expect(described_class.new(token, request: request).include_any_scope?(scopes)).to be(true) end it 'returns true if the list of required scopes is blank' do token = double("token", scopes: []) + scopes = [] - expect(described_class.new(token, request: request).include_any_scope?([])).to be(true) + expect(described_class.new(token, request: request).include_any_scope?(scopes)).to be(true) end it "returns false if there are no scopes in common between the required scopes and the token scopes" do token = double("token", scopes: [:api, :read_user]) + scopes = [scope({ name: :other_scope })] - expect(described_class.new(token, request: request).include_any_scope?([{ name: :other_scope }])).to be(false) + expect(described_class.new(token, request: request).include_any_scope?(scopes)).to be(false) end context "conditions" do it "ignores any scopes whose `if` condition returns false" do token = double("token", scopes: [:api, :read_user]) + scopes = [scope({ name: :api, if: ->(_) { false } })] - expect(described_class.new(token, request: request).include_any_scope?([{ name: :api, if: ->(_) { false } }])).to be(false) + expect(described_class.new(token, request: request).include_any_scope?(scopes)).to be(false) end it "does not ignore scopes whose `if` condition is not set" do token = double("token", scopes: [:api, :read_user]) + scopes = [scope({ name: :api, if: ->(_) { false } }), scope({ name: :read_user })] - expect(described_class.new(token, request: request).include_any_scope?([{ name: :api, if: ->(_) { false } }, { name: :read_user }])).to be(true) + expect(described_class.new(token, request: request).include_any_scope?(scopes)).to be(true) end it "does not ignore scopes whose `if` condition returns true" do token = double("token", scopes: [:api, :read_user]) + scopes = [scope({ name: :api, if: ->(_) { true } }), scope({ name: :read_user, if: ->(_) { false } })] - expect(described_class.new(token, request: request).include_any_scope?([{ name: :api, if: ->(_) { true } }, { name: :read_user, if: ->(_) { false } }])).to be(true) + expect(described_class.new(token, request: request).include_any_scope?(scopes)).to be(true) end end end -- cgit v1.2.3 From 468e8b55585d54b1f92f647e8a1932f22610889e Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Wed, 28 Jun 2017 18:17:53 +0800 Subject: Fix doc, test, and form --- spec/lib/gitlab/import_export/safe_model_attributes.yml | 1 + 1 file changed, 1 insertion(+) (limited to 'spec') diff --git a/spec/lib/gitlab/import_export/safe_model_attributes.yml b/spec/lib/gitlab/import_export/safe_model_attributes.yml index fadd3ad1330..f782cf533e8 100644 --- a/spec/lib/gitlab/import_export/safe_model_attributes.yml +++ b/spec/lib/gitlab/import_export/safe_model_attributes.yml @@ -383,6 +383,7 @@ Project: - printing_merge_request_link_enabled - build_allow_git_fetch - last_repository_updated_at +- ci_config_file Author: - name ProjectFeature: -- cgit v1.2.3 From 0d5e6536e7c18d839b1c1da0807aa90ba5be3e06 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Wed, 28 Jun 2017 18:29:14 +0800 Subject: Fix the test and implement missing update --- spec/models/ci/pipeline_spec.rb | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'spec') diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index 8fb6759d3ab..fef40874d95 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -744,31 +744,45 @@ describe Ci::Pipeline, models: true do describe 'yaml config file resolution' do let(:project) { FactoryGirl.build(:project) } - let(:pipeline) { create(:ci_empty_pipeline, project: project) } + it 'uses custom ci config file path when present' do allow(project).to receive(:ci_config_file) { 'custom/path' } + expect(pipeline.ci_yaml_file_path).to eq('custom/path/.gitlab-ci.yml') end + it 'uses root when custom path is nil' do allow(project).to receive(:ci_config_file) { nil } + expect(pipeline.ci_yaml_file_path).to eq('.gitlab-ci.yml') end + it 'uses root when custom path is empty' do allow(project).to receive(:ci_config_file) { '' } + expect(pipeline.ci_yaml_file_path).to eq('.gitlab-ci.yml') end + it 'allows custom filename' do allow(project).to receive(:ci_config_file) { 'custom/path/.my-config.yml' } + expect(pipeline.ci_yaml_file_path).to eq('custom/path/.my-config.yml') end + it 'custom filename must be yml' do allow(project).to receive(:ci_config_file) { 'custom/path/.my-config.cnf' } + expect(pipeline.ci_yaml_file_path).to eq('custom/path/.my-config.cnf/.gitlab-ci.yml') end + it 'reports error if the file is not found' do + allow(project).to receive(:ci_config_file) { 'custom' } + pipeline.ci_yaml_file - expect(pipeline.yaml_errors).to eq('Failed to load CI config file') + + expect(pipeline.yaml_errors) + .to eq('Failed to load CI/CD config file at custom/.gitlab-ci.yml') end end -- cgit v1.2.3 From 289fae78e971e117e69fb87602f5f6284419b863 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Wed, 28 Jun 2017 19:29:56 +0200 Subject: Rename flipper_group to feature_group MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- spec/requests/api/features_spec.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'spec') diff --git a/spec/requests/api/features_spec.rb b/spec/requests/api/features_spec.rb index 0ee0749c7a1..1d8aaeea8f2 100644 --- a/spec/requests/api/features_spec.rb +++ b/spec/requests/api/features_spec.rb @@ -88,8 +88,8 @@ describe API::Features do 'gates' => [{ 'key' => 'boolean', 'value' => true }]) end - it 'creates an enabled feature for the given Flipper group when passed flipper_group=perf_team' do - post api("/features/#{feature_name}", admin), value: 'true', flipper_group: 'perf_team' + it 'creates an enabled feature for the given Flipper group when passed feature_group=perf_team' do + post api("/features/#{feature_name}", admin), value: 'true', feature_group: 'perf_team' expect(response).to have_http_status(201) expect(json_response).to eq( @@ -147,8 +147,8 @@ describe API::Features do 'gates' => [{ 'key' => 'boolean', 'value' => true }]) end - it 'enables the feature for the given Flipper group when passed flipper_group=perf_team' do - post api("/features/#{feature_name}", admin), value: 'true', flipper_group: 'perf_team' + it 'enables the feature for the given Flipper group when passed feature_group=perf_team' do + post api("/features/#{feature_name}", admin), value: 'true', feature_group: 'perf_team' expect(response).to have_http_status(201) expect(json_response).to eq( @@ -188,11 +188,11 @@ describe API::Features do 'gates' => [{ 'key' => 'boolean', 'value' => false }]) end - it 'disables the feature for the given Flipper group when passed flipper_group=perf_team' do + it 'disables the feature for the given Flipper group when passed feature_group=perf_team' do feature.enable(Feature.group(:perf_team)) expect(Feature.get(feature_name).enabled?(admin)).to be_truthy - post api("/features/#{feature_name}", admin), value: 'false', flipper_group: 'perf_team' + post api("/features/#{feature_name}", admin), value: 'false', feature_group: 'perf_team' expect(response).to have_http_status(201) expect(json_response).to eq( -- cgit v1.2.3 From f26d4778656c32f550391d1986c4af1ed150364d Mon Sep 17 00:00:00 2001 From: Mike Greiling Date: Mon, 26 Jun 2017 22:43:32 -0500 Subject: dynamically import emoji helpers for AwardsHandler class --- spec/javascripts/awards_handler_spec.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'spec') diff --git a/spec/javascripts/awards_handler_spec.js b/spec/javascripts/awards_handler_spec.js index 3fc03324d16..8e056882108 100644 --- a/spec/javascripts/awards_handler_spec.js +++ b/spec/javascripts/awards_handler_spec.js @@ -1,7 +1,7 @@ /* eslint-disable space-before-function-paren, no-var, one-var, one-var-declaration-per-line, no-unused-expressions, comma-dangle, new-parens, no-unused-vars, quotes, jasmine/no-spec-dupes, prefer-template, max-len */ import Cookies from 'js-cookie'; -import AwardsHandler from '~/awards_handler'; +import loadAwardsHandler from '~/awards_handler'; import '~/lib/utils/common_utils'; @@ -26,14 +26,13 @@ import '~/lib/utils/common_utils'; describe('AwardsHandler', function() { preloadFixtures('issues/issue_with_comment.html.raw'); - beforeEach(function() { + beforeEach(function(done) { loadFixtures('issues/issue_with_comment.html.raw'); - awardsHandler = new AwardsHandler; - spyOn(awardsHandler, 'postEmoji').and.callFake((function(_this) { - return function(button, url, emoji, cb) { - return cb(); - }; - })(this)); + loadAwardsHandler(true).then((obj) => { + awardsHandler = obj; + spyOn(awardsHandler, 'postEmoji').and.callFake((button, url, emoji, cb) => cb()); + done(); + }).catch(fail); let isEmojiMenuBuilt = false; openAndWaitForEmojiMenu = function() { -- cgit v1.2.3 From b8ec1f4201c74c500e4f7010b238c7920599da7a Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Wed, 28 Jun 2017 07:12:23 +0000 Subject: Extract a `Gitlab::Scope` class. - To represent an authorization scope, such as `api` or `read_user` - This is a better abstraction than the hash we were previously using. --- .../services/access_token_validation_service_spec.rb | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'spec') diff --git a/spec/services/access_token_validation_service_spec.rb b/spec/services/access_token_validation_service_spec.rb index 279f4ed93ac..660a05e0b6d 100644 --- a/spec/services/access_token_validation_service_spec.rb +++ b/spec/services/access_token_validation_service_spec.rb @@ -1,37 +1,33 @@ require 'spec_helper' describe AccessTokenValidationService, services: true do - def scope(data) - OpenStruct.new(data) - end - describe ".include_any_scope?" do let(:request) { double("request") } it "returns true if the required scope is present in the token's scopes" do token = double("token", scopes: [:api, :read_user]) - scopes = [scope({ name: :api })] + scopes = [API::Scope.new(:api)] expect(described_class.new(token, request: request).include_any_scope?(scopes)).to be(true) end it "returns true if more than one of the required scopes is present in the token's scopes" do token = double("token", scopes: [:api, :read_user, :other_scope]) - scopes = [scope({ name: :api }), scope({ name: :other_scope })] + scopes = [API::Scope.new(:api), API::Scope.new(:other_scope)] expect(described_class.new(token, request: request).include_any_scope?(scopes)).to be(true) end it "returns true if the list of required scopes is an exact match for the token's scopes" do token = double("token", scopes: [:api, :read_user, :other_scope]) - scopes = [scope({ name: :api }), scope({ name: :read_user }), scope({ name: :other_scope })] + scopes = [API::Scope.new(:api), API::Scope.new(:read_user), API::Scope.new(:other_scope)] expect(described_class.new(token, request: request).include_any_scope?(scopes)).to be(true) end it "returns true if the list of required scopes contains all of the token's scopes, in addition to others" do token = double("token", scopes: [:api, :read_user]) - scopes = [scope({ name: :api }), scope({ name: :read_user }), scope({ name: :other_scope })] + scopes = [API::Scope.new(:api), API::Scope.new(:read_user), API::Scope.new(:other_scope)] expect(described_class.new(token, request: request).include_any_scope?(scopes)).to be(true) end @@ -45,7 +41,7 @@ describe AccessTokenValidationService, services: true do it "returns false if there are no scopes in common between the required scopes and the token scopes" do token = double("token", scopes: [:api, :read_user]) - scopes = [scope({ name: :other_scope })] + scopes = [API::Scope.new(:other_scope)] expect(described_class.new(token, request: request).include_any_scope?(scopes)).to be(false) end @@ -53,21 +49,21 @@ describe AccessTokenValidationService, services: true do context "conditions" do it "ignores any scopes whose `if` condition returns false" do token = double("token", scopes: [:api, :read_user]) - scopes = [scope({ name: :api, if: ->(_) { false } })] + scopes = [API::Scope.new(:api, if: ->(_) { false })] expect(described_class.new(token, request: request).include_any_scope?(scopes)).to be(false) end it "does not ignore scopes whose `if` condition is not set" do token = double("token", scopes: [:api, :read_user]) - scopes = [scope({ name: :api, if: ->(_) { false } }), scope({ name: :read_user })] + scopes = [API::Scope.new(:api, if: ->(_) { false }), API::Scope.new(:read_user)] expect(described_class.new(token, request: request).include_any_scope?(scopes)).to be(true) end it "does not ignore scopes whose `if` condition returns true" do token = double("token", scopes: [:api, :read_user]) - scopes = [scope({ name: :api, if: ->(_) { true } }), scope({ name: :read_user, if: ->(_) { false } })] + scopes = [API::Scope.new(:api, if: ->(_) { true }), API::Scope.new(:read_user, if: ->(_) { false })] expect(described_class.new(token, request: request).include_any_scope?(scopes)).to be(true) end -- cgit v1.2.3 From af89b19d69c043b2e9d40ef260adf97e00d1f791 Mon Sep 17 00:00:00 2001 From: Alexander Randa Date: Thu, 29 Jun 2017 13:30:33 +0300 Subject: Replaces 'dashboard/new-project.feature' spinach with rspec --- spec/features/dashboard/projects_spec.rb | 16 ++++-- spec/features/projects/new_project_spec.rb | 89 +++++++++++++++++++++++------- 2 files changed, 81 insertions(+), 24 deletions(-) (limited to 'spec') diff --git a/spec/features/dashboard/projects_spec.rb b/spec/features/dashboard/projects_spec.rb index f29186f368d..e9ef5d7983a 100644 --- a/spec/features/dashboard/projects_spec.rb +++ b/spec/features/dashboard/projects_spec.rb @@ -1,8 +1,8 @@ require 'spec_helper' -RSpec.describe 'Dashboard Projects', feature: true do +feature 'Dashboard Projects' do let(:user) { create(:user) } - let(:project) { create(:project, name: "awesome stuff") } + let(:project) { create(:project, name: 'awesome stuff') } let(:project2) { create(:project, :public, name: 'Community project') } before do @@ -15,6 +15,14 @@ RSpec.describe 'Dashboard Projects', feature: true do expect(page).to have_content('awesome stuff') end + it 'shows "New project" button' do + visit dashboard_projects_path + + page.within '#content-body' do + expect(page).to have_link('New project') + end + end + context 'when last_repository_updated_at, last_activity_at and update_at are present' do it 'shows the last_repository_updated_at attribute as the update date' do project.update_attributes!(last_repository_updated_at: Time.now, last_activity_at: 1.hour.ago) @@ -47,8 +55,8 @@ RSpec.describe 'Dashboard Projects', feature: true do end end - describe "with a pipeline", redis: true do - let!(:pipeline) { create(:ci_pipeline, project: project, sha: project.commit.sha) } + describe 'with a pipeline', redis: true do + let(:pipeline) { create(:ci_pipeline, project: project, sha: project.commit.sha) } before do # Since the cache isn't updated when a new pipeline is created diff --git a/spec/features/projects/new_project_spec.rb b/spec/features/projects/new_project_spec.rb index 37d9a97033b..22fb1223739 100644 --- a/spec/features/projects/new_project_spec.rb +++ b/spec/features/projects/new_project_spec.rb @@ -1,13 +1,27 @@ -require "spec_helper" +require 'spec_helper' -feature "New project", feature: true do +feature 'New project' do let(:user) { create(:admin) } before do - gitlab_sign_in(user) + sign_in(user) end - context "Visibility level selector" do + it 'shows "New project" page' do + visit new_project_path + + expect(page).to have_content('Project path') + expect(page).to have_content('Project name') + + expect(page).to have_link('GitHub') + expect(page).to have_link('Bitbucket') + expect(page).to have_link('GitLab.com') + expect(page).to have_link('Google Code') + expect(page).to have_button('Repo by URL') + expect(page).to have_link('GitLab export') + end + + context 'Visibility level selector' do Gitlab::VisibilityLevel.options.each do |key, level| it "sets selector to #{key}" do stub_application_setting(default_project_visibility: level) @@ -28,20 +42,20 @@ feature "New project", feature: true do end end - context "Namespace selector" do - context "with user namespace" do + context 'Namespace selector' do + context 'with user namespace' do before do visit new_project_path end - it "selects the user namespace" do - namespace = find("#project_namespace_id") + it 'selects the user namespace' do + namespace = find('#project_namespace_id') expect(namespace.text).to eq user.username end end - context "with group namespace" do + context 'with group namespace' do let(:group) { create(:group, :private, owner: user) } before do @@ -49,13 +63,13 @@ feature "New project", feature: true do visit new_project_path(namespace_id: group.id) end - it "selects the group namespace" do - namespace = find("#project_namespace_id option[selected]") + it 'selects the group namespace' do + namespace = find('#project_namespace_id option[selected]') expect(namespace.text).to eq group.name end - context "on validation error" do + context 'on validation error' do before do fill_in('project_path', with: 'private-group-project') choose('Internal') @@ -64,15 +78,15 @@ feature "New project", feature: true do expect(page).to have_css '.project-edit-errors .alert.alert-danger' end - it "selects the group namespace" do - namespace = find("#project_namespace_id option[selected]") + it 'selects the group namespace' do + namespace = find('#project_namespace_id option[selected]') expect(namespace.text).to eq group.name end end end - context "with subgroup namespace" do + context 'with subgroup namespace' do let(:group) { create(:group, :private, owner: user) } let(:subgroup) { create(:group, parent: group) } @@ -81,8 +95,8 @@ feature "New project", feature: true do visit new_project_path(namespace_id: subgroup.id) end - it "selects the group namespace" do - namespace = find("#project_namespace_id option[selected]") + it 'selects the group namespace' do + namespace = find('#project_namespace_id option[selected]') expect(namespace.text).to eq subgroup.full_path end @@ -94,10 +108,45 @@ feature "New project", feature: true do visit new_project_path end - it 'does not autocomplete sensitive git repo URL' do - autocomplete = find('#project_import_url')['autocomplete'] + context 'from git repository url' do + before do + first('.import_git').click + end + + it 'does not autocomplete sensitive git repo URL' do + autocomplete = find('#project_import_url')['autocomplete'] + + expect(autocomplete).to eq('off') + end + + it 'shows import instructions' do + git_import_instructions = first('.js-toggle-content') - expect(autocomplete).to eq('off') + expect(git_import_instructions).to be_visible + expect(git_import_instructions).to have_content 'Git repository URL' + end + end + + context 'from GitHub' do + before do + first('.import_github').click + end + + it 'shows import instructions' do + expect(page).to have_content('Import Projects from GitHub') + expect(current_path).to eq new_import_github_path + end + end + + context 'from Google Code' do + before do + first('.import_google_code').click + end + + it 'shows import instructions' do + expect(page).to have_content('Import projects from Google Code') + expect(current_path).to eq new_import_google_code_path + end end end end -- cgit v1.2.3 From 2c74e73f6f994346192acb2e723b026c2ec55f8b Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Thu, 29 Jun 2017 22:25:31 +0800 Subject: We no longer test the presence of the key --- spec/models/ci/variable_spec.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'spec') diff --git a/spec/models/ci/variable_spec.rb b/spec/models/ci/variable_spec.rb index 77201c6f419..50f7c029af8 100644 --- a/spec/models/ci/variable_spec.rb +++ b/spec/models/ci/variable_spec.rb @@ -7,7 +7,6 @@ describe Ci::Variable, models: true do describe 'validations' do it { is_expected.to include_module(HasVariable) } - it { is_expected.to validate_presence_of(:key) } it { is_expected.to validate_uniqueness_of(:key).scoped_to(:project_id, :environment_scope) } it { is_expected.to validate_length_of(:key).is_at_most(255) } it { is_expected.to allow_value('foo').for(:key) } -- cgit v1.2.3 From a67bf93b78ce8aa0bc61aab5a2008983746d4a62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Fri, 16 Jun 2017 17:27:57 +0200 Subject: Fix the performance bar spec that was not asserting the right thing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- spec/features/user_can_display_performance_bar_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'spec') diff --git a/spec/features/user_can_display_performance_bar_spec.rb b/spec/features/user_can_display_performance_bar_spec.rb index 1bd7e038939..24fff1a3052 100644 --- a/spec/features/user_can_display_performance_bar_spec.rb +++ b/spec/features/user_can_display_performance_bar_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'User can display performacne bar', :js do +describe 'User can display performance bar', :js do shared_examples 'performance bar is disabled' do it 'does not show the performance bar by default' do expect(page).not_to have_css('#peek') @@ -27,8 +27,8 @@ describe 'User can display performacne bar', :js do find('body').native.send_keys('pb') end - it 'does not show the performance bar by default' do - expect(page).not_to have_css('#peek') + it 'shows the performance bar' do + expect(page).to have_css('#peek') end end end -- cgit v1.2.3 From fa93156528bca4306e040a1b73720b6411942fcf Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Fri, 23 Jun 2017 17:02:33 -0700 Subject: Defer project destroys within a namespace in Groups::DestroyService#async_execute Group#destroy would actually hard-delete all associated projects even though the acts_as_paranoia gem is used, preventing Projects::DestroyService from doing any work. We first noticed this while trying to log all projects deletion to the Geo log. --- spec/models/namespace_spec.rb | 11 ++++++ spec/services/groups/destroy_service_spec.rb | 52 +++++++++++++++++----------- 2 files changed, 43 insertions(+), 20 deletions(-) (limited to 'spec') diff --git a/spec/models/namespace_spec.rb b/spec/models/namespace_spec.rb index d4f898f6d9f..62c4ea01ce1 100644 --- a/spec/models/namespace_spec.rb +++ b/spec/models/namespace_spec.rb @@ -342,6 +342,17 @@ describe Namespace, models: true do end end + describe '#soft_delete_without_removing_associations' do + let(:project1) { create(:project_empty_repo, namespace: namespace) } + + it 'updates the deleted_at timestamp but preserves projects' do + namespace.soft_delete_without_removing_associations + + expect(Project.all).to include(project1) + expect(namespace.deleted_at).not_to be_nil + end + end + describe '#user_ids_for_project_authorizations' do it 'returns the user IDs for which to refresh authorizations' do expect(namespace.user_ids_for_project_authorizations) diff --git a/spec/services/groups/destroy_service_spec.rb b/spec/services/groups/destroy_service_spec.rb index a37257d1bf4..d59b37bee36 100644 --- a/spec/services/groups/destroy_service_spec.rb +++ b/spec/services/groups/destroy_service_spec.rb @@ -15,6 +15,14 @@ describe Groups::DestroyService, services: true do group.add_user(user, Gitlab::Access::OWNER) end + def destroy_group(group, user, async) + if async + Groups::DestroyService.new(group, user).async_execute + else + Groups::DestroyService.new(group, user).execute + end + end + shared_examples 'group destruction' do |async| context 'database records' do before do @@ -30,30 +38,14 @@ describe Groups::DestroyService, services: true do context 'file system' do context 'Sidekiq inline' do before do - # Run sidekiq immediatly to check that renamed dir will be removed + # Run sidekiq immediately to check that renamed dir will be removed Sidekiq::Testing.inline! { destroy_group(group, user, async) } end - it { expect(gitlab_shell.exists?(project.repository_storage_path, group.path)).to be_falsey } - it { expect(gitlab_shell.exists?(project.repository_storage_path, remove_path)).to be_falsey } - end - - context 'Sidekiq fake' do - before do - # Don't run sidekiq to check if renamed repository exists - Sidekiq::Testing.fake! { destroy_group(group, user, async) } + it 'verifies that paths have been deleted' do + expect(gitlab_shell.exists?(project.repository_storage_path, group.path)).to be_falsey + expect(gitlab_shell.exists?(project.repository_storage_path, remove_path)).to be_falsey end - - it { expect(gitlab_shell.exists?(project.repository_storage_path, group.path)).to be_falsey } - it { expect(gitlab_shell.exists?(project.repository_storage_path, remove_path)).to be_truthy } - end - end - - def destroy_group(group, user, async) - if async - Groups::DestroyService.new(group, user).async_execute - else - Groups::DestroyService.new(group, user).execute end end end @@ -61,6 +53,26 @@ describe Groups::DestroyService, services: true do describe 'asynchronous delete' do it_behaves_like 'group destruction', true + context 'Sidekiq fake' do + before do + # Don't run Sidekiq to verify that group and projects are not actually destroyed + Sidekiq::Testing.fake! { destroy_group(group, user, true) } + end + + after do + # Clean up stale directories + gitlab_shell.rm_namespace(project.repository_storage_path, group.path) + gitlab_shell.rm_namespace(project.repository_storage_path, remove_path) + end + + it 'verifies original paths and projects still exist' do + expect(gitlab_shell.exists?(project.repository_storage_path, group.path)).to be_truthy + expect(gitlab_shell.exists?(project.repository_storage_path, remove_path)).to be_falsey + expect(Project.unscoped.count).to eq(1) + expect(Group.unscoped.count).to eq(2) + end + end + context 'potential race conditions' do context "when the `GroupDestroyWorker` task runs immediately" do it "deletes the group" do -- cgit v1.2.3 From 81e9c2842574b10d694a8e29665c77fde7fd6ae5 Mon Sep 17 00:00:00 2001 From: Bryce Johnson Date: Mon, 12 Jun 2017 14:43:21 -0400 Subject: Render add-diff-note button with server. This commit moves the rendering of the button back to the server, and shows/hides it using opacity rather than display. It also removes the transform applied to the button on hover (scale). Previously, both of these factors automatically triggered a reflow, which creates a performance bottleneck on pages with larger DOM size. MR: !12103 --- spec/features/expand_collapse_diffs_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/features/expand_collapse_diffs_spec.rb b/spec/features/expand_collapse_diffs_spec.rb index ea749528c11..d492a15ea17 100644 --- a/spec/features/expand_collapse_diffs_spec.rb +++ b/spec/features/expand_collapse_diffs_spec.rb @@ -129,7 +129,7 @@ feature 'Expand and collapse diffs', js: true, feature: true do before do large_diff.find('.diff-line-num', match: :prefer_exact).hover - large_diff.find('.add-diff-note').click + large_diff.find('.add-diff-note', match: :prefer_exact).click large_diff.find('.note-textarea').send_keys comment_text large_diff.find_button('Comment').click wait_for_requests -- cgit v1.2.3 From 55c6be2fb08b53ddf98307c0cc4667b1385a2ced Mon Sep 17 00:00:00 2001 From: Taurie Davis Date: Thu, 29 Jun 2017 17:34:06 +0000 Subject: Clean up issuable lists --- spec/features/issues/filtered_search/filter_issues_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/features/issues/filtered_search/filter_issues_spec.rb b/spec/features/issues/filtered_search/filter_issues_spec.rb index 863f8f75cd8..4cb728cc82b 100644 --- a/spec/features/issues/filtered_search/filter_issues_spec.rb +++ b/spec/features/issues/filtered_search/filter_issues_spec.rb @@ -459,7 +459,7 @@ describe 'Filter issues', js: true, feature: true do context 'issue label clicked' do before do - find('.issues-list .issue .issue-info a .label', text: multiple_words_label.title).click + find('.issues-list .issue .issue-main-info .issuable-info a .label', text: multiple_words_label.title).click end it 'filters' do -- cgit v1.2.3 From a7335c1188d32edd58aebdb818dbf4c49899149b Mon Sep 17 00:00:00 2001 From: Jose Ivan Vargas Date: Wed, 28 Jun 2017 13:16:40 -0500 Subject: Refactored tests and added a breakpoint to the merge_request_tabs --- spec/features/issuables/user_sees_sidebar_spec.rb | 30 ++++++++++++++++++++++ spec/features/issues/issue_sidebar_spec.rb | 17 ------------ .../features/issuable_sidebar_shared_examples.rb | 9 +++++++ 3 files changed, 39 insertions(+), 17 deletions(-) create mode 100644 spec/features/issuables/user_sees_sidebar_spec.rb create mode 100644 spec/support/shared_examples/features/issuable_sidebar_shared_examples.rb (limited to 'spec') diff --git a/spec/features/issuables/user_sees_sidebar_spec.rb b/spec/features/issuables/user_sees_sidebar_spec.rb new file mode 100644 index 00000000000..4d7a7dc1806 --- /dev/null +++ b/spec/features/issuables/user_sees_sidebar_spec.rb @@ -0,0 +1,30 @@ +require 'rails_helper' + +describe 'Issue Sidebar on Mobile' do + include MobileHelpers + + let(:project) { create(:project, :public) } + let(:merge_request) { create(:merge_request, source_project: project) } + let(:issue) { create(:issue, project: project) } + let!(:user) { create(:user)} + + before do + sign_in(user) + end + + context 'mobile sidebar on merge requests', js: true do + before do + visit namespace_project_merge_request_path(merge_request.project.namespace, merge_request.project, merge_request) + end + + it_behaves_like "issue sidebar stays collapsed on mobile" + end + + context 'mobile sidebar on issues', js: true do + before do + visit namespace_project_issue_path(project.namespace, project, issue) + end + + it_behaves_like "issue sidebar stays collapsed on mobile" + end +end diff --git a/spec/features/issues/issue_sidebar_spec.rb b/spec/features/issues/issue_sidebar_spec.rb index cd06b5af675..09724781a27 100644 --- a/spec/features/issues/issue_sidebar_spec.rb +++ b/spec/features/issues/issue_sidebar_spec.rb @@ -6,7 +6,6 @@ feature 'Issue Sidebar', feature: true do let(:group) { create(:group, :nested) } let(:project) { create(:project, :public, namespace: group) } let(:issue) { create(:issue, project: project) } - let(:merge_request) { create(:merge_request, source_project: project) } let!(:user) { create(:user)} let!(:label) { create(:label, project: project, title: 'bug') } @@ -155,22 +154,6 @@ feature 'Issue Sidebar', feature: true do end end - context 'as a allowed mobile user', js: true do - before do - project.team << [user, :developer] - resize_screen_xs - end - - context 'mobile sidebar' do - it 'collapses the sidebar for small screens on an issue/merge_request' do - visit_issue(project, issue) - expect(page).not_to have_css('aside.right-sidebar.right-sidebar-collapsed') - visit namespace_project_merge_request_path(merge_request.project.namespace, merge_request.project, merge_request) - expect(page).not_to have_css('aside.right-sidebar.right-sidebar-collapsed') - end - end - end - context 'as a guest' do before do project.team << [user, :guest] diff --git a/spec/support/shared_examples/features/issuable_sidebar_shared_examples.rb b/spec/support/shared_examples/features/issuable_sidebar_shared_examples.rb new file mode 100644 index 00000000000..96c821b26f7 --- /dev/null +++ b/spec/support/shared_examples/features/issuable_sidebar_shared_examples.rb @@ -0,0 +1,9 @@ +shared_examples 'issue sidebar stays collapsed on mobile' do + before do + resize_screen_xs + end + + it 'keeps the sidebar collapsed' do + expect(page).not_to have_css('.right-sidebar.right-sidebar-collapsed') + end +end -- cgit v1.2.3 From f4e6aba1bbeca043a29b4903cef2f5b99a1faac3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Rodr=C3=ADguez?= Date: Thu, 29 Jun 2017 15:22:40 -0400 Subject: Set the GL_REPOSITORY env variable on Gitlab::Git::Hook --- .../projects/import_export/import_file_spec.rb | 2 +- spec/lib/gitlab/git/hook_spec.rb | 38 ++++++++++++++++------ .../lib/gitlab/import_export/repo_restorer_spec.rb | 2 +- spec/models/repository_spec.rb | 15 +++------ spec/services/git_hooks_service_spec.rb | 7 ++-- 5 files changed, 38 insertions(+), 26 deletions(-) (limited to 'spec') diff --git a/spec/features/projects/import_export/import_file_spec.rb b/spec/features/projects/import_export/import_file_spec.rb index a111aa87c52..3f8d2255298 100644 --- a/spec/features/projects/import_export/import_file_spec.rb +++ b/spec/features/projects/import_export/import_file_spec.rb @@ -98,6 +98,6 @@ feature 'Import/Export - project import integration test', feature: true, js: tr end def project_hook_exists?(project) - Gitlab::Git::Hook.new('post-receive', project.repository.path).exists? + Gitlab::Git::Hook.new('post-receive', project).exists? end end diff --git a/spec/lib/gitlab/git/hook_spec.rb b/spec/lib/gitlab/git/hook_spec.rb index 3f279c21865..73518656bde 100644 --- a/spec/lib/gitlab/git/hook_spec.rb +++ b/spec/lib/gitlab/git/hook_spec.rb @@ -4,18 +4,20 @@ require 'fileutils' describe Gitlab::Git::Hook, lib: true do describe "#trigger" do let(:project) { create(:project, :repository) } + let(:repo_path) { project.repository.path } let(:user) { create(:user) } + let(:gl_id) { Gitlab::GlId.gl_id(user) } def create_hook(name) - FileUtils.mkdir_p(File.join(project.repository.path, 'hooks')) - File.open(File.join(project.repository.path, 'hooks', name), 'w', 0755) do |f| + FileUtils.mkdir_p(File.join(repo_path, 'hooks')) + File.open(File.join(repo_path, 'hooks', name), 'w', 0755) do |f| f.write('exit 0') end end def create_failing_hook(name) - FileUtils.mkdir_p(File.join(project.repository.path, 'hooks')) - File.open(File.join(project.repository.path, 'hooks', name), 'w', 0755) do |f| + FileUtils.mkdir_p(File.join(repo_path, 'hooks')) + File.open(File.join(repo_path, 'hooks', name), 'w', 0755) do |f| f.write(<<-HOOK) echo 'regular message from the hook' echo 'error message from the hook' 1>&2 @@ -27,13 +29,29 @@ describe Gitlab::Git::Hook, lib: true do ['pre-receive', 'post-receive', 'update'].each do |hook_name| context "when triggering a #{hook_name} hook" do context "when the hook is successful" do + let(:hook_path) { File.join(repo_path, 'hooks', hook_name) } + let(:gl_repository) { Gitlab::GlRepository.gl_repository(project, false) } + let(:env) do + { + 'GL_ID' => gl_id, + 'PWD' => repo_path, + 'GL_PROTOCOL' => 'web', + 'GL_REPOSITORY' => gl_repository + } + end + it "returns success with no errors" do create_hook(hook_name) - hook = Gitlab::Git::Hook.new(hook_name, project.repository.path) + hook = Gitlab::Git::Hook.new(hook_name, project) blank = Gitlab::Git::BLANK_SHA ref = Gitlab::Git::BRANCH_REF_PREFIX + 'new_branch' - status, errors = hook.trigger(Gitlab::GlId.gl_id(user), blank, blank, ref) + if hook_name != 'update' + expect(Open3).to receive(:popen3) + .with(env, hook_path, chdir: repo_path).and_call_original + end + + status, errors = hook.trigger(gl_id, blank, blank, ref) expect(status).to be true expect(errors).to be_blank end @@ -42,11 +60,11 @@ describe Gitlab::Git::Hook, lib: true do context "when the hook is unsuccessful" do it "returns failure with errors" do create_failing_hook(hook_name) - hook = Gitlab::Git::Hook.new(hook_name, project.repository.path) + hook = Gitlab::Git::Hook.new(hook_name, project) blank = Gitlab::Git::BLANK_SHA ref = Gitlab::Git::BRANCH_REF_PREFIX + 'new_branch' - status, errors = hook.trigger(Gitlab::GlId.gl_id(user), blank, blank, ref) + status, errors = hook.trigger(gl_id, blank, blank, ref) expect(status).to be false expect(errors).to eq("error message from the hook\n") end @@ -56,11 +74,11 @@ describe Gitlab::Git::Hook, lib: true do context "when the hook doesn't exist" do it "returns success with no errors" do - hook = Gitlab::Git::Hook.new('unknown_hook', project.repository.path) + hook = Gitlab::Git::Hook.new('unknown_hook', project) blank = Gitlab::Git::BLANK_SHA ref = Gitlab::Git::BRANCH_REF_PREFIX + 'new_branch' - status, errors = hook.trigger(Gitlab::GlId.gl_id(user), blank, blank, ref) + status, errors = hook.trigger(gl_id, blank, blank, ref) expect(status).to be true expect(errors).to be_nil end diff --git a/spec/lib/gitlab/import_export/repo_restorer_spec.rb b/spec/lib/gitlab/import_export/repo_restorer_spec.rb index 168a59e5139..30b6a0d8845 100644 --- a/spec/lib/gitlab/import_export/repo_restorer_spec.rb +++ b/spec/lib/gitlab/import_export/repo_restorer_spec.rb @@ -34,7 +34,7 @@ describe Gitlab::ImportExport::RepoRestorer, services: true do it 'has the webhooks' do restorer.restore - expect(Gitlab::Git::Hook.new('post-receive', project.repository.path_to_repo)).to exist + expect(Gitlab::Git::Hook.new('post-receive', project)).to exist end end end diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 3e984ec7588..c69f0a495db 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -780,7 +780,7 @@ describe Repository, models: true do context 'when pre hooks were successful' do it 'runs without errors' do expect_any_instance_of(GitHooksService).to receive(:execute) - .with(user, project.repository.path_to_repo, old_rev, blank_sha, 'refs/heads/feature') + .with(user, project, old_rev, blank_sha, 'refs/heads/feature') expect { repository.rm_branch(user, 'feature') }.not_to raise_error end @@ -823,12 +823,7 @@ describe Repository, models: true do service = GitHooksService.new expect(GitHooksService).to receive(:new).and_return(service) expect(service).to receive(:execute) - .with( - user, - repository.path_to_repo, - old_rev, - new_rev, - 'refs/heads/feature') + .with(user, project, old_rev, new_rev, 'refs/heads/feature') .and_yield(service).and_return(true) end @@ -1474,9 +1469,9 @@ describe Repository, models: true do it 'passes commit SHA to pre-receive and update hooks,\ and tag SHA to post-receive hook' do - pre_receive_hook = Gitlab::Git::Hook.new('pre-receive', repository.path_to_repo) - update_hook = Gitlab::Git::Hook.new('update', repository.path_to_repo) - post_receive_hook = Gitlab::Git::Hook.new('post-receive', repository.path_to_repo) + pre_receive_hook = Gitlab::Git::Hook.new('pre-receive', project) + update_hook = Gitlab::Git::Hook.new('update', project) + post_receive_hook = Gitlab::Git::Hook.new('post-receive', project) allow(Gitlab::Git::Hook).to receive(:new) .and_return(pre_receive_hook, update_hook, post_receive_hook) diff --git a/spec/services/git_hooks_service_spec.rb b/spec/services/git_hooks_service_spec.rb index ac7ccfbaab0..213678c27f5 100644 --- a/spec/services/git_hooks_service_spec.rb +++ b/spec/services/git_hooks_service_spec.rb @@ -12,7 +12,6 @@ describe GitHooksService, services: true do @oldrev = sample_commit.parent_id @newrev = sample_commit.id @ref = 'refs/heads/feature' - @repo_path = project.repository.path_to_repo end describe '#execute' do @@ -21,7 +20,7 @@ describe GitHooksService, services: true do hook = double(trigger: [true, nil]) expect(Gitlab::Git::Hook).to receive(:new).exactly(3).times.and_return(hook) - service.execute(user, @repo_path, @blankrev, @newrev, @ref) { } + service.execute(user, project, @blankrev, @newrev, @ref) { } end end @@ -31,7 +30,7 @@ describe GitHooksService, services: true do expect(service).not_to receive(:run_hook).with('post-receive') expect do - service.execute(user, @repo_path, @blankrev, @newrev, @ref) + service.execute(user, project, @blankrev, @newrev, @ref) end.to raise_error(GitHooksService::PreReceiveError) end end @@ -43,7 +42,7 @@ describe GitHooksService, services: true do expect(service).not_to receive(:run_hook).with('post-receive') expect do - service.execute(user, @repo_path, @blankrev, @newrev, @ref) + service.execute(user, project, @blankrev, @newrev, @ref) end.to raise_error(GitHooksService::PreReceiveError) end end -- cgit v1.2.3 From 2446252cfd1f5a7d7329099e8d6371fcffa99971 Mon Sep 17 00:00:00 2001 From: Douglas Barbosa Alexandre Date: Thu, 29 Jun 2017 18:53:32 -0300 Subject: Expires full_path cache after project is renamed --- spec/models/concerns/routable_spec.rb | 12 ++++++++++++ spec/models/project_spec.rb | 2 ++ 2 files changed, 14 insertions(+) (limited to 'spec') diff --git a/spec/models/concerns/routable_spec.rb b/spec/models/concerns/routable_spec.rb index 65f05121b40..be82a601b36 100644 --- a/spec/models/concerns/routable_spec.rb +++ b/spec/models/concerns/routable_spec.rb @@ -132,6 +132,18 @@ describe Group, 'Routable' do end end + describe '#expires_full_path_cache' do + context 'with RequestStore active', :request_store do + it 'expires the full_path cache' do + expect(group).to receive(:uncached_full_path).twice.and_call_original + + 3.times { group.full_path } + group.expires_full_path_cache + 3.times { group.full_path } + end + end + end + describe '#full_name' do let(:group) { create(:group) } let(:nested_group) { create(:group, parent: group) } diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 1390848ff4a..6ff4ec3d417 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -1216,6 +1216,8 @@ describe Project, models: true do expect(project).to receive(:expire_caches_before_rename) + expect(project).to receive(:expires_full_path_cache) + project.rename_repo end -- cgit v1.2.3 From b3b034b849800e71ce8872a6f4db8fb6b9b91b4e Mon Sep 17 00:00:00 2001 From: Douglas Barbosa Alexandre Date: Thu, 29 Jun 2017 19:11:33 -0300 Subject: Expires full_path cache after repository is transferred --- spec/services/projects/transfer_service_spec.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'spec') diff --git a/spec/services/projects/transfer_service_spec.rb b/spec/services/projects/transfer_service_spec.rb index 76c52d55ae5..441a5276c56 100644 --- a/spec/services/projects/transfer_service_spec.rb +++ b/spec/services/projects/transfer_service_spec.rb @@ -30,6 +30,12 @@ describe Projects::TransferService, services: true do transfer_project(project, user, group) end + it 'expires full_path cache' do + expect(project).to receive(:expires_full_path_cache) + + transfer_project(project, user, group) + end + it 'executes system hooks' do expect_any_instance_of(Projects::TransferService).to receive(:execute_system_hooks) -- cgit v1.2.3 From 553346a4f4ffff4ed8cfabc090529a02021f1ca4 Mon Sep 17 00:00:00 2001 From: Winnie Hellmann Date: Thu, 29 Jun 2017 22:31:58 +0000 Subject: Remove empty afterEach() from issue_show app_spec.js --- spec/javascripts/issue_show/components/app_spec.js | 3 --- 1 file changed, 3 deletions(-) (limited to 'spec') diff --git a/spec/javascripts/issue_show/components/app_spec.js b/spec/javascripts/issue_show/components/app_spec.js index 9df92318864..bc13373a27e 100644 --- a/spec/javascripts/issue_show/components/app_spec.js +++ b/spec/javascripts/issue_show/components/app_spec.js @@ -42,9 +42,6 @@ describe('Issuable output', () => { }).$mount(); }); - afterEach(() => { - }); - it('should render a title/description/edited and update title/description/edited on update', (done) => { vm.poll.options.successCallback({ json() { -- cgit v1.2.3 From 790c740cce8487d1155607355d06f42ee2e83fac Mon Sep 17 00:00:00 2001 From: Michael Kozono Date: Thu, 29 Jun 2017 10:54:10 -0700 Subject: Increase CI retries to 4 for these examples By default it is 2 tries in CI. --- spec/lib/gitlab/health_checks/fs_shards_check_spec.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'spec') diff --git a/spec/lib/gitlab/health_checks/fs_shards_check_spec.rb b/spec/lib/gitlab/health_checks/fs_shards_check_spec.rb index 61c10d47434..c8c402b4f71 100644 --- a/spec/lib/gitlab/health_checks/fs_shards_check_spec.rb +++ b/spec/lib/gitlab/health_checks/fs_shards_check_spec.rb @@ -97,6 +97,12 @@ describe Gitlab::HealthChecks::FsShardsCheck do }.with_indifferent_access end + # Unsolved intermittent failure in CI https://gitlab.com/gitlab-org/gitlab-ce/issues/31128 + around(:each) do |example| + times_to_try = ENV['CI'] ? 4 : 1 + example.run_with_retry retry: times_to_try + end + it { is_expected.to all(have_attributes(labels: { shard: :default })) } it { is_expected.to include(an_object_having_attributes(name: :filesystem_accessible, value: 0)) } -- cgit v1.2.3 From 53c409cb07d295043c5e1cff738c84b3aa7405a8 Mon Sep 17 00:00:00 2001 From: Michael Kozono Date: Thu, 29 Jun 2017 16:53:41 -0700 Subject: =?UTF-8?q?Rspec/AroundBlock=20doesn=E2=80=99t=20know=20about=20rs?= =?UTF-8?q?pec-retry?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/lib/gitlab/health_checks/fs_shards_check_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/lib/gitlab/health_checks/fs_shards_check_spec.rb b/spec/lib/gitlab/health_checks/fs_shards_check_spec.rb index c8c402b4f71..fbacbc4a338 100644 --- a/spec/lib/gitlab/health_checks/fs_shards_check_spec.rb +++ b/spec/lib/gitlab/health_checks/fs_shards_check_spec.rb @@ -98,7 +98,7 @@ describe Gitlab::HealthChecks::FsShardsCheck do end # Unsolved intermittent failure in CI https://gitlab.com/gitlab-org/gitlab-ce/issues/31128 - around(:each) do |example| + around(:each) do |example| # rubocop:disable RSpec/AroundBlock times_to_try = ENV['CI'] ? 4 : 1 example.run_with_retry retry: times_to_try end -- cgit v1.2.3 From 17ba052f5c9d7c390b350469d15ffc674a943b07 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Fri, 30 Jun 2017 15:23:46 +0800 Subject: Update wordings, allow only full path, add tests --- spec/models/ci/pipeline_spec.rb | 26 +++++++------------------- spec/models/project_spec.rb | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 19 deletions(-) (limited to 'spec') diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index 5ed02031708..8d4d87def5e 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -748,47 +748,35 @@ describe Ci::Pipeline, models: true do end end - describe 'yaml config file resolution' do - let(:project) { FactoryGirl.build(:project) } + describe '#ci_yaml_file_path' do + let(:project) { create(:empty_project) } let(:pipeline) { create(:ci_empty_pipeline, project: project) } - it 'uses custom ci config file path when present' do + it 'returns the path from project' do allow(project).to receive(:ci_config_file) { 'custom/path' } - expect(pipeline.ci_yaml_file_path).to eq('custom/path/.gitlab-ci.yml') + expect(pipeline.ci_yaml_file_path).to eq('custom/path') end - it 'uses root when custom path is nil' do + it 'returns default when custom path is nil' do allow(project).to receive(:ci_config_file) { nil } expect(pipeline.ci_yaml_file_path).to eq('.gitlab-ci.yml') end - it 'uses root when custom path is empty' do + it 'returns default when custom path is empty' do allow(project).to receive(:ci_config_file) { '' } expect(pipeline.ci_yaml_file_path).to eq('.gitlab-ci.yml') end - it 'allows custom filename' do - allow(project).to receive(:ci_config_file) { 'custom/path/.my-config.yml' } - - expect(pipeline.ci_yaml_file_path).to eq('custom/path/.my-config.yml') - end - - it 'custom filename must be yml' do - allow(project).to receive(:ci_config_file) { 'custom/path/.my-config.cnf' } - - expect(pipeline.ci_yaml_file_path).to eq('custom/path/.my-config.cnf/.gitlab-ci.yml') - end - it 'reports error if the file is not found' do allow(project).to receive(:ci_config_file) { 'custom' } pipeline.ci_yaml_file expect(pipeline.yaml_errors) - .to eq('Failed to load CI/CD config file at custom/.gitlab-ci.yml') + .to eq('Failed to load CI/CD config file at custom') end end diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index fb39357659c..349f9c3d7eb 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -144,6 +144,8 @@ describe Project, models: true do it { is_expected.to validate_length_of(:description).is_at_most(2000) } it { is_expected.to validate_length_of(:ci_config_file).is_at_most(255) } + it { is_expected.to allow_value('').for(:ci_config_file) } + it { is_expected.not_to allow_value('test/../foo').for(:ci_config_file) } it { is_expected.to validate_presence_of(:creator) } @@ -1491,6 +1493,28 @@ describe Project, models: true do end end + describe '#ci_config_file=' do + let(:project) { create(:empty_project) } + + it 'sets nil' do + project.update!(ci_config_file: nil) + + expect(project.ci_config_file).to be_nil + end + + it 'sets a string' do + project.update!(ci_config_file: 'foo/.gitlab_ci.yml') + + expect(project.ci_config_file).to eq('foo/.gitlab_ci.yml') + end + + it 'sets a string but remove all leading slashes' do + project.update!(ci_config_file: '///foo//.gitlab_ci.yml') + + expect(project.ci_config_file).to eq('foo//.gitlab_ci.yml') + end + end + describe 'Project import job' do let(:project) { create(:empty_project, import_url: generate(:url)) } -- cgit v1.2.3 From afbc7520c296196d0f3f95d4a24a9e42c0e41f3c Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Fri, 30 Jun 2017 07:32:25 +0000 Subject: `AccessTokenValidationService` accepts `String` or `API::Scope` scopes. - There's no need to use `API::Scope` for scopes that don't have `if` conditions, such as in `lib/gitlab/auth.rb`. --- spec/services/access_token_validation_service_spec.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'spec') diff --git a/spec/services/access_token_validation_service_spec.rb b/spec/services/access_token_validation_service_spec.rb index 660a05e0b6d..11225fad18a 100644 --- a/spec/services/access_token_validation_service_spec.rb +++ b/spec/services/access_token_validation_service_spec.rb @@ -6,28 +6,28 @@ describe AccessTokenValidationService, services: true do it "returns true if the required scope is present in the token's scopes" do token = double("token", scopes: [:api, :read_user]) - scopes = [API::Scope.new(:api)] + scopes = [:api] expect(described_class.new(token, request: request).include_any_scope?(scopes)).to be(true) end it "returns true if more than one of the required scopes is present in the token's scopes" do token = double("token", scopes: [:api, :read_user, :other_scope]) - scopes = [API::Scope.new(:api), API::Scope.new(:other_scope)] + scopes = [:api, :other_scope] expect(described_class.new(token, request: request).include_any_scope?(scopes)).to be(true) end it "returns true if the list of required scopes is an exact match for the token's scopes" do token = double("token", scopes: [:api, :read_user, :other_scope]) - scopes = [API::Scope.new(:api), API::Scope.new(:read_user), API::Scope.new(:other_scope)] + scopes = [:api, :read_user, :other_scope] expect(described_class.new(token, request: request).include_any_scope?(scopes)).to be(true) end it "returns true if the list of required scopes contains all of the token's scopes, in addition to others" do token = double("token", scopes: [:api, :read_user]) - scopes = [API::Scope.new(:api), API::Scope.new(:read_user), API::Scope.new(:other_scope)] + scopes = [:api, :read_user, :other_scope] expect(described_class.new(token, request: request).include_any_scope?(scopes)).to be(true) end @@ -41,7 +41,7 @@ describe AccessTokenValidationService, services: true do it "returns false if there are no scopes in common between the required scopes and the token scopes" do token = double("token", scopes: [:api, :read_user]) - scopes = [API::Scope.new(:other_scope)] + scopes = [:other_scope] expect(described_class.new(token, request: request).include_any_scope?(scopes)).to be(false) end @@ -56,7 +56,7 @@ describe AccessTokenValidationService, services: true do it "does not ignore scopes whose `if` condition is not set" do token = double("token", scopes: [:api, :read_user]) - scopes = [API::Scope.new(:api, if: ->(_) { false }), API::Scope.new(:read_user)] + scopes = [API::Scope.new(:api, if: ->(_) { false }), :read_user] expect(described_class.new(token, request: request).include_any_scope?(scopes)).to be(true) end -- cgit v1.2.3 From 057c3c4e31df9dc8b1866b185dbf6d89e2751e3c Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Fri, 30 Jun 2017 16:14:48 +0800 Subject: Introduce CI_CONFIG_PATH --- spec/models/ci/build_spec.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'spec') diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 488697f74eb..e5fd549f0d7 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -1179,6 +1179,7 @@ describe Ci::Build, :models do { key: 'CI_PROJECT_NAMESPACE', value: project.namespace.full_path, public: true }, { key: 'CI_PROJECT_URL', value: project.web_url, public: true }, { key: 'CI_PIPELINE_ID', value: pipeline.id.to_s, public: true }, + { key: 'CI_CONFIG_PATH', value: pipeline.ci_yaml_file_path, 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 } @@ -1469,6 +1470,16 @@ describe Ci::Build, :models do it { is_expected.to include(deployment_variable) } end + context 'when project has custom CI config path' do + let(:ci_config_path) { { key: 'CI_CONFIG_PATH', value: 'custom', public: true } } + + before do + project.update(ci_config_file: 'custom') + end + + it { is_expected.to include(ci_config_path) } + end + context 'returns variables in valid order' do let(:build_pre_var) { { key: 'build', value: 'value' } } let(:project_pre_var) { { key: 'project', value: 'value' } } -- cgit v1.2.3 From 42ccb5981a8425216f9d69372754c52510f0cade Mon Sep 17 00:00:00 2001 From: Sean McGivern Date: Tue, 20 Jun 2017 16:38:14 +0100 Subject: Only do complicated confidentiality checks when necessary When we are filtering by a single project, and the current user has access to see confidential issues on that project, we don't need to filter by confidentiality at all - just as if the user were an admin. The filter by confidentiality often picks a non-optimal query plan: for instance, AND-ing the results of all issues in the project (a relatively small set), and all issues in the states requested (a huge set), rather than just starting small and winnowing further. --- spec/finders/issues_finder_spec.rb | 125 +++++++++++++++++++++++++++++++++---- 1 file changed, 112 insertions(+), 13 deletions(-) (limited to 'spec') diff --git a/spec/finders/issues_finder_spec.rb b/spec/finders/issues_finder_spec.rb index 8ace1fb5751..dfa15e859a4 100644 --- a/spec/finders/issues_finder_spec.rb +++ b/spec/finders/issues_finder_spec.rb @@ -295,22 +295,121 @@ describe IssuesFinder do end end - describe '.not_restricted_by_confidentiality' do - let(:authorized_user) { create(:user) } - let(:project) { create(:empty_project, namespace: authorized_user.namespace) } - let!(:public_issue) { create(:issue, project: project) } - let!(:confidential_issue) { create(:issue, project: project, confidential: true) } - - it 'returns non confidential issues for nil user' do - expect(described_class.send(:not_restricted_by_confidentiality, nil)).to include(public_issue) - end + describe '#not_restricted_by_confidentiality' do + let(:guest) { create(:user) } + set(:authorized_user) { create(:user) } + set(:project) { create(:empty_project, namespace: authorized_user.namespace) } + set(:public_issue) { create(:issue, project: project) } + set(:confidential_issue) { create(:issue, project: project, confidential: true) } + + context 'when no project filter is given' do + let(:params) { {} } + + context 'for an anonymous user' do + subject { described_class.new(nil, params).not_restricted_by_confidentiality } + + it 'returns only public issues' do + expect(subject).to include(public_issue) + expect(subject).not_to include(confidential_issue) + end + end + + context 'for a user without project membership' do + subject { described_class.new(user, params).not_restricted_by_confidentiality } + + it 'returns only public issues' do + expect(subject).to include(public_issue) + expect(subject).not_to include(confidential_issue) + end + end + + context 'for a guest user' do + subject { described_class.new(guest, params).not_restricted_by_confidentiality } + + before do + project.add_guest(guest) + end + + it 'returns only public issues' do + expect(subject).to include(public_issue) + expect(subject).not_to include(confidential_issue) + end + end + + context 'for a project member with access to view confidential issues' do + subject { described_class.new(authorized_user, params).not_restricted_by_confidentiality } - it 'returns non confidential issues for user not authorized for the issues projects' do - expect(described_class.send(:not_restricted_by_confidentiality, user)).to include(public_issue) + it 'returns all issues' do + expect(subject).to include(public_issue, confidential_issue) + end + end end - it 'returns all issues for user authorized for the issues projects' do - expect(described_class.send(:not_restricted_by_confidentiality, authorized_user)).to include(public_issue, confidential_issue) + context 'when searching within a specific project' do + let(:params) { { project_id: project.id } } + + context 'for an anonymous user' do + subject { described_class.new(nil, params).not_restricted_by_confidentiality } + + it 'returns only public issues' do + expect(subject).to include(public_issue) + expect(subject).not_to include(confidential_issue) + end + + it 'does not filter by confidentiality' do + expect(Issue).not_to receive(:where).with(a_string_matching('confidential'), anything) + + subject + end + end + + context 'for a user without project membership' do + subject { described_class.new(user, params).not_restricted_by_confidentiality } + + it 'returns only public issues' do + expect(subject).to include(public_issue) + expect(subject).not_to include(confidential_issue) + end + + it 'filters by confidentiality' do + expect(Issue).to receive(:where).with(a_string_matching('confidential'), anything) + + subject + end + end + + context 'for a guest user' do + subject { described_class.new(guest, params).not_restricted_by_confidentiality } + + before do + project.add_guest(guest) + end + + it 'returns only public issues' do + expect(subject).to include(public_issue) + expect(subject).not_to include(confidential_issue) + end + + it 'filters by confidentiality' do + expect(Issue).to receive(:where).with(a_string_matching('confidential'), anything) + + subject + end + end + + context 'for a project member with access to view confidential issues' do + subject { described_class.new(authorized_user, params).not_restricted_by_confidentiality } + + it 'returns all issues' do + expect(subject).to include(public_issue, confidential_issue) + end + + it 'does not filter by confidentiality' do + expect(Issue).not_to receive(:where).with(a_string_matching('confidential'), anything) + + subject + end + end end end end -- cgit v1.2.3 From 20bb678d91715817f3da04c7a1b73db84295accd Mon Sep 17 00:00:00 2001 From: Sean McGivern Date: Thu, 22 Jun 2017 20:58:20 +0100 Subject: Cache total issue / MR counts for project by user type This runs a slightly slower query to get the issue and MR counts in the navigation, but caches by user type (can see all / none confidential issues) for two minutes. --- spec/helpers/issuables_helper_spec.rb | 49 ++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 6 deletions(-) (limited to 'spec') diff --git a/spec/helpers/issuables_helper_spec.rb b/spec/helpers/issuables_helper_spec.rb index 15cb620199d..7dfda388de4 100644 --- a/spec/helpers/issuables_helper_spec.rb +++ b/spec/helpers/issuables_helper_spec.rb @@ -77,20 +77,58 @@ describe IssuablesHelper do }.with_indifferent_access end + let(:finder) { double(:finder, user_cannot_see_confidential_issues?: true, user_can_see_all_confidential_issues?: false) } + + before do + allow(helper).to receive(:issues_finder).and_return(finder) + allow(helper).to receive(:merge_requests_finder).and_return(finder) + end + it 'returns the cached value when called for the same issuable type & with the same params' do expect(helper).to receive(:params).twice.and_return(params) - expect(helper).to receive(:issuables_count_for_state).with(:issues, :opened).and_return(42) + expect(finder).to receive(:count_by_state).and_return(opened: 42) expect(helper.issuables_state_counter_text(:issues, :opened)) .to eq('Open 42') - expect(helper).not_to receive(:issuables_count_for_state) + expect(finder).not_to receive(:count_by_state) expect(helper.issuables_state_counter_text(:issues, :opened)) .to eq('Open 42') end + it 'takes confidential status into account when searching for issues' do + allow(helper).to receive(:params).and_return(params) + expect(finder).to receive(:count_by_state).and_return(opened: 42) + + expect(helper.issuables_state_counter_text(:issues, :opened)) + .to include('42') + + expect(finder).to receive(:user_cannot_see_confidential_issues?).and_return(false) + expect(finder).to receive(:count_by_state).and_return(opened: 40) + + expect(helper.issuables_state_counter_text(:issues, :opened)) + .to include('40') + + expect(finder).to receive(:user_can_see_all_confidential_issues?).and_return(true) + expect(finder).to receive(:count_by_state).and_return(opened: 45) + + expect(helper.issuables_state_counter_text(:issues, :opened)) + .to include('45') + end + + it 'does not take confidential status into account when searching for merge requests' do + allow(helper).to receive(:params).and_return(params) + expect(finder).to receive(:count_by_state).and_return(opened: 42) + expect(finder).not_to receive(:user_cannot_see_confidential_issues?) + expect(finder).not_to receive(:user_can_see_all_confidential_issues?) + + expect(helper.issuables_state_counter_text(:merge_requests, :opened)) + .to include('42') + end + it 'does not take some keys into account in the cache key' do + expect(finder).to receive(:count_by_state).and_return(opened: 42) expect(helper).to receive(:params).and_return({ author_id: '11', state: 'foo', @@ -98,11 +136,11 @@ describe IssuablesHelper do utf8: 'foo', page: 'foo' }.with_indifferent_access) - expect(helper).to receive(:issuables_count_for_state).with(:issues, :opened).and_return(42) expect(helper.issuables_state_counter_text(:issues, :opened)) .to eq('Open 42') + expect(finder).not_to receive(:count_by_state) expect(helper).to receive(:params).and_return({ author_id: '11', state: 'bar', @@ -110,7 +148,6 @@ describe IssuablesHelper do utf8: 'bar', page: 'bar' }.with_indifferent_access) - expect(helper).not_to receive(:issuables_count_for_state) expect(helper.issuables_state_counter_text(:issues, :opened)) .to eq('Open 42') @@ -118,13 +155,13 @@ describe IssuablesHelper do it 'does not take params order into account in the cache key' do expect(helper).to receive(:params).and_return('author_id' => '11', 'state' => 'opened') - expect(helper).to receive(:issuables_count_for_state).with(:issues, :opened).and_return(42) + expect(finder).to receive(:count_by_state).and_return(opened: 42) expect(helper.issuables_state_counter_text(:issues, :opened)) .to eq('Open 42') expect(helper).to receive(:params).and_return('state' => 'opened', 'author_id' => '11') - expect(helper).not_to receive(:issuables_count_for_state) + expect(finder).not_to receive(:count_by_state) expect(helper.issuables_state_counter_text(:issues, :opened)) .to eq('Open 42') -- cgit v1.2.3 From 0c6cdd07829668e04012219eb21cc60db8c1eabc Mon Sep 17 00:00:00 2001 From: Sean McGivern Date: Thu, 29 Jun 2017 12:43:56 +0100 Subject: Make finders responsible for counter cache keys --- spec/finders/issues_finder_spec.rb | 18 +++++++------- spec/helpers/issuables_helper_spec.rb | 46 +++++++++++++++++------------------ 2 files changed, 31 insertions(+), 33 deletions(-) (limited to 'spec') diff --git a/spec/finders/issues_finder_spec.rb b/spec/finders/issues_finder_spec.rb index dfa15e859a4..4a52f0d5c58 100644 --- a/spec/finders/issues_finder_spec.rb +++ b/spec/finders/issues_finder_spec.rb @@ -295,7 +295,7 @@ describe IssuesFinder do end end - describe '#not_restricted_by_confidentiality' do + describe '#with_confidentiality_access_check' do let(:guest) { create(:user) } set(:authorized_user) { create(:user) } set(:project) { create(:empty_project, namespace: authorized_user.namespace) } @@ -306,7 +306,7 @@ describe IssuesFinder do let(:params) { {} } context 'for an anonymous user' do - subject { described_class.new(nil, params).not_restricted_by_confidentiality } + subject { described_class.new(nil, params).with_confidentiality_access_check } it 'returns only public issues' do expect(subject).to include(public_issue) @@ -315,7 +315,7 @@ describe IssuesFinder do end context 'for a user without project membership' do - subject { described_class.new(user, params).not_restricted_by_confidentiality } + subject { described_class.new(user, params).with_confidentiality_access_check } it 'returns only public issues' do expect(subject).to include(public_issue) @@ -324,7 +324,7 @@ describe IssuesFinder do end context 'for a guest user' do - subject { described_class.new(guest, params).not_restricted_by_confidentiality } + subject { described_class.new(guest, params).with_confidentiality_access_check } before do project.add_guest(guest) @@ -337,7 +337,7 @@ describe IssuesFinder do end context 'for a project member with access to view confidential issues' do - subject { described_class.new(authorized_user, params).not_restricted_by_confidentiality } + subject { described_class.new(authorized_user, params).with_confidentiality_access_check } it 'returns all issues' do expect(subject).to include(public_issue, confidential_issue) @@ -349,7 +349,7 @@ describe IssuesFinder do let(:params) { { project_id: project.id } } context 'for an anonymous user' do - subject { described_class.new(nil, params).not_restricted_by_confidentiality } + subject { described_class.new(nil, params).with_confidentiality_access_check } it 'returns only public issues' do expect(subject).to include(public_issue) @@ -364,7 +364,7 @@ describe IssuesFinder do end context 'for a user without project membership' do - subject { described_class.new(user, params).not_restricted_by_confidentiality } + subject { described_class.new(user, params).with_confidentiality_access_check } it 'returns only public issues' do expect(subject).to include(public_issue) @@ -379,7 +379,7 @@ describe IssuesFinder do end context 'for a guest user' do - subject { described_class.new(guest, params).not_restricted_by_confidentiality } + subject { described_class.new(guest, params).with_confidentiality_access_check } before do project.add_guest(guest) @@ -398,7 +398,7 @@ describe IssuesFinder do end context 'for a project member with access to view confidential issues' do - subject { described_class.new(authorized_user, params).not_restricted_by_confidentiality } + subject { described_class.new(authorized_user, params).with_confidentiality_access_check } it 'returns all issues' do expect(subject).to include(public_issue, confidential_issue) diff --git a/spec/helpers/issuables_helper_spec.rb b/spec/helpers/issuables_helper_spec.rb index 7dfda388de4..d2e918ef014 100644 --- a/spec/helpers/issuables_helper_spec.rb +++ b/spec/helpers/issuables_helper_spec.rb @@ -77,59 +77,57 @@ describe IssuablesHelper do }.with_indifferent_access end - let(:finder) { double(:finder, user_cannot_see_confidential_issues?: true, user_can_see_all_confidential_issues?: false) } + let(:issues_finder) { IssuesFinder.new(nil, params) } + let(:merge_requests_finder) { MergeRequestsFinder.new(nil, params) } before do - allow(helper).to receive(:issues_finder).and_return(finder) - allow(helper).to receive(:merge_requests_finder).and_return(finder) + allow(helper).to receive(:issues_finder).and_return(issues_finder) + allow(helper).to receive(:merge_requests_finder).and_return(merge_requests_finder) end it 'returns the cached value when called for the same issuable type & with the same params' do - expect(helper).to receive(:params).twice.and_return(params) - expect(finder).to receive(:count_by_state).and_return(opened: 42) + expect(issues_finder).to receive(:count_by_state).and_return(opened: 42) expect(helper.issuables_state_counter_text(:issues, :opened)) .to eq('Open 42') - expect(finder).not_to receive(:count_by_state) + expect(issues_finder).not_to receive(:count_by_state) expect(helper.issuables_state_counter_text(:issues, :opened)) .to eq('Open 42') end it 'takes confidential status into account when searching for issues' do - allow(helper).to receive(:params).and_return(params) - expect(finder).to receive(:count_by_state).and_return(opened: 42) + expect(issues_finder).to receive(:count_by_state).and_return(opened: 42) expect(helper.issuables_state_counter_text(:issues, :opened)) .to include('42') - expect(finder).to receive(:user_cannot_see_confidential_issues?).and_return(false) - expect(finder).to receive(:count_by_state).and_return(opened: 40) + expect(issues_finder).to receive(:user_cannot_see_confidential_issues?).twice.and_return(false) + expect(issues_finder).to receive(:count_by_state).and_return(opened: 40) expect(helper.issuables_state_counter_text(:issues, :opened)) .to include('40') - expect(finder).to receive(:user_can_see_all_confidential_issues?).and_return(true) - expect(finder).to receive(:count_by_state).and_return(opened: 45) + expect(issues_finder).to receive(:user_can_see_all_confidential_issues?).and_return(true) + expect(issues_finder).to receive(:count_by_state).and_return(opened: 45) expect(helper.issuables_state_counter_text(:issues, :opened)) .to include('45') end it 'does not take confidential status into account when searching for merge requests' do - allow(helper).to receive(:params).and_return(params) - expect(finder).to receive(:count_by_state).and_return(opened: 42) - expect(finder).not_to receive(:user_cannot_see_confidential_issues?) - expect(finder).not_to receive(:user_can_see_all_confidential_issues?) + expect(merge_requests_finder).to receive(:count_by_state).and_return(opened: 42) + expect(merge_requests_finder).not_to receive(:user_cannot_see_confidential_issues?) + expect(merge_requests_finder).not_to receive(:user_can_see_all_confidential_issues?) expect(helper.issuables_state_counter_text(:merge_requests, :opened)) .to include('42') end it 'does not take some keys into account in the cache key' do - expect(finder).to receive(:count_by_state).and_return(opened: 42) - expect(helper).to receive(:params).and_return({ + expect(issues_finder).to receive(:count_by_state).and_return(opened: 42) + expect(issues_finder).to receive(:params).and_return({ author_id: '11', state: 'foo', sort: 'foo', @@ -140,8 +138,8 @@ describe IssuablesHelper do expect(helper.issuables_state_counter_text(:issues, :opened)) .to eq('Open 42') - expect(finder).not_to receive(:count_by_state) - expect(helper).to receive(:params).and_return({ + expect(issues_finder).not_to receive(:count_by_state) + expect(issues_finder).to receive(:params).and_return({ author_id: '11', state: 'bar', sort: 'bar', @@ -154,14 +152,14 @@ describe IssuablesHelper do end it 'does not take params order into account in the cache key' do - expect(helper).to receive(:params).and_return('author_id' => '11', 'state' => 'opened') - expect(finder).to receive(:count_by_state).and_return(opened: 42) + expect(issues_finder).to receive(:params).and_return('author_id' => '11', 'state' => 'opened') + expect(issues_finder).to receive(:count_by_state).and_return(opened: 42) expect(helper.issuables_state_counter_text(:issues, :opened)) .to eq('Open 42') - expect(helper).to receive(:params).and_return('state' => 'opened', 'author_id' => '11') - expect(finder).not_to receive(:count_by_state) + expect(issues_finder).to receive(:params).and_return('state' => 'opened', 'author_id' => '11') + expect(issues_finder).not_to receive(:count_by_state) expect(helper.issuables_state_counter_text(:issues, :opened)) .to eq('Open 42') -- cgit v1.2.3 From 7648f113814a78ffde802172197ba2b0074ec753 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Wed, 28 Jun 2017 17:33:48 +0200 Subject: Remove unnecessary contexts --- spec/lib/gitlab/git/repository_spec.rb | 174 ++++++++++++------------------ spec/lib/gitlab/gitaly_client/ref_spec.rb | 4 - spec/models/environment_spec.rb | 27 ++--- 3 files changed, 74 insertions(+), 131 deletions(-) (limited to 'spec') diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb index 0cd458bf933..464cb41a842 100644 --- a/spec/lib/gitlab/git/repository_spec.rb +++ b/spec/lib/gitlab/git/repository_spec.rb @@ -5,6 +5,11 @@ describe Gitlab::Git::Repository, seed_helper: true do let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH) } + after do + # Prevent cached stubs (gRPC connection objects) from poisoning tests. + Gitlab::GitalyClient.clear_stubs! + end + describe "Respond to" do subject { repository } @@ -30,31 +35,21 @@ describe Gitlab::Git::Repository, seed_helper: true do expect(repository.root_ref.encoding).to eq(Encoding.find('UTF-8')) end - context 'with gitaly enabled' do - before do - stub_gitaly - end - - after do - Gitlab::GitalyClient.clear_stubs! - end - - it 'gets the branch name from GitalyClient' do - expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:default_branch_name) - repository.root_ref - end + it 'gets the branch name from GitalyClient' do + expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:default_branch_name) + repository.root_ref + end - it 'wraps GRPC not found' do - expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:default_branch_name) - .and_raise(GRPC::NotFound) - expect { repository.root_ref }.to raise_error(Gitlab::Git::Repository::NoRepository) - end + it 'wraps GRPC not found' do + expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:default_branch_name) + .and_raise(GRPC::NotFound) + expect { repository.root_ref }.to raise_error(Gitlab::Git::Repository::NoRepository) + end - it 'wraps GRPC exceptions' do - expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:default_branch_name) - .and_raise(GRPC::Unknown) - expect { repository.root_ref }.to raise_error(Gitlab::Git::CommandError) - end + it 'wraps GRPC exceptions' do + expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:default_branch_name) + .and_raise(GRPC::Unknown) + expect { repository.root_ref }.to raise_error(Gitlab::Git::CommandError) end end @@ -135,31 +130,21 @@ describe Gitlab::Git::Repository, seed_helper: true do it { is_expected.to include("master") } it { is_expected.not_to include("branch-from-space") } - context 'with gitaly enabled' do - before do - stub_gitaly - end - - after do - Gitlab::GitalyClient.clear_stubs! - end - - it 'gets the branch names from GitalyClient' do - expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:branch_names) - subject - end + it 'gets the branch names from GitalyClient' do + expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:branch_names) + subject + end - it 'wraps GRPC not found' do - expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:branch_names) - .and_raise(GRPC::NotFound) - expect { subject }.to raise_error(Gitlab::Git::Repository::NoRepository) - end + it 'wraps GRPC not found' do + expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:branch_names) + .and_raise(GRPC::NotFound) + expect { subject }.to raise_error(Gitlab::Git::Repository::NoRepository) + end - it 'wraps GRPC other exceptions' do - expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:branch_names) - .and_raise(GRPC::Unknown) - expect { subject }.to raise_error(Gitlab::Git::CommandError) - end + it 'wraps GRPC other exceptions' do + expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:branch_names) + .and_raise(GRPC::Unknown) + expect { subject }.to raise_error(Gitlab::Git::CommandError) end end @@ -183,31 +168,21 @@ describe Gitlab::Git::Repository, seed_helper: true do it { is_expected.to include("v1.0.0") } it { is_expected.not_to include("v5.0.0") } - context 'with gitaly enabled' do - before do - stub_gitaly - end - - after do - Gitlab::GitalyClient.clear_stubs! - end - - it 'gets the tag names from GitalyClient' do - expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:tag_names) - subject - end + it 'gets the tag names from GitalyClient' do + expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:tag_names) + subject + end - it 'wraps GRPC not found' do - expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:tag_names) - .and_raise(GRPC::NotFound) - expect { subject }.to raise_error(Gitlab::Git::Repository::NoRepository) - end + it 'wraps GRPC not found' do + expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:tag_names) + .and_raise(GRPC::NotFound) + expect { subject }.to raise_error(Gitlab::Git::Repository::NoRepository) + end - it 'wraps GRPC exceptions' do - expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:tag_names) - .and_raise(GRPC::Unknown) - expect { subject }.to raise_error(Gitlab::Git::CommandError) - end + it 'wraps GRPC exceptions' do + expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:tag_names) + .and_raise(GRPC::Unknown) + expect { subject }.to raise_error(Gitlab::Git::CommandError) end end @@ -1281,42 +1256,32 @@ describe Gitlab::Git::Repository, seed_helper: true do expect(@repo.local_branches.any? { |branch| branch.name == 'local_branch' }).to eq(true) end - context 'with gitaly enabled' do - before do - stub_gitaly - end - - after do - Gitlab::GitalyClient.clear_stubs! - end - - it 'returns a Branch with UTF-8 fields' do - branches = @repo.local_branches.to_a - expect(branches.size).to be > 0 - utf_8 = Encoding.find('utf-8') - branches.each do |branch| - expect(branch.name.encoding).to eq(utf_8) - expect(branch.target.encoding).to eq(utf_8) unless branch.target.nil? - end + it 'returns a Branch with UTF-8 fields' do + branches = @repo.local_branches.to_a + expect(branches.size).to be > 0 + utf_8 = Encoding.find('utf-8') + branches.each do |branch| + expect(branch.name.encoding).to eq(utf_8) + expect(branch.target.encoding).to eq(utf_8) unless branch.target.nil? end + end - it 'gets the branches from GitalyClient' do - expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:local_branches) - .and_return([]) - @repo.local_branches - end + it 'gets the branches from GitalyClient' do + expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:local_branches) + .and_return([]) + @repo.local_branches + end - it 'wraps GRPC not found' do - expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:local_branches) - .and_raise(GRPC::NotFound) - expect { @repo.local_branches }.to raise_error(Gitlab::Git::Repository::NoRepository) - end + it 'wraps GRPC not found' do + expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:local_branches) + .and_raise(GRPC::NotFound) + expect { @repo.local_branches }.to raise_error(Gitlab::Git::Repository::NoRepository) + end - it 'wraps GRPC exceptions' do - expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:local_branches) - .and_raise(GRPC::Unknown) - expect { @repo.local_branches }.to raise_error(Gitlab::Git::CommandError) - end + it 'wraps GRPC exceptions' do + expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:local_branches) + .and_raise(GRPC::Unknown) + expect { @repo.local_branches }.to raise_error(Gitlab::Git::CommandError) end end @@ -1395,11 +1360,4 @@ describe Gitlab::Git::Repository, seed_helper: true do sha = Rugged::Commit.create(repo, options) repo.lookup(sha) end - - def stub_gitaly - allow(Gitlab::GitalyClient).to receive(:feature_enabled?).and_return(true) - - stub = double(:stub) - allow(Gitaly::Ref::Stub).to receive(:new).and_return(stub) - end end diff --git a/spec/lib/gitlab/gitaly_client/ref_spec.rb b/spec/lib/gitlab/gitaly_client/ref_spec.rb index 8ad39a02b93..986ae348652 100644 --- a/spec/lib/gitlab/gitaly_client/ref_spec.rb +++ b/spec/lib/gitlab/gitaly_client/ref_spec.rb @@ -6,10 +6,6 @@ describe Gitlab::GitalyClient::Ref do let(:relative_path) { project.path_with_namespace + '.git' } let(:client) { described_class.new(project.repository) } - before do - allow(Gitlab.config.gitaly).to receive(:enabled).and_return(true) - end - after do # When we say `expect_any_instance_of(Gitaly::Ref::Stub)` a double is created, # and because GitalyClient shares stubs these will get passed from example to diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb index b0635c6a90a..0a2cd8c2957 100644 --- a/spec/models/environment_spec.rb +++ b/spec/models/environment_spec.rb @@ -120,28 +120,17 @@ describe Environment, models: true do let(:head_commit) { project.commit } let(:commit) { project.commit.parent } - context 'Gitaly find_ref_name feature disabled' do - it 'returns deployment id for the environment' do - expect(environment.first_deployment_for(commit)).to eq deployment1 - end + it 'returns deployment id for the environment' do + expect(environment.first_deployment_for(commit)).to eq deployment1 + end - it 'return nil when no deployment is found' do - expect(environment.first_deployment_for(head_commit)).to eq nil - end + it 'return nil when no deployment is found' do + expect(environment.first_deployment_for(head_commit)).to eq nil end - # TODO: Uncomment when feature is reenabled - # context 'Gitaly find_ref_name feature enabled' do - # before do - # allow(Gitlab::GitalyClient).to receive(:feature_enabled?).with(:find_ref_name).and_return(true) - # end - # - # it 'calls GitalyClient' do - # expect_any_instance_of(Gitlab::GitalyClient::Ref).to receive(:find_ref_name) - # - # environment.first_deployment_for(commit) - # end - # end + it 'returns a UTF-8 ref' do + expect(environment.first_deployment_for(commit).ref).to be_utf8 + end end describe '#environment_type' do -- cgit v1.2.3 From 8a62f304ef541b93ac47dab3b69b645f2b65537a Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Wed, 28 Jun 2017 17:44:37 +0200 Subject: Add a UTF-8 encoding matcher --- spec/lib/gitlab/git/blame_spec.rb | 3 +++ spec/lib/gitlab/git/branch_spec.rb | 2 +- spec/lib/gitlab/git/diff_spec.rb | 2 +- spec/lib/gitlab/git/repository_spec.rb | 11 +++++------ spec/support/matchers/be_utf8.rb | 9 +++++++++ 5 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 spec/support/matchers/be_utf8.rb (limited to 'spec') diff --git a/spec/lib/gitlab/git/blame_spec.rb b/spec/lib/gitlab/git/blame_spec.rb index 8b041ac69b1..66c016d14b3 100644 --- a/spec/lib/gitlab/git/blame_spec.rb +++ b/spec/lib/gitlab/git/blame_spec.rb @@ -20,6 +20,7 @@ describe Gitlab::Git::Blame, seed_helper: true do expect(data.size).to eq(95) expect(data.first[:commit]).to be_kind_of(Gitlab::Git::Commit) expect(data.first[:line]).to eq("# Contribute to GitLab") + expect(data.first[:line]).to be_utf8 end end @@ -40,6 +41,7 @@ describe Gitlab::Git::Blame, seed_helper: true do expect(data.size).to eq(1) expect(data.first[:commit]).to be_kind_of(Gitlab::Git::Commit) expect(data.first[:line]).to eq("Ä ü") + expect(data.first[:line]).to be_utf8 end end @@ -61,6 +63,7 @@ describe Gitlab::Git::Blame, seed_helper: true do expect(data.size).to eq(1) expect(data.first[:commit]).to be_kind_of(Gitlab::Git::Commit) expect(data.first[:line]).to eq(" ") + expect(data.first[:line]).to be_utf8 end end end diff --git a/spec/lib/gitlab/git/branch_spec.rb b/spec/lib/gitlab/git/branch_spec.rb index 9dba4397e79..d1d7ed1d02a 100644 --- a/spec/lib/gitlab/git/branch_spec.rb +++ b/spec/lib/gitlab/git/branch_spec.rb @@ -48,7 +48,7 @@ describe Gitlab::Git::Branch, seed_helper: true do expect(Gitlab::Git::Commit).to receive(:decorate) .with(hash_including(attributes)).and_call_original - expect(branch.dereferenced_target.message.encoding).to be(Encoding::UTF_8) + expect(branch.dereferenced_target.message).to be_utf8 end end diff --git a/spec/lib/gitlab/git/diff_spec.rb b/spec/lib/gitlab/git/diff_spec.rb index d50ccb0df30..d97e85364c2 100644 --- a/spec/lib/gitlab/git/diff_spec.rb +++ b/spec/lib/gitlab/git/diff_spec.rb @@ -180,7 +180,7 @@ EOT let(:raw_patch) { @raw_diff_hash[:diff].encode(Encoding::ASCII_8BIT) } it 'encodes diff patch to UTF-8' do - expect(diff.diff.encoding).to eq(Encoding::UTF_8) + expect(diff.diff).to be_utf8 end end end diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb index 464cb41a842..9e924c2541b 100644 --- a/spec/lib/gitlab/git/repository_spec.rb +++ b/spec/lib/gitlab/git/repository_spec.rb @@ -32,7 +32,7 @@ describe Gitlab::Git::Repository, seed_helper: true do end it 'returns UTF-8' do - expect(repository.root_ref.encoding).to eq(Encoding.find('UTF-8')) + expect(repository.root_ref).to be_utf8 end it 'gets the branch name from GitalyClient' do @@ -124,7 +124,7 @@ describe Gitlab::Git::Repository, seed_helper: true do end it 'returns UTF-8' do - expect(subject.first.encoding).to eq(Encoding.find('UTF-8')) + expect(subject.first).to be_utf8 end it { is_expected.to include("master") } @@ -158,7 +158,7 @@ describe Gitlab::Git::Repository, seed_helper: true do end it 'returns UTF-8' do - expect(subject.first.encoding).to eq(Encoding.find('UTF-8')) + expect(subject.first).to be_utf8 end describe '#last' do @@ -1259,10 +1259,9 @@ describe Gitlab::Git::Repository, seed_helper: true do it 'returns a Branch with UTF-8 fields' do branches = @repo.local_branches.to_a expect(branches.size).to be > 0 - utf_8 = Encoding.find('utf-8') branches.each do |branch| - expect(branch.name.encoding).to eq(utf_8) - expect(branch.target.encoding).to eq(utf_8) unless branch.target.nil? + expect(branch.name).to be_utf8 + expect(branch.target).to be_utf8 unless branch.target.nil? end end diff --git a/spec/support/matchers/be_utf8.rb b/spec/support/matchers/be_utf8.rb new file mode 100644 index 00000000000..ea806352422 --- /dev/null +++ b/spec/support/matchers/be_utf8.rb @@ -0,0 +1,9 @@ +RSpec::Matchers.define :be_utf8 do |_| + match do |actual| + actual.is_a?(String) && actual.encoding == Encoding.find('UTF-8') + end + + description do + "be a String with encoding UTF-8" + end +end -- cgit v1.2.3 From 9da3076944146444cb864d5db066a766c76b1935 Mon Sep 17 00:00:00 2001 From: Adam Niedzielski Date: Fri, 30 Jun 2017 14:47:53 +0200 Subject: Improve support for external issue references --- spec/factories/projects.rb | 2 +- .../filter/external_issue_reference_filter_spec.rb | 4 +-- .../banzai/filter/issue_reference_filter_spec.rb | 25 ---------------- spec/lib/banzai/pipeline/gfm_pipeline_spec.rb | 33 ++++++++++++++++++++++ .../banzai/reference_parser/issue_parser_spec.rb | 10 ------- spec/models/project_services/jira_service_spec.rb | 6 ++-- .../project_services/redmine_service_spec.rb | 4 +-- spec/services/git_push_service_spec.rb | 12 -------- .../issue_tracker_service_shared_example.rb | 8 +++--- 9 files changed, 45 insertions(+), 59 deletions(-) create mode 100644 spec/lib/banzai/pipeline/gfm_pipeline_spec.rb (limited to 'spec') diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb index aef1c17a239..1bb2db11e7f 100644 --- a/spec/factories/projects.rb +++ b/spec/factories/projects.rb @@ -220,7 +220,7 @@ FactoryGirl.define do active: true, properties: { 'project_url' => 'http://redmine/projects/project_name_in_redmine', - 'issues_url' => "http://redmine/#{project.id}/project_name_in_redmine/:id", + 'issues_url' => 'http://redmine/projects/project_name_in_redmine/issues/:id', 'new_issue_url' => 'http://redmine/projects/project_name_in_redmine/issues/new' } ) diff --git a/spec/lib/banzai/filter/external_issue_reference_filter_spec.rb b/spec/lib/banzai/filter/external_issue_reference_filter_spec.rb index a4bb043f8f1..b7d82c36ddd 100644 --- a/spec/lib/banzai/filter/external_issue_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/external_issue_reference_filter_spec.rb @@ -88,12 +88,12 @@ describe Banzai::Filter::ExternalIssueReferenceFilter, lib: true do it 'queries the collection on the first call' do expect_any_instance_of(Project).to receive(:default_issues_tracker?).once.and_call_original - expect_any_instance_of(Project).to receive(:issue_reference_pattern).once.and_call_original + expect_any_instance_of(Project).to receive(:external_issue_reference_pattern).once.and_call_original not_cached = reference_filter.call("look for #{reference}", { project: project }) expect_any_instance_of(Project).not_to receive(:default_issues_tracker?) - expect_any_instance_of(Project).not_to receive(:issue_reference_pattern) + expect_any_instance_of(Project).not_to receive(:external_issue_reference_pattern) cached = reference_filter.call("look for #{reference}", { project: project }) diff --git a/spec/lib/banzai/filter/issue_reference_filter_spec.rb b/spec/lib/banzai/filter/issue_reference_filter_spec.rb index e5c1deb338b..a79d365d6c5 100644 --- a/spec/lib/banzai/filter/issue_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/issue_reference_filter_spec.rb @@ -39,13 +39,6 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do let(:reference) { "##{issue.iid}" } - it 'ignores valid references when using non-default tracker' do - allow(project).to receive(:default_issues_tracker?).and_return(false) - - exp = act = "Issue #{reference}" - expect(reference_filter(act).to_html).to eq exp - end - it 'links to a valid reference' do doc = reference_filter("Fixed #{reference}") @@ -340,24 +333,6 @@ describe Banzai::Filter::IssueReferenceFilter, lib: true do .to eq({ project => { issue.iid => issue } }) end end - - context 'using an external issue tracker' do - it 'returns a Hash containing the issues per project' do - doc = Nokogiri::HTML.fragment('') - filter = described_class.new(doc, project: project) - - expect(project).to receive(:default_issues_tracker?).and_return(false) - - expect(filter).to receive(:projects_per_reference) - .and_return({ project.path_with_namespace => project }) - - expect(filter).to receive(:references_per_project) - .and_return({ project.path_with_namespace => Set.new([1]) }) - - expect(filter.issues_per_project[project][1]) - .to be_an_instance_of(ExternalIssue) - end - end end describe '.references_in' do diff --git a/spec/lib/banzai/pipeline/gfm_pipeline_spec.rb b/spec/lib/banzai/pipeline/gfm_pipeline_spec.rb new file mode 100644 index 00000000000..2b8c76f2bb8 --- /dev/null +++ b/spec/lib/banzai/pipeline/gfm_pipeline_spec.rb @@ -0,0 +1,33 @@ +require 'rails_helper' + +describe Banzai::Pipeline::GfmPipeline do + describe 'integration between parsing regular and external issue references' do + let(:project) { create(:redmine_project, :public) } + + it 'allows to use shorthand external reference syntax for Redmine' do + markdown = '#12' + + result = described_class.call(markdown, project: project)[:output] + link = result.css('a').first + + expect(link['href']).to eq 'http://redmine/projects/project_name_in_redmine/issues/12' + end + + it 'parses cross-project references to regular issues' do + other_project = create(:empty_project, :public) + issue = create(:issue, project: other_project) + markdown = issue.to_reference(project, full: true) + + result = described_class.call(markdown, project: project)[:output] + link = result.css('a').first + + expect(link['href']).to eq( + Gitlab::Routing.url_helpers.namespace_project_issue_path( + other_project.namespace, + other_project, + issue + ) + ) + end + end +end diff --git a/spec/lib/banzai/reference_parser/issue_parser_spec.rb b/spec/lib/banzai/reference_parser/issue_parser_spec.rb index 58e1a0c1bc1..acdd23f81f3 100644 --- a/spec/lib/banzai/reference_parser/issue_parser_spec.rb +++ b/spec/lib/banzai/reference_parser/issue_parser_spec.rb @@ -39,16 +39,6 @@ describe Banzai::ReferenceParser::IssueParser, lib: true do expect(subject.nodes_visible_to_user(user, [link])).to eq([]) end end - - context 'when the project uses an external issue tracker' do - it 'returns all nodes' do - link = double(:link) - - expect(project).to receive(:external_issue_tracker).and_return(true) - - expect(subject.nodes_visible_to_user(user, [link])).to eq([link]) - end - end end describe '#referenced_by' do diff --git a/spec/models/project_services/jira_service_spec.rb b/spec/models/project_services/jira_service_spec.rb index c86f56c55eb..4a1de76f099 100644 --- a/spec/models/project_services/jira_service_spec.rb +++ b/spec/models/project_services/jira_service_spec.rb @@ -64,12 +64,12 @@ describe JiraService, models: true do end end - describe '#reference_pattern' do + describe '.reference_pattern' do it_behaves_like 'allows project key on reference pattern' it 'does not allow # on the code' do - expect(subject.reference_pattern.match('#123')).to be_nil - expect(subject.reference_pattern.match('1#23#12')).to be_nil + expect(described_class.reference_pattern.match('#123')).to be_nil + expect(described_class.reference_pattern.match('1#23#12')).to be_nil end end diff --git a/spec/models/project_services/redmine_service_spec.rb b/spec/models/project_services/redmine_service_spec.rb index 6631d9040b1..441b3f896ca 100644 --- a/spec/models/project_services/redmine_service_spec.rb +++ b/spec/models/project_services/redmine_service_spec.rb @@ -31,11 +31,11 @@ describe RedmineService, models: true do end end - describe '#reference_pattern' do + describe '.reference_pattern' do it_behaves_like 'allows project key on reference pattern' it 'does allow # on the reference' do - expect(subject.reference_pattern.match('#123')[:issue]).to eq('123') + expect(described_class.reference_pattern.match('#123')[:issue]).to eq('123') end end end diff --git a/spec/services/git_push_service_spec.rb b/spec/services/git_push_service_spec.rb index ca827fc0f39..8e8816870e1 100644 --- a/spec/services/git_push_service_spec.rb +++ b/spec/services/git_push_service_spec.rb @@ -401,18 +401,6 @@ describe GitPushService, services: true do expect(SystemNoteService).not_to receive(:cross_reference) execute_service(project, commit_author, @oldrev, @newrev, @ref ) end - - it "doesn't close issues when external issue tracker is in use" do - allow_any_instance_of(Project).to receive(:default_issues_tracker?) - .and_return(false) - external_issue_tracker = double(title: 'My Tracker', issue_path: issue.iid, reference_pattern: project.issue_reference_pattern) - allow_any_instance_of(Project).to receive(:external_issue_tracker).and_return(external_issue_tracker) - - # The push still shouldn't create cross-reference notes. - expect do - execute_service(project, commit_author, @oldrev, @newrev, 'refs/heads/hurf' ) - end.not_to change { Note.where(project_id: project.id, system: true).count } - end end context "to non-default branches" do diff --git a/spec/support/issue_tracker_service_shared_example.rb b/spec/support/issue_tracker_service_shared_example.rb index e70b3963d9d..a6ab03cb808 100644 --- a/spec/support/issue_tracker_service_shared_example.rb +++ b/spec/support/issue_tracker_service_shared_example.rb @@ -8,15 +8,15 @@ end RSpec.shared_examples 'allows project key on reference pattern' do |url_attr| it 'allows underscores in the project name' do - expect(subject.reference_pattern.match('EXT_EXT-1234')[0]).to eq 'EXT_EXT-1234' + expect(described_class.reference_pattern.match('EXT_EXT-1234')[0]).to eq 'EXT_EXT-1234' end it 'allows numbers in the project name' do - expect(subject.reference_pattern.match('EXT3_EXT-1234')[0]).to eq 'EXT3_EXT-1234' + expect(described_class.reference_pattern.match('EXT3_EXT-1234')[0]).to eq 'EXT3_EXT-1234' end it 'requires the project name to begin with A-Z' do - expect(subject.reference_pattern.match('3EXT_EXT-1234')).to eq nil - expect(subject.reference_pattern.match('EXT_EXT-1234')[0]).to eq 'EXT_EXT-1234' + expect(described_class.reference_pattern.match('3EXT_EXT-1234')).to eq nil + expect(described_class.reference_pattern.match('EXT_EXT-1234')[0]).to eq 'EXT_EXT-1234' end end -- cgit v1.2.3 From 3c88a7869b87693ba8c3fb9814d39437dd569a31 Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Thu, 29 Jun 2017 07:43:41 +0000 Subject: Implement review comments for !12445 from @godfat and @rymai. - Use `GlobalPolicy` to authorize the users that a non-authenticated user can fetch from `/api/v4/users`. We allow access if the `Gitlab::VisibilityLevel::PUBLIC` visibility level is not restricted. - Further, as before, `/api/v4/users` is only accessible to unauthenticated users if the `username` parameter is passed. - Turn off `authenticate!` for the `/api/v4/users` endpoint by matching on the actual route + method, rather than the description. - Change the type of `current_user` check in `UsersFinder` to be more compatible with EE. --- spec/requests/api/users_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index 01541901330..bf7ed2d3ad6 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -34,7 +34,7 @@ describe API::Users do it "returns authorization error when the `username` parameter refers to an inaccessible user" do user = create(:user) - expect(Ability).to receive(:allowed?).with(nil, :read_user, user).and_return(false) + stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::PUBLIC]) get api("/users"), username: user.username -- cgit v1.2.3 From 9e3ef082be2595921319279ec095c2765a66e9e9 Mon Sep 17 00:00:00 2001 From: Kushal Pandya Date: Fri, 30 Jun 2017 14:10:09 +0000 Subject: Remove placeholder note when award emoji slash command is applied --- spec/javascripts/notes_spec.js | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'spec') diff --git a/spec/javascripts/notes_spec.js b/spec/javascripts/notes_spec.js index 5ece4ed080b..2c096ed08a8 100644 --- a/spec/javascripts/notes_spec.js +++ b/spec/javascripts/notes_spec.js @@ -523,6 +523,51 @@ import '~/notes'; }); }); + describe('postComment with Slash commands', () => { + const sampleComment = '/assign @root\n/award :100:'; + const note = { + commands_changes: { + assignee_id: 1, + emoji_award: '100' + }, + errors: { + commands_only: ['Commands applied'] + }, + valid: false + }; + let $form; + let $notesContainer; + + beforeEach(() => { + this.notes = new Notes('', []); + window.gon.current_username = 'root'; + window.gon.current_user_fullname = 'Administrator'; + gl.awardsHandler = { + addAwardToEmojiBar: () => {}, + scrollToAwards: () => {} + }; + gl.GfmAutoComplete = { + dataSources: { + commands: '/root/test-project/autocomplete_sources/commands' + } + }; + $form = $('form.js-main-target-form'); + $notesContainer = $('ul.main-notes-list'); + $form.find('textarea.js-note-text').val(sampleComment); + }); + + it('should remove slash command placeholder when comment with slash commands is done posting', () => { + const deferred = $.Deferred(); + spyOn($, 'ajax').and.returnValue(deferred.promise()); + spyOn(gl.awardsHandler, 'addAwardToEmojiBar').and.callThrough(); + $('.js-comment-button').click(); + + expect($notesContainer.find('.system-note.being-posted').length).toEqual(1); // Placeholder shown + deferred.resolve(note); + expect($notesContainer.find('.system-note.being-posted').length).toEqual(0); // Placeholder removed + }); + }); + describe('update comment with script tags', () => { const sampleComment = ''; const updatedComment = ''; -- cgit v1.2.3 From 9c8075c4b95f090fc6f00c897f6bf097d29ee8bf Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Thu, 29 Jun 2017 23:26:23 -0700 Subject: Make Project#ensure_repository force create a repo In Geo, Project#ensure_repository is used to make sure that a Git repo is available to be fetched on a secondary. If a project were a fork, this directory would never be created. Closes gitlab-org/gitlab-ee#2800 --- spec/models/project_spec.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'spec') diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 1390848ff4a..0eeaf68a02a 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -1357,6 +1357,19 @@ describe Project, models: true do project.ensure_repository end + + it 'creates the repository if it is a fork' do + expect(project).to receive(:forked?).and_return(true) + + allow(project).to receive(:repository_exists?) + .and_return(false) + + expect(shell).to receive(:add_repository) + .with(project.repository_storage_path, project.path_with_namespace) + .and_return(true) + + project.ensure_repository + end end describe '#user_can_push_to_empty_repo?' do -- cgit v1.2.3 From 1b0c6ffd512d0bee24964936da02e1b10d6a5a67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Thu, 29 Jun 2017 18:03:17 +0200 Subject: Disable RSpec/BeforeAfterAll and enable RSpec/ImplicitExpect cops MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- spec/models/project_group_link_spec.rb | 12 ++++++------ spec/models/project_services/external_wiki_service_spec.rb | 4 ++-- spec/models/project_spec.rb | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'spec') diff --git a/spec/models/project_group_link_spec.rb b/spec/models/project_group_link_spec.rb index 4161b9158b1..d68d8b719cd 100644 --- a/spec/models/project_group_link_spec.rb +++ b/spec/models/project_group_link_spec.rb @@ -2,8 +2,8 @@ require 'spec_helper' describe ProjectGroupLink do describe "Associations" do - it { should belong_to(:group) } - it { should belong_to(:project) } + it { is_expected.to belong_to(:group) } + it { is_expected.to belong_to(:project) } end describe "Validation" do @@ -12,10 +12,10 @@ describe ProjectGroupLink do let(:project) { create(:project, group: group) } let!(:project_group_link) { create(:project_group_link, project: project) } - it { should validate_presence_of(:project_id) } - it { should validate_uniqueness_of(:group_id).scoped_to(:project_id).with_message(/already shared/) } - it { should validate_presence_of(:group) } - it { should validate_presence_of(:group_access) } + it { is_expected.to validate_presence_of(:project_id) } + it { is_expected.to validate_uniqueness_of(:group_id).scoped_to(:project_id).with_message(/already shared/) } + it { is_expected.to validate_presence_of(:group) } + it { is_expected.to validate_presence_of(:group_access) } it "doesn't allow a project to be shared with the group it is in" do project_group_link.group = group diff --git a/spec/models/project_services/external_wiki_service_spec.rb b/spec/models/project_services/external_wiki_service_spec.rb index 291fc645a1c..ef10df9e092 100644 --- a/spec/models/project_services/external_wiki_service_spec.rb +++ b/spec/models/project_services/external_wiki_service_spec.rb @@ -3,8 +3,8 @@ require 'spec_helper' describe ExternalWikiService, models: true do include ExternalWikiHelper describe "Associations" do - it { should belong_to :project } - it { should have_one :service_hook } + it { is_expected.to belong_to :project } + it { is_expected.to have_one :service_hook } end describe 'Validations' do diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 1390848ff4a..f9b702c54aa 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -823,13 +823,13 @@ describe Project, models: true do let(:avatar_path) { "/#{project.full_path}/avatar" } - it { should eq "http://#{Gitlab.config.gitlab.host}#{avatar_path}" } + it { is_expected.to eq "http://#{Gitlab.config.gitlab.host}#{avatar_path}" } end context 'when git repo is empty' do let(:project) { create(:empty_project) } - it { should eq nil } + it { is_expected.to eq nil } end end -- cgit v1.2.3 From 912613c41be3790b004f65935e8380aea9e5895f Mon Sep 17 00:00:00 2001 From: Michael Kozono Date: Fri, 30 Jun 2017 09:00:07 -0700 Subject: Reduce 28 test runs to 4 14 to 2, but these shared examples are used twice. This was already done in another context further down the file. --- .../gitlab/health_checks/fs_shards_check_spec.rb | 36 ++++++++++++---------- 1 file changed, 20 insertions(+), 16 deletions(-) (limited to 'spec') diff --git a/spec/lib/gitlab/health_checks/fs_shards_check_spec.rb b/spec/lib/gitlab/health_checks/fs_shards_check_spec.rb index fbacbc4a338..b333e162909 100644 --- a/spec/lib/gitlab/health_checks/fs_shards_check_spec.rb +++ b/spec/lib/gitlab/health_checks/fs_shards_check_spec.rb @@ -103,30 +103,34 @@ describe Gitlab::HealthChecks::FsShardsCheck do example.run_with_retry retry: times_to_try end - it { is_expected.to all(have_attributes(labels: { shard: :default })) } - - it { is_expected.to include(an_object_having_attributes(name: :filesystem_accessible, value: 0)) } - it { is_expected.to include(an_object_having_attributes(name: :filesystem_readable, value: 0)) } - it { is_expected.to include(an_object_having_attributes(name: :filesystem_writable, value: 0)) } - - it { is_expected.to include(an_object_having_attributes(name: :filesystem_access_latency, value: be >= 0)) } - it { is_expected.to include(an_object_having_attributes(name: :filesystem_read_latency, value: be >= 0)) } - it { is_expected.to include(an_object_having_attributes(name: :filesystem_write_latency, value: be >= 0)) } + it 'provides metrics' do + expect(subject).to all(have_attributes(labels: { shard: :default })) + expect(subject).to include(an_object_having_attributes(name: :filesystem_accessible, value: 0)) + expect(subject).to include(an_object_having_attributes(name: :filesystem_readable, value: 0)) + expect(subject).to include(an_object_having_attributes(name: :filesystem_writable, value: 0)) + + expect(subject).to include(an_object_having_attributes(name: :filesystem_access_latency, value: be >= 0)) + expect(subject).to include(an_object_having_attributes(name: :filesystem_read_latency, value: be >= 0)) + expect(subject).to include(an_object_having_attributes(name: :filesystem_write_latency, value: be >= 0)) + end end context 'storage points to directory that has both read and write rights' do before do FileUtils.chmod_R(0755, tmp_dir) end - it { is_expected.to all(have_attributes(labels: { shard: :default })) } - it { is_expected.to include(an_object_having_attributes(name: :filesystem_accessible, value: 1)) } - it { is_expected.to include(an_object_having_attributes(name: :filesystem_readable, value: 1)) } - it { is_expected.to include(an_object_having_attributes(name: :filesystem_writable, value: 1)) } + it 'provides metrics' do + expect(subject).to all(have_attributes(labels: { shard: :default })) - it { is_expected.to include(an_object_having_attributes(name: :filesystem_access_latency, value: be >= 0)) } - it { is_expected.to include(an_object_having_attributes(name: :filesystem_read_latency, value: be >= 0)) } - it { is_expected.to include(an_object_having_attributes(name: :filesystem_write_latency, value: be >= 0)) } + expect(subject).to include(an_object_having_attributes(name: :filesystem_accessible, value: 1)) + expect(subject).to include(an_object_having_attributes(name: :filesystem_readable, value: 1)) + expect(subject).to include(an_object_having_attributes(name: :filesystem_writable, value: 1)) + + expect(subject).to include(an_object_having_attributes(name: :filesystem_access_latency, value: be >= 0)) + expect(subject).to include(an_object_having_attributes(name: :filesystem_read_latency, value: be >= 0)) + expect(subject).to include(an_object_having_attributes(name: :filesystem_write_latency, value: be >= 0)) + end end end end -- cgit v1.2.3 From ec396fd93ab800e8b962f7b8bc6095f8ab754d93 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Fri, 30 Jun 2017 16:52:11 +0000 Subject: New navigation breadcrumbs --- spec/helpers/groups_helper_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/helpers/groups_helper_spec.rb b/spec/helpers/groups_helper_spec.rb index 8da22dc78fa..e3f9d9db9eb 100644 --- a/spec/helpers/groups_helper_spec.rb +++ b/spec/helpers/groups_helper_spec.rb @@ -91,7 +91,7 @@ describe GroupsHelper do let!(:very_deep_nested_group) { create(:group, parent: deep_nested_group) } it 'outputs the groups in the correct order' do - expect(group_title(very_deep_nested_group)).to match(/>#{group.name}<\/a>.*>#{nested_group.name}<\/a>.*>#{deep_nested_group.name}<\/a>/) + expect(helper.group_title(very_deep_nested_group)).to match(/>#{group.name}<\/a>.*>#{nested_group.name}<\/a>.*>#{deep_nested_group.name}<\/a>/) end end end -- cgit v1.2.3 From 3900b2f3783490ec0d5ab7dbbe946b14bdc3b975 Mon Sep 17 00:00:00 2001 From: Horacio Bertorello Date: Thu, 29 Jun 2017 02:23:38 -0300 Subject: Hide archived project labels from group issue tracker --- spec/finders/labels_finder_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'spec') diff --git a/spec/finders/labels_finder_spec.rb b/spec/finders/labels_finder_spec.rb index 1724cdba830..95d96354b77 100644 --- a/spec/finders/labels_finder_spec.rb +++ b/spec/finders/labels_finder_spec.rb @@ -49,12 +49,12 @@ describe LabelsFinder do end context 'filtering by group_id' do - it 'returns labels available for any project within the group' do + it 'returns labels available for any non-archived project within the group' do group_1.add_developer(user) - + project_1.archive! finder = described_class.new(user, group_id: group_1.id) - expect(finder.execute).to eq [group_label_2, project_label_1, group_label_1, project_label_5] + expect(finder.execute).to eq [group_label_2, group_label_1, project_label_5] end end -- cgit v1.2.3 From dcdf2a8bc58e5a9750f3a4dfdb4b1795863b3853 Mon Sep 17 00:00:00 2001 From: Tomasz Maczukin Date: Wed, 28 Jun 2017 21:30:38 +0200 Subject: Make entrypoint and command keys to be array of strings --- spec/lib/ci/gitlab_ci_yaml_processor_spec.rb | 25 +++++++++++++++++-------- spec/lib/gitlab/ci/config/entry/image_spec.rb | 4 ++-- spec/lib/gitlab/ci/config/entry/service_spec.rb | 6 +++--- 3 files changed, 22 insertions(+), 13 deletions(-) (limited to 'spec') diff --git a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb index af0e7855a9b..e02317adbad 100644 --- a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb +++ b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb @@ -598,8 +598,10 @@ module Ci describe "Image and service handling" do context "when extended docker configuration is used" do it "returns image and service when defined" do - config = YAML.dump({ image: { name: "ruby:2.1" }, - services: ["mysql", { name: "docker:dind", alias: "docker" }], + config = YAML.dump({ image: { name: "ruby:2.1", entrypoint: ["/usr/local/bin/init", "run"] }, + services: ["mysql", { name: "docker:dind", alias: "docker", + entrypoint: ["/usr/local/bin/init", "run"], + command: ["/usr/local/bin/init", "run"] }], before_script: ["pwd"], rspec: { script: "rspec" } }) @@ -614,8 +616,10 @@ module Ci coverage_regex: nil, tag_list: [], options: { - image: { name: "ruby:2.1" }, - services: [{ name: "mysql" }, { name: "docker:dind", alias: "docker" }] + image: { name: "ruby:2.1", entrypoint: ["/usr/local/bin/init", "run"] }, + services: [{ name: "mysql" }, + { name: "docker:dind", alias: "docker", entrypoint: ["/usr/local/bin/init", "run"], + command: ["/usr/local/bin/init", "run"] }] }, allow_failure: false, when: "on_success", @@ -628,8 +632,11 @@ module Ci config = YAML.dump({ image: "ruby:2.1", services: ["mysql"], before_script: ["pwd"], - rspec: { image: { name: "ruby:2.5" }, - services: [{ name: "postgresql", alias: "db-pg" }, "docker:dind"], script: "rspec" } }) + rspec: { image: { name: "ruby:2.5", entrypoint: ["/usr/local/bin/init", "run"] }, + services: [{ name: "postgresql", alias: "db-pg", + entrypoint: ["/usr/local/bin/init", "run"], + command: ["/usr/local/bin/init", "run"] }, "docker:dind"], + script: "rspec" } }) config_processor = GitlabCiYamlProcessor.new(config, path) @@ -642,8 +649,10 @@ module Ci coverage_regex: nil, tag_list: [], options: { - image: { name: "ruby:2.5" }, - services: [{ name: "postgresql", alias: "db-pg" }, { name: "docker:dind" }] + image: { name: "ruby:2.5", entrypoint: ["/usr/local/bin/init", "run"] }, + services: [{ name: "postgresql", alias: "db-pg", entrypoint: ["/usr/local/bin/init", "run"], + command: ["/usr/local/bin/init", "run"]}, + { name: "docker:dind" }] }, allow_failure: false, when: "on_success", diff --git a/spec/lib/gitlab/ci/config/entry/image_spec.rb b/spec/lib/gitlab/ci/config/entry/image_spec.rb index bca22e39500..d8800fb675b 100644 --- a/spec/lib/gitlab/ci/config/entry/image_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/image_spec.rb @@ -38,7 +38,7 @@ describe Gitlab::Ci::Config::Entry::Image do end context 'when configuration is a hash' do - let(:config) { { name: 'ruby:2.2', entrypoint: '/bin/sh' } } + let(:config) { { name: 'ruby:2.2', entrypoint: ['/bin/sh', 'run'] } } describe '#value' do it 'returns image hash' do @@ -66,7 +66,7 @@ describe Gitlab::Ci::Config::Entry::Image do describe '#entrypoint' do it "returns image's entrypoint" do - expect(entry.entrypoint).to eq '/bin/sh' + expect(entry.entrypoint).to eq ['/bin/sh', 'run'] end end end diff --git a/spec/lib/gitlab/ci/config/entry/service_spec.rb b/spec/lib/gitlab/ci/config/entry/service_spec.rb index 7202fe525e4..24b7086c34c 100644 --- a/spec/lib/gitlab/ci/config/entry/service_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/service_spec.rb @@ -43,7 +43,7 @@ describe Gitlab::Ci::Config::Entry::Service do context 'when configuration is a hash' do let(:config) do - { name: 'postgresql:9.5', alias: 'db', command: 'cmd', entrypoint: '/bin/sh' } + { name: 'postgresql:9.5', alias: 'db', command: ['cmd', 'run'], entrypoint: ['/bin/sh', 'run'] } end describe '#valid?' do @@ -72,13 +72,13 @@ describe Gitlab::Ci::Config::Entry::Service do describe '#command' do it "returns service's command" do - expect(entry.command).to eq 'cmd' + expect(entry.command).to eq ['cmd', 'run'] end end describe '#entrypoint' do it "returns service's entrypoint" do - expect(entry.entrypoint).to eq '/bin/sh' + expect(entry.entrypoint).to eq ['/bin/sh', 'run'] end end end -- cgit v1.2.3 From 16ff3229cbb71e05f9cea3a16b481a8120dfcb7e Mon Sep 17 00:00:00 2001 From: Tomasz Maczukin Date: Fri, 30 Jun 2017 13:30:19 +0200 Subject: Fix rubocop offenses --- spec/lib/ci/gitlab_ci_yaml_processor_spec.rb | 2 +- spec/lib/gitlab/ci/config/entry/image_spec.rb | 4 ++-- spec/lib/gitlab/ci/config/entry/service_spec.rb | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'spec') diff --git a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb index e02317adbad..482f03aa0cc 100644 --- a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb +++ b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb @@ -651,7 +651,7 @@ module Ci options: { image: { name: "ruby:2.5", entrypoint: ["/usr/local/bin/init", "run"] }, services: [{ name: "postgresql", alias: "db-pg", entrypoint: ["/usr/local/bin/init", "run"], - command: ["/usr/local/bin/init", "run"]}, + command: ["/usr/local/bin/init", "run"] }, { name: "docker:dind" }] }, allow_failure: false, diff --git a/spec/lib/gitlab/ci/config/entry/image_spec.rb b/spec/lib/gitlab/ci/config/entry/image_spec.rb index d8800fb675b..1a4d9ed5517 100644 --- a/spec/lib/gitlab/ci/config/entry/image_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/image_spec.rb @@ -38,7 +38,7 @@ describe Gitlab::Ci::Config::Entry::Image do end context 'when configuration is a hash' do - let(:config) { { name: 'ruby:2.2', entrypoint: ['/bin/sh', 'run'] } } + let(:config) { { name: 'ruby:2.2', entrypoint: %w(/bin/sh run) } } describe '#value' do it 'returns image hash' do @@ -66,7 +66,7 @@ describe Gitlab::Ci::Config::Entry::Image do describe '#entrypoint' do it "returns image's entrypoint" do - expect(entry.entrypoint).to eq ['/bin/sh', 'run'] + expect(entry.entrypoint).to eq %w(/bin/sh run) end end end diff --git a/spec/lib/gitlab/ci/config/entry/service_spec.rb b/spec/lib/gitlab/ci/config/entry/service_spec.rb index 24b7086c34c..9ebf947a751 100644 --- a/spec/lib/gitlab/ci/config/entry/service_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/service_spec.rb @@ -43,7 +43,7 @@ describe Gitlab::Ci::Config::Entry::Service do context 'when configuration is a hash' do let(:config) do - { name: 'postgresql:9.5', alias: 'db', command: ['cmd', 'run'], entrypoint: ['/bin/sh', 'run'] } + { name: 'postgresql:9.5', alias: 'db', command: %w(cmd run), entrypoint: %w(/bin/sh run) } end describe '#valid?' do @@ -72,13 +72,13 @@ describe Gitlab::Ci::Config::Entry::Service do describe '#command' do it "returns service's command" do - expect(entry.command).to eq ['cmd', 'run'] + expect(entry.command).to eq %w(cmd run) end end describe '#entrypoint' do it "returns service's entrypoint" do - expect(entry.entrypoint).to eq ['/bin/sh', 'run'] + expect(entry.entrypoint).to eq %w(/bin/sh run) end end end -- cgit v1.2.3 From 96e986327c4dad9248f9013f191119ffafe4a6d8 Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Mon, 3 Jul 2017 05:14:00 +0000 Subject: Implement review comments for !12445 from @jneen. - Fix duplicate `prevent` declaration - Add spec for `GlobalPolicy` --- spec/policies/global_policy_spec.rb | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 spec/policies/global_policy_spec.rb (limited to 'spec') diff --git a/spec/policies/global_policy_spec.rb b/spec/policies/global_policy_spec.rb new file mode 100644 index 00000000000..bb0fa0c0e9c --- /dev/null +++ b/spec/policies/global_policy_spec.rb @@ -0,0 +1,34 @@ +require 'spec_helper' + +describe GlobalPolicy, models: true do + let(:current_user) { create(:user) } + let(:user) { create(:user) } + + subject { GlobalPolicy.new(current_user, [user]) } + + describe "reading the list of users" do + context "for a logged in user" do + it { is_expected.to be_allowed(:read_users_list) } + end + + context "for an anonymous user" do + let(:current_user) { nil } + + context "when the public level is restricted" do + before do + stub_application_setting(restricted_visibility_levels: [Gitlab::VisibilityLevel::PUBLIC]) + end + + it { is_expected.not_to be_allowed(:read_users_list) } + end + + context "when the public level is not restricted" do + before do + stub_application_setting(restricted_visibility_levels: []) + end + + it { is_expected.to be_allowed(:read_users_list) } + end + end + end +end -- cgit v1.2.3 From d8ab0d609da979bf255660fb36d1a976c149b344 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Mon, 3 Jul 2017 14:17:43 +0800 Subject: Give project to the dummy pipeline --- spec/support/cycle_analytics_helpers.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/support/cycle_analytics_helpers.rb b/spec/support/cycle_analytics_helpers.rb index 6e1eb5c678d..c0a5491a430 100644 --- a/spec/support/cycle_analytics_helpers.rb +++ b/spec/support/cycle_analytics_helpers.rb @@ -74,7 +74,9 @@ module CycleAnalyticsHelpers def dummy_pipeline @dummy_pipeline ||= - Ci::Pipeline.new(sha: project.repository.commit('master').sha) + Ci::Pipeline.new( + sha: project.repository.commit('master').sha, + project: project) end def new_dummy_job(environment) -- cgit v1.2.3 From a080aa13a86cd0bfc11c728d9999deeafaa0a5d0 Mon Sep 17 00:00:00 2001 From: "Luke \"Jared\" Bennett" Date: Mon, 3 Jul 2017 07:44:58 +0000 Subject: Resolve "Issue Board -> "Remove from board" button when viewing an issue gives js error and fails" --- spec/features/boards/sidebar_spec.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'spec') diff --git a/spec/features/boards/sidebar_spec.rb b/spec/features/boards/sidebar_spec.rb index 301c243febd..1c9595def21 100644 --- a/spec/features/boards/sidebar_spec.rb +++ b/spec/features/boards/sidebar_spec.rb @@ -79,6 +79,22 @@ describe 'Issue Boards', feature: true, js: true do end end + it 'does not show remove button for backlog or closed issues' do + create(:issue, project: project) + create(:issue, :closed, project: project) + + visit namespace_project_board_path(project.namespace, project, board) + wait_for_requests + + click_card(find('.board:nth-child(1)').first('.card')) + + expect(find('.issue-boards-sidebar')).not_to have_button 'Remove from board' + + click_card(find('.board:nth-child(3)').first('.card')) + + expect(find('.issue-boards-sidebar')).not_to have_button 'Remove from board' + end + context 'assignee' do it 'updates the issues assignee' do click_card(card) -- cgit v1.2.3 From 9270277274b22cc92fa0bfdc9b6eb003b85f131d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Mon, 3 Jul 2017 12:55:15 +0200 Subject: Eagerly create a milestone that is used in a feature spec MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- spec/features/issues/update_issues_spec.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'spec') diff --git a/spec/features/issues/update_issues_spec.rb b/spec/features/issues/update_issues_spec.rb index dc981406e4e..df704b55839 100644 --- a/spec/features/issues/update_issues_spec.rb +++ b/spec/features/issues/update_issues_spec.rb @@ -1,16 +1,16 @@ require 'rails_helper' -feature 'Multiple issue updating from issues#index', feature: true do +feature 'Multiple issue updating from issues#index', :js do let!(:project) { create(:project) } let!(:issue) { create(:issue, project: project) } let!(:user) { create(:user)} before do project.team << [user, :master] - gitlab_sign_in(user) + sign_in(user) end - context 'status', js: true do + context 'status' do it 'sets to closed' do visit namespace_project_issues_path(project.namespace, project) @@ -37,7 +37,7 @@ feature 'Multiple issue updating from issues#index', feature: true do end end - context 'assignee', js: true do + context 'assignee' do it 'updates to current user' do visit namespace_project_issues_path(project.namespace, project) @@ -67,8 +67,8 @@ feature 'Multiple issue updating from issues#index', feature: true do end end - context 'milestone', js: true do - let(:milestone) { create(:milestone, project: project) } + context 'milestone' do + let!(:milestone) { create(:milestone, project: project) } it 'updates milestone' do visit namespace_project_issues_path(project.namespace, project) -- cgit v1.2.3 From ea9dd29a76477e73104764d2e7f937bb2ccce8c0 Mon Sep 17 00:00:00 2001 From: Douglas Barbosa Alexandre Date: Mon, 3 Jul 2017 12:38:01 -0300 Subject: Reset @full_path to nil when cache expires --- spec/models/concerns/routable_spec.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'spec') diff --git a/spec/models/concerns/routable_spec.rb b/spec/models/concerns/routable_spec.rb index be82a601b36..36aedd2f701 100644 --- a/spec/models/concerns/routable_spec.rb +++ b/spec/models/concerns/routable_spec.rb @@ -135,11 +135,12 @@ describe Group, 'Routable' do describe '#expires_full_path_cache' do context 'with RequestStore active', :request_store do it 'expires the full_path cache' do - expect(group).to receive(:uncached_full_path).twice.and_call_original + expect(group.full_path).to eq('foo') - 3.times { group.full_path } + group.route.update(path: 'bar', name: 'bar') group.expires_full_path_cache - 3.times { group.full_path } + + expect(group.full_path).to eq('bar') end end end -- cgit v1.2.3 From 2a829d0f530c1721271400c46cfc7f0387dc789a Mon Sep 17 00:00:00 2001 From: Jose Ivan Vargas Date: Mon, 3 Jul 2017 10:43:56 -0500 Subject: Fixed the y_label not setting correctly for each graph on the monitoring dashboard --- spec/javascripts/monitoring/mock_data.js | 4 ++-- spec/javascripts/monitoring/monitoring_column_spec.js | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'spec') diff --git a/spec/javascripts/monitoring/mock_data.js b/spec/javascripts/monitoring/mock_data.js index 6f4cb989847..56d938e1fbe 100644 --- a/spec/javascripts/monitoring/mock_data.js +++ b/spec/javascripts/monitoring/mock_data.js @@ -13,7 +13,7 @@ const metricsGroupsAPIResponse = { 'queries': [ { 'query_range': 'avg(container_memory_usage_bytes{%{environment_filter}}) / 2^20', - 'label': 'Container memory', + 'y_label': 'Memory', 'unit': 'MiB', 'result': [ { @@ -2477,7 +2477,7 @@ export const singleRowMetrics = [ { 'title': 'CPU usage', 'weight': 1, - 'y_label': 'Values', + 'y_label': 'Memory', 'queries': [ { 'query_range': 'avg(rate(container_cpu_usage_seconds_total{%{environment_filter}}[2m])) * 100', diff --git a/spec/javascripts/monitoring/monitoring_column_spec.js b/spec/javascripts/monitoring/monitoring_column_spec.js index c8787f9708c..b3bc97adc9f 100644 --- a/spec/javascripts/monitoring/monitoring_column_spec.js +++ b/spec/javascripts/monitoring/monitoring_column_spec.js @@ -94,4 +94,15 @@ describe('MonitoringColumn', () => { done(); }); }); + + it('has a title for the y-axis that comes from the backend', () => { + const component = createComponent({ + columnData: singleRowMetrics[0], + classType: 'col-md-6', + updateAspectRatio: false, + deploymentData, + }); + + expect(component.yAxisLabel).toEqual(component.columnData.y_label); + }); }); -- cgit v1.2.3 From dd9264011bf554567b3e7f860c2acbf53dfa3f77 Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Wed, 14 Jun 2017 04:30:07 +0000 Subject: Add integration tests around OAuth login. - There was previously a test for `saml` login in `login_spec`, but this didn't seem to be passing. A lot of things didn't seem right here, and I suspect that this test hasn't been running. I'll investigate this further. - It took almost a whole working day to figure out this line: OmniAuth.config.full_host = ->(request) { request['REQUEST_URI'].sub(request['REQUEST_PATH'], '') } As always, it's obvious in retrospect, but it took some digging to figure out tests were failing and returning 404s during the callback phase. - Test all OAuth providers - github, twitter, bitbucket, gitlab, google, and facebook --- spec/features/oauth_login_spec.rb | 58 +++++++++++++++++++++++++++++++++++++++ spec/support/login_helpers.rb | 7 +++++ 2 files changed, 65 insertions(+) create mode 100644 spec/features/oauth_login_spec.rb (limited to 'spec') diff --git a/spec/features/oauth_login_spec.rb b/spec/features/oauth_login_spec.rb new file mode 100644 index 00000000000..f960dacdcac --- /dev/null +++ b/spec/features/oauth_login_spec.rb @@ -0,0 +1,58 @@ +require 'spec_helper' + +feature 'OAuth Login', feature: true, js: true do + def enter_code(code) + fill_in 'user_otp_attempt', with: code + click_button 'Verify code' + end + + def provider_config(provider) + OpenStruct.new(name: provider.to_s, app_id: 'app_id', app_secret: 'app_secret') + end + + def stub_omniauth_config(provider) + OmniAuth.config.add_mock(provider, OmniAuth::AuthHash.new({ provider: provider.to_s, uid: "12345" })) + Rails.application.env_config['devise.mapping'] = Devise.mappings[:user] + Rails.application.env_config["omniauth.auth"] = OmniAuth.config.mock_auth[provider] + end + + providers = [:github, :twitter, :bitbucket, :gitlab, :google_oauth2, :facebook] + + before do + OmniAuth.config.full_host = ->(request) { request['REQUEST_URI'].sub(request['REQUEST_PATH'], '') } + + messages = { + enabled: true, + allow_single_sign_on: providers.map(&:to_s), + providers: providers.map { |provider| provider_config(provider) } + } + + allow(Gitlab.config.omniauth).to receive_messages(messages) + end + + providers.each do |provider| + context "when the user logs in using the #{provider} provider" do + context "when two-factor authentication is disabled" do + it 'logs the user in' do + stub_omniauth_config(provider) + user = create(:omniauth_user, extern_uid: 'my-uid', provider: provider.to_s) + login_via(provider.to_s, user, 'my-uid') + + expect(current_path).to eq root_path + save_screenshot + end + end + + context "when two-factor authentication is enabled" do + it 'logs the user in' do + stub_omniauth_config(provider) + user = create(:omniauth_user, :two_factor, extern_uid: 'my-uid', provider: provider.to_s) + login_via(provider.to_s, user, 'my-uid') + + enter_code(user.current_otp) + expect(current_path).to eq root_path + end + end + end + end +end diff --git a/spec/support/login_helpers.rb b/spec/support/login_helpers.rb index 4c88958264b..27f12cacc62 100644 --- a/spec/support/login_helpers.rb +++ b/spec/support/login_helpers.rb @@ -62,6 +62,13 @@ module LoginHelpers Thread.current[:current_user] = user end + def login_via(provider, user, uid) + mock_auth_hash(provider, uid, user.email) + visit new_user_session_path + expect(page).to have_content('Sign in with') + click_link "oauth-login-#{provider}" + end + def mock_auth_hash(provider, uid, email) # The mock_auth configuration allows you to set per-provider (or default) # authentication hashes to return during integration testing. -- cgit v1.2.3 From 6bfc355e17ef2a431940b6f697b7cd6b743fb8ad Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Thu, 15 Jun 2017 04:40:47 +0000 Subject: Test the "Remember Me" flow for OAuth-based login. --- spec/features/oauth_login_spec.rb | 61 +++++++++++++++++++++++++++++++++++++-- spec/support/capybara_helpers.rb | 5 ++++ spec/support/login_helpers.rb | 5 +++- 3 files changed, 68 insertions(+), 3 deletions(-) (limited to 'spec') diff --git a/spec/features/oauth_login_spec.rb b/spec/features/oauth_login_spec.rb index f960dacdcac..2d51abd0e97 100644 --- a/spec/features/oauth_login_spec.rb +++ b/spec/features/oauth_login_spec.rb @@ -19,7 +19,7 @@ feature 'OAuth Login', feature: true, js: true do providers = [:github, :twitter, :bitbucket, :gitlab, :google_oauth2, :facebook] before do - OmniAuth.config.full_host = ->(request) { request['REQUEST_URI'].sub(request['REQUEST_PATH'], '') } + OmniAuth.config.full_host = ->(request) { request['REQUEST_URI'].sub(/#{request['REQUEST_PATH']}.*/, '') } messages = { enabled: true, @@ -39,7 +39,6 @@ feature 'OAuth Login', feature: true, js: true do login_via(provider.to_s, user, 'my-uid') expect(current_path).to eq root_path - save_screenshot end end @@ -53,6 +52,64 @@ feature 'OAuth Login', feature: true, js: true do expect(current_path).to eq root_path end end + + context 'when "remember me" is checked' do + context "when two-factor authentication is disabled" do + it 'remembers the user after a browser restart' do + stub_omniauth_config(provider) + user = create(:omniauth_user, extern_uid: 'my-uid', provider: provider.to_s) + login_via(provider.to_s, user, 'my-uid', remember_me: true) + + restart_browser + + visit(root_path) + expect(current_path).to eq root_path + end + end + + context "when two-factor authentication is enabled" do + it 'remembers the user after a browser restart' do + stub_omniauth_config(provider) + user = create(:omniauth_user, :two_factor, extern_uid: 'my-uid', provider: provider.to_s) + login_via(provider.to_s, user, 'my-uid', remember_me: true) + enter_code(user.current_otp) + + restart_browser + + visit(root_path) + expect(current_path).to eq root_path + end + end + end + + context 'when "remember me" is not checked' do + context "when two-factor authentication is disabled" do + it 'does not remember the user after a browser restart' do + stub_omniauth_config(provider) + user = create(:omniauth_user, extern_uid: 'my-uid', provider: provider.to_s) + login_via(provider.to_s, user, 'my-uid', remember_me: false) + + restart_browser + + visit(root_path) + expect(current_path).to eq new_user_session_path + end + end + + context "when two-factor authentication is enabled" do + it 'remembers the user after a browser restart' do + stub_omniauth_config(provider) + user = create(:omniauth_user, :two_factor, extern_uid: 'my-uid', provider: provider.to_s) + login_via(provider.to_s, user, 'my-uid', remember_me: false) + enter_code(user.current_otp) + + restart_browser + + visit(root_path) + expect(current_path).to eq new_user_session_path + end + end + end end end end diff --git a/spec/support/capybara_helpers.rb b/spec/support/capybara_helpers.rb index b57a3493aff..1037e9def8c 100644 --- a/spec/support/capybara_helpers.rb +++ b/spec/support/capybara_helpers.rb @@ -35,6 +35,11 @@ module CapybaraHelpers visit 'about:blank' visit url end + + # Simulate a browser restart by clearing the session cookie. + def restart_browser + page.driver.remove_cookie('_gitlab_session') + end end RSpec.configure do |config| diff --git a/spec/support/login_helpers.rb b/spec/support/login_helpers.rb index 27f12cacc62..789cf9baae2 100644 --- a/spec/support/login_helpers.rb +++ b/spec/support/login_helpers.rb @@ -62,10 +62,13 @@ module LoginHelpers Thread.current[:current_user] = user end - def login_via(provider, user, uid) + def login_via(provider, user, uid, remember_me: false) mock_auth_hash(provider, uid, user.email) visit new_user_session_path expect(page).to have_content('Sign in with') + + check "Remember Me" if remember_me + click_link "oauth-login-#{provider}" end -- cgit v1.2.3 From de0dcfe577f7e5a849e081734eb4a396bc70d3dc Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Mon, 19 Jun 2017 04:40:24 +0000 Subject: Add more providers to the OAuth login integration tests. - Added saml, authentiq, cas3, and auth0 - Crowd seems to be a special case that will be handled separately. --- spec/features/oauth_login_spec.rb | 43 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) (limited to 'spec') diff --git a/spec/features/oauth_login_spec.rb b/spec/features/oauth_login_spec.rb index 2d51abd0e97..b37c14bd638 100644 --- a/spec/features/oauth_login_spec.rb +++ b/spec/features/oauth_login_spec.rb @@ -7,7 +7,20 @@ feature 'OAuth Login', feature: true, js: true do end def provider_config(provider) - OpenStruct.new(name: provider.to_s, app_id: 'app_id', app_secret: 'app_secret') + if provider == :saml + OpenStruct.new( + name: 'saml', label: 'saml', + args: { + assertion_consumer_service_url: 'https://localhost:3443/users/auth/saml/callback', + idp_cert_fingerprint: '26:43:2C:47:AF:F0:6B:D0:07:9C:AD:A3:74:FE:5D:94:5F:4E:9E:52', + idp_sso_target_url: 'https://idp.example.com/sso/saml', + issuer: 'https://localhost:3443/', + name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient' + } + ) + else + OpenStruct.new(name: provider.to_s, app_id: 'app_id', app_secret: 'app_secret') + end end def stub_omniauth_config(provider) @@ -16,7 +29,8 @@ feature 'OAuth Login', feature: true, js: true do Rails.application.env_config["omniauth.auth"] = OmniAuth.config.mock_auth[provider] end - providers = [:github, :twitter, :bitbucket, :gitlab, :google_oauth2, :facebook] + providers = [:github, :twitter, :bitbucket, :gitlab, :google_oauth2, + :facebook, :authentiq, :cas3, :auth0] before do OmniAuth.config.full_host = ->(request) { request['REQUEST_URI'].sub(/#{request['REQUEST_PATH']}.*/, '') } @@ -24,12 +38,37 @@ feature 'OAuth Login', feature: true, js: true do messages = { enabled: true, allow_single_sign_on: providers.map(&:to_s), + auto_link_saml_user: true, providers: providers.map { |provider| provider_config(provider) } } allow(Gitlab.config.omniauth).to receive_messages(messages) end + # context 'logging in via OAuth' do + # def saml_config + + # end + # def stub_omniauth_config(messages) + # Rails.application.env_config['devise.mapping'] = Devise.mappings[:user] + # Rails.application.routes.disable_clear_and_finalize = true + # Rails.application.routes.draw do + # post '/users/auth/saml' => 'omniauth_callbacks#saml' + # end + # allow(Gitlab::OAuth::Provider).to receive_messages(providers: [:saml], config_for: saml_config) + # allow(Gitlab.config.omniauth).to receive_messages(messages) + # expect_any_instance_of(Object).to receive(:omniauth_authorize_path).with(:user, "saml").and_return('/users/auth/saml') + # end + # it 'shows 2FA prompt after OAuth login' do + # stub_omniauth_config(enabled: true, auto_link_saml_user: true, allow_single_sign_on: ['saml'], providers: [saml_config]) + # user = create(:omniauth_user, :two_factor, extern_uid: 'my-uid', provider: 'saml') + # login_via('saml', user, 'my-uid') + # expect(page).to have_content('Two-Factor Authentication') + # enter_code(user.current_otp) + # expect(current_path).to eq root_path + # end + # end + providers.each do |provider| context "when the user logs in using the #{provider} provider" do context "when two-factor authentication is disabled" do -- cgit v1.2.3 From a931ead00cfa25752b9d66fd2c34f8463fdc54fc Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Mon, 19 Jun 2017 07:55:09 +0000 Subject: Add Omniauth OAuth config to the test section of `gitlab.yml` - I tried to get this to work by stubbing out portions of the config within the test. This didn't work as expected because Devise/Omniauth loaded before the stub could run, and the stubbed config was ignored. - I attempted to fix this by reloading Devise/Omniauth after stubbing the config. This successfully got Devise to load the stubbed providers, but failed while trying to access a route such as `user_gitlab_omniauth_authorize_path`. - I spent a while trying to figure this out (even trying `Rails.application.reload_routes!`), but nothing seemed to work. - I settled for adding this config directly to `gitlab.yml` rather than go down this path any further. --- spec/features/oauth_login_spec.rb | 52 +-------------------------------------- 1 file changed, 1 insertion(+), 51 deletions(-) (limited to 'spec') diff --git a/spec/features/oauth_login_spec.rb b/spec/features/oauth_login_spec.rb index b37c14bd638..8e02bc88fad 100644 --- a/spec/features/oauth_login_spec.rb +++ b/spec/features/oauth_login_spec.rb @@ -6,23 +6,6 @@ feature 'OAuth Login', feature: true, js: true do click_button 'Verify code' end - def provider_config(provider) - if provider == :saml - OpenStruct.new( - name: 'saml', label: 'saml', - args: { - assertion_consumer_service_url: 'https://localhost:3443/users/auth/saml/callback', - idp_cert_fingerprint: '26:43:2C:47:AF:F0:6B:D0:07:9C:AD:A3:74:FE:5D:94:5F:4E:9E:52', - idp_sso_target_url: 'https://idp.example.com/sso/saml', - issuer: 'https://localhost:3443/', - name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient' - } - ) - else - OpenStruct.new(name: provider.to_s, app_id: 'app_id', app_secret: 'app_secret') - end - end - def stub_omniauth_config(provider) OmniAuth.config.add_mock(provider, OmniAuth::AuthHash.new({ provider: provider.to_s, uid: "12345" })) Rails.application.env_config['devise.mapping'] = Devise.mappings[:user] @@ -32,43 +15,10 @@ feature 'OAuth Login', feature: true, js: true do providers = [:github, :twitter, :bitbucket, :gitlab, :google_oauth2, :facebook, :authentiq, :cas3, :auth0] - before do + before(:all) do OmniAuth.config.full_host = ->(request) { request['REQUEST_URI'].sub(/#{request['REQUEST_PATH']}.*/, '') } - - messages = { - enabled: true, - allow_single_sign_on: providers.map(&:to_s), - auto_link_saml_user: true, - providers: providers.map { |provider| provider_config(provider) } - } - - allow(Gitlab.config.omniauth).to receive_messages(messages) end - # context 'logging in via OAuth' do - # def saml_config - - # end - # def stub_omniauth_config(messages) - # Rails.application.env_config['devise.mapping'] = Devise.mappings[:user] - # Rails.application.routes.disable_clear_and_finalize = true - # Rails.application.routes.draw do - # post '/users/auth/saml' => 'omniauth_callbacks#saml' - # end - # allow(Gitlab::OAuth::Provider).to receive_messages(providers: [:saml], config_for: saml_config) - # allow(Gitlab.config.omniauth).to receive_messages(messages) - # expect_any_instance_of(Object).to receive(:omniauth_authorize_path).with(:user, "saml").and_return('/users/auth/saml') - # end - # it 'shows 2FA prompt after OAuth login' do - # stub_omniauth_config(enabled: true, auto_link_saml_user: true, allow_single_sign_on: ['saml'], providers: [saml_config]) - # user = create(:omniauth_user, :two_factor, extern_uid: 'my-uid', provider: 'saml') - # login_via('saml', user, 'my-uid') - # expect(page).to have_content('Two-Factor Authentication') - # enter_code(user.current_otp) - # expect(current_path).to eq root_path - # end - # end - providers.each do |provider| context "when the user logs in using the #{provider} provider" do context "when two-factor authentication is disabled" do -- cgit v1.2.3 From 4c34374d16411e728300be9f709bb3a7d10fbbde Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Fri, 30 Jun 2017 16:36:36 +0000 Subject: Implement review comments for !11963 from @adamniedzielski. - Change double quotes to single quotes. - Why is `OmniAuth.config.full_host` being reassigned in the integration test? - Use `map` over `map!` to avoid `dup` in the `gitlab:info` rake task - Other minor changes --- spec/features/oauth_login_spec.rb | 36 ++++++++++++++++++++++-------------- spec/support/capybara_helpers.rb | 2 +- spec/support/login_helpers.rb | 2 +- 3 files changed, 24 insertions(+), 16 deletions(-) (limited to 'spec') diff --git a/spec/features/oauth_login_spec.rb b/spec/features/oauth_login_spec.rb index 8e02bc88fad..452b920307c 100644 --- a/spec/features/oauth_login_spec.rb +++ b/spec/features/oauth_login_spec.rb @@ -1,27 +1,35 @@ require 'spec_helper' -feature 'OAuth Login', feature: true, js: true do +feature 'OAuth Login', js: true do def enter_code(code) fill_in 'user_otp_attempt', with: code click_button 'Verify code' end def stub_omniauth_config(provider) - OmniAuth.config.add_mock(provider, OmniAuth::AuthHash.new({ provider: provider.to_s, uid: "12345" })) + OmniAuth.config.add_mock(provider, OmniAuth::AuthHash.new(provider: provider.to_s, uid: "12345")) Rails.application.env_config['devise.mapping'] = Devise.mappings[:user] - Rails.application.env_config["omniauth.auth"] = OmniAuth.config.mock_auth[provider] + Rails.application.env_config['omniauth.auth'] = OmniAuth.config.mock_auth[provider] end providers = [:github, :twitter, :bitbucket, :gitlab, :google_oauth2, :facebook, :authentiq, :cas3, :auth0] before(:all) do + # The OmniAuth `full_host` parameter doesn't get set correctly (it gets set to something like `http://localhost` + # here), and causes integration tests to fail with 404s. We set the `full_host` by removing the request path (and + # anything after it) from the request URI. + @omniauth_config_full_host = OmniAuth.config.full_host OmniAuth.config.full_host = ->(request) { request['REQUEST_URI'].sub(/#{request['REQUEST_PATH']}.*/, '') } end + after(:all) do + OmniAuth.config.full_host = @omniauth_config_full_host + end + providers.each do |provider| context "when the user logs in using the #{provider} provider" do - context "when two-factor authentication is disabled" do + context 'when two-factor authentication is disabled' do it 'logs the user in' do stub_omniauth_config(provider) user = create(:omniauth_user, extern_uid: 'my-uid', provider: provider.to_s) @@ -31,7 +39,7 @@ feature 'OAuth Login', feature: true, js: true do end end - context "when two-factor authentication is enabled" do + context 'when two-factor authentication is enabled' do it 'logs the user in' do stub_omniauth_config(provider) user = create(:omniauth_user, :two_factor, extern_uid: 'my-uid', provider: provider.to_s) @@ -43,27 +51,27 @@ feature 'OAuth Login', feature: true, js: true do end context 'when "remember me" is checked' do - context "when two-factor authentication is disabled" do + context 'when two-factor authentication is disabled' do it 'remembers the user after a browser restart' do stub_omniauth_config(provider) user = create(:omniauth_user, extern_uid: 'my-uid', provider: provider.to_s) login_via(provider.to_s, user, 'my-uid', remember_me: true) - restart_browser + clear_browser_session visit(root_path) expect(current_path).to eq root_path end end - context "when two-factor authentication is enabled" do + context 'when two-factor authentication is enabled' do it 'remembers the user after a browser restart' do stub_omniauth_config(provider) user = create(:omniauth_user, :two_factor, extern_uid: 'my-uid', provider: provider.to_s) login_via(provider.to_s, user, 'my-uid', remember_me: true) enter_code(user.current_otp) - restart_browser + clear_browser_session visit(root_path) expect(current_path).to eq root_path @@ -72,27 +80,27 @@ feature 'OAuth Login', feature: true, js: true do end context 'when "remember me" is not checked' do - context "when two-factor authentication is disabled" do + context 'when two-factor authentication is disabled' do it 'does not remember the user after a browser restart' do stub_omniauth_config(provider) user = create(:omniauth_user, extern_uid: 'my-uid', provider: provider.to_s) login_via(provider.to_s, user, 'my-uid', remember_me: false) - restart_browser + clear_browser_session visit(root_path) expect(current_path).to eq new_user_session_path end end - context "when two-factor authentication is enabled" do - it 'remembers the user after a browser restart' do + context 'when two-factor authentication is enabled' do + it 'does not remember the user after a browser restart' do stub_omniauth_config(provider) user = create(:omniauth_user, :two_factor, extern_uid: 'my-uid', provider: provider.to_s) login_via(provider.to_s, user, 'my-uid', remember_me: false) enter_code(user.current_otp) - restart_browser + clear_browser_session visit(root_path) expect(current_path).to eq new_user_session_path diff --git a/spec/support/capybara_helpers.rb b/spec/support/capybara_helpers.rb index 1037e9def8c..3eb7bea3227 100644 --- a/spec/support/capybara_helpers.rb +++ b/spec/support/capybara_helpers.rb @@ -37,7 +37,7 @@ module CapybaraHelpers end # Simulate a browser restart by clearing the session cookie. - def restart_browser + def clear_browser_session page.driver.remove_cookie('_gitlab_session') end end diff --git a/spec/support/login_helpers.rb b/spec/support/login_helpers.rb index 789cf9baae2..184c7b5125a 100644 --- a/spec/support/login_helpers.rb +++ b/spec/support/login_helpers.rb @@ -67,7 +67,7 @@ module LoginHelpers visit new_user_session_path expect(page).to have_content('Sign in with') - check "Remember Me" if remember_me + check 'Remember Me' if remember_me click_link "oauth-login-#{provider}" end -- cgit v1.2.3 From 73f5b02b4fa275bbd3a5880144114ea69f594307 Mon Sep 17 00:00:00 2001 From: Douglas Barbosa Alexandre Date: Mon, 3 Jul 2017 14:37:20 -0300 Subject: Change the force flag to a keyword argument --- spec/models/project_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 0eeaf68a02a..1a56f6f5c59 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -1344,7 +1344,7 @@ describe Project, models: true do .with(project.repository_storage_path, project.path_with_namespace) .and_return(true) - expect(project).to receive(:create_repository) + expect(project).to receive(:create_repository).with(force: true) project.ensure_repository end -- cgit v1.2.3 From d8cc0d0115aefe02b611489a89cb11c125d802af Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Mon, 3 Jul 2017 18:28:29 +0000 Subject: Speed up operations performed by gitlab-shell --- spec/lib/gitlab/popen_spec.rb | 13 ++++++- spec/lib/gitlab/shell_spec.rb | 87 ++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 94 insertions(+), 6 deletions(-) (limited to 'spec') diff --git a/spec/lib/gitlab/popen_spec.rb b/spec/lib/gitlab/popen_spec.rb index 4ae216d55b0..af50ecdb2ab 100644 --- a/spec/lib/gitlab/popen_spec.rb +++ b/spec/lib/gitlab/popen_spec.rb @@ -32,6 +32,17 @@ describe 'Gitlab::Popen', lib: true, no_db: true do end end + context 'with custom options' do + let(:vars) { { 'foobar' => 123, 'PWD' => path } } + let(:options) { { chdir: path } } + + it 'calls popen3 with the provided environment variables' do + expect(Open3).to receive(:popen3).with(vars, 'ls', options) + + @output, @status = @klass.new.popen(%w(ls), path, { 'foobar' => 123 }) + end + end + context 'without a directory argument' do before do @output, @status = @klass.new.popen(%w(ls)) @@ -45,7 +56,7 @@ describe 'Gitlab::Popen', lib: true, no_db: true do before do @output, @status = @klass.new.popen(%w[cat]) { |stdin| stdin.write 'hello' } end - + it { expect(@status).to be_zero } it { expect(@output).to eq('hello') } end diff --git a/spec/lib/gitlab/shell_spec.rb b/spec/lib/gitlab/shell_spec.rb index a97a0f8452b..5b1b8f9516a 100644 --- a/spec/lib/gitlab/shell_spec.rb +++ b/spec/lib/gitlab/shell_spec.rb @@ -4,6 +4,7 @@ require 'stringio' describe Gitlab::Shell, lib: true do let(:project) { double('Project', id: 7, path: 'diaspora') } let(:gitlab_shell) { Gitlab::Shell.new } + let(:popen_vars) { { 'GIT_TERMINAL_PROMPT' => ENV['GIT_TERMINAL_PROMPT'] } } before do allow(Project).to receive(:find).and_return(project) @@ -50,7 +51,7 @@ describe Gitlab::Shell, lib: true do describe '#add_key' do it 'removes trailing garbage' do allow(gitlab_shell).to receive(:gitlab_shell_keys_path).and_return(:gitlab_shell_keys_path) - expect(Gitlab::Utils).to receive(:system_silent).with( + expect(gitlab_shell).to receive(:gitlab_shell_fast_execute).with( [:gitlab_shell_keys_path, 'add-key', 'key-123', 'ssh-rsa foobar'] ) @@ -100,17 +101,91 @@ describe Gitlab::Shell, lib: true do allow(Gitlab.config.gitlab_shell).to receive(:git_timeout).and_return(800) end + describe '#add_repository' do + it 'returns true when the command succeeds' do + expect(Gitlab::Popen).to receive(:popen) + .with([projects_path, 'add-project', 'current/storage', 'project/path.git'], + nil, popen_vars).and_return([nil, 0]) + + expect(gitlab_shell.add_repository('current/storage', 'project/path')).to be true + end + + it 'returns false when the command fails' do + expect(Gitlab::Popen).to receive(:popen) + .with([projects_path, 'add-project', 'current/storage', 'project/path.git'], + nil, popen_vars).and_return(["error", 1]) + + expect(gitlab_shell.add_repository('current/storage', 'project/path')).to be false + end + end + + describe '#remove_repository' do + it 'returns true when the command succeeds' do + expect(Gitlab::Popen).to receive(:popen) + .with([projects_path, 'rm-project', 'current/storage', 'project/path.git'], + nil, popen_vars).and_return([nil, 0]) + + expect(gitlab_shell.remove_repository('current/storage', 'project/path')).to be true + end + + it 'returns false when the command fails' do + expect(Gitlab::Popen).to receive(:popen) + .with([projects_path, 'rm-project', 'current/storage', 'project/path.git'], + nil, popen_vars).and_return(["error", 1]) + + expect(gitlab_shell.remove_repository('current/storage', 'project/path')).to be false + end + end + + describe '#mv_repository' do + it 'returns true when the command succeeds' do + expect(Gitlab::Popen).to receive(:popen) + .with([projects_path, 'mv-project', 'current/storage', 'project/path.git', 'project/newpath.git'], + nil, popen_vars).and_return([nil, 0]) + + expect(gitlab_shell.mv_repository('current/storage', 'project/path', 'project/newpath')).to be true + end + + it 'returns false when the command fails' do + expect(Gitlab::Popen).to receive(:popen) + .with([projects_path, 'mv-project', 'current/storage', 'project/path.git', 'project/newpath.git'], + nil, popen_vars).and_return(["error", 1]) + + expect(gitlab_shell.mv_repository('current/storage', 'project/path', 'project/newpath')).to be false + end + end + + describe '#fork_repository' do + it 'returns true when the command succeeds' do + expect(Gitlab::Popen).to receive(:popen) + .with([projects_path, 'fork-project', 'current/storage', 'project/path.git', 'new/storage', 'new-namespace'], + nil, popen_vars).and_return([nil, 0]) + + expect(gitlab_shell.fork_repository('current/storage', 'project/path', 'new/storage', 'new-namespace')).to be true + end + + it 'return false when the command fails' do + expect(Gitlab::Popen).to receive(:popen) + .with([projects_path, 'fork-project', 'current/storage', 'project/path.git', 'new/storage', 'new-namespace'], + nil, popen_vars).and_return(["error", 1]) + + expect(gitlab_shell.fork_repository('current/storage', 'project/path', 'new/storage', 'new-namespace')).to be false + end + end + describe '#fetch_remote' do it 'returns true when the command succeeds' do expect(Gitlab::Popen).to receive(:popen) - .with([projects_path, 'fetch-remote', 'current/storage', 'project/path.git', 'new/storage', '800']).and_return([nil, 0]) + .with([projects_path, 'fetch-remote', 'current/storage', 'project/path.git', 'new/storage', '800'], + nil, popen_vars).and_return([nil, 0]) expect(gitlab_shell.fetch_remote('current/storage', 'project/path', 'new/storage')).to be true end it 'raises an exception when the command fails' do expect(Gitlab::Popen).to receive(:popen) - .with([projects_path, 'fetch-remote', 'current/storage', 'project/path.git', 'new/storage', '800']).and_return(["error", 1]) + .with([projects_path, 'fetch-remote', 'current/storage', 'project/path.git', 'new/storage', '800'], + nil, popen_vars).and_return(["error", 1]) expect { gitlab_shell.fetch_remote('current/storage', 'project/path', 'new/storage') }.to raise_error(Gitlab::Shell::Error, "error") end @@ -119,14 +194,16 @@ describe Gitlab::Shell, lib: true do describe '#import_repository' do it 'returns true when the command succeeds' do expect(Gitlab::Popen).to receive(:popen) - .with([projects_path, 'import-project', 'current/storage', 'project/path.git', 'https://gitlab.com/gitlab-org/gitlab-ce.git', "800"]).and_return([nil, 0]) + .with([projects_path, 'import-project', 'current/storage', 'project/path.git', 'https://gitlab.com/gitlab-org/gitlab-ce.git', "800"], + nil, popen_vars).and_return([nil, 0]) expect(gitlab_shell.import_repository('current/storage', 'project/path', 'https://gitlab.com/gitlab-org/gitlab-ce.git')).to be true end it 'raises an exception when the command fails' do expect(Gitlab::Popen).to receive(:popen) - .with([projects_path, 'import-project', 'current/storage', 'project/path.git', 'https://gitlab.com/gitlab-org/gitlab-ce.git', "800"]).and_return(["error", 1]) + .with([projects_path, 'import-project', 'current/storage', 'project/path.git', 'https://gitlab.com/gitlab-org/gitlab-ce.git', "800"], + nil, popen_vars).and_return(["error", 1]) expect { gitlab_shell.import_repository('current/storage', 'project/path', 'https://gitlab.com/gitlab-org/gitlab-ce.git') }.to raise_error(Gitlab::Shell::Error, "error") end -- cgit v1.2.3 From 63bf2457e40ffd465d9a5aeee9b26b1c82432f9d Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Tue, 4 Jul 2017 03:08:30 +0800 Subject: Follow feedback on the merge request --- spec/models/ci/pipeline_spec.rb | 25 ++----------------------- spec/models/project_spec.rb | 24 ++++++++++++++++++++++++ spec/support/cycle_analytics_helpers.rb | 4 +--- 3 files changed, 27 insertions(+), 26 deletions(-) (limited to 'spec') diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index 8d4d87def5e..e36e9082036 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -748,30 +748,9 @@ describe Ci::Pipeline, models: true do end end - describe '#ci_yaml_file_path' do - let(:project) { create(:empty_project) } - let(:pipeline) { create(:ci_empty_pipeline, project: project) } - - it 'returns the path from project' do - allow(project).to receive(:ci_config_file) { 'custom/path' } - - expect(pipeline.ci_yaml_file_path).to eq('custom/path') - end - - it 'returns default when custom path is nil' do - allow(project).to receive(:ci_config_file) { nil } - - expect(pipeline.ci_yaml_file_path).to eq('.gitlab-ci.yml') - end - - it 'returns default when custom path is empty' do - allow(project).to receive(:ci_config_file) { '' } - - expect(pipeline.ci_yaml_file_path).to eq('.gitlab-ci.yml') - end - + describe '#ci_yaml_file' do it 'reports error if the file is not found' do - allow(project).to receive(:ci_config_file) { 'custom' } + allow(pipeline.project).to receive(:ci_config_file) { 'custom' } pipeline.ci_yaml_file diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 349f9c3d7eb..f06f7d6b54b 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -1493,6 +1493,30 @@ describe Project, models: true do end end + describe '#ci_config_file_for_pipeline' do + let(:project) { create(:empty_project) } + + subject { project.ci_config_file_for_pipeline } + + it 'returns the path from project' do + allow(project).to receive(:ci_config_file) { 'custom/path' } + + is_expected.to eq('custom/path') + end + + it 'returns default when custom path is nil' do + allow(project).to receive(:ci_config_file) { nil } + + is_expected.to eq('.gitlab-ci.yml') + end + + it 'returns default when custom path is empty' do + allow(project).to receive(:ci_config_file) { '' } + + is_expected.to eq('.gitlab-ci.yml') + end + end + describe '#ci_config_file=' do let(:project) { create(:empty_project) } diff --git a/spec/support/cycle_analytics_helpers.rb b/spec/support/cycle_analytics_helpers.rb index c0a5491a430..916544babcf 100644 --- a/spec/support/cycle_analytics_helpers.rb +++ b/spec/support/cycle_analytics_helpers.rb @@ -74,9 +74,7 @@ module CycleAnalyticsHelpers def dummy_pipeline @dummy_pipeline ||= - Ci::Pipeline.new( - sha: project.repository.commit('master').sha, - project: project) + project.pipelines.build(sha: project.repository.commit('master').sha) end def new_dummy_job(environment) -- cgit v1.2.3 From 9a0f5bd55bc9f1514909a59283fbc0651e11c127 Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Mon, 3 Jul 2017 19:37:37 +0000 Subject: Fix build for !11963. - Don't use `request.env['omniauth.params']` if it isn't present. - Remove the `saml` section from the `gitlab.yml` test section. Some tests depend on this section not being initially present, so it can be overridden in the test. This MR doesn't add any tests for SAML, so we didn't really need this in the first place anyway. - Clean up the test -> omniauth section of `gitlab.yml` --- spec/support/login_helpers.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/support/login_helpers.rb b/spec/support/login_helpers.rb index 184c7b5125a..99e7806353d 100644 --- a/spec/support/login_helpers.rb +++ b/spec/support/login_helpers.rb @@ -118,6 +118,7 @@ module LoginHelpers end allow(Gitlab::OAuth::Provider).to receive_messages(providers: [:saml], config_for: mock_saml_config) stub_omniauth_setting(messages) - expect_any_instance_of(Object).to receive(:omniauth_authorize_path).with(:user, "saml").and_return('/users/auth/saml') + 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 end -- cgit v1.2.3 From e0f106ae97334d622c6eb7580e72e17181fddd6e Mon Sep 17 00:00:00 2001 From: Toon Claes Date: Tue, 4 Jul 2017 11:51:00 +0200 Subject: DeleteMergedBranchesService should not delete protected branches When deleting all the branches that are merged, the protected branches should not be deleted. --- spec/services/delete_merged_branches_service_spec.rb | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'spec') diff --git a/spec/services/delete_merged_branches_service_spec.rb b/spec/services/delete_merged_branches_service_spec.rb index cae74df9c90..fe21ca0b3cb 100644 --- a/spec/services/delete_merged_branches_service_spec.rb +++ b/spec/services/delete_merged_branches_service_spec.rb @@ -24,6 +24,14 @@ describe DeleteMergedBranchesService, services: true do expect(project.repository.branch_names).to include('master') end + it 'keeps protected branches' do + create(:protected_branch, project: project, name: 'improve/awesome') + + service.execute + + expect(project.repository.branch_names).to include('improve/awesome') + end + context 'user without rights' do let(:user) { create(:user) } -- cgit v1.2.3 From 4d9c2bad369d510877dff719d94a5f98b1ee4dfe Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Tue, 4 Jul 2017 03:22:19 +0800 Subject: Fix config path --- spec/models/ci/build_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index e5fd549f0d7..1553d6d3a9a 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -1179,7 +1179,7 @@ describe Ci::Build, :models do { key: 'CI_PROJECT_NAMESPACE', value: project.namespace.full_path, public: true }, { key: 'CI_PROJECT_URL', value: project.web_url, public: true }, { key: 'CI_PIPELINE_ID', value: pipeline.id.to_s, public: true }, - { key: 'CI_CONFIG_PATH', value: pipeline.ci_yaml_file_path, public: true }, + { key: 'CI_CONFIG_PATH', value: project.ci_config_file_for_pipeline, 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 } -- cgit v1.2.3 From 84e37683cb838337f84df387ec8e8251e167fa20 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Tue, 4 Jul 2017 03:35:06 +0800 Subject: Make sure we remove null characters --- spec/models/project_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'spec') diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index f06f7d6b54b..4ef768123bd 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -1532,8 +1532,8 @@ describe Project, models: true do expect(project.ci_config_file).to eq('foo/.gitlab_ci.yml') end - it 'sets a string but remove all leading slashes' do - project.update!(ci_config_file: '///foo//.gitlab_ci.yml') + it 'sets a string but remove all leading slashes and null characters' do + project.update!(ci_config_file: "///f\0oo/\0/.gitlab_ci.yml") expect(project.ci_config_file).to eq('foo//.gitlab_ci.yml') end -- cgit v1.2.3 From f39fe34afb4a69ebca462219abb881e243f4a955 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Thu, 29 Jun 2017 14:11:42 +0200 Subject: Add test for GitalyClient::Ref#find_ref_name --- spec/lib/gitlab/gitaly_client/ref_spec.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'spec') diff --git a/spec/lib/gitlab/gitaly_client/ref_spec.rb b/spec/lib/gitlab/gitaly_client/ref_spec.rb index 986ae348652..b7de7e598e3 100644 --- a/spec/lib/gitlab/gitaly_client/ref_spec.rb +++ b/spec/lib/gitlab/gitaly_client/ref_spec.rb @@ -78,4 +78,13 @@ describe Gitlab::GitalyClient::Ref do expect { client.local_branches(sort_by: 'invalid_sort') }.to raise_error(ArgumentError) end end + + describe '#find_ref_name', seed_helper: true do + let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH) } + let(:client) { described_class.new(repository) } + subject { client.find_ref_name(SeedRepo::Commit::ID, 'refs/heads/master') } + + it { should be_utf8 } + it { should eq('refs/heads/master') } + end end -- cgit v1.2.3 From ec35a9e8609c3e110e025629f5058433ce06b123 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Thu, 29 Jun 2017 14:37:54 +0200 Subject: Remove unnecessary clear_stubs calls --- spec/lib/gitlab/git/repository_spec.rb | 5 ----- spec/lib/gitlab/gitaly_client/ref_spec.rb | 7 ------- 2 files changed, 12 deletions(-) (limited to 'spec') diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb index 9e924c2541b..f1cdd86edb9 100644 --- a/spec/lib/gitlab/git/repository_spec.rb +++ b/spec/lib/gitlab/git/repository_spec.rb @@ -5,11 +5,6 @@ describe Gitlab::Git::Repository, seed_helper: true do let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH) } - after do - # Prevent cached stubs (gRPC connection objects) from poisoning tests. - Gitlab::GitalyClient.clear_stubs! - end - describe "Respond to" do subject { repository } diff --git a/spec/lib/gitlab/gitaly_client/ref_spec.rb b/spec/lib/gitlab/gitaly_client/ref_spec.rb index b7de7e598e3..df22fcad902 100644 --- a/spec/lib/gitlab/gitaly_client/ref_spec.rb +++ b/spec/lib/gitlab/gitaly_client/ref_spec.rb @@ -6,13 +6,6 @@ describe Gitlab::GitalyClient::Ref do let(:relative_path) { project.path_with_namespace + '.git' } let(:client) { described_class.new(project.repository) } - after do - # When we say `expect_any_instance_of(Gitaly::Ref::Stub)` a double is created, - # and because GitalyClient shares stubs these will get passed from example to - # example, which will cause an error, so we clean the stubs after each example. - Gitlab::GitalyClient.clear_stubs! - end - describe '#branch_names' do it 'sends a find_all_branch_names message' do expect_any_instance_of(Gitaly::Ref::Stub) -- cgit v1.2.3 From 1501a4f578fa947af66a981fd56885be8467d5b5 Mon Sep 17 00:00:00 2001 From: Nick Thomas Date: Tue, 4 Jul 2017 11:48:25 +0100 Subject: Clean up the ForkedProjectLink specs --- spec/models/forked_project_link_spec.rb | 64 ++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 29 deletions(-) (limited to 'spec') diff --git a/spec/models/forked_project_link_spec.rb b/spec/models/forked_project_link_spec.rb index 6e8d43f988c..4fd250bd4c6 100644 --- a/spec/models/forked_project_link_spec.rb +++ b/spec/models/forked_project_link_spec.rb @@ -2,53 +2,59 @@ require 'spec_helper' describe ForkedProjectLink, "add link on fork" do let(:project_from) { create(:project, :repository) } + let(:project_to) { fork_project(project_from, user) } let(:user) { create(:user) } let(:namespace) { user.namespace } before do - create(:project_member, :reporter, user: user, project: project_from) - @project_to = fork_project(project_from, user) + project_from.add_reporter(user) + end + + it 'project_from knows its forks' do + _ = project_to + + expect(project_from.forks.count).to eq(1) end it "project_to knows it is forked" do - expect(@project_to.forked?).to be_truthy + expect(project_to.forked?).to be_truthy end it "project knows who it is forked from" do - expect(@project_to.forked_from_project).to eq(project_from) + expect(project_to.forked_from_project).to eq(project_from) end -end -describe '#forked?' do - let(:forked_project_link) { build(:forked_project_link) } - let(:project_from) { create(:project, :repository) } - let(:project_to) { create(:project, forked_project_link: forked_project_link) } + describe '#forked?' do + let(:project_to) { create(:project, forked_project_link: forked_project_link) } + let(:forked_project_link) { build(:forked_project_link) } - before :each do - forked_project_link.forked_from_project = project_from - forked_project_link.forked_to_project = project_to - forked_project_link.save! - end + before do + forked_project_link.forked_from_project = project_from + forked_project_link.forked_to_project = project_to + forked_project_link.save! + end - it "project_to knows it is forked" do - expect(project_to.forked?).to be_truthy - end + it "project_to knows it is forked" do + expect(project_to.forked?).to be_truthy + end - it "project_from is not forked" do - expect(project_from.forked?).to be_falsey - end + it "project_from is not forked" do + expect(project_from.forked?).to be_falsey + end - it "project_to.destroy destroys fork_link" do - expect(forked_project_link).to receive(:destroy) - project_to.destroy + it "project_to.destroy destroys fork_link" do + expect(forked_project_link).to receive(:destroy) + + project_to.destroy + end end -end -def fork_project(from_project, user) - shell = double('gitlab_shell', fork_repository: true) + def fork_project(from_project, user) + service = Projects::ForkService.new(from_project, user) + shell = double('gitlab_shell', fork_repository: true) - service = Projects::ForkService.new(from_project, user) - allow(service).to receive(:gitlab_shell).and_return(shell) + allow(service).to receive(:gitlab_shell).and_return(shell) - service.execute + service.execute + end end -- cgit v1.2.3 From cb1f3423876f84861facc4c3631eeb4b453ceee6 Mon Sep 17 00:00:00 2001 From: Nick Thomas Date: Mon, 3 Jul 2017 11:31:37 +0100 Subject: Don't resolve fork relationships for projects pending delete --- spec/models/forked_project_link_spec.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'spec') diff --git a/spec/models/forked_project_link_spec.rb b/spec/models/forked_project_link_spec.rb index 4fd250bd4c6..5c13cf584f9 100644 --- a/spec/models/forked_project_link_spec.rb +++ b/spec/models/forked_project_link_spec.rb @@ -24,6 +24,22 @@ describe ForkedProjectLink, "add link on fork" do expect(project_to.forked_from_project).to eq(project_from) end + context 'project_to is pending_delete' do + before do + project_to.update!(pending_delete: true) + end + + it { expect(project_from.forks.count).to eq(0) } + end + + context 'project_from is pending_delete' do + before do + project_from.update!(pending_delete: true) + end + + it { expect(project_to.forked_from_project).to be_nil } + end + describe '#forked?' do let(:project_to) { create(:project, forked_project_link: forked_project_link) } let(:forked_project_link) { build(:forked_project_link) } -- cgit v1.2.3 From 0c7e1c167b4849df000dfd524ddf82c00d180903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Tue, 4 Jul 2017 13:51:28 +0200 Subject: wait_for_requests is not needed when AJAX is not in play MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also, using page.current_path instead of current_url and move the URL expectation after the page content expectations. Signed-off-by: Rémy Coutable --- spec/features/issues/move_spec.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'spec') diff --git a/spec/features/issues/move_spec.rb b/spec/features/issues/move_spec.rb index 21a7637fe7f..d6e78157e5f 100644 --- a/spec/features/issues/move_spec.rb +++ b/spec/features/issues/move_spec.rb @@ -41,13 +41,10 @@ feature 'issue move to another project' do find('#issuable-move', visible: false).set(new_project.id) click_button('Save changes') - wait_for_requests - - expect(current_url).to include project_path(new_project) - expect(page).to have_content("Text with #{cross_reference}#{mr.to_reference}") expect(page).to have_content("moved from #{cross_reference}#{issue.to_reference}") expect(page).to have_content(issue.title) + expect(page.current_path).to include project_path(new_project) end scenario 'searching project dropdown', js: true do -- cgit v1.2.3 From 4818f904c2150411e4d84e67abe2fcaa45448abe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Tue, 4 Jul 2017 13:10:43 +0200 Subject: Use stub_application_setting when testing ApplicationHelper#support_url MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- spec/helpers/application_helper_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 56daeffde27..f161dbb4cf0 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -292,7 +292,7 @@ describe ApplicationHelper do let(:alternate_url) { 'http://company.example.com/getting-help' } before do - allow(current_application_settings).to receive(:help_page_support_url) { alternate_url } + stub_application_setting(help_page_support_url: alternate_url) end it 'returns the alternate support url' do -- cgit v1.2.3 From d1488268b2e31b8f3549c6e1e46955619535cd98 Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Tue, 4 Jul 2017 12:19:48 +0000 Subject: Simplify authentication logic in the v4 users API for !12445. - Rather than using an explicit check to turn off authentication for the `/users` endpoint, simply call `authenticate_non_get!`. - All `GET` endpoints we wish to restrict already call `authenticated_as_admin!`, and so remain inacessible to anonymous users. - This _does_ open up the `/users/:id` endpoint to anonymous access. It contains the same access check that `/users` users, and so is safe for use here. - More context: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/12445#note_34031323 --- spec/requests/api/users_spec.rb | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'spec') diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index aa95ae8c7cc..8640c16203e 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -169,6 +169,7 @@ describe API::Users do describe "GET /users/:id" do it "returns a user by id" do get api("/users/#{user.id}", user) + expect(response).to have_http_status(200) expect(json_response['username']).to eq(user.username) end @@ -179,9 +180,22 @@ describe API::Users do expect(json_response['is_admin']).to be_nil end - it "returns a 401 if unauthenticated" do - get api("/users/9998") - expect(response).to have_http_status(401) + context 'for an anonymous user' do + it "returns a user by id" do + get api("/users/#{user.id}") + + expect(response).to have_http_status(200) + expect(json_response['username']).to eq(user.username) + end + + it "returns a 404 if the target user is present but inaccessible" do + allow(Ability).to receive(:allowed?).and_call_original + allow(Ability).to receive(:allowed?).with(nil, :read_user, user).and_return(false) + + get api("/users/#{user.id}") + + expect(response).to have_http_status(404) + end end it "returns a 404 error if user id not found" do -- cgit v1.2.3 From 2ae8158c8c1ac6add71b4f3ef8738c5919bdca4e Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Tue, 4 Jul 2017 11:59:41 +0000 Subject: Add Jasmine tests for `OAuthRememberMe` --- .../fixtures/oauth_remember_me.html.haml | 5 +++++ spec/javascripts/oauth_remember_me_spec.js | 26 ++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 spec/javascripts/fixtures/oauth_remember_me.html.haml create mode 100644 spec/javascripts/oauth_remember_me_spec.js (limited to 'spec') diff --git a/spec/javascripts/fixtures/oauth_remember_me.html.haml b/spec/javascripts/fixtures/oauth_remember_me.html.haml new file mode 100644 index 00000000000..7886e995e57 --- /dev/null +++ b/spec/javascripts/fixtures/oauth_remember_me.html.haml @@ -0,0 +1,5 @@ +#oauth-container + %input#remember_me{ type: "checkbox" } + + %a.oauth-login.twitter{ href: "http://example.com/" } + %a.oauth-login.github{ href: "http://example.com/" } diff --git a/spec/javascripts/oauth_remember_me_spec.js b/spec/javascripts/oauth_remember_me_spec.js new file mode 100644 index 00000000000..f90e0093d25 --- /dev/null +++ b/spec/javascripts/oauth_remember_me_spec.js @@ -0,0 +1,26 @@ +import OAuthRememberMe from '~/oauth_remember_me'; + +describe('OAuthRememberMe', () => { + preloadFixtures('static/oauth_remember_me.html.raw'); + + beforeEach(() => { + loadFixtures('static/oauth_remember_me.html.raw'); + + new OAuthRememberMe({ container: $('#oauth-container') }).bindEvents(); + }); + + it('adds the "remember_me" query parameter to all OAuth login buttons', () => { + $('#oauth-container #remember_me').click(); + + expect($('#oauth-container .oauth-login.twitter').attr('href')).toBe('http://example.com/?remember_me=1'); + expect($('#oauth-container .oauth-login.github').attr('href')).toBe('http://example.com/?remember_me=1'); + }); + + it('removes the "remember_me" query parameter from all OAuth login buttons', () => { + $('#oauth-container #remember_me').click(); + $('#oauth-container #remember_me').click(); + + expect($('#oauth-container .oauth-login.twitter').attr('href')).toBe('http://example.com/'); + expect($('#oauth-container .oauth-login.github').attr('href')).toBe('http://example.com/'); + }); +}); -- cgit v1.2.3 From 2210a71b17d41ca0f1b5b4e619aa7fa8f41ad5cd Mon Sep 17 00:00:00 2001 From: Diego Souza Date: Tue, 4 Jul 2017 15:18:51 +0000 Subject: Remove group modal like remove project modal. Closes #33130 --- spec/features/groups_spec.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'spec') diff --git a/spec/features/groups_spec.rb b/spec/features/groups_spec.rb index ecacca00a61..c1dc7be7088 100644 --- a/spec/features/groups_spec.rb +++ b/spec/features/groups_spec.rb @@ -135,7 +135,7 @@ feature 'Group', feature: true do expect(page).not_to have_content('secret-group') end - describe 'group edit' do + describe 'group edit', js: true do let(:group) { create(:group) } let(:path) { edit_group_path(group) } let(:new_name) { 'new-name' } @@ -157,8 +157,8 @@ feature 'Group', feature: true do end it 'removes group' do - click_link 'Remove group' - + expect { remove_with_confirm('Remove group', group.path) }.to change {Group.count}.by(-1) + expect(group.members.all.count).to be_zero expect(page).to have_content "scheduled for deletion" end end @@ -212,4 +212,10 @@ feature 'Group', feature: true do expect(page).to have_content(nested_group.name) end end + + def remove_with_confirm(button_text, confirm_with) + click_button button_text + fill_in 'confirm_name_input', with: confirm_with + click_button 'Confirm' + end end -- cgit v1.2.3 From 26ac691a688cb569a7345d8f31a406d467240bb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Chojnacki?= Date: Tue, 4 Jul 2017 15:28:34 +0000 Subject: Instrument Unicorn with Ruby exporter --- spec/initializers/8_metrics_spec.rb | 10 +- .../metrics/connection_rack_middleware_spec.rb | 88 ++++++++++++ spec/lib/gitlab/metrics/influx_sampler_spec.rb | 150 +++++++++++++++++++++ spec/lib/gitlab/metrics/sampler_spec.rb | 150 --------------------- spec/lib/gitlab/metrics/unicorn_sampler_spec.rb | 108 +++++++++++++++ 5 files changed, 355 insertions(+), 151 deletions(-) create mode 100644 spec/lib/gitlab/metrics/connection_rack_middleware_spec.rb create mode 100644 spec/lib/gitlab/metrics/influx_sampler_spec.rb delete mode 100644 spec/lib/gitlab/metrics/sampler_spec.rb create mode 100644 spec/lib/gitlab/metrics/unicorn_sampler_spec.rb (limited to 'spec') diff --git a/spec/initializers/8_metrics_spec.rb b/spec/initializers/8_metrics_spec.rb index a507d7f7f2b..d4189f902fd 100644 --- a/spec/initializers/8_metrics_spec.rb +++ b/spec/initializers/8_metrics_spec.rb @@ -1,17 +1,25 @@ require 'spec_helper' -require_relative '../../config/initializers/8_metrics' describe 'instrument_classes', lib: true do let(:config) { double(:config) } + let(:unicorn_sampler) { double(:unicorn_sampler) } + let(:influx_sampler) { double(:influx_sampler) } + before do allow(config).to receive(:instrument_method) allow(config).to receive(:instrument_methods) allow(config).to receive(:instrument_instance_method) allow(config).to receive(:instrument_instance_methods) + allow(Gitlab::Metrics::UnicornSampler).to receive(:initialize_instance).and_return(unicorn_sampler) + allow(Gitlab::Metrics::InfluxSampler).to receive(:initialize_instance).and_return(influx_sampler) + allow(unicorn_sampler).to receive(:start) + allow(influx_sampler).to receive(:start) + allow(Gitlab::Application).to receive(:configure) end it 'can autoload and instrument all files' do + require_relative '../../config/initializers/8_metrics' expect { instrument_classes(config) }.not_to raise_error end end diff --git a/spec/lib/gitlab/metrics/connection_rack_middleware_spec.rb b/spec/lib/gitlab/metrics/connection_rack_middleware_spec.rb new file mode 100644 index 00000000000..94251af305f --- /dev/null +++ b/spec/lib/gitlab/metrics/connection_rack_middleware_spec.rb @@ -0,0 +1,88 @@ +require 'spec_helper' + +describe Gitlab::Metrics::ConnectionRackMiddleware do + let(:app) { double('app') } + subject { described_class.new(app) } + + around do |example| + Timecop.freeze { example.run } + end + + describe '#call' do + let(:status) { 100 } + let(:env) { { 'REQUEST_METHOD' => 'GET' } } + let(:stack_result) { [status, {}, 'body'] } + + before do + allow(app).to receive(:call).and_return(stack_result) + end + + context '@app.call succeeds with 200' do + before do + allow(app).to receive(:call).and_return([200, nil, nil]) + end + + it 'increments response count with status label' do + expect(described_class).to receive_message_chain(:rack_response_count, :increment).with(include(status: 200, method: 'get')) + + subject.call(env) + end + + it 'increments requests count' do + expect(described_class).to receive_message_chain(:rack_request_count, :increment).with(method: 'get') + + subject.call(env) + end + + it 'measures execution time' do + execution_time = 10 + allow(app).to receive(:call) do |*args| + Timecop.freeze(execution_time.seconds) + end + + expect(described_class).to receive_message_chain(:rack_execution_time, :observe).with({}, execution_time) + + subject.call(env) + end + end + + context '@app.call throws exception' do + let(:rack_response_count) { double('rack_response_count') } + + before do + allow(app).to receive(:call).and_raise(StandardError) + allow(described_class).to receive(:rack_response_count).and_return(rack_response_count) + end + + it 'increments exceptions count' do + expect(described_class).to receive_message_chain(:rack_uncaught_errors_count, :increment) + + expect { subject.call(env) }.to raise_error(StandardError) + end + + it 'increments requests count' do + expect(described_class).to receive_message_chain(:rack_request_count, :increment).with(method: 'get') + + expect { subject.call(env) }.to raise_error(StandardError) + end + + it "does't increment response count" do + expect(described_class.rack_response_count).not_to receive(:increment) + + expect { subject.call(env) }.to raise_error(StandardError) + end + + it 'measures execution time' do + execution_time = 10 + allow(app).to receive(:call) do |*args| + Timecop.freeze(execution_time.seconds) + raise StandardError + end + + expect(described_class).to receive_message_chain(:rack_execution_time, :observe).with({}, execution_time) + + expect { subject.call(env) }.to raise_error(StandardError) + end + end + end +end diff --git a/spec/lib/gitlab/metrics/influx_sampler_spec.rb b/spec/lib/gitlab/metrics/influx_sampler_spec.rb new file mode 100644 index 00000000000..0bc68d64276 --- /dev/null +++ b/spec/lib/gitlab/metrics/influx_sampler_spec.rb @@ -0,0 +1,150 @@ +require 'spec_helper' + +describe Gitlab::Metrics::InfluxSampler do + let(:sampler) { described_class.new(5) } + + after do + Allocations.stop if Gitlab::Metrics.mri? + end + + describe '#start' do + it 'runs once and gathers a sample at a given interval' do + expect(sampler).to receive(:sleep).with(a_kind_of(Numeric)).twice + expect(sampler).to receive(:sample).once + expect(sampler).to receive(:running).and_return(false, true, false) + + sampler.start.join + end + end + + describe '#sample' do + it 'samples various statistics' do + expect(sampler).to receive(:sample_memory_usage) + expect(sampler).to receive(:sample_file_descriptors) + expect(sampler).to receive(:sample_objects) + expect(sampler).to receive(:sample_gc) + expect(sampler).to receive(:flush) + + sampler.sample + end + + it 'clears any GC profiles' do + expect(sampler).to receive(:flush) + expect(GC::Profiler).to receive(:clear) + + sampler.sample + end + end + + describe '#flush' do + it 'schedules the metrics using Sidekiq' do + expect(Gitlab::Metrics).to receive(:submit_metrics) + .with([an_instance_of(Hash)]) + + sampler.sample_memory_usage + sampler.flush + end + end + + describe '#sample_memory_usage' do + it 'adds a metric containing the memory usage' do + expect(Gitlab::Metrics::System).to receive(:memory_usage) + .and_return(9000) + + expect(sampler).to receive(:add_metric) + .with(/memory_usage/, value: 9000) + .and_call_original + + sampler.sample_memory_usage + end + end + + describe '#sample_file_descriptors' do + it 'adds a metric containing the amount of open file descriptors' do + expect(Gitlab::Metrics::System).to receive(:file_descriptor_count) + .and_return(4) + + expect(sampler).to receive(:add_metric) + .with(/file_descriptors/, value: 4) + .and_call_original + + sampler.sample_file_descriptors + end + end + + if Gitlab::Metrics.mri? + describe '#sample_objects' do + it 'adds a metric containing the amount of allocated objects' do + expect(sampler).to receive(:add_metric) + .with(/object_counts/, an_instance_of(Hash), an_instance_of(Hash)) + .at_least(:once) + .and_call_original + + sampler.sample_objects + end + + it 'ignores classes without a name' do + expect(Allocations).to receive(:to_hash).and_return({ Class.new => 4 }) + + expect(sampler).not_to receive(:add_metric) + .with('object_counts', an_instance_of(Hash), type: nil) + + sampler.sample_objects + end + end + end + + describe '#sample_gc' do + it 'adds a metric containing garbage collection statistics' do + expect(GC::Profiler).to receive(:total_time).and_return(0.24) + + expect(sampler).to receive(:add_metric) + .with(/gc_statistics/, an_instance_of(Hash)) + .and_call_original + + sampler.sample_gc + end + end + + describe '#add_metric' do + it 'prefixes the series name for a Rails process' do + expect(sampler).to receive(:sidekiq?).and_return(false) + + expect(Gitlab::Metrics::Metric).to receive(:new) + .with('rails_cats', { value: 10 }, {}) + .and_call_original + + sampler.add_metric('cats', value: 10) + end + + it 'prefixes the series name for a Sidekiq process' do + expect(sampler).to receive(:sidekiq?).and_return(true) + + expect(Gitlab::Metrics::Metric).to receive(:new) + .with('sidekiq_cats', { value: 10 }, {}) + .and_call_original + + sampler.add_metric('cats', value: 10) + end + end + + describe '#sleep_interval' do + it 'returns a Numeric' do + expect(sampler.sleep_interval).to be_a_kind_of(Numeric) + end + + # Testing random behaviour is very hard, so treat this test as a basic smoke + # test instead of a very accurate behaviour/unit test. + it 'does not return the same interval twice in a row' do + last = nil + + 100.times do + interval = sampler.sleep_interval + + expect(interval).not_to eq(last) + + last = interval + end + end + end +end diff --git a/spec/lib/gitlab/metrics/sampler_spec.rb b/spec/lib/gitlab/metrics/sampler_spec.rb deleted file mode 100644 index d07ce6f81af..00000000000 --- a/spec/lib/gitlab/metrics/sampler_spec.rb +++ /dev/null @@ -1,150 +0,0 @@ -require 'spec_helper' - -describe Gitlab::Metrics::Sampler do - let(:sampler) { described_class.new(5) } - - after do - Allocations.stop if Gitlab::Metrics.mri? - end - - describe '#start' do - it 'gathers a sample at a given interval' do - expect(sampler).to receive(:sleep).with(a_kind_of(Numeric)) - expect(sampler).to receive(:sample) - expect(sampler).to receive(:loop).and_yield - - sampler.start.join - end - end - - describe '#sample' do - it 'samples various statistics' do - expect(sampler).to receive(:sample_memory_usage) - expect(sampler).to receive(:sample_file_descriptors) - expect(sampler).to receive(:sample_objects) - expect(sampler).to receive(:sample_gc) - expect(sampler).to receive(:flush) - - sampler.sample - end - - it 'clears any GC profiles' do - expect(sampler).to receive(:flush) - expect(GC::Profiler).to receive(:clear) - - sampler.sample - end - end - - describe '#flush' do - it 'schedules the metrics using Sidekiq' do - expect(Gitlab::Metrics).to receive(:submit_metrics) - .with([an_instance_of(Hash)]) - - sampler.sample_memory_usage - sampler.flush - end - end - - describe '#sample_memory_usage' do - it 'adds a metric containing the memory usage' do - expect(Gitlab::Metrics::System).to receive(:memory_usage) - .and_return(9000) - - expect(sampler).to receive(:add_metric) - .with(/memory_usage/, value: 9000) - .and_call_original - - sampler.sample_memory_usage - end - end - - describe '#sample_file_descriptors' do - it 'adds a metric containing the amount of open file descriptors' do - expect(Gitlab::Metrics::System).to receive(:file_descriptor_count) - .and_return(4) - - expect(sampler).to receive(:add_metric) - .with(/file_descriptors/, value: 4) - .and_call_original - - sampler.sample_file_descriptors - end - end - - if Gitlab::Metrics.mri? - describe '#sample_objects' do - it 'adds a metric containing the amount of allocated objects' do - expect(sampler).to receive(:add_metric) - .with(/object_counts/, an_instance_of(Hash), an_instance_of(Hash)) - .at_least(:once) - .and_call_original - - sampler.sample_objects - end - - it 'ignores classes without a name' do - expect(Allocations).to receive(:to_hash).and_return({ Class.new => 4 }) - - expect(sampler).not_to receive(:add_metric) - .with('object_counts', an_instance_of(Hash), type: nil) - - sampler.sample_objects - end - end - end - - describe '#sample_gc' do - it 'adds a metric containing garbage collection statistics' do - expect(GC::Profiler).to receive(:total_time).and_return(0.24) - - expect(sampler).to receive(:add_metric) - .with(/gc_statistics/, an_instance_of(Hash)) - .and_call_original - - sampler.sample_gc - end - end - - describe '#add_metric' do - it 'prefixes the series name for a Rails process' do - expect(sampler).to receive(:sidekiq?).and_return(false) - - expect(Gitlab::Metrics::Metric).to receive(:new) - .with('rails_cats', { value: 10 }, {}) - .and_call_original - - sampler.add_metric('cats', value: 10) - end - - it 'prefixes the series name for a Sidekiq process' do - expect(sampler).to receive(:sidekiq?).and_return(true) - - expect(Gitlab::Metrics::Metric).to receive(:new) - .with('sidekiq_cats', { value: 10 }, {}) - .and_call_original - - sampler.add_metric('cats', value: 10) - end - end - - describe '#sleep_interval' do - it 'returns a Numeric' do - expect(sampler.sleep_interval).to be_a_kind_of(Numeric) - end - - # Testing random behaviour is very hard, so treat this test as a basic smoke - # test instead of a very accurate behaviour/unit test. - it 'does not return the same interval twice in a row' do - last = nil - - 100.times do - interval = sampler.sleep_interval - - expect(interval).not_to eq(last) - - last = interval - end - end - end -end diff --git a/spec/lib/gitlab/metrics/unicorn_sampler_spec.rb b/spec/lib/gitlab/metrics/unicorn_sampler_spec.rb new file mode 100644 index 00000000000..dc0d1f2e940 --- /dev/null +++ b/spec/lib/gitlab/metrics/unicorn_sampler_spec.rb @@ -0,0 +1,108 @@ +require 'spec_helper' + +describe Gitlab::Metrics::UnicornSampler do + subject { described_class.new(1.second) } + + describe '#sample' do + let(:unicorn) { double('unicorn') } + let(:raindrops) { double('raindrops') } + let(:stats) { double('stats') } + + before do + stub_const('Unicorn', unicorn) + stub_const('Raindrops::Linux', raindrops) + allow(raindrops).to receive(:unix_listener_stats).and_return({}) + allow(raindrops).to receive(:tcp_listener_stats).and_return({}) + end + + context 'unicorn listens on unix sockets' do + let(:socket_address) { '/some/sock' } + let(:sockets) { [socket_address] } + + before do + allow(unicorn).to receive(:listener_names).and_return(sockets) + end + + it 'samples socket data' do + expect(raindrops).to receive(:unix_listener_stats).with(sockets) + + subject.sample + end + + context 'stats collected' do + before do + allow(stats).to receive(:active).and_return('active') + allow(stats).to receive(:queued).and_return('queued') + allow(raindrops).to receive(:unix_listener_stats).and_return({ socket_address => stats }) + end + + it 'updates metrics type unix and with addr' do + labels = { type: 'unix', address: socket_address } + + expect(subject).to receive_message_chain(:unicorn_active_connections, :set).with(labels, 'active') + expect(subject).to receive_message_chain(:unicorn_queued_connections, :set).with(labels, 'queued') + + subject.sample + end + end + end + + context 'unicorn listens on tcp sockets' do + let(:tcp_socket_address) { '0.0.0.0:8080' } + let(:tcp_sockets) { [tcp_socket_address] } + + before do + allow(unicorn).to receive(:listener_names).and_return(tcp_sockets) + end + + it 'samples socket data' do + expect(raindrops).to receive(:tcp_listener_stats).with(tcp_sockets) + + subject.sample + end + + context 'stats collected' do + before do + allow(stats).to receive(:active).and_return('active') + allow(stats).to receive(:queued).and_return('queued') + allow(raindrops).to receive(:tcp_listener_stats).and_return({ tcp_socket_address => stats }) + end + + it 'updates metrics type unix and with addr' do + labels = { type: 'tcp', address: tcp_socket_address } + + expect(subject).to receive_message_chain(:unicorn_active_connections, :set).with(labels, 'active') + expect(subject).to receive_message_chain(:unicorn_queued_connections, :set).with(labels, 'queued') + + subject.sample + end + end + end + end + + describe '#start' do + context 'when enabled' do + before do + allow(subject).to receive(:enabled?).and_return(true) + end + + it 'creates new thread' do + expect(Thread).to receive(:new) + + subject.start + end + end + + context 'when disabled' do + before do + allow(subject).to receive(:enabled?).and_return(false) + end + + it "doesn't create new thread" do + expect(Thread).not_to receive(:new) + + subject.start + end + end + end +end -- cgit v1.2.3 From 6489d1ad4ff40b6d5acf92280dde756d37bd2489 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Thu, 29 Jun 2017 16:48:56 -0500 Subject: Prevent accidental deletion of protected MR source branch by repeating checks before actual deletion --- spec/services/merge_requests/merge_service_spec.rb | 69 ++++++++++++++++++---- 1 file changed, 58 insertions(+), 11 deletions(-) (limited to 'spec') diff --git a/spec/services/merge_requests/merge_service_spec.rb b/spec/services/merge_requests/merge_service_spec.rb index 711059208c1..19d9e4049fe 100644 --- a/spec/services/merge_requests/merge_service_spec.rb +++ b/spec/services/merge_requests/merge_service_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' describe MergeRequests::MergeService, services: true do let(:user) { create(:user) } let(:user2) { create(:user) } - let(:merge_request) { create(:merge_request, assignee: user2) } + let(:merge_request) { create(:merge_request, :simple, author: user2, assignee: user2) } let(:project) { merge_request.project } before do @@ -133,18 +133,65 @@ describe MergeRequests::MergeService, services: true do it { expect(todo).to be_done } end - context 'remove source branch by author' do - let(:service) do - merge_request.merge_params['force_remove_source_branch'] = '1' - merge_request.save! - MergeRequests::MergeService.new(project, user, commit_message: 'Awesome message') + context 'source branch removal' do + context 'when the source branch is protected' do + let(:service) do + MergeRequests::MergeService.new(project, user, should_remove_source_branch: '1') + end + + before do + create(:protected_branch, project: project, name: merge_request.source_branch) + end + + it 'does not delete the source branch' do + expect(DeleteBranchService).not_to receive(:new) + service.execute(merge_request) + end end - it 'removes the source branch' do - expect(DeleteBranchService).to receive(:new) - .with(merge_request.source_project, merge_request.author) - .and_call_original - service.execute(merge_request) + context 'when the source branch is the default branch' do + let(:service) do + MergeRequests::MergeService.new(project, user, should_remove_source_branch: '1') + end + + before do + allow(project).to receive(:root_ref?).with(merge_request.source_branch).and_return(true) + end + + it 'does not delete the source branch' do + expect(DeleteBranchService).not_to receive(:new) + service.execute(merge_request) + end + end + + context 'when the source branch can be removed' do + context 'when MR author set the source branch to be removed' do + let(:service) do + merge_request.merge_params['force_remove_source_branch'] = '1' + merge_request.save! + MergeRequests::MergeService.new(project, user, commit_message: 'Awesome message') + end + + it 'removes the source branch using the author user' do + expect(DeleteBranchService).to receive(:new) + .with(merge_request.source_project, merge_request.author) + .and_call_original + service.execute(merge_request) + end + end + + context 'when MR merger set the source branch to be removed' do + let(:service) do + MergeRequests::MergeService.new(project, user, commit_message: 'Awesome message', should_remove_source_branch: '1') + end + + it 'removes the source branch using the current user' do + expect(DeleteBranchService).to receive(:new) + .with(merge_request.source_project, user) + .and_call_original + service.execute(merge_request) + end + end end end -- cgit v1.2.3 From 2c78c7f4cdb1fae2650563f80feb294d2b7e5d80 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 4 Jul 2017 17:08:41 +0000 Subject: Revert "Merge branch 'revert-12499' into 'master'" This reverts merge request !12557 --- spec/models/concerns/sortable_spec.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 spec/models/concerns/sortable_spec.rb (limited to 'spec') diff --git a/spec/models/concerns/sortable_spec.rb b/spec/models/concerns/sortable_spec.rb new file mode 100644 index 00000000000..d1e17c4f684 --- /dev/null +++ b/spec/models/concerns/sortable_spec.rb @@ -0,0 +1,21 @@ +require 'spec_helper' + +describe Sortable do + let(:relation) { Issue.all } + + describe '#where' do + it 'orders by id, descending' do + order_node = relation.where(iid: 1).order_values.first + expect(order_node).to be_a(Arel::Nodes::Descending) + expect(order_node.expr.name).to eq(:id) + end + end + + describe '#find_by' do + it 'does not order' do + expect(relation).to receive(:unscope).with(:order).and_call_original + + relation.find_by(iid: 1) + end + end +end -- cgit v1.2.3 From 94258a6500855ca37e42e442ede642091a8d4366 Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Wed, 5 Jul 2017 03:44:40 +0000 Subject: Fix build for !12300. - The `/users` and `/users/:id` APIs are now accessible without authentication (!12445), and so scopes are not relevant for these endpoints. - Previously, we were testing our scope declaration against these two methods. This commit moves these tests to other `GET` user endpoints which still require authentication. --- spec/requests/api/users_spec.rb | 49 +++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 14 deletions(-) (limited to 'spec') diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index b8109ce401c..70b94a09e6b 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -113,13 +113,6 @@ describe API::Users do expect(json_response.first.keys).not_to include 'is_admin' end - - context "scopes" do - let(:path) { "/users" } - let(:api_call) { method(:api) } - - include_examples 'allows the "read_user" scope' - end end context "when admin" do @@ -216,13 +209,6 @@ describe API::Users do expect(response).to have_http_status(404) end - - context "scopes" do - let(:path) { "/users/#{user.id}" } - let(:api_call) { method(:api) } - - include_examples 'allows the "read_user" scope' - end end describe "POST /users" do @@ -909,6 +895,13 @@ describe API::Users do expect(response).to match_response_schema('public_api/v4/user/public') expect(json_response['id']).to eq(user.id) end + + context "scopes" do + let(:path) { "/user" } + let(:api_call) { method(:api) } + + include_examples 'allows the "read_user" scope' + end end context 'with admin' do @@ -978,6 +971,13 @@ describe API::Users do expect(json_response).to be_an Array expect(json_response.first["title"]).to eq(key.title) end + + context "scopes" do + let(:path) { "/user/keys" } + let(:api_call) { method(:api) } + + include_examples 'allows the "read_user" scope' + end end end @@ -1011,6 +1011,13 @@ describe API::Users do expect(response).to have_http_status(404) end + + context "scopes" do + let(:path) { "/user/keys/#{key.id}" } + let(:api_call) { method(:api) } + + include_examples 'allows the "read_user" scope' + end end describe "POST /user/keys" do @@ -1100,6 +1107,13 @@ describe API::Users do expect(json_response).to be_an Array expect(json_response.first["email"]).to eq(email.email) end + + context "scopes" do + let(:path) { "/user/emails" } + let(:api_call) { method(:api) } + + include_examples 'allows the "read_user" scope' + end end end @@ -1132,6 +1146,13 @@ describe API::Users do expect(response).to have_http_status(404) end + + context "scopes" do + let(:path) { "/user/emails/#{email.id}" } + let(:api_call) { method(:api) } + + include_examples 'allows the "read_user" scope' + end end describe "POST /user/emails" do -- cgit v1.2.3 From f127183f37b2b456400500b47e782241e918b4df Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Wed, 5 Jul 2017 09:36:08 +0200 Subject: Add test example for external commit status retries --- spec/requests/api/commit_statuses_spec.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'spec') diff --git a/spec/requests/api/commit_statuses_spec.rb b/spec/requests/api/commit_statuses_spec.rb index cdb60fc0d1a..8b62aa268d9 100644 --- a/spec/requests/api/commit_statuses_spec.rb +++ b/spec/requests/api/commit_statuses_spec.rb @@ -237,6 +237,28 @@ describe API::CommitStatuses do end end + context 'when retrying a commit status' do + before do + post api(post_url, developer), + { state: 'failed', name: 'test', ref: 'master' } + + post api(post_url, developer), + { state: 'success', name: 'test', ref: 'master' } + end + + it 'correctly posts a new commit status' do + expect(response).to have_http_status(201) + expect(json_response['sha']).to eq(commit.id) + expect(json_response['status']).to eq('success') + end + + it 'retries a commit status' do + expect(CommitStatus.count).to eq 2 + expect(CommitStatus.first).to be_retried + expect(CommitStatus.last.pipeline).to be_success + end + end + context 'when status is invalid' do before do post api(post_url, developer), state: 'invalid' -- cgit v1.2.3 From b67d1d64cce624dfc9e99d836ebd23cbd0e21eb6 Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Tue, 4 Jul 2017 15:14:13 +0200 Subject: Migrate #submodule_url_for to Gitaly --- spec/lib/gitlab/git/repository_spec.rb | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'spec') diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb index 0cd458bf933..aa7326721b7 100644 --- a/spec/lib/gitlab/git/repository_spec.rb +++ b/spec/lib/gitlab/git/repository_spec.rb @@ -358,6 +358,38 @@ describe Gitlab::Git::Repository, seed_helper: true do end end + describe '#submodule_url_for' do + let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH) } + let(:ref) { 'master' } + + def submodule_url(path) + repository.submodule_url_for(ref, path) + end + + it { expect(submodule_url('six')).to eq('git://github.com/randx/six.git') } + it { expect(submodule_url('nested/six')).to eq('git://github.com/randx/six.git') } + it { expect(submodule_url('deeper/nested/six')).to eq('git://github.com/randx/six.git') } + it { expect(submodule_url('invalid/path')).to eq(nil) } + + context 'uncommitted submodule dir' do + let(:ref) { 'fix-existing-submodule-dir' } + + it { expect(submodule_url('submodule-existing-dir')).to eq(nil) } + end + + context 'tags' do + let(:ref) { 'v1.2.1' } + + it { expect(submodule_url('six')).to eq('git://github.com/randx/six.git') } + end + + context 'no submodules at commit' do + let(:ref) { '6d39438' } + + it { expect(submodule_url('six')).to eq(nil) } + end + end + context '#submodules' do let(:repository) { Gitlab::Git::Repository.new('default', TEST_REPO_PATH) } -- cgit v1.2.3 From 60b8156a25ae308200a3cacf463eba6ab472afcf Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Wed, 5 Jul 2017 19:29:18 +0800 Subject: Fix cycle analytics tests by making pipeline valid --- spec/support/cycle_analytics_helpers.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/support/cycle_analytics_helpers.rb b/spec/support/cycle_analytics_helpers.rb index 916544babcf..0bbb7e23079 100644 --- a/spec/support/cycle_analytics_helpers.rb +++ b/spec/support/cycle_analytics_helpers.rb @@ -74,7 +74,10 @@ module CycleAnalyticsHelpers def dummy_pipeline @dummy_pipeline ||= - project.pipelines.build(sha: project.repository.commit('master').sha) + project.pipelines.build( + sha: project.repository.commit('master').sha, + ref: 'master', + source: :push) end def new_dummy_job(environment) -- cgit v1.2.3 From 9f7e5e45df9b7d99b97e40d1c08250925a408875 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Wed, 5 Jul 2017 20:04:53 +0800 Subject: Add back Pipeline#ci_yaml_file_path due to all the troubles --- spec/models/ci/build_spec.rb | 2 +- spec/models/ci/pipeline_spec.rb | 22 ++++++++++++++++++++++ spec/models/project_spec.rb | 24 ------------------------ 3 files changed, 23 insertions(+), 25 deletions(-) (limited to 'spec') diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 1553d6d3a9a..e5fd549f0d7 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -1179,7 +1179,7 @@ describe Ci::Build, :models do { key: 'CI_PROJECT_NAMESPACE', value: project.namespace.full_path, public: true }, { key: 'CI_PROJECT_URL', value: project.web_url, public: true }, { key: 'CI_PIPELINE_ID', value: pipeline.id.to_s, public: true }, - { key: 'CI_CONFIG_PATH', value: project.ci_config_file_for_pipeline, public: true }, + { key: 'CI_CONFIG_PATH', value: pipeline.ci_yaml_file_path, 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 } diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index e36e9082036..a24b1e6c818 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -748,6 +748,28 @@ describe Ci::Pipeline, models: true do end end + describe '#ci_yaml_file_path' do + subject { pipeline.ci_yaml_file_path } + + it 'returns the path from project' do + allow(pipeline.project).to receive(:ci_config_file) { 'custom/path' } + + is_expected.to eq('custom/path') + end + + it 'returns default when custom path is nil' do + allow(pipeline.project).to receive(:ci_config_file) { nil } + + is_expected.to eq('.gitlab-ci.yml') + end + + it 'returns default when custom path is empty' do + allow(pipeline.project).to receive(:ci_config_file) { '' } + + is_expected.to eq('.gitlab-ci.yml') + end + end + describe '#ci_yaml_file' do it 'reports error if the file is not found' do allow(pipeline.project).to receive(:ci_config_file) { 'custom' } diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 4ef768123bd..a682fa82bf0 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -1493,30 +1493,6 @@ describe Project, models: true do end end - describe '#ci_config_file_for_pipeline' do - let(:project) { create(:empty_project) } - - subject { project.ci_config_file_for_pipeline } - - it 'returns the path from project' do - allow(project).to receive(:ci_config_file) { 'custom/path' } - - is_expected.to eq('custom/path') - end - - it 'returns default when custom path is nil' do - allow(project).to receive(:ci_config_file) { nil } - - is_expected.to eq('.gitlab-ci.yml') - end - - it 'returns default when custom path is empty' do - allow(project).to receive(:ci_config_file) { '' } - - is_expected.to eq('.gitlab-ci.yml') - end - end - describe '#ci_config_file=' do let(:project) { create(:empty_project) } -- cgit v1.2.3 From 9f5ac179d1ca4819006c66ae385ba7153f6c7e4f Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Wed, 5 Jul 2017 20:11:01 +0800 Subject: Rename ci_config_file to ci_config_path --- .../gitlab/import_export/safe_model_attributes.yml | 2 +- spec/models/ci/build_spec.rb | 2 +- spec/models/ci/pipeline_spec.rb | 8 ++++---- spec/models/project_spec.rb | 20 ++++++++++---------- spec/requests/api/projects_spec.rb | 4 ++-- 5 files changed, 18 insertions(+), 18 deletions(-) (limited to 'spec') diff --git a/spec/lib/gitlab/import_export/safe_model_attributes.yml b/spec/lib/gitlab/import_export/safe_model_attributes.yml index f782cf533e8..697ddf52af9 100644 --- a/spec/lib/gitlab/import_export/safe_model_attributes.yml +++ b/spec/lib/gitlab/import_export/safe_model_attributes.yml @@ -383,7 +383,7 @@ Project: - printing_merge_request_link_enabled - build_allow_git_fetch - last_repository_updated_at -- ci_config_file +- ci_config_path Author: - name ProjectFeature: diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index e5fd549f0d7..f955d9c81b8 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -1474,7 +1474,7 @@ describe Ci::Build, :models do let(:ci_config_path) { { key: 'CI_CONFIG_PATH', value: 'custom', public: true } } before do - project.update(ci_config_file: 'custom') + project.update(ci_config_path: 'custom') end it { is_expected.to include(ci_config_path) } diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index a24b1e6c818..ba0696fa210 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -752,19 +752,19 @@ describe Ci::Pipeline, models: true do subject { pipeline.ci_yaml_file_path } it 'returns the path from project' do - allow(pipeline.project).to receive(:ci_config_file) { 'custom/path' } + allow(pipeline.project).to receive(:ci_config_path) { 'custom/path' } is_expected.to eq('custom/path') end it 'returns default when custom path is nil' do - allow(pipeline.project).to receive(:ci_config_file) { nil } + allow(pipeline.project).to receive(:ci_config_path) { nil } is_expected.to eq('.gitlab-ci.yml') end it 'returns default when custom path is empty' do - allow(pipeline.project).to receive(:ci_config_file) { '' } + allow(pipeline.project).to receive(:ci_config_path) { '' } is_expected.to eq('.gitlab-ci.yml') end @@ -772,7 +772,7 @@ describe Ci::Pipeline, models: true do describe '#ci_yaml_file' do it 'reports error if the file is not found' do - allow(pipeline.project).to receive(:ci_config_file) { 'custom' } + allow(pipeline.project).to receive(:ci_config_path) { 'custom' } pipeline.ci_yaml_file diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index a682fa82bf0..6197a390da8 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -143,9 +143,9 @@ describe Project, models: true do it { is_expected.to validate_length_of(:description).is_at_most(2000) } - it { is_expected.to validate_length_of(:ci_config_file).is_at_most(255) } - it { is_expected.to allow_value('').for(:ci_config_file) } - it { is_expected.not_to allow_value('test/../foo').for(:ci_config_file) } + it { is_expected.to validate_length_of(:ci_config_path).is_at_most(255) } + it { is_expected.to allow_value('').for(:ci_config_path) } + it { is_expected.not_to allow_value('test/../foo').for(:ci_config_path) } it { is_expected.to validate_presence_of(:creator) } @@ -1493,25 +1493,25 @@ describe Project, models: true do end end - describe '#ci_config_file=' do + describe '#ci_config_path=' do let(:project) { create(:empty_project) } it 'sets nil' do - project.update!(ci_config_file: nil) + project.update!(ci_config_path: nil) - expect(project.ci_config_file).to be_nil + expect(project.ci_config_path).to be_nil end it 'sets a string' do - project.update!(ci_config_file: 'foo/.gitlab_ci.yml') + project.update!(ci_config_path: 'foo/.gitlab_ci.yml') - expect(project.ci_config_file).to eq('foo/.gitlab_ci.yml') + expect(project.ci_config_path).to eq('foo/.gitlab_ci.yml') end it 'sets a string but remove all leading slashes and null characters' do - project.update!(ci_config_file: "///f\0oo/\0/.gitlab_ci.yml") + project.update!(ci_config_path: "///f\0oo/\0/.gitlab_ci.yml") - expect(project.ci_config_file).to eq('foo//.gitlab_ci.yml') + expect(project.ci_config_path).to eq('foo//.gitlab_ci.yml') end end diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index d19ce2d9887..8ac65ecccab 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -348,7 +348,7 @@ 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_file: 'a/custom/path' + ci_config_path: 'a/custom/path' }) post api('/projects', user), project @@ -654,7 +654,7 @@ describe API::Projects do expect(json_response['star_count']).to be_present expect(json_response['forks_count']).to be_present expect(json_response['public_jobs']).to be_present - expect(json_response['ci_config_file']).to be_nil + expect(json_response['ci_config_path']).to be_nil expect(json_response['shared_with_groups']).to be_an Array expect(json_response['shared_with_groups'].length).to eq(1) expect(json_response['shared_with_groups'][0]['group_id']).to eq(group.id) -- cgit v1.2.3 From 9651521ea7f1cd4d77f7ab11359d8b0075b52fa6 Mon Sep 17 00:00:00 2001 From: Alexander Randa Date: Thu, 22 Jun 2017 14:43:52 +0000 Subject: Replace 'snippets/snippets.feature' spinach with rspec --- spec/factories/personal_snippets.rb | 4 - spec/factories/project_snippets.rb | 5 - spec/factories/snippets.rb | 7 ++ spec/features/snippets/create_snippet_spec.rb | 105 -------------------- spec/features/snippets/edit_snippet_spec.rb | 38 -------- .../features/snippets/user_creates_snippet_spec.rb | 107 +++++++++++++++++++++ .../features/snippets/user_deletes_snippet_spec.rb | 19 ++++ spec/features/snippets/user_edits_snippet_spec.rb | 58 +++++++++++ 8 files changed, 191 insertions(+), 152 deletions(-) delete mode 100644 spec/factories/personal_snippets.rb delete mode 100644 spec/factories/project_snippets.rb delete mode 100644 spec/features/snippets/create_snippet_spec.rb delete mode 100644 spec/features/snippets/edit_snippet_spec.rb create mode 100644 spec/features/snippets/user_creates_snippet_spec.rb create mode 100644 spec/features/snippets/user_deletes_snippet_spec.rb create mode 100644 spec/features/snippets/user_edits_snippet_spec.rb (limited to 'spec') diff --git a/spec/factories/personal_snippets.rb b/spec/factories/personal_snippets.rb deleted file mode 100644 index 0f13b2c1020..00000000000 --- a/spec/factories/personal_snippets.rb +++ /dev/null @@ -1,4 +0,0 @@ -FactoryGirl.define do - factory :personal_snippet, parent: :snippet, class: :PersonalSnippet do - end -end diff --git a/spec/factories/project_snippets.rb b/spec/factories/project_snippets.rb deleted file mode 100644 index e0fe1b36fd3..00000000000 --- a/spec/factories/project_snippets.rb +++ /dev/null @@ -1,5 +0,0 @@ -FactoryGirl.define do - factory :project_snippet, parent: :snippet, class: :ProjectSnippet do - project factory: :empty_project - end -end diff --git a/spec/factories/snippets.rb b/spec/factories/snippets.rb index 388f662e6e5..f6ce99d50f9 100644 --- a/spec/factories/snippets.rb +++ b/spec/factories/snippets.rb @@ -18,4 +18,11 @@ FactoryGirl.define do visibility_level Snippet::PRIVATE end end + + factory :project_snippet, parent: :snippet, class: :ProjectSnippet do + project factory: :empty_project + end + + factory :personal_snippet, parent: :snippet, class: :PersonalSnippet do + end end diff --git a/spec/features/snippets/create_snippet_spec.rb b/spec/features/snippets/create_snippet_spec.rb deleted file mode 100644 index ac5c14ed427..00000000000 --- a/spec/features/snippets/create_snippet_spec.rb +++ /dev/null @@ -1,105 +0,0 @@ -require 'rails_helper' - -feature 'Create Snippet', :js, feature: true do - include DropzoneHelper - - before do - gitlab_sign_in :user - visit new_snippet_path - end - - def fill_form - fill_in 'personal_snippet_title', with: 'My Snippet Title' - fill_in 'personal_snippet_description', with: 'My Snippet **Description**' - page.within('.file-editor') do - find('.ace_editor').native.send_keys 'Hello World!' - end - end - - scenario 'Authenticated user creates a snippet' do - fill_form - - click_button('Create snippet') - wait_for_requests - - expect(page).to have_content('My Snippet Title') - page.within('.snippet-header .description') do - expect(page).to have_content('My Snippet Description') - expect(page).to have_selector('strong') - end - expect(page).to have_content('Hello World!') - end - - scenario 'previews a snippet with file' do - fill_in 'personal_snippet_description', with: 'My Snippet' - dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif') - find('.js-md-preview-button').click - - page.within('#new_personal_snippet .md-preview') do - expect(page).to have_content('My Snippet') - - link = find('a.no-attachment-icon img[alt="banana_sample"]')['src'] - expect(link).to match(%r{/uploads/temp/\h{32}/banana_sample\.gif\z}) - - visit(link) - expect(page.status_code).to eq(200) - end - end - - scenario 'uploads a file when dragging into textarea' do - fill_form - - dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif') - - expect(page.find_field("personal_snippet_description").value).to have_content('banana_sample') - - click_button('Create snippet') - wait_for_requests - - link = find('a.no-attachment-icon img[alt="banana_sample"]')['src'] - expect(link).to match(%r{/uploads/personal_snippet/#{Snippet.last.id}/\h{32}/banana_sample\.gif\z}) - - visit(link) - expect(page.status_code).to eq(200) - end - - scenario 'validation fails for the first time' do - fill_in 'personal_snippet_title', with: 'My Snippet Title' - click_button('Create snippet') - - expect(page).to have_selector('#error_explanation') - - fill_form - dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif') - - click_button('Create snippet') - wait_for_requests - - expect(page).to have_content('My Snippet Title') - page.within('.snippet-header .description') do - expect(page).to have_content('My Snippet Description') - expect(page).to have_selector('strong') - end - expect(page).to have_content('Hello World!') - link = find('a.no-attachment-icon img[alt="banana_sample"]')['src'] - expect(link).to match(%r{/uploads/personal_snippet/#{Snippet.last.id}/\h{32}/banana_sample\.gif\z}) - - visit(link) - expect(page.status_code).to eq(200) - end - - scenario 'Authenticated user creates a snippet with + in filename' do - fill_in 'personal_snippet_title', with: 'My Snippet Title' - page.within('.file-editor') do - find(:xpath, "//input[@id='personal_snippet_file_name']").set 'snippet+file+name' - find('.ace_editor').native.send_keys 'Hello World!' - end - - click_button 'Create snippet' - wait_for_requests - - expect(page).to have_content('My Snippet Title') - expect(page).to have_content('snippet+file+name') - expect(page).to have_content('Hello World!') - end -end diff --git a/spec/features/snippets/edit_snippet_spec.rb b/spec/features/snippets/edit_snippet_spec.rb deleted file mode 100644 index 860e1b156d6..00000000000 --- a/spec/features/snippets/edit_snippet_spec.rb +++ /dev/null @@ -1,38 +0,0 @@ -require 'rails_helper' - -feature 'Edit Snippet', :js, feature: true do - include DropzoneHelper - - let(:file_name) { 'test.rb' } - let(:content) { 'puts "test"' } - - let(:user) { create(:user) } - let(:snippet) { create(:personal_snippet, :public, file_name: file_name, content: content, author: user) } - - before do - gitlab_sign_in(user) - - visit edit_snippet_path(snippet) - wait_for_requests - end - - it 'updates the snippet' do - fill_in 'personal_snippet_title', with: 'New Snippet Title' - - click_button('Save changes') - wait_for_requests - - expect(page).to have_content('New Snippet Title') - end - - it 'updates the snippet with files attached' do - dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif') - expect(page.find_field("personal_snippet_description").value).to have_content('banana_sample') - - click_button('Save changes') - wait_for_requests - - link = find('a.no-attachment-icon img[alt="banana_sample"]')['src'] - expect(link).to match(%r{/uploads/personal_snippet/#{snippet.id}/\h{32}/banana_sample\.gif\z}) - end -end diff --git a/spec/features/snippets/user_creates_snippet_spec.rb b/spec/features/snippets/user_creates_snippet_spec.rb new file mode 100644 index 00000000000..57dec14b480 --- /dev/null +++ b/spec/features/snippets/user_creates_snippet_spec.rb @@ -0,0 +1,107 @@ +require 'rails_helper' + +feature 'User creates snippet', :js, feature: true do + include DropzoneHelper + + let(:user) { create(:user) } + + before do + sign_in(user) + visit new_snippet_path + end + + def fill_form + fill_in 'personal_snippet_title', with: 'My Snippet Title' + fill_in 'personal_snippet_description', with: 'My Snippet **Description**' + page.within('.file-editor') do + find('.ace_editor').native.send_keys 'Hello World!' + end + end + + scenario 'Authenticated user creates a snippet' do + fill_form + + click_button('Create snippet') + wait_for_requests + + expect(page).to have_content('My Snippet Title') + page.within('.snippet-header .description') do + expect(page).to have_content('My Snippet Description') + expect(page).to have_selector('strong') + end + expect(page).to have_content('Hello World!') + end + + scenario 'previews a snippet with file' do + fill_in 'personal_snippet_description', with: 'My Snippet' + dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif') + find('.js-md-preview-button').click + + page.within('#new_personal_snippet .md-preview') do + expect(page).to have_content('My Snippet') + + link = find('a.no-attachment-icon img[alt="banana_sample"]')['src'] + expect(link).to match(%r{/uploads/temp/\h{32}/banana_sample\.gif\z}) + + visit(link) + expect(page.status_code).to eq(200) + end + end + + scenario 'uploads a file when dragging into textarea' do + fill_form + + dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif') + + expect(page.find_field("personal_snippet_description").value).to have_content('banana_sample') + + click_button('Create snippet') + wait_for_requests + + link = find('a.no-attachment-icon img[alt="banana_sample"]')['src'] + expect(link).to match(%r{/uploads/personal_snippet/#{Snippet.last.id}/\h{32}/banana_sample\.gif\z}) + + visit(link) + expect(page.status_code).to eq(200) + end + + scenario 'validation fails for the first time' do + fill_in 'personal_snippet_title', with: 'My Snippet Title' + click_button('Create snippet') + + expect(page).to have_selector('#error_explanation') + + fill_form + dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif') + + click_button('Create snippet') + wait_for_requests + + expect(page).to have_content('My Snippet Title') + page.within('.snippet-header .description') do + expect(page).to have_content('My Snippet Description') + expect(page).to have_selector('strong') + end + expect(page).to have_content('Hello World!') + link = find('a.no-attachment-icon img[alt="banana_sample"]')['src'] + expect(link).to match(%r{/uploads/personal_snippet/#{Snippet.last.id}/\h{32}/banana_sample\.gif\z}) + + visit(link) + expect(page.status_code).to eq(200) + end + + scenario 'Authenticated user creates a snippet with + in filename' do + fill_in 'personal_snippet_title', with: 'My Snippet Title' + page.within('.file-editor') do + find(:xpath, "//input[@id='personal_snippet_file_name']").set 'snippet+file+name' + find('.ace_editor').native.send_keys 'Hello World!' + end + + click_button 'Create snippet' + wait_for_requests + + expect(page).to have_content('My Snippet Title') + expect(page).to have_content('snippet+file+name') + expect(page).to have_content('Hello World!') + end +end diff --git a/spec/features/snippets/user_deletes_snippet_spec.rb b/spec/features/snippets/user_deletes_snippet_spec.rb new file mode 100644 index 00000000000..162c2c9e730 --- /dev/null +++ b/spec/features/snippets/user_deletes_snippet_spec.rb @@ -0,0 +1,19 @@ +require 'rails_helper' + +feature 'User deletes snippet', feature: true do + let(:user) { create(:user) } + let(:content) { 'puts "test"' } + let(:snippet) { create(:personal_snippet, :public, content: content, author: user) } + + before do + sign_in(user) + + visit snippet_path(snippet) + end + + it 'deletes the snippet' do + first(:link, 'Delete').click + + expect(page).not_to have_content(snippet.title) + end +end diff --git a/spec/features/snippets/user_edits_snippet_spec.rb b/spec/features/snippets/user_edits_snippet_spec.rb new file mode 100644 index 00000000000..cff64423873 --- /dev/null +++ b/spec/features/snippets/user_edits_snippet_spec.rb @@ -0,0 +1,58 @@ +require 'rails_helper' + +feature 'User edits snippet', :js, feature: true do + include DropzoneHelper + + let(:file_name) { 'test.rb' } + let(:content) { 'puts "test"' } + + let(:user) { create(:user) } + let(:snippet) { create(:personal_snippet, :public, file_name: file_name, content: content, author: user) } + + before do + sign_in(user) + + visit edit_snippet_path(snippet) + wait_for_requests + end + + it 'updates the snippet' do + fill_in 'personal_snippet_title', with: 'New Snippet Title' + + click_button('Save changes') + wait_for_requests + + expect(page).to have_content('New Snippet Title') + end + + it 'updates the snippet with files attached' do + dropzone_file Rails.root.join('spec', 'fixtures', 'banana_sample.gif') + expect(page.find_field('personal_snippet_description').value).to have_content('banana_sample') + + click_button('Save changes') + wait_for_requests + + link = find('a.no-attachment-icon img[alt="banana_sample"]')['src'] + expect(link).to match(%r{/uploads/personal_snippet/#{snippet.id}/\h{32}/banana_sample\.gif\z}) + end + + it 'updates the snippet to make it internal' do + choose 'Internal' + + click_button 'Save changes' + wait_for_requests + + expect(page).to have_no_xpath("//i[@class='fa fa-lock']") + expect(page).to have_xpath("//i[@class='fa fa-shield']") + end + + it 'updates the snippet to make it public' do + choose 'Public' + + click_button 'Save changes' + wait_for_requests + + expect(page).to have_no_xpath("//i[@class='fa fa-lock']") + expect(page).to have_xpath("//i[@class='fa fa-globe']") + end +end -- cgit v1.2.3 From 35f4a00f371ae60477bdbafe9f8274c8560320cb Mon Sep 17 00:00:00 2001 From: Nick Thomas Date: Tue, 27 Jun 2017 15:38:12 +0100 Subject: Introduce cache policies for CI jobs --- spec/factories/ci/builds.rb | 3 +- spec/lib/ci/gitlab_ci_yaml_processor_spec.rb | 9 +++-- spec/lib/gitlab/ci/config/entry/cache_spec.rb | 52 ++++++++++++++++++++------ spec/lib/gitlab/ci/config/entry/global_spec.rb | 8 ++-- spec/lib/gitlab/ci/config/entry/job_spec.rb | 4 +- spec/requests/api/runner_spec.rb | 3 +- 6 files changed, 56 insertions(+), 23 deletions(-) (limited to 'spec') diff --git a/spec/factories/ci/builds.rb b/spec/factories/ci/builds.rb index 0cc498f0ce9..a77f01ecb00 100644 --- a/spec/factories/ci/builds.rb +++ b/spec/factories/ci/builds.rb @@ -207,7 +207,8 @@ FactoryGirl.define do cache: { key: 'cache_key', untracked: false, - paths: ['vendor/*'] + paths: ['vendor/*'], + policy: 'pull-push' } } end diff --git a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb index 482f03aa0cc..ef58ef1b0cd 100644 --- a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb +++ b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb @@ -878,7 +878,8 @@ module Ci expect(config_processor.builds_for_stage_and_ref("test", "master").first[:options][:cache]).to eq( paths: ["logs/", "binaries/"], untracked: true, - key: 'key' + key: 'key', + policy: 'pull-push' ) end @@ -896,7 +897,8 @@ module Ci expect(config_processor.builds_for_stage_and_ref("test", "master").first[:options][:cache]).to eq( paths: ["logs/", "binaries/"], untracked: true, - key: 'key' + key: 'key', + policy: 'pull-push' ) end @@ -915,7 +917,8 @@ module Ci expect(config_processor.builds_for_stage_and_ref("test", "master").first[:options][:cache]).to eq( paths: ["test/"], untracked: false, - key: 'local' + key: 'local', + policy: 'pull-push' ) end end diff --git a/spec/lib/gitlab/ci/config/entry/cache_spec.rb b/spec/lib/gitlab/ci/config/entry/cache_spec.rb index 878b1d6b862..8f711e02f9b 100644 --- a/spec/lib/gitlab/ci/config/entry/cache_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/cache_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe Gitlab::Ci::Config::Entry::Cache do - let(:entry) { described_class.new(config) } + subject(:entry) { described_class.new(config) } describe 'validations' do before do @@ -9,22 +9,44 @@ describe Gitlab::Ci::Config::Entry::Cache do end context 'when entry config value is correct' do + let(:policy) { nil } + let(:config) do { key: 'some key', untracked: true, - paths: ['some/path/'] } + paths: ['some/path/'], + policy: policy } end describe '#value' do it 'returns hash value' do - expect(entry.value).to eq config + expect(entry.value).to eq(key: 'some key', untracked: true, paths: ['some/path/'], policy: 'pull-push') end end describe '#valid?' do - it 'is valid' do - expect(entry).to be_valid - end + it { is_expected.to be_valid } + end + + context 'policy is pull-push' do + let(:policy) { 'pull-push' } + + it { is_expected.to be_valid } + it { expect(entry.value).to include(policy: 'pull-push') } + end + + context 'policy is push' do + let(:policy) { 'push' } + + it { is_expected.to be_valid } + it { expect(entry.value).to include(policy: 'push') } + end + + context 'policy is pull' do + let(:policy) { 'pull' } + + it { is_expected.to be_valid } + it { expect(entry.value).to include(policy: 'pull') } end context 'when key is missing' do @@ -44,12 +66,20 @@ describe Gitlab::Ci::Config::Entry::Cache do context 'when entry value is not correct' do describe '#errors' do + subject { entry.errors } context 'when is not a hash' do let(:config) { 'ls' } it 'reports errors with config value' do - expect(entry.errors) - .to include 'cache config should be a hash' + is_expected.to include 'cache config should be a hash' + end + end + + context 'when policy is unknown' do + let(:config) { { policy: "unknown" } } + + it 'reports error' do + is_expected.to include('cache policy should be pull-push, push, or pull') end end @@ -57,8 +87,7 @@ describe Gitlab::Ci::Config::Entry::Cache do let(:config) { { key: 1 } } it 'reports error with descendants' do - expect(entry.errors) - .to include 'key config should be a string or symbol' + is_expected.to include 'key config should be a string or symbol' end end @@ -66,8 +95,7 @@ describe Gitlab::Ci::Config::Entry::Cache do let(:config) { { invalid: true } } it 'reports error with descendants' do - expect(entry.errors) - .to include 'cache config contains unknown keys: invalid' + is_expected.to include 'cache config contains unknown keys: invalid' end end end diff --git a/spec/lib/gitlab/ci/config/entry/global_spec.rb b/spec/lib/gitlab/ci/config/entry/global_spec.rb index 293f112b2b0..1860ed79bfd 100644 --- a/spec/lib/gitlab/ci/config/entry/global_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/global_spec.rb @@ -143,7 +143,7 @@ describe Gitlab::Ci::Config::Entry::Global do describe '#cache_value' do it 'returns cache configuration' do expect(global.cache_value) - .to eq(key: 'k', untracked: true, paths: ['public/']) + .to eq(key: 'k', untracked: true, paths: ['public/'], policy: 'pull-push') end end @@ -157,7 +157,7 @@ describe Gitlab::Ci::Config::Entry::Global do image: { name: 'ruby:2.2' }, services: [{ name: 'postgres:9.1' }, { name: 'mysql:5.5' }], stage: 'test', - cache: { key: 'k', untracked: true, paths: ['public/'] }, + cache: { key: 'k', untracked: true, paths: ['public/'], policy: 'pull-push' }, variables: { 'VAR' => 'value' }, ignore: false, after_script: ['make clean'] }, @@ -168,7 +168,7 @@ describe Gitlab::Ci::Config::Entry::Global do image: { name: 'ruby:2.2' }, services: [{ name: 'postgres:9.1' }, { name: 'mysql:5.5' }], stage: 'test', - cache: { key: 'k', untracked: true, paths: ['public/'] }, + cache: { key: 'k', untracked: true, paths: ['public/'], policy: 'pull-push' }, variables: {}, ignore: false, after_script: ['make clean'] } @@ -212,7 +212,7 @@ describe Gitlab::Ci::Config::Entry::Global do describe '#cache_value' do it 'returns correct cache definition' do - expect(global.cache_value).to eq(key: 'a') + expect(global.cache_value).to eq(key: 'a', policy: 'pull-push') end end end diff --git a/spec/lib/gitlab/ci/config/entry/job_spec.rb b/spec/lib/gitlab/ci/config/entry/job_spec.rb index 92cba689f47..c5cad887b64 100644 --- a/spec/lib/gitlab/ci/config/entry/job_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/job_spec.rb @@ -109,7 +109,7 @@ describe Gitlab::Ci::Config::Entry::Job do it 'overrides global config' do expect(entry[:image].value).to eq(name: 'some_image') - expect(entry[:cache].value).to eq(key: 'test') + expect(entry[:cache].value).to eq(key: 'test', policy: 'pull-push') end end @@ -123,7 +123,7 @@ describe Gitlab::Ci::Config::Entry::Job do it 'uses config from global entry' do expect(entry[:image].value).to eq 'specified' - expect(entry[:cache].value).to eq(key: 'test') + expect(entry[:cache].value).to eq(key: 'test', policy: 'pull-push') end end end diff --git a/spec/requests/api/runner_spec.rb b/spec/requests/api/runner_spec.rb index 339a57a1f20..ca5d98c78ef 100644 --- a/spec/requests/api/runner_spec.rb +++ b/spec/requests/api/runner_spec.rb @@ -351,7 +351,8 @@ describe API::Runner do let(:expected_cache) do [{ 'key' => 'cache_key', 'untracked' => false, - 'paths' => ['vendor/*'] }] + 'paths' => ['vendor/*'], + 'policy' => 'pull-push' }] end it 'picks a job' do -- cgit v1.2.3 From d1e0b1b3a8404f3a7b54db09c46fb614ca3fcb93 Mon Sep 17 00:00:00 2001 From: Tiago Botelho Date: Mon, 3 Jul 2017 13:55:43 +0100 Subject: Allow creation of files and directories with spaces in web UI --- spec/lib/gitlab/git/index_spec.rb | 19 +++++++++++++++++++ spec/models/repository_spec.rb | 10 ++++++++++ 2 files changed, 29 insertions(+) (limited to 'spec') diff --git a/spec/lib/gitlab/git/index_spec.rb b/spec/lib/gitlab/git/index_spec.rb index 21b71654251..8d63f81e4fd 100644 --- a/spec/lib/gitlab/git/index_spec.rb +++ b/spec/lib/gitlab/git/index_spec.rb @@ -25,6 +25,16 @@ describe Gitlab::Git::Index, seed_helper: true do expect(entry).not_to be_nil expect(repository.lookup(entry[:oid]).content).to eq(options[:content]) end + + it 'creates the file if file_path has spaces in between words' do + options[:file_path] = 'new file.txt' + + index.create(options) + entry = index.get(options[:file_path]) + + expect(entry).not_to be_nil + expect(repository.lookup(entry[:oid]).content).to eq(options[:content]) + end end context 'when a file at that path exists' do @@ -81,6 +91,15 @@ describe Gitlab::Git::Index, seed_helper: true do expect(entry).not_to be_nil end + + it 'creates the dir if it has spaces in between words' do + options[:file_path] = 'new dir' + + index.create_dir(options) + entry = index.get(options[:file_path] + '/.gitkeep') + + expect(entry).not_to be_nil + end end context 'when a file at that path exists' do diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index c69f0a495db..80b363355da 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -347,6 +347,16 @@ describe Repository, models: true do expect(blob.data).to eq('Changelog!') end + it 'creates new file with spaces in between successfully' do + expect do + repository.create_file(user, 'NEW FILE', 'File!', + message: 'Create NEW FILE', + branch_name: 'master') + end.to change { repository.commits('master').count }.by(1) + + expect(repository.blob_at('master', 'NEW FILE').data).to eq('File!') + end + it 'respects the autocrlf setting' do repository.create_file(user, 'hello.txt', "Hello,\r\nWorld", message: 'Add hello world', -- cgit v1.2.3 From 8a3022a69826272fb5eb111c016770965a5484b3 Mon Sep 17 00:00:00 2001 From: Sean McGivern Date: Wed, 5 Jul 2017 16:01:40 +0000 Subject: Revert "Merge branch '18000-remember-me-for-oauth-login' into 'master'" This reverts merge request !11963 --- spec/features/oauth_login_spec.rb | 112 --------------------- .../fixtures/oauth_remember_me.html.haml | 5 - spec/javascripts/oauth_remember_me_spec.js | 26 ----- spec/support/capybara_helpers.rb | 5 - spec/support/login_helpers.rb | 13 +-- 5 files changed, 1 insertion(+), 160 deletions(-) delete mode 100644 spec/features/oauth_login_spec.rb delete mode 100644 spec/javascripts/fixtures/oauth_remember_me.html.haml delete mode 100644 spec/javascripts/oauth_remember_me_spec.js (limited to 'spec') diff --git a/spec/features/oauth_login_spec.rb b/spec/features/oauth_login_spec.rb deleted file mode 100644 index 452b920307c..00000000000 --- a/spec/features/oauth_login_spec.rb +++ /dev/null @@ -1,112 +0,0 @@ -require 'spec_helper' - -feature 'OAuth Login', js: true do - def enter_code(code) - fill_in 'user_otp_attempt', with: code - click_button 'Verify code' - end - - def stub_omniauth_config(provider) - OmniAuth.config.add_mock(provider, OmniAuth::AuthHash.new(provider: provider.to_s, uid: "12345")) - Rails.application.env_config['devise.mapping'] = Devise.mappings[:user] - Rails.application.env_config['omniauth.auth'] = OmniAuth.config.mock_auth[provider] - end - - providers = [:github, :twitter, :bitbucket, :gitlab, :google_oauth2, - :facebook, :authentiq, :cas3, :auth0] - - before(:all) do - # The OmniAuth `full_host` parameter doesn't get set correctly (it gets set to something like `http://localhost` - # here), and causes integration tests to fail with 404s. We set the `full_host` by removing the request path (and - # anything after it) from the request URI. - @omniauth_config_full_host = OmniAuth.config.full_host - OmniAuth.config.full_host = ->(request) { request['REQUEST_URI'].sub(/#{request['REQUEST_PATH']}.*/, '') } - end - - after(:all) do - OmniAuth.config.full_host = @omniauth_config_full_host - end - - providers.each do |provider| - context "when the user logs in using the #{provider} provider" do - context 'when two-factor authentication is disabled' do - it 'logs the user in' do - stub_omniauth_config(provider) - user = create(:omniauth_user, extern_uid: 'my-uid', provider: provider.to_s) - login_via(provider.to_s, user, 'my-uid') - - expect(current_path).to eq root_path - end - end - - context 'when two-factor authentication is enabled' do - it 'logs the user in' do - stub_omniauth_config(provider) - user = create(:omniauth_user, :two_factor, extern_uid: 'my-uid', provider: provider.to_s) - login_via(provider.to_s, user, 'my-uid') - - enter_code(user.current_otp) - expect(current_path).to eq root_path - end - end - - context 'when "remember me" is checked' do - context 'when two-factor authentication is disabled' do - it 'remembers the user after a browser restart' do - stub_omniauth_config(provider) - user = create(:omniauth_user, extern_uid: 'my-uid', provider: provider.to_s) - login_via(provider.to_s, user, 'my-uid', remember_me: true) - - clear_browser_session - - visit(root_path) - expect(current_path).to eq root_path - end - end - - context 'when two-factor authentication is enabled' do - it 'remembers the user after a browser restart' do - stub_omniauth_config(provider) - user = create(:omniauth_user, :two_factor, extern_uid: 'my-uid', provider: provider.to_s) - login_via(provider.to_s, user, 'my-uid', remember_me: true) - enter_code(user.current_otp) - - clear_browser_session - - visit(root_path) - expect(current_path).to eq root_path - end - end - end - - context 'when "remember me" is not checked' do - context 'when two-factor authentication is disabled' do - it 'does not remember the user after a browser restart' do - stub_omniauth_config(provider) - user = create(:omniauth_user, extern_uid: 'my-uid', provider: provider.to_s) - login_via(provider.to_s, user, 'my-uid', remember_me: false) - - clear_browser_session - - visit(root_path) - expect(current_path).to eq new_user_session_path - end - end - - context 'when two-factor authentication is enabled' do - it 'does not remember the user after a browser restart' do - stub_omniauth_config(provider) - user = create(:omniauth_user, :two_factor, extern_uid: 'my-uid', provider: provider.to_s) - login_via(provider.to_s, user, 'my-uid', remember_me: false) - enter_code(user.current_otp) - - clear_browser_session - - visit(root_path) - expect(current_path).to eq new_user_session_path - end - end - end - end - end -end diff --git a/spec/javascripts/fixtures/oauth_remember_me.html.haml b/spec/javascripts/fixtures/oauth_remember_me.html.haml deleted file mode 100644 index 7886e995e57..00000000000 --- a/spec/javascripts/fixtures/oauth_remember_me.html.haml +++ /dev/null @@ -1,5 +0,0 @@ -#oauth-container - %input#remember_me{ type: "checkbox" } - - %a.oauth-login.twitter{ href: "http://example.com/" } - %a.oauth-login.github{ href: "http://example.com/" } diff --git a/spec/javascripts/oauth_remember_me_spec.js b/spec/javascripts/oauth_remember_me_spec.js deleted file mode 100644 index f90e0093d25..00000000000 --- a/spec/javascripts/oauth_remember_me_spec.js +++ /dev/null @@ -1,26 +0,0 @@ -import OAuthRememberMe from '~/oauth_remember_me'; - -describe('OAuthRememberMe', () => { - preloadFixtures('static/oauth_remember_me.html.raw'); - - beforeEach(() => { - loadFixtures('static/oauth_remember_me.html.raw'); - - new OAuthRememberMe({ container: $('#oauth-container') }).bindEvents(); - }); - - it('adds the "remember_me" query parameter to all OAuth login buttons', () => { - $('#oauth-container #remember_me').click(); - - expect($('#oauth-container .oauth-login.twitter').attr('href')).toBe('http://example.com/?remember_me=1'); - expect($('#oauth-container .oauth-login.github').attr('href')).toBe('http://example.com/?remember_me=1'); - }); - - it('removes the "remember_me" query parameter from all OAuth login buttons', () => { - $('#oauth-container #remember_me').click(); - $('#oauth-container #remember_me').click(); - - expect($('#oauth-container .oauth-login.twitter').attr('href')).toBe('http://example.com/'); - expect($('#oauth-container .oauth-login.github').attr('href')).toBe('http://example.com/'); - }); -}); diff --git a/spec/support/capybara_helpers.rb b/spec/support/capybara_helpers.rb index 3eb7bea3227..b57a3493aff 100644 --- a/spec/support/capybara_helpers.rb +++ b/spec/support/capybara_helpers.rb @@ -35,11 +35,6 @@ module CapybaraHelpers visit 'about:blank' visit url end - - # Simulate a browser restart by clearing the session cookie. - def clear_browser_session - page.driver.remove_cookie('_gitlab_session') - end end RSpec.configure do |config| diff --git a/spec/support/login_helpers.rb b/spec/support/login_helpers.rb index 99e7806353d..4c88958264b 100644 --- a/spec/support/login_helpers.rb +++ b/spec/support/login_helpers.rb @@ -62,16 +62,6 @@ module LoginHelpers Thread.current[:current_user] = user end - def login_via(provider, user, uid, remember_me: false) - mock_auth_hash(provider, uid, user.email) - visit new_user_session_path - expect(page).to have_content('Sign in with') - - check 'Remember Me' if remember_me - - click_link "oauth-login-#{provider}" - end - def mock_auth_hash(provider, uid, email) # The mock_auth configuration allows you to set per-provider (or default) # authentication hashes to return during integration testing. @@ -118,7 +108,6 @@ module LoginHelpers end allow(Gitlab::OAuth::Provider).to receive_messages(providers: [:saml], config_for: mock_saml_config) stub_omniauth_setting(messages) - 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') + expect_any_instance_of(Object).to receive(:omniauth_authorize_path).with(:user, "saml").and_return('/users/auth/saml') end end -- cgit v1.2.3 From f04033654554f202fc027b359b043653177275fc Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Wed, 5 Jul 2017 16:08:53 +0000 Subject: Handles realtime with 2 states for environments table --- .../environments/environments_store_spec.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'spec') diff --git a/spec/javascripts/environments/environments_store_spec.js b/spec/javascripts/environments/environments_store_spec.js index 6e855530b21..f2c6ec24dd7 100644 --- a/spec/javascripts/environments/environments_store_spec.js +++ b/spec/javascripts/environments/environments_store_spec.js @@ -86,6 +86,16 @@ describe('Store', () => { 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', () => { @@ -97,6 +107,17 @@ describe('Store', () => { 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', () => { -- cgit v1.2.3 From fe13f110412d85c05dc68e5ee1db499f681bf722 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Thu, 29 Jun 2017 12:06:35 -0500 Subject: Create and use project path helpers that only need a project, no namespace --- .../projects/artifacts_controller_spec.rb | 11 +--- spec/controllers/projects/blob_controller_spec.rb | 11 ++-- .../projects/branches_controller_spec.rb | 8 +-- .../controllers/projects/commit_controller_spec.rb | 8 +-- .../projects/compare_controller_spec.rb | 4 +- .../projects/environments_controller_spec.rb | 4 +- .../projects/group_links_controller_spec.rb | 6 +- .../projects/imports_controller_spec.rb | 10 +-- .../controllers/projects/issues_controller_spec.rb | 4 +- .../controllers/projects/labels_controller_spec.rb | 4 +- .../projects/mattermosts_controller_spec.rb | 4 +- .../projects/pages_domains_controller_spec.rb | 4 +- .../projects/project_members_controller_spec.rb | 16 ++--- .../projects/services_controller_spec.rb | 2 +- .../projects/snippets_controller_spec.rb | 6 +- .../projects/variables_controller_spec.rb | 4 +- spec/controllers/projects_controller_spec.rb | 2 +- .../sent_notifications_controller_spec.rb | 4 +- spec/controllers/snippets_controller_spec.rb | 2 +- .../admin_disables_git_access_protocol_spec.rb | 2 +- spec/features/admin/admin_projects_spec.rb | 8 +-- .../admin/admin_uses_repository_checks_spec.rb | 2 +- spec/features/atom/issues_spec.rb | 8 +-- spec/features/auto_deploy_spec.rb | 4 +- spec/features/boards/add_issues_modal_spec.rb | 4 +- spec/features/boards/boards_spec.rb | 12 ++-- spec/features/boards/issue_ordering_spec.rb | 6 +- spec/features/boards/keyboard_shortcut_spec.rb | 2 +- spec/features/boards/modal_filter_spec.rb | 2 +- spec/features/boards/new_issue_spec.rb | 4 +- spec/features/boards/sidebar_spec.rb | 4 +- spec/features/boards/sub_group_project_spec.rb | 2 +- spec/features/commits_spec.rb | 4 +- spec/features/container_registry_spec.rb | 3 +- spec/features/copy_as_gfm_spec.rb | 16 ++--- spec/features/cycle_analytics_spec.rb | 8 +-- .../project_member_activity_index_spec.rb | 2 +- spec/features/dashboard/projects_spec.rb | 2 +- spec/features/dashboard/todos/todos_spec.rb | 2 +- spec/features/discussion_comments/commit_spec.rb | 2 +- spec/features/discussion_comments/issue_spec.rb | 2 +- .../discussion_comments/merge_request_spec.rb | 2 +- spec/features/discussion_comments/snippets_spec.rb | 2 +- spec/features/expand_collapse_diffs_spec.rb | 6 +- spec/features/explore/new_menu_spec.rb | 18 ++--- spec/features/gitlab_flavored_markdown_spec.rb | 24 +++---- spec/features/issuables/issuable_list_spec.rb | 4 +- spec/features/issuables/user_sees_sidebar_spec.rb | 4 +- spec/features/issues/award_emoji_spec.rb | 6 +- spec/features/issues/award_spec.rb | 8 +-- .../features/issues/bulk_assignment_labels_spec.rb | 4 +- .../issues/create_branch_merge_request_spec.rb | 16 ++--- ..._issue_for_discussions_in_merge_request_spec.rb | 18 ++--- ..._for_single_discussion_in_merge_request_spec.rb | 10 +-- .../filtered_search/dropdown_assignee_spec.rb | 2 +- .../issues/filtered_search/dropdown_author_spec.rb | 2 +- .../issues/filtered_search/dropdown_hint_spec.rb | 2 +- .../issues/filtered_search/dropdown_label_spec.rb | 2 +- .../filtered_search/dropdown_milestone_spec.rb | 2 +- .../issues/filtered_search/filter_issues_spec.rb | 6 +- .../issues/filtered_search/recent_searches_spec.rb | 18 ++--- .../issues/filtered_search/search_bar_spec.rb | 2 +- .../issues/filtered_search/visual_tokens_spec.rb | 2 +- spec/features/issues/form_spec.rb | 9 ++- spec/features/issues/gfm_autocomplete_spec.rb | 2 +- spec/features/issues/group_label_sidebar_spec.rb | 8 +-- spec/features/issues/issue_sidebar_spec.rb | 2 +- spec/features/issues/markdown_toolbar_spec.rb | 2 +- spec/features/issues/move_spec.rb | 6 +- spec/features/issues/note_polling_spec.rb | 8 +-- spec/features/issues/notes_on_issues_spec.rb | 2 +- spec/features/issues/spam_issues_spec.rb | 4 +- spec/features/issues/todo_spec.rb | 6 +- spec/features/issues/update_issues_spec.rb | 12 ++-- .../issues/user_uses_slash_commands_spec.rb | 14 ++-- spec/features/issues_spec.rb | 76 +++++++++++----------- spec/features/merge_requests/assign_issues_spec.rb | 2 +- spec/features/merge_requests/award_spec.rb | 8 +-- ...f_mergeable_with_unresolved_discussions_spec.rb | 2 +- spec/features/merge_requests/cherry_pick_spec.rb | 4 +- spec/features/merge_requests/closes_issues_spec.rb | 2 +- spec/features/merge_requests/conflicts_spec.rb | 6 +- spec/features/merge_requests/create_new_mr_spec.rb | 24 +++---- .../merge_requests/created_from_fork_spec.rb | 3 +- .../merge_requests/deleted_source_branch_spec.rb | 6 +- .../merge_requests/diff_notes_avatars_spec.rb | 10 +-- .../merge_requests/diff_notes_resolve_spec.rb | 2 +- spec/features/merge_requests/diffs_spec.rb | 12 ++-- spec/features/merge_requests/discussion_spec.rb | 8 +-- spec/features/merge_requests/edit_mr_spec.rb | 4 +- .../merge_requests/filter_by_labels_spec.rb | 2 +- .../merge_requests/filter_merge_requests_spec.rb | 14 ++-- spec/features/merge_requests/form_spec.rb | 12 ++-- .../merge_commit_message_toggle_spec.rb | 2 +- .../merge_immediately_with_pipeline_spec.rb | 2 +- .../merge_when_pipeline_succeeds_spec.rb | 2 +- .../merge_requests/mini_pipeline_graph_spec.rb | 4 +- .../only_allow_merge_if_build_succeeds_spec.rb | 2 +- spec/features/merge_requests/pipelines_spec.rb | 4 +- spec/features/merge_requests/target_branch_spec.rb | 5 +- .../toggle_whitespace_changes_spec.rb | 2 +- .../merge_requests/toggler_behavior_spec.rb | 2 +- .../merge_requests/update_merge_requests_spec.rb | 12 ++-- .../user_lists_merge_requests_spec.rb | 4 +- .../merge_requests/user_posts_diff_notes_spec.rb | 14 ++-- .../merge_requests/user_posts_notes_spec.rb | 2 +- .../merge_requests/user_sees_system_notes_spec.rb | 4 +- .../user_uses_slash_commands_spec.rb | 12 ++-- spec/features/merge_requests/versions_spec.rb | 5 +- .../merge_requests/widget_deployments_spec.rb | 2 +- spec/features/merge_requests/widget_spec.rb | 23 +++---- spec/features/merge_requests/wip_message_spec.rb | 6 +- spec/features/milestone_spec.rb | 6 +- spec/features/milestones/show_spec.rb | 2 +- spec/features/participants_autocomplete_spec.rb | 6 +- spec/features/projects/activity/rss_spec.rb | 2 +- spec/features/projects/artifacts/browse_spec.rb | 2 +- spec/features/projects/artifacts/download_spec.rb | 8 +-- spec/features/projects/artifacts/file_spec.rb | 2 +- spec/features/projects/artifacts/raw_spec.rb | 2 +- spec/features/projects/badges/coverage_spec.rb | 3 +- spec/features/projects/badges/list_spec.rb | 2 +- .../blobs/blob_line_permalink_updater_spec.rb | 18 ++--- spec/features/projects/blobs/blob_show_spec.rb | 2 +- spec/features/projects/blobs/edit_spec.rb | 22 +++---- .../features/projects/blobs/shortcuts_blob_spec.rb | 6 +- .../projects/branches/download_buttons_spec.rb | 6 +- .../branches/new_branch_ref_dropdown_spec.rb | 2 +- spec/features/projects/branches_spec.rb | 26 ++++---- spec/features/projects/commit/builds_spec.rb | 2 +- spec/features/projects/commit/cherry_pick_spec.rb | 4 +- .../projects/commit/mini_pipeline_graph_spec.rb | 4 +- spec/features/projects/commit/rss_spec.rb | 2 +- spec/features/projects/compare_spec.rb | 2 +- spec/features/projects/deploy_keys_spec.rb | 2 +- ...eloper_views_empty_project_instructions_spec.rb | 2 +- spec/features/projects/diffs/diff_show_spec.rb | 2 +- spec/features/projects/edit_spec.rb | 2 +- .../environments/environment_metrics_spec.rb | 4 +- .../projects/environments/environment_spec.rb | 14 ++-- .../projects/environments/environments_spec.rb | 12 ++-- spec/features/projects/features_visibility_spec.rb | 34 +++++----- spec/features/projects/files/browse_files_spec.rb | 2 +- .../projects/files/creating_a_file_spec.rb | 2 +- .../projects/files/dockerfile_dropdown_spec.rb | 2 +- .../projects/files/download_buttons_spec.rb | 7 +- .../projects/files/edit_file_soft_wrap_spec.rb | 2 +- .../features/projects/files/editing_a_file_spec.rb | 2 +- .../files_sort_submodules_with_folders_spec.rb | 2 +- .../projects/files/find_file_keyboard_spec.rb | 2 +- spec/features/projects/files/find_files_spec.rb | 11 +--- .../projects/files/gitignore_dropdown_spec.rb | 2 +- .../projects/files/gitlab_ci_yml_dropdown_spec.rb | 2 +- .../project_owner_creates_license_file_spec.rb | 10 +-- ...to_create_license_file_in_empty_project_spec.rb | 6 +- .../projects/files/template_type_dropdown_spec.rb | 10 +-- spec/features/projects/files/undo_template_spec.rb | 4 +- .../projects/gfm_autocomplete_load_spec.rb | 4 +- spec/features/projects/group_links_spec.rb | 6 +- .../projects/guest_navigation_menu_spec.rb | 14 ++-- .../projects/import_export/export_file_spec.rb | 4 +- .../import_export/namespace_export_file_spec.rb | 4 +- spec/features/projects/issuable_templates_spec.rb | 8 +-- spec/features/projects/issues/list_spec.rb | 2 +- spec/features/projects/issues/rss_spec.rb | 2 +- spec/features/projects/jobs_spec.rb | 71 ++++++++++---------- .../labels/issues_sorted_by_priority_spec.rb | 4 +- spec/features/projects/labels/subscription_spec.rb | 4 +- .../projects/labels/update_prioritization_spec.rb | 14 ++-- .../projects/main/download_buttons_spec.rb | 6 +- spec/features/projects/main/rss_spec.rb | 2 +- .../members/anonymous_user_sees_members_spec.rb | 4 +- spec/features/projects/members/group_links_spec.rb | 4 +- ...group_member_cannot_leave_group_project_spec.rb | 2 +- ...not_request_access_to_his_group_project_spec.rb | 2 +- .../projects/members/group_members_spec.rb | 8 +-- ...uester_cannot_request_access_to_project_spec.rb | 2 +- spec/features/projects/members/list_spec.rb | 2 +- ...master_adds_member_with_expiration_date_spec.rb | 4 +- .../members/master_manages_access_requests_spec.rb | 6 +- ...er_cannot_request_access_to_his_project_spec.rb | 2 +- .../projects/members/member_leaves_project_spec.rb | 2 +- .../members/owner_cannot_leave_project_spec.rb | 2 +- ...er_cannot_request_access_to_his_project_spec.rb | 2 +- spec/features/projects/members/sorting_spec.rb | 2 +- .../projects/members/user_requests_access_spec.rb | 8 +-- .../features/projects/merge_request_button_spec.rb | 26 ++++---- spec/features/projects/merge_requests/list_spec.rb | 10 +-- .../features/projects/milestones/milestone_spec.rb | 6 +- .../projects/milestones/milestones_sorting_spec.rb | 2 +- spec/features/projects/milestones/new_spec.rb | 2 +- spec/features/projects/no_password_spec.rb | 8 +-- spec/features/projects/pages_spec.rb | 6 +- spec/features/projects/pipeline_schedules_spec.rb | 6 +- spec/features/projects/pipelines/pipeline_spec.rb | 8 +-- spec/features/projects/pipelines/pipelines_spec.rb | 16 ++--- spec/features/projects/project_settings_spec.rb | 16 ++--- spec/features/projects/ref_switcher_spec.rb | 2 +- .../projects/services/jira_service_spec.rb | 8 +-- .../services/mattermost_slash_command_spec.rb | 6 +- .../projects/services/slack_service_spec.rb | 2 +- .../projects/services/slack_slash_command_spec.rb | 6 +- .../projects/settings/integration_settings_spec.rb | 10 +-- .../settings/merge_requests_settings_spec.rb | 2 - .../projects/settings/pipelines_settings_spec.rb | 4 +- .../projects/settings/repository_settings_spec.rb | 12 ++-- .../projects/settings/visibility_settings_spec.rb | 4 +- spec/features/projects/shortcuts_spec.rb | 2 +- .../projects/snippets/create_snippet_spec.rb | 4 +- spec/features/projects/snippets/show_spec.rb | 6 +- spec/features/projects/snippets_spec.rb | 6 +- spec/features/projects/sub_group_issuables_spec.rb | 4 +- .../projects/tags/download_buttons_spec.rb | 6 +- spec/features/projects/tree/rss_spec.rb | 2 +- spec/features/projects/user_create_dir_spec.rb | 4 +- .../features/projects/user_creates_project_spec.rb | 2 +- spec/features/projects/view_on_env_spec.rb | 12 ++-- .../projects/wiki/markdown_preview_spec.rb | 2 +- spec/features/projects/wiki/shortcuts_spec.rb | 2 +- .../projects/wiki/user_creates_wiki_page_spec.rb | 2 +- .../wiki/user_git_access_wiki_page_spec.rb | 2 +- .../projects/wiki/user_updates_wiki_page_spec.rb | 2 +- .../wiki/user_views_project_wiki_page_spec.rb | 9 +-- .../wiki/user_views_wiki_in_project_page_spec.rb | 8 +-- spec/features/projects_spec.rb | 12 ++-- spec/features/protected_branches_spec.rb | 14 ++-- spec/features/protected_tags_spec.rb | 14 ++-- spec/features/reportable_note/commit_spec.rb | 4 +- spec/features/reportable_note/issue_spec.rb | 2 +- .../features/reportable_note/merge_request_spec.rb | 2 +- spec/features/reportable_note/snippets_spec.rb | 2 +- spec/features/runners_spec.rb | 4 +- spec/features/search_spec.rb | 16 ++--- .../security/project/internal_access_spec.rb | 62 +++++++++--------- .../security/project/private_access_spec.rb | 62 +++++++++--------- .../security/project/public_access_spec.rb | 62 +++++++++--------- .../project/snippet/internal_access_spec.rb | 12 ++-- .../project/snippet/private_access_spec.rb | 8 +-- .../security/project/snippet/public_access_spec.rb | 16 ++--- spec/features/tags/master_creates_tag_spec.rb | 8 +-- spec/features/tags/master_deletes_tag_spec.rb | 6 +- spec/features/tags/master_updates_tag_spec.rb | 6 +- spec/features/tags/master_views_tags_spec.rb | 20 +++--- spec/features/task_lists_spec.rb | 16 ++--- spec/features/triggers_spec.rb | 20 +++--- .../uploads/user_uploads_file_to_note_spec.rb | 2 +- spec/features/variables_spec.rb | 2 +- spec/fixtures/markdown.md.erb | 22 +++---- spec/helpers/application_helper_spec.rb | 2 +- spec/helpers/gitlab_routing_helper_spec.rb | 12 ++-- spec/helpers/issues_helper_spec.rb | 2 +- spec/helpers/markup_helper_spec.rb | 12 ++-- spec/helpers/milestones_helper_spec.rb | 4 +- spec/helpers/notes_helper_spec.rb | 14 ++-- .../filter/commit_range_reference_filter_spec.rb | 14 ++-- .../banzai/filter/commit_reference_filter_spec.rb | 8 +-- .../banzai/filter/label_reference_filter_spec.rb | 62 +++++++----------- .../filter/merge_request_reference_filter_spec.rb | 15 ++--- .../filter/milestone_reference_filter_spec.rb | 22 +++---- .../banzai/filter/snippet_reference_filter_spec.rb | 14 ++-- .../banzai/filter/user_reference_filter_spec.rb | 2 +- spec/lib/banzai/pipeline/gfm_pipeline_spec.rb | 6 +- spec/lib/gitlab/closing_issue_extractor_spec.rb | 8 +-- spec/mailers/notify_spec.rb | 43 ++++++------ .../projects/cycle_analytics_events_spec.rb | 22 +++---- spec/serializers/deploy_key_entity_spec.rb | 2 +- spec/services/system_note_service_spec.rb | 8 +-- spec/spec_helper.rb | 2 +- spec/support/issue_helpers.rb | 2 +- spec/support/merge_request_helpers.rb | 2 +- .../access_control_ce_shared_examples.rb | 4 +- spec/support/routing_helpers.rb | 3 + .../protected_branches_access_control_ce.rb | 8 +-- spec/views/ci/status/_badge.html.haml_spec.rb | 3 +- .../merge_requests/_commits.html.haml_spec.rb | 5 +- 275 files changed, 1023 insertions(+), 1131 deletions(-) create mode 100644 spec/support/routing_helpers.rb (limited to 'spec') diff --git a/spec/controllers/projects/artifacts_controller_spec.rb b/spec/controllers/projects/artifacts_controller_spec.rb index 428bc45b842..d2c613a2423 100644 --- a/spec/controllers/projects/artifacts_controller_spec.rb +++ b/spec/controllers/projects/artifacts_controller_spec.rb @@ -134,10 +134,7 @@ describe Projects::ArtifactsController do context 'found the job and redirect' do shared_examples 'redirect to the job' do it 'redirects' do - path = browse_namespace_project_job_artifacts_path( - project.namespace, - project, - job) + path = browse_project_job_artifacts_path(project, job) expect(response).to redirect_to(path) end @@ -174,11 +171,7 @@ describe Projects::ArtifactsController do end it 'redirects' do - path = file_namespace_project_job_artifacts_path( - project.namespace, - project, - job, - 'README.md') + path = file_project_job_artifacts_path(project, job, 'README.md') expect(response).to redirect_to(path) end diff --git a/spec/controllers/projects/blob_controller_spec.rb b/spec/controllers/projects/blob_controller_spec.rb index 561bc219bb4..02bbc48dc59 100644 --- a/spec/controllers/projects/blob_controller_spec.rb +++ b/spec/controllers/projects/blob_controller_spec.rb @@ -117,7 +117,7 @@ describe Projects::BlobController do end it 'redirects to blob show' do - expect(response).to redirect_to(namespace_project_blob_path(project.namespace, project, 'master/CHANGELOG')) + expect(response).to redirect_to(project_blob_path(project, 'master/CHANGELOG')) end end @@ -164,7 +164,7 @@ describe Projects::BlobController do end def blob_after_edit_path - namespace_project_blob_path(project.namespace, project, 'master/CHANGELOG') + project_blob_path(project, 'master/CHANGELOG') end before do @@ -186,7 +186,7 @@ describe Projects::BlobController do it 'redirects to MR diff' do put :update, mr_params - after_edit_path = diffs_namespace_project_merge_request_path(project.namespace, project, merge_request) + after_edit_path = diffs_project_merge_request_path(project, merge_request) file_anchor = "##{Digest::SHA1.hexdigest('CHANGELOG')}" expect(response).to redirect_to(after_edit_path + file_anchor) end @@ -223,7 +223,7 @@ describe Projects::BlobController do it 'redirects to blob' do put :update, default_params - expect(response).to redirect_to(namespace_project_blob_path(forked_project.namespace, forked_project, 'master/CHANGELOG')) + expect(response).to redirect_to(project_blob_path(forked_project, 'master/CHANGELOG')) end end @@ -235,8 +235,7 @@ describe Projects::BlobController do put :update, default_params expect(response).to redirect_to( - namespace_project_new_merge_request_path( - forked_project.namespace, + project_new_merge_request_path( forked_project, merge_request: { source_project_id: forked_project.id, diff --git a/spec/controllers/projects/branches_controller_spec.rb b/spec/controllers/projects/branches_controller_spec.rb index 14426b09c73..9cd4e9dbf84 100644 --- a/spec/controllers/projects/branches_controller_spec.rb +++ b/spec/controllers/projects/branches_controller_spec.rb @@ -110,7 +110,7 @@ describe Projects::BranchesController do branch_name: branch, issue_iid: issue.iid - expect(response).to redirect_to namespace_project_tree_path(project.namespace, project, branch) + expect(response).to redirect_to project_tree_path(project, branch) end it 'redirects to autodeploy setup page' do @@ -127,7 +127,7 @@ describe Projects::BranchesController do branch_name: branch, issue_iid: issue.iid - expect(response.location).to include(namespace_project_new_blob_path(project.namespace, project, branch)) + expect(response.location).to include(project_new_blob_path(project, branch)) expect(response).to have_http_status(302) end end @@ -303,7 +303,7 @@ describe Projects::BranchesController do it 'redirects to branches path' do expect(response) - .to redirect_to(namespace_project_branches_path(project.namespace, project)) + .to redirect_to(project_branches_path(project)) end end end @@ -323,7 +323,7 @@ describe Projects::BranchesController do it 'redirects to branches' do destroy_all_merged - expect(response).to redirect_to namespace_project_branches_path(project.namespace, project) + expect(response).to redirect_to project_branches_path(project) end it 'starts worker to delete merged branches' do diff --git a/spec/controllers/projects/commit_controller_spec.rb b/spec/controllers/projects/commit_controller_spec.rb index e10da40eaab..eb61a0c080c 100644 --- a/spec/controllers/projects/commit_controller_spec.rb +++ b/spec/controllers/projects/commit_controller_spec.rb @@ -169,7 +169,7 @@ describe Projects::CommitController do start_branch: 'master', id: commit.id) - expect(response).to redirect_to namespace_project_commits_path(project.namespace, project, 'master') + expect(response).to redirect_to project_commits_path(project, 'master') expect(flash[:notice]).to eq('The commit has been successfully reverted.') end end @@ -191,7 +191,7 @@ describe Projects::CommitController do start_branch: 'master', id: commit.id) - expect(response).to redirect_to namespace_project_commit_path(project.namespace, project, commit.id) + expect(response).to redirect_to project_commit_path(project, commit.id) expect(flash[:alert]).to match('Sorry, we cannot revert this commit automatically.') end end @@ -218,7 +218,7 @@ describe Projects::CommitController do start_branch: 'master', id: master_pickable_commit.id) - expect(response).to redirect_to namespace_project_commits_path(project.namespace, project, 'master') + expect(response).to redirect_to project_commits_path(project, 'master') expect(flash[:notice]).to eq('The commit has been successfully cherry-picked.') end end @@ -240,7 +240,7 @@ describe Projects::CommitController do start_branch: 'master', id: master_pickable_commit.id) - expect(response).to redirect_to namespace_project_commit_path(project.namespace, project, master_pickable_commit.id) + expect(response).to redirect_to project_commit_path(project, master_pickable_commit.id) expect(flash[:alert]).to match('Sorry, we cannot cherry-pick this commit automatically.') end end diff --git a/spec/controllers/projects/compare_controller_spec.rb b/spec/controllers/projects/compare_controller_spec.rb index 8f4694c9854..b4f9fd9b7a2 100644 --- a/spec/controllers/projects/compare_controller_spec.rb +++ b/spec/controllers/projects/compare_controller_spec.rb @@ -72,7 +72,7 @@ describe Projects::CompareController do from: '', to: 'master') - expect(response).to redirect_to(namespace_project_compare_index_path(project.namespace, project, to: 'master')) + expect(response).to redirect_to(project_compare_index_path(project, to: 'master')) end it 'redirects back to index when params[:to] is empty and preserves params[:from]' do @@ -82,7 +82,7 @@ describe Projects::CompareController do from: 'master', to: '') - expect(response).to redirect_to(namespace_project_compare_index_path(project.namespace, project, from: 'master')) + expect(response).to redirect_to(project_compare_index_path(project, from: 'master')) end it 'redirects back to index when params[:from] and params[:to] are empty' do diff --git a/spec/controllers/projects/environments_controller_spec.rb b/spec/controllers/projects/environments_controller_spec.rb index ad0b046742d..9db8ff5bbaa 100644 --- a/spec/controllers/projects/environments_controller_spec.rb +++ b/spec/controllers/projects/environments_controller_spec.rb @@ -184,7 +184,7 @@ describe Projects::EnvironmentsController do expect(response).to have_http_status(200) expect(json_response).to eq( { 'redirect_url' => - namespace_project_job_url(project.namespace, project, action) }) + project_job_url(project, action) }) end end @@ -198,7 +198,7 @@ describe Projects::EnvironmentsController do expect(response).to have_http_status(200) expect(json_response).to eq( { 'redirect_url' => - namespace_project_environment_url(project.namespace, project, environment) }) + project_environment_url(project, environment) }) end end end diff --git a/spec/controllers/projects/group_links_controller_spec.rb b/spec/controllers/projects/group_links_controller_spec.rb index b5435357f53..48a2994cbc0 100644 --- a/spec/controllers/projects/group_links_controller_spec.rb +++ b/spec/controllers/projects/group_links_controller_spec.rb @@ -34,7 +34,7 @@ describe Projects::GroupLinksController do it 'redirects to project group links page' do expect(response).to redirect_to( - namespace_project_settings_members_path(project.namespace, project) + project_settings_members_path(project) ) end end @@ -65,7 +65,7 @@ describe Projects::GroupLinksController do it 'redirects to project group links page' do expect(response).to redirect_to( - namespace_project_settings_members_path(project.namespace, project) + project_settings_members_path(project) ) end end @@ -79,7 +79,7 @@ describe Projects::GroupLinksController do it 'redirects to project group links page' do expect(response).to redirect_to( - namespace_project_settings_members_path(project.namespace, project) + project_settings_members_path(project) ) expect(flash[:alert]).to eq('Please select a group.') end diff --git a/spec/controllers/projects/imports_controller_spec.rb b/spec/controllers/projects/imports_controller_spec.rb index 6724b474179..9be61342616 100644 --- a/spec/controllers/projects/imports_controller_spec.rb +++ b/spec/controllers/projects/imports_controller_spec.rb @@ -59,7 +59,7 @@ describe Projects::ImportsController do it 'redirects to new_namespace_project_import_path' do get :show, namespace_id: project.namespace.to_param, project_id: project - expect(response).to redirect_to new_namespace_project_import_path(project.namespace, project) + expect(response).to redirect_to new_project_import_path(project) end end @@ -75,7 +75,7 @@ describe Projects::ImportsController do get :show, namespace_id: project.namespace.to_param, project_id: project expect(flash[:notice]).to eq 'The project was successfully forked.' - expect(response).to redirect_to namespace_project_path(project.namespace, project) + expect(response).to redirect_to project_path(project) end end @@ -84,14 +84,14 @@ describe Projects::ImportsController do get :show, namespace_id: project.namespace.to_param, project_id: project expect(flash[:notice]).to eq 'The project was successfully imported.' - expect(response).to redirect_to namespace_project_path(project.namespace, project) + expect(response).to redirect_to project_path(project) end end context 'when continue params is present' do let(:params) do { - to: namespace_project_path(project.namespace, project), + to: project_path(project), notice: 'Finished' } end @@ -120,7 +120,7 @@ describe Projects::ImportsController do it 'redirects to namespace_project_path' do get :show, namespace_id: project.namespace.to_param, project_id: project - expect(response).to redirect_to namespace_project_path(project.namespace, project) + expect(response).to redirect_to project_path(project) end end end diff --git a/spec/controllers/projects/issues_controller_spec.rb b/spec/controllers/projects/issues_controller_spec.rb index 9f98427a86b..22aad0b3225 100644 --- a/spec/controllers/projects/issues_controller_spec.rb +++ b/spec/controllers/projects/issues_controller_spec.rb @@ -35,7 +35,7 @@ describe Projects::IssuesController do it "returns 301 if request path doesn't match project path" do get :index, namespace_id: project.namespace, project_id: project.path.upcase - expect(response).to redirect_to(namespace_project_issues_path(project.namespace, project)) + expect(response).to redirect_to(project_issues_path(project)) end it "returns 404 when issues are disabled" do @@ -329,7 +329,7 @@ describe Projects::IssuesController do update_verified_issue expect(response) - .to redirect_to(namespace_project_issue_path(project.namespace, project, issue)) + .to redirect_to(project_issue_path(project, issue)) end it 'accepts an issue after recaptcha is verified' do diff --git a/spec/controllers/projects/labels_controller_spec.rb b/spec/controllers/projects/labels_controller_spec.rb index bf1776eb320..f19ad4c2c81 100644 --- a/spec/controllers/projects/labels_controller_spec.rb +++ b/spec/controllers/projects/labels_controller_spec.rb @@ -178,7 +178,7 @@ describe Projects::LabelsController do it 'redirects to the correct casing' do get :index, namespace_id: project.namespace, project_id: project.to_param.upcase - expect(response).to redirect_to(namespace_project_labels_path(project.namespace, project)) + expect(response).to redirect_to(project_labels_path(project)) expect(controller).not_to set_flash[:notice] end end @@ -191,7 +191,7 @@ describe Projects::LabelsController do it 'redirects to the canonical path' do get :index, namespace_id: project.namespace, project_id: project.to_param + 'old' - expect(response).to redirect_to(namespace_project_labels_path(project.namespace, project)) + expect(response).to redirect_to(project_labels_path(project)) expect(controller).to set_flash[:notice].to(project_moved_message(redirect_route, project)) end end diff --git a/spec/controllers/projects/mattermosts_controller_spec.rb b/spec/controllers/projects/mattermosts_controller_spec.rb index 422a8b6fac0..12e413db902 100644 --- a/spec/controllers/projects/mattermosts_controller_spec.rb +++ b/spec/controllers/projects/mattermosts_controller_spec.rb @@ -38,7 +38,7 @@ describe Projects::MattermostsController do it 'shows the error' do allow_any_instance_of(MattermostSlashCommandsService).to receive(:configure).and_return([false, "error message"]) - expect(subject).to redirect_to(new_namespace_project_mattermost_url(project.namespace, project)) + expect(subject).to redirect_to(new_project_mattermost_url(project)) end end @@ -51,7 +51,7 @@ describe Projects::MattermostsController do subject service = project.services.last - expect(subject).to redirect_to(edit_namespace_project_service_url(project.namespace, project, service)) + expect(subject).to redirect_to(edit_project_service_url(project, service)) end end end diff --git a/spec/controllers/projects/pages_domains_controller_spec.rb b/spec/controllers/projects/pages_domains_controller_spec.rb index 33853c4b9d0..920189be381 100644 --- a/spec/controllers/projects/pages_domains_controller_spec.rb +++ b/spec/controllers/projects/pages_domains_controller_spec.rb @@ -46,7 +46,7 @@ describe Projects::PagesDomainsController do post(:create, request_params.merge(pages_domain: pages_domain_params)) end.to change { PagesDomain.count }.by(1) - expect(response).to redirect_to(namespace_project_pages_path(project.namespace, project)) + expect(response).to redirect_to(project_pages_path(project)) end end @@ -56,7 +56,7 @@ describe Projects::PagesDomainsController do delete(:destroy, request_params.merge(id: pages_domain.domain)) end.to change { PagesDomain.count }.by(-1) - expect(response).to redirect_to(namespace_project_pages_path(project.namespace, project)) + expect(response).to redirect_to(project_pages_path(project)) end end diff --git a/spec/controllers/projects/project_members_controller_spec.rb b/spec/controllers/projects/project_members_controller_spec.rb index f2b59ba82ca..548ec8f487f 100644 --- a/spec/controllers/projects/project_members_controller_spec.rb +++ b/spec/controllers/projects/project_members_controller_spec.rb @@ -9,7 +9,7 @@ describe Projects::ProjectMembersController do get :index, namespace_id: project.namespace, project_id: project expect(response).to have_http_status(302) - expect(response.location).to include namespace_project_settings_members_path(project.namespace, project) + expect(response.location).to include project_settings_members_path(project) end end @@ -50,7 +50,7 @@ describe Projects::ProjectMembersController do access_level: Gitlab::Access::GUEST expect(response).to set_flash.to 'Users were successfully added.' - expect(response).to redirect_to(namespace_project_settings_members_path(project.namespace, project)) + expect(response).to redirect_to(project_settings_members_path(project)) end it 'adds no user to members' do @@ -62,7 +62,7 @@ describe Projects::ProjectMembersController do access_level: Gitlab::Access::GUEST expect(response).to set_flash.to 'Message' - expect(response).to redirect_to(namespace_project_settings_members_path(project.namespace, project)) + expect(response).to redirect_to(project_settings_members_path(project)) end end end @@ -111,7 +111,7 @@ describe Projects::ProjectMembersController do id: member expect(response).to redirect_to( - namespace_project_settings_members_path(project.namespace, project) + project_settings_members_path(project) ) expect(project.members).not_to include member end @@ -183,7 +183,7 @@ describe Projects::ProjectMembersController do project_id: project expect(response).to set_flash.to 'Your access request to the project has been withdrawn.' - expect(response).to redirect_to(namespace_project_path(project.namespace, project)) + expect(response).to redirect_to(project_path(project)) expect(project.requesters).to be_empty expect(project.users).not_to include user end @@ -202,7 +202,7 @@ describe Projects::ProjectMembersController do expect(response).to set_flash.to 'Your request for access has been queued for review.' expect(response).to redirect_to( - namespace_project_path(project.namespace, project) + project_path(project) ) expect(project.requesters.exists?(user_id: user)).to be_truthy expect(project.users).not_to include user @@ -253,7 +253,7 @@ describe Projects::ProjectMembersController do id: member expect(response).to redirect_to( - namespace_project_settings_members_path(project.namespace, project) + project_settings_members_path(project) ) expect(project.members).to include member end @@ -290,7 +290,7 @@ describe Projects::ProjectMembersController do expect(project.team_members).to include member expect(response).to set_flash.to 'Successfully imported' expect(response).to redirect_to( - namespace_project_settings_members_path(project.namespace, project) + project_settings_members_path(project) ) end end diff --git a/spec/controllers/projects/services_controller_spec.rb b/spec/controllers/projects/services_controller_spec.rb index 4dc227a36d4..5a9d8a75f3e 100644 --- a/spec/controllers/projects/services_controller_spec.rb +++ b/spec/controllers/projects/services_controller_spec.rb @@ -79,7 +79,7 @@ describe Projects::ServicesController do put :update, namespace_id: project.namespace.id, project_id: project.id, id: service.id, service: { active: true } - expect(response).to redirect_to(namespace_project_settings_integrations_path(project.namespace, project)) + expect(response).to redirect_to(project_settings_integrations_path(project)) expect(flash[:notice]).to eq 'HipChat activated.' end end diff --git a/spec/controllers/projects/snippets_controller_spec.rb b/spec/controllers/projects/snippets_controller_spec.rb index ec0b7f8c967..cc444f31797 100644 --- a/spec/controllers/projects/snippets_controller_spec.rb +++ b/spec/controllers/projects/snippets_controller_spec.rb @@ -148,7 +148,7 @@ describe Projects::SnippetsController do { spam_log_id: spam_logs.last.id, recaptcha_verification: true }) - expect(response).to redirect_to(Snippet.last) + expect(response).to redirect_to(project_snippet_path(project, Snippet.last)) end end end @@ -228,7 +228,7 @@ describe Projects::SnippetsController do { spam_log_id: spam_logs.last.id, recaptcha_verification: true }) - expect(response).to redirect_to(snippet) + expect(response).to redirect_to(project_snippet_path(project, snippet)) end end end @@ -273,7 +273,7 @@ describe Projects::SnippetsController do { spam_log_id: spam_logs.last.id, recaptcha_verification: true }) - expect(response).to redirect_to(snippet) + expect(response).to redirect_to(project_snippet_path(project, snippet)) end end end diff --git a/spec/controllers/projects/variables_controller_spec.rb b/spec/controllers/projects/variables_controller_spec.rb index 1ecfe48475c..a0ecc756653 100644 --- a/spec/controllers/projects/variables_controller_spec.rb +++ b/spec/controllers/projects/variables_controller_spec.rb @@ -16,7 +16,7 @@ describe Projects::VariablesController do variable: { key: "one", value: "two" } expect(flash[:notice]).to include 'Variables were successfully updated.' - expect(response).to redirect_to(namespace_project_settings_ci_cd_path(project.namespace, project)) + expect(response).to redirect_to(project_settings_ci_cd_path(project)) end end @@ -44,7 +44,7 @@ describe Projects::VariablesController do id: variable.id, variable: { key: variable.key, value: 'two' } expect(flash[:notice]).to include 'Variable was successfully updated.' - expect(response).to redirect_to(namespace_project_variables_path(project.namespace, project)) + expect(response).to redirect_to(project_variables_path(project)) end it 'renders the action #show if the variable key is invalid' do diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index 240a81367d0..f96fe7ad5cb 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -482,7 +482,7 @@ describe ProjectsController do it 'redirects to the canonical path (testing non-show action)' do get :refs, namespace_id: 'foo', id: 'bar' - expect(response).to redirect_to(refs_namespace_project_path(namespace_id: public_project.namespace, id: public_project)) + expect(response).to redirect_to(refs_project_path(public_project)) expect(controller).to set_flash[:notice].to(project_moved_message(redirect_route, public_project)) end end diff --git a/spec/controllers/sent_notifications_controller_spec.rb b/spec/controllers/sent_notifications_controller_spec.rb index 917bd44c91b..7340a4e16c0 100644 --- a/spec/controllers/sent_notifications_controller_spec.rb +++ b/spec/controllers/sent_notifications_controller_spec.rb @@ -88,7 +88,7 @@ describe SentNotificationsController, type: :controller do it 'redirects to the issue page' do expect(response) - .to redirect_to(namespace_project_issue_path(project.namespace, project, issue)) + .to redirect_to(project_issue_path(project, issue)) end end @@ -114,7 +114,7 @@ describe SentNotificationsController, type: :controller do it 'redirects to the merge request page' do expect(response) - .to redirect_to(namespace_project_merge_request_path(project.namespace, project, merge_request)) + .to redirect_to(project_merge_request_path(project, merge_request)) end end end diff --git a/spec/controllers/snippets_controller_spec.rb b/spec/controllers/snippets_controller_spec.rb index 430d1208cd1..15416a89017 100644 --- a/spec/controllers/snippets_controller_spec.rb +++ b/spec/controllers/snippets_controller_spec.rb @@ -341,7 +341,7 @@ describe SnippetsController do { spam_log_id: spam_logs.last.id, recaptcha_verification: true }) - expect(response).to redirect_to(snippet) + expect(response).to redirect_to(snippet_path(snippet)) end end end diff --git a/spec/features/admin/admin_disables_git_access_protocol_spec.rb b/spec/features/admin/admin_disables_git_access_protocol_spec.rb index 679bf63e0fd..063d54270bd 100644 --- a/spec/features/admin/admin_disables_git_access_protocol_spec.rb +++ b/spec/features/admin/admin_disables_git_access_protocol_spec.rb @@ -51,7 +51,7 @@ feature 'Admin disables Git access protocol', feature: true do end def visit_project - visit namespace_project_path(project.namespace, project) + visit project_path(project) end def disable_http_protocol diff --git a/spec/features/admin/admin_projects_spec.rb b/spec/features/admin/admin_projects_spec.rb index a4ce3e1d5ee..c6488cea798 100644 --- a/spec/features/admin/admin_projects_spec.rb +++ b/spec/features/admin/admin_projects_spec.rb @@ -42,7 +42,7 @@ describe "Admin::Projects", feature: true do end it do - expect(current_path).to eq admin_namespace_project_path(project.namespace, project) + expect(current_path).to eq admin_project_path(project) end it "has project info" do @@ -62,7 +62,7 @@ describe "Admin::Projects", feature: true do end it 'transfers project to group web', js: true do - visit admin_namespace_project_path(project.namespace, project) + visit admin_project_path(project) click_button 'Search for Namespace' click_link 'group: web' @@ -79,7 +79,7 @@ describe "Admin::Projects", feature: true do end it 'adds admin a to a project as developer', js: true do - visit namespace_project_project_members_path(project.namespace, project) + visit project_project_members_path(project) page.within '.users-project-form' do select2(current_user.id, from: '#user_ids', multiple: true) @@ -102,7 +102,7 @@ describe "Admin::Projects", feature: true do end it 'removes admin from the project' do - visit namespace_project_project_members_path(project.namespace, project) + visit project_project_members_path(project) page.within '.content-list' do expect(page).to have_content(current_user.name) diff --git a/spec/features/admin/admin_uses_repository_checks_spec.rb b/spec/features/admin/admin_uses_repository_checks_spec.rb index 91d70435db8..5be0e2b2f17 100644 --- a/spec/features/admin/admin_uses_repository_checks_spec.rb +++ b/spec/features/admin/admin_uses_repository_checks_spec.rb @@ -43,6 +43,6 @@ feature 'Admin uses repository checks', feature: true do end def visit_admin_project_page(project) - visit admin_namespace_project_path(project.namespace, project) + visit admin_project_path(project) end end diff --git a/spec/features/atom/issues_spec.rb b/spec/features/atom/issues_spec.rb index b94ad973fed..f7d170a7bf6 100644 --- a/spec/features/atom/issues_spec.rb +++ b/spec/features/atom/issues_spec.rb @@ -16,7 +16,7 @@ describe 'Issues Feed', feature: true do context 'when authenticated' do it 'renders atom feed' do gitlab_sign_in user - visit namespace_project_issues_path(project.namespace, project, :atom) + visit project_issues_path(project, :atom) expect(response_headers['Content-Type']) .to have_content('application/atom+xml') @@ -30,7 +30,7 @@ describe 'Issues Feed', feature: true do context 'when authenticated via private token' do it 'renders atom feed' do - visit namespace_project_issues_path(project.namespace, project, :atom, + visit project_issues_path(project, :atom, private_token: user.private_token) expect(response_headers['Content-Type']) @@ -45,7 +45,7 @@ describe 'Issues Feed', feature: true do context 'when authenticated via RSS token' do it 'renders atom feed' do - visit namespace_project_issues_path(project.namespace, project, :atom, + visit project_issues_path(project, :atom, rss_token: user.rss_token) expect(response_headers['Content-Type']) @@ -59,7 +59,7 @@ describe 'Issues Feed', feature: true do end it "renders atom feed with url parameters for project issues" do - visit namespace_project_issues_path(project.namespace, project, + visit project_issues_path(project, :atom, rss_token: user.rss_token, state: 'opened', assignee_id: user.id) link = find('link[type="application/atom+xml"]') diff --git a/spec/features/auto_deploy_spec.rb b/spec/features/auto_deploy_spec.rb index 74f5f70702a..3536d59bb08 100644 --- a/spec/features/auto_deploy_spec.rb +++ b/spec/features/auto_deploy_spec.rb @@ -16,7 +16,7 @@ describe 'Auto deploy' do end it 'does not show a button to set up auto deploy' do - visit namespace_project_path(project.namespace, project) + visit project_path(project) expect(page).to have_no_content('Set up auto deploy') end end @@ -24,7 +24,7 @@ describe 'Auto deploy' do context 'when a deployment service is active' do before do project.kubernetes_service.update!(active: true) - visit namespace_project_path(project.namespace, project) + visit project_path(project) end it 'shows a button to set up auto deploy' do diff --git a/spec/features/boards/add_issues_modal_spec.rb b/spec/features/boards/add_issues_modal_spec.rb index ba58af22841..eeb63f3f81a 100644 --- a/spec/features/boards/add_issues_modal_spec.rb +++ b/spec/features/boards/add_issues_modal_spec.rb @@ -16,12 +16,12 @@ describe 'Issue Boards add issue modal', :feature, :js do gitlab_sign_in(user) - visit namespace_project_board_path(project.namespace, project, board) + visit project_board_path(project, board) wait_for_requests end it 'resets filtered search state' do - visit namespace_project_board_path(project.namespace, project, board, search: 'testing') + visit project_board_path(project, board, search: 'testing') wait_for_requests diff --git a/spec/features/boards/boards_spec.rb b/spec/features/boards/boards_spec.rb index 87fc31d414c..1f697581179 100644 --- a/spec/features/boards/boards_spec.rb +++ b/spec/features/boards/boards_spec.rb @@ -17,7 +17,7 @@ describe 'Issue Boards', feature: true, js: true do context 'no lists' do before do - visit namespace_project_board_path(project.namespace, project, board) + visit project_board_path(project, board) wait_for_requests expect(page).to have_selector('.board', count: 3) end @@ -81,7 +81,7 @@ describe 'Issue Boards', feature: true, js: true do let!(:issue9) { create(:labeled_issue, project: project, labels: [planning, testing, bug, accepting], relative_position: 1) } before do - visit namespace_project_board_path(project.namespace, project, board) + visit project_board_path(project, board) wait_for_requests @@ -158,7 +158,7 @@ describe 'Issue Boards', feature: true, js: true do create(:labeled_issue, project: project, labels: [planning]) end - visit namespace_project_board_path(project.namespace, project, board) + visit project_board_path(project, board) wait_for_requests page.within(find('.board:nth-child(2)')) do @@ -507,7 +507,7 @@ describe 'Issue Boards', feature: true, js: true do context 'keyboard shortcuts' do before do - visit namespace_project_board_path(project.namespace, project, board) + visit project_board_path(project, board) wait_for_requests end @@ -520,7 +520,7 @@ describe 'Issue Boards', feature: true, js: true do context 'signed out user' do before do gitlab_sign_out - visit namespace_project_board_path(project.namespace, project, board) + visit project_board_path(project, board) wait_for_requests end @@ -544,7 +544,7 @@ describe 'Issue Boards', feature: true, js: true do project.team << [user_guest, :guest] gitlab_sign_out gitlab_sign_in(user_guest) - visit namespace_project_board_path(project.namespace, project, board) + visit project_board_path(project, board) wait_for_requests end diff --git a/spec/features/boards/issue_ordering_spec.rb b/spec/features/boards/issue_ordering_spec.rb index 1e620061e5e..62693fb3d11 100644 --- a/spec/features/boards/issue_ordering_spec.rb +++ b/spec/features/boards/issue_ordering_spec.rb @@ -22,7 +22,7 @@ describe 'Issue Boards', :feature, :js do let!(:issue4) { create(:labeled_issue, project: project, labels: [label]) } before do - visit namespace_project_board_path(project.namespace, project, board) + visit project_board_path(project, board) wait_for_requests expect(page).to have_selector('.board', count: 3) @@ -47,7 +47,7 @@ describe 'Issue Boards', :feature, :js do context 'ordering in list' do before do - visit namespace_project_board_path(project.namespace, project, board) + visit project_board_path(project, board) wait_for_requests expect(page).to have_selector('.board', count: 3) @@ -110,7 +110,7 @@ describe 'Issue Boards', :feature, :js do let!(:issue6) { create(:labeled_issue, project: project, title: 'testing 3', labels: [label2], relative_position: 1.0) } before do - visit namespace_project_board_path(project.namespace, project, board) + visit project_board_path(project, board) wait_for_requests expect(page).to have_selector('.board', count: 4) diff --git a/spec/features/boards/keyboard_shortcut_spec.rb b/spec/features/boards/keyboard_shortcut_spec.rb index ed3b38e6a7e..34ae6c9d81d 100644 --- a/spec/features/boards/keyboard_shortcut_spec.rb +++ b/spec/features/boards/keyboard_shortcut_spec.rb @@ -8,7 +8,7 @@ describe 'Issue Boards shortcut', feature: true, js: true do gitlab_sign_in :admin - visit namespace_project_path(project.namespace, project) + visit project_path(project) end it 'takes user to issue board index' do diff --git a/spec/features/boards/modal_filter_spec.rb b/spec/features/boards/modal_filter_spec.rb index 8899e1ef5e5..40d1191a597 100644 --- a/spec/features/boards/modal_filter_spec.rb +++ b/spec/features/boards/modal_filter_spec.rb @@ -202,7 +202,7 @@ describe 'Issue Boards add issue modal filtering', :feature, :js do end def visit_board - visit namespace_project_board_path(project.namespace, project, board) + visit project_board_path(project, board) wait_for_requests click_button('Add issues') diff --git a/spec/features/boards/new_issue_spec.rb b/spec/features/boards/new_issue_spec.rb index 77cd87d6601..fa9d8b3f33d 100644 --- a/spec/features/boards/new_issue_spec.rb +++ b/spec/features/boards/new_issue_spec.rb @@ -12,7 +12,7 @@ describe 'Issue Boards new issue', feature: true, js: true do gitlab_sign_in(user) - visit namespace_project_board_path(project.namespace, project, board) + visit project_board_path(project, board) wait_for_requests expect(page).to have_selector('.board', count: 3) @@ -83,7 +83,7 @@ describe 'Issue Boards new issue', feature: true, js: true do context 'unauthorized user' do before do - visit namespace_project_board_path(project.namespace, project, board) + visit project_board_path(project, board) wait_for_requests end diff --git a/spec/features/boards/sidebar_spec.rb b/spec/features/boards/sidebar_spec.rb index 1c9595def21..f96ceffbc7d 100644 --- a/spec/features/boards/sidebar_spec.rb +++ b/spec/features/boards/sidebar_spec.rb @@ -22,7 +22,7 @@ describe 'Issue Boards', feature: true, js: true do gitlab_sign_in(user) - visit namespace_project_board_path(project.namespace, project, board) + visit project_board_path(project, board) wait_for_requests end @@ -83,7 +83,7 @@ describe 'Issue Boards', feature: true, js: true do create(:issue, project: project) create(:issue, :closed, project: project) - visit namespace_project_board_path(project.namespace, project, board) + visit project_board_path(project, board) wait_for_requests click_card(find('.board:nth-child(1)').first('.card')) diff --git a/spec/features/boards/sub_group_project_spec.rb b/spec/features/boards/sub_group_project_spec.rb index d57ae6a71e7..ddff4737563 100644 --- a/spec/features/boards/sub_group_project_spec.rb +++ b/spec/features/boards/sub_group_project_spec.rb @@ -15,7 +15,7 @@ describe 'Sub-group project issue boards', :feature, :js do gitlab_sign_in(user) - visit namespace_project_board_path(project.namespace, project, board) + visit project_board_path(project, board) wait_for_requests end diff --git a/spec/features/commits_spec.rb b/spec/features/commits_spec.rb index 0373f649ee8..fb1e47994ef 100644 --- a/spec/features/commits_spec.rb +++ b/spec/features/commits_spec.rb @@ -66,7 +66,7 @@ describe 'Commits' do end before do - visit namespace_project_commits_path(project.namespace, project, :master) + visit project_commits_path(project, :master) end it 'shows correct build status from default branch' do @@ -192,7 +192,7 @@ describe 'Commits' do before do project.team << [user, :master] sign_in(user) - visit namespace_project_commits_path(project.namespace, project, branch_name) + visit project_commits_path(project, branch_name) end it 'includes the committed_date for each commit' do diff --git a/spec/features/container_registry_spec.rb b/spec/features/container_registry_spec.rb index 80d16539d5a..55ef1ef29bd 100644 --- a/spec/features/container_registry_spec.rb +++ b/spec/features/container_registry_spec.rb @@ -55,7 +55,6 @@ describe "Container Registry" do end def visit_container_registry - visit namespace_project_container_registry_index_path( - project.namespace, project) + visit project_container_registry_index_path(project) end end diff --git a/spec/features/copy_as_gfm_spec.rb b/spec/features/copy_as_gfm_spec.rb index 005c88f6bab..25c5df56d57 100644 --- a/spec/features/copy_as_gfm_spec.rb +++ b/spec/features/copy_as_gfm_spec.rb @@ -16,7 +16,7 @@ describe 'Copy as GFM', feature: true, js: true do # `markdown` helper expects a `@project` variable @project = @feat.project - visit namespace_project_issue_path(@project.namespace, @project, @feat.issue) + visit project_issue_path(@project, @feat.issue) end # The filters referenced in lib/banzai/pipeline/gfm_pipeline.rb convert GitLab Flavored Markdown (GFM) to HTML. @@ -121,13 +121,13 @@ describe 'Copy as GFM', feature: true, js: true do # full issue reference @feat.issue.to_reference(full: true), # issue URL - namespace_project_issue_url(@project.namespace, @project, @feat.issue), + project_issue_url(@project, @feat.issue), # issue URL with note anchor - namespace_project_issue_url(@project.namespace, @project, @feat.issue, anchor: 'note_123'), + project_issue_url(@project, @feat.issue, anchor: 'note_123'), # issue link - "[Issue](#{namespace_project_issue_url(@project.namespace, @project, @feat.issue)})", + "[Issue](#{project_issue_url(@project, @feat.issue)})", # issue link with note anchor - "[Issue](#{namespace_project_issue_url(@project.namespace, @project, @feat.issue, anchor: 'note_123')})" + "[Issue](#{project_issue_url(@project, @feat.issue, anchor: 'note_123')})" ) verify( @@ -466,7 +466,7 @@ describe 'Copy as GFM', feature: true, js: true do context 'from a diff' do before do - visit namespace_project_commit_path(project.namespace, project, sample_commit.id) + visit project_commit_path(project, sample_commit.id) end context 'selecting one word of text' do @@ -507,7 +507,7 @@ describe 'Copy as GFM', feature: true, js: true do context 'from a blob' do before do - visit namespace_project_blob_path(project.namespace, project, File.join('master', 'files/ruby/popen.rb')) + visit project_blob_path(project, File.join('master', 'files/ruby/popen.rb')) wait_for_requests end @@ -549,7 +549,7 @@ describe 'Copy as GFM', feature: true, js: true do context 'from a GFM code block' do before do - visit namespace_project_blob_path(project.namespace, project, File.join('markdown', 'doc/api/users.md')) + visit project_blob_path(project, File.join('markdown', 'doc/api/users.md')) wait_for_requests end diff --git a/spec/features/cycle_analytics_spec.rb b/spec/features/cycle_analytics_spec.rb index 5a7ea975455..7825d23c8f9 100644 --- a/spec/features/cycle_analytics_spec.rb +++ b/spec/features/cycle_analytics_spec.rb @@ -16,7 +16,7 @@ feature 'Cycle Analytics', feature: true, js: true do gitlab_sign_in(user) - visit namespace_project_cycle_analytics_path(project.namespace, project) + visit project_cycle_analytics_path(project) wait_for_requests end @@ -39,7 +39,7 @@ feature 'Cycle Analytics', feature: true, js: true do deploy_master gitlab_sign_in(user) - visit namespace_project_cycle_analytics_path(project.namespace, project) + visit project_cycle_analytics_path(project) end it 'shows data on each stage' do @@ -71,7 +71,7 @@ feature 'Cycle Analytics', feature: true, js: true do project.team << [user, :master] gitlab_sign_in(user) - visit namespace_project_cycle_analytics_path(project.namespace, project) + visit project_cycle_analytics_path(project) wait_for_requests end @@ -94,7 +94,7 @@ feature 'Cycle Analytics', feature: true, js: true do deploy_master gitlab_sign_in(guest) - visit namespace_project_cycle_analytics_path(project.namespace, project) + visit project_cycle_analytics_path(project) wait_for_requests end diff --git a/spec/features/dashboard/project_member_activity_index_spec.rb b/spec/features/dashboard/project_member_activity_index_spec.rb index 0ba87d921d0..ea0b2e99c3e 100644 --- a/spec/features/dashboard/project_member_activity_index_spec.rb +++ b/spec/features/dashboard/project_member_activity_index_spec.rb @@ -10,7 +10,7 @@ feature 'Project member activity', feature: true, js: true do def visit_activities_and_wait_with_event(event_type) Event.create(project: project, author_id: user.id, action: event_type) - visit activity_namespace_project_path(project.namespace, project) + visit activity_project_path(project) wait_for_requests end diff --git a/spec/features/dashboard/projects_spec.rb b/spec/features/dashboard/projects_spec.rb index e9ef5d7983a..7d1fe2bd435 100644 --- a/spec/features/dashboard/projects_spec.rb +++ b/spec/features/dashboard/projects_spec.rb @@ -68,7 +68,7 @@ feature 'Dashboard Projects' do it 'shows that the last pipeline passed' do visit dashboard_projects_path - expect(page).to have_xpath("//a[@href='#{pipelines_namespace_project_commit_path(project.namespace, project, project.commit)}']") + expect(page).to have_xpath("//a[@href='#{pipelines_project_commit_path(project, project.commit)}']") end end diff --git a/spec/features/dashboard/todos/todos_spec.rb b/spec/features/dashboard/todos/todos_spec.rb index 7fa4d198e00..30bab7eeaa7 100644 --- a/spec/features/dashboard/todos/todos_spec.rb +++ b/spec/features/dashboard/todos/todos_spec.rb @@ -330,7 +330,7 @@ feature 'Dashboard Todos' do end it 'links to the pipelines for the merge request' do - href = pipelines_namespace_project_merge_request_path(project.namespace, project, todo.target) + href = pipelines_project_merge_request_path(project, todo.target) expect(page).to have_link "merge request #{todo.target.to_reference(full: true)}", href end diff --git a/spec/features/discussion_comments/commit_spec.rb b/spec/features/discussion_comments/commit_spec.rb index 96128061e4d..620184e2933 100644 --- a/spec/features/discussion_comments/commit_spec.rb +++ b/spec/features/discussion_comments/commit_spec.rb @@ -11,7 +11,7 @@ describe 'Discussion Comments Merge Request', :feature, :js do project.add_master(user) gitlab_sign_in(user) - visit namespace_project_commit_path(project.namespace, project, sample_commit.id) + visit project_commit_path(project, sample_commit.id) end it_behaves_like 'discussion comments', 'commit' diff --git a/spec/features/discussion_comments/issue_spec.rb b/spec/features/discussion_comments/issue_spec.rb index d7c1cd12fb5..f90f82f8a48 100644 --- a/spec/features/discussion_comments/issue_spec.rb +++ b/spec/features/discussion_comments/issue_spec.rb @@ -9,7 +9,7 @@ describe 'Discussion Comments Issue', :feature, :js do project.add_master(user) gitlab_sign_in(user) - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) end it_behaves_like 'discussion comments', 'issue' diff --git a/spec/features/discussion_comments/merge_request_spec.rb b/spec/features/discussion_comments/merge_request_spec.rb index 31fb9c72d25..577d9c69bbc 100644 --- a/spec/features/discussion_comments/merge_request_spec.rb +++ b/spec/features/discussion_comments/merge_request_spec.rb @@ -9,7 +9,7 @@ describe 'Discussion Comments Merge Request', :feature, :js do project.add_master(user) gitlab_sign_in(user) - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) end it_behaves_like 'discussion comments', 'merge request' diff --git a/spec/features/discussion_comments/snippets_spec.rb b/spec/features/discussion_comments/snippets_spec.rb index 998d633c83d..a59be88db7d 100644 --- a/spec/features/discussion_comments/snippets_spec.rb +++ b/spec/features/discussion_comments/snippets_spec.rb @@ -9,7 +9,7 @@ describe 'Discussion Comments Issue', :feature, :js do project.add_master(user) gitlab_sign_in(user) - visit namespace_project_snippet_path(project.namespace, project, snippet) + visit project_snippet_path(project, snippet) end it_behaves_like 'discussion comments', 'snippet' diff --git a/spec/features/expand_collapse_diffs_spec.rb b/spec/features/expand_collapse_diffs_spec.rb index d492a15ea17..f45752ab3f3 100644 --- a/spec/features/expand_collapse_diffs_spec.rb +++ b/spec/features/expand_collapse_diffs_spec.rb @@ -14,7 +14,7 @@ feature 'Expand and collapse diffs', js: true, feature: true do # Ensure that undiffable.md is in .gitattributes project.repository.copy_gitattributes(branch) - visit namespace_project_commit_path(project.namespace, project, project.commit(branch)) + visit project_commit_path(project, project.commit(branch)) execute_script('window.ajaxUris = []; $(document).ajaxSend(function(event, xhr, settings) { ajaxUris.push(settings.url) });') end @@ -38,7 +38,7 @@ feature 'Expand and collapse diffs', js: true, feature: true do expect(large_diff).not_to have_selector('.code') expect(large_diff).to have_selector('.nothing-here-block') - visit namespace_project_commit_path(project.namespace, project, project.commit(branch), anchor: "#{large_diff[:id]}_0_1") + visit project_commit_path(project, project.commit(branch), anchor: "#{large_diff[:id]}_0_1") execute_script('window.location.reload()') wait_for_requests @@ -52,7 +52,7 @@ feature 'Expand and collapse diffs', js: true, feature: true do expect(large_diff).not_to have_selector('.code') expect(large_diff).to have_selector('.nothing-here-block') - visit namespace_project_commit_path(project.namespace, project, project.commit(branch), anchor: large_diff[:id]) + visit project_commit_path(project, project.commit(branch), anchor: large_diff[:id]) execute_script('window.location.reload()') wait_for_requests diff --git a/spec/features/explore/new_menu_spec.rb b/spec/features/explore/new_menu_spec.rb index 2d7e703688f..5cd72e1d249 100644 --- a/spec/features/explore/new_menu_spec.rb +++ b/spec/features/explore/new_menu_spec.rb @@ -47,7 +47,7 @@ feature 'Top Plus Menu', feature: true, js: true do end scenario 'click on New issue shows new issue page' do - visit namespace_project_path(project.namespace, project) + visit project_path(project) click_topmenuitem("New issue") @@ -56,7 +56,7 @@ feature 'Top Plus Menu', feature: true, js: true do end scenario 'click on New merge request shows new merge request page' do - visit namespace_project_path(project.namespace, project) + visit project_path(project) click_topmenuitem("New merge request") @@ -66,7 +66,7 @@ feature 'Top Plus Menu', feature: true, js: true do end scenario 'click on New project snippet shows new snippet page' do - visit namespace_project_path(project.namespace, project) + visit project_path(project) page.within '.header-content' do find('.header-new-dropdown-toggle').trigger('click') @@ -107,7 +107,7 @@ feature 'Top Plus Menu', feature: true, js: true do end scenario 'click on New issue shows new issue page' do - visit namespace_project_path(project.namespace, project) + visit project_path(project) click_topmenuitem("New issue") @@ -116,31 +116,31 @@ feature 'Top Plus Menu', feature: true, js: true do end scenario 'has no New merge request menu item' do - visit namespace_project_path(project.namespace, project) + visit project_path(project) hasnot_topmenuitem("New merge request") end scenario 'has no New project snippet menu item' do - visit namespace_project_path(project.namespace, project) + visit project_path(project) expect(find('.header-new.dropdown')).not_to have_selector('.header-new-project-snippet') end scenario 'public project has no New Issue Button' do - visit namespace_project_path(public_project.namespace, public_project) + visit project_path(public_project) hasnot_topmenuitem("New issue") end scenario 'public project has no New merge request menu item' do - visit namespace_project_path(public_project.namespace, public_project) + visit project_path(public_project) hasnot_topmenuitem("New merge request") end scenario 'public project has no New project snippet menu item' do - visit namespace_project_path(public_project.namespace, public_project) + visit project_path(public_project) expect(find('.header-new.dropdown')).not_to have_selector('.header-new-project-snippet') end diff --git a/spec/features/gitlab_flavored_markdown_spec.rb b/spec/features/gitlab_flavored_markdown_spec.rb index 2d13af2a52a..8659a868682 100644 --- a/spec/features/gitlab_flavored_markdown_spec.rb +++ b/spec/features/gitlab_flavored_markdown_spec.rb @@ -25,25 +25,25 @@ describe "GitLab Flavored Markdown", feature: true do end it "renders title in commits#index" do - visit namespace_project_commits_path(project.namespace, project, 'master', limit: 1) + visit project_commits_path(project, 'master', limit: 1) expect(page).to have_link(issue.to_reference) end it "renders title in commits#show" do - visit namespace_project_commit_path(project.namespace, project, commit) + visit project_commit_path(project, commit) expect(page).to have_link(issue.to_reference) end it "renders description in commits#show" do - visit namespace_project_commit_path(project.namespace, project, commit) + visit project_commit_path(project, commit) expect(page).to have_link(fred.to_reference) end it "renders title in repositories#branches" do - visit namespace_project_branches_path(project.namespace, project) + visit project_branches_path(project) expect(page).to have_link(issue.to_reference) end @@ -66,19 +66,19 @@ describe "GitLab Flavored Markdown", feature: true do end it "renders subject in issues#index" do - visit namespace_project_issues_path(project.namespace, project) + visit project_issues_path(project) expect(page).to have_link(@other_issue.to_reference) end it "renders subject in issues#show" do - visit namespace_project_issue_path(project.namespace, project, @issue) + visit project_issue_path(project, @issue) expect(page).to have_link(@other_issue.to_reference) end it "renders details in issues#show" do - visit namespace_project_issue_path(project.namespace, project, @issue) + visit project_issue_path(project, @issue) expect(page).to have_link(fred.to_reference) end @@ -92,13 +92,13 @@ describe "GitLab Flavored Markdown", feature: true do end it "renders title in merge_requests#index" do - visit namespace_project_merge_requests_path(project.namespace, project) + visit project_merge_requests_path(project) expect(page).to have_link(issue.to_reference) end it "renders title in merge_requests#show" do - visit namespace_project_merge_request_path(project.namespace, project, @merge_request) + visit project_merge_request_path(project, @merge_request) expect(page).to have_link(issue.to_reference) end @@ -113,19 +113,19 @@ describe "GitLab Flavored Markdown", feature: true do end it "renders title in milestones#index" do - visit namespace_project_milestones_path(project.namespace, project) + visit project_milestones_path(project) expect(page).to have_link(issue.to_reference) end it "renders title in milestones#show" do - visit namespace_project_milestone_path(project.namespace, project, @milestone) + visit project_milestone_path(project, @milestone) expect(page).to have_link(issue.to_reference) end it "renders description in milestones#show" do - visit namespace_project_milestone_path(project.namespace, project, @milestone) + visit project_milestone_path(project, @milestone) expect(page).to have_link(fred.to_reference) end diff --git a/spec/features/issuables/issuable_list_spec.rb b/spec/features/issuables/issuable_list_spec.rb index f3a5a8463d1..5046bfb5949 100644 --- a/spec/features/issuables/issuable_list_spec.rb +++ b/spec/features/issuables/issuable_list_spec.rb @@ -39,9 +39,9 @@ describe 'issuable list', feature: true do def visit_issuable_list(issuable_type) if issuable_type == :issue - visit namespace_project_issues_path(project.namespace, project) + visit project_issues_path(project) else - visit namespace_project_merge_requests_path(project.namespace, project) + visit project_merge_requests_path(project) end end diff --git a/spec/features/issuables/user_sees_sidebar_spec.rb b/spec/features/issuables/user_sees_sidebar_spec.rb index 4d7a7dc1806..948d151a517 100644 --- a/spec/features/issuables/user_sees_sidebar_spec.rb +++ b/spec/features/issuables/user_sees_sidebar_spec.rb @@ -14,7 +14,7 @@ describe 'Issue Sidebar on Mobile' do context 'mobile sidebar on merge requests', js: true do before do - visit namespace_project_merge_request_path(merge_request.project.namespace, merge_request.project, merge_request) + visit project_merge_request_path(merge_request.project, merge_request) end it_behaves_like "issue sidebar stays collapsed on mobile" @@ -22,7 +22,7 @@ describe 'Issue Sidebar on Mobile' do context 'mobile sidebar on issues', js: true do before do - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) end it_behaves_like "issue sidebar stays collapsed on mobile" diff --git a/spec/features/issues/award_emoji_spec.rb b/spec/features/issues/award_emoji_spec.rb index 6698e2c79a1..2c84965f7f3 100644 --- a/spec/features/issues/award_emoji_spec.rb +++ b/spec/features/issues/award_emoji_spec.rb @@ -19,7 +19,7 @@ describe 'Awards Emoji', feature: true do before do # The `heart_tip` emoji is not valid anymore so we need to skip validation issue.award_emoji.build(user: user, name: 'heart_tip').save!(validate: false) - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) wait_for_requests end @@ -33,7 +33,7 @@ describe 'Awards Emoji', feature: true do let!(:note) { create(:note_on_issue, noteable: issue, project: issue.project, note: "Hello world") } before do - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) wait_for_requests end @@ -97,7 +97,7 @@ describe 'Awards Emoji', feature: true do context 'unauthorized user', js: true do before do - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) end it 'has disabled emoji button' do diff --git a/spec/features/issues/award_spec.rb b/spec/features/issues/award_spec.rb index a1c97caea20..62c5fce81b6 100644 --- a/spec/features/issues/award_spec.rb +++ b/spec/features/issues/award_spec.rb @@ -8,7 +8,7 @@ feature 'Issue awards', js: true, feature: true do describe 'logged in' do before do gitlab_sign_in(user) - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) wait_for_requests end @@ -17,7 +17,7 @@ feature 'Issue awards', js: true, feature: true do expect(page).to have_selector('.js-emoji-btn.active') expect(first('.js-emoji-btn')).to have_content '1' - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) expect(first('.js-emoji-btn')).to have_content '1' end @@ -26,7 +26,7 @@ feature 'Issue awards', js: true, feature: true do find('.js-emoji-btn.active').click expect(first('.js-emoji-btn')).to have_content '0' - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) expect(first('.js-emoji-btn')).to have_content '0' end @@ -40,7 +40,7 @@ feature 'Issue awards', js: true, feature: true do describe 'logged out' do before do - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) wait_for_requests end diff --git a/spec/features/issues/bulk_assignment_labels_spec.rb b/spec/features/issues/bulk_assignment_labels_spec.rb index a99c19cb787..86226d97f79 100644 --- a/spec/features/issues/bulk_assignment_labels_spec.rb +++ b/spec/features/issues/bulk_assignment_labels_spec.rb @@ -348,7 +348,7 @@ feature 'Issues > Labels bulk assignment', feature: true do before do gitlab_sign_in user - visit namespace_project_issues_path(project.namespace, project) + visit project_issues_path(project) end context 'cannot bulk assign labels' do @@ -410,7 +410,7 @@ feature 'Issues > Labels bulk assignment', feature: true do end def enable_bulk_update - visit namespace_project_issues_path(project.namespace, project) + visit project_issues_path(project) click_button 'Edit Issues' end diff --git a/spec/features/issues/create_branch_merge_request_spec.rb b/spec/features/issues/create_branch_merge_request_spec.rb index aa538803dd8..f730141f82c 100644 --- a/spec/features/issues/create_branch_merge_request_spec.rb +++ b/spec/features/issues/create_branch_merge_request_spec.rb @@ -12,7 +12,7 @@ feature 'Create Branch/Merge Request Dropdown on issue page', feature: true, js: end it 'allows creating a merge request from the issue page' do - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) select_dropdown_option('create-mr') @@ -21,21 +21,21 @@ feature 'Create Branch/Merge Request Dropdown on issue page', feature: true, js: expect(page).to have_content("created branch 1-cherry-coloured-funk") expect(page).to have_content("mentioned in merge request !1") - visit namespace_project_merge_request_path(project.namespace, project, MergeRequest.first) + visit project_merge_request_path(project, MergeRequest.first) expect(page).to have_content('WIP: Resolve "Cherry-Coloured Funk"') - expect(current_path).to eq(namespace_project_merge_request_path(project.namespace, project, MergeRequest.first)) + expect(current_path).to eq(project_merge_request_path(project, MergeRequest.first)) end it 'allows creating a branch from the issue page' do - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) select_dropdown_option('create-branch') wait_for_requests expect(page).to have_selector('.dropdown-toggle-text ', text: '1-cherry-coloured-funk') - expect(current_path).to eq namespace_project_tree_path(project.namespace, project, '1-cherry-coloured-funk') + expect(current_path).to eq project_tree_path(project, '1-cherry-coloured-funk') end context "when there is a referenced merge request" do @@ -52,7 +52,7 @@ feature 'Create Branch/Merge Request Dropdown on issue page', feature: true, js: before do referenced_mr.cache_merge_request_closes_issues!(user) - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) end it 'disables the create branch button' do @@ -66,7 +66,7 @@ feature 'Create Branch/Merge Request Dropdown on issue page', feature: true, js: it 'disables the create branch button' do issue = create(:issue, :confidential, project: project) - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) expect(page).not_to have_css('.create-mr-dropdown-wrap') end @@ -75,7 +75,7 @@ feature 'Create Branch/Merge Request Dropdown on issue page', feature: true, js: context 'for visitors' do before do - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) end it 'shows no buttons' do diff --git a/spec/features/issues/create_issue_for_discussions_in_merge_request_spec.rb b/spec/features/issues/create_issue_for_discussions_in_merge_request_spec.rb index 5f631043e15..3b7622882c1 100644 --- a/spec/features/issues/create_issue_for_discussions_in_merge_request_spec.rb +++ b/spec/features/issues/create_issue_for_discussions_in_merge_request_spec.rb @@ -10,12 +10,12 @@ feature 'Resolving all open discussions in a merge request from an issue', featu before do project.team << [user, :master] gitlab_sign_in user - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) end it 'shows a button to resolve all discussions by creating a new issue' do within('#resolve-count-app') do - expect(page).to have_link "Resolve all discussions in new issue", href: new_namespace_project_issue_path(project.namespace, project, merge_request_to_resolve_discussions_of: merge_request.iid) + expect(page).to have_link "Resolve all discussions in new issue", href: new_project_issue_path(project, merge_request_to_resolve_discussions_of: merge_request.iid) end end @@ -25,13 +25,13 @@ feature 'Resolving all open discussions in a merge request from an issue', featu end it 'hides the link for creating a new issue' do - expect(page).not_to have_link "Resolve all discussions in new issue", href: new_namespace_project_issue_path(project.namespace, project, merge_request_to_resolve_discussions_of: merge_request.iid) + expect(page).not_to have_link "Resolve all discussions in new issue", href: new_project_issue_path(project, merge_request_to_resolve_discussions_of: merge_request.iid) end end context 'creating an issue for discussions' do before do - click_link "Resolve all discussions in new issue", href: new_namespace_project_issue_path(project.namespace, project, merge_request_to_resolve_discussions_of: merge_request.iid) + click_link "Resolve all discussions in new issue", href: new_project_issue_path(project, merge_request_to_resolve_discussions_of: merge_request.iid) end it_behaves_like 'creating an issue for a discussion' @@ -45,7 +45,7 @@ feature 'Resolving all open discussions in a merge request from an issue', featu context 'with the internal tracker disabled' do before do project.project_feature.update_attribute(:issues_access_level, ProjectFeature::DISABLED) - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) end it 'does not show a link to create a new issue' do @@ -55,7 +55,7 @@ feature 'Resolving all open discussions in a merge request from an issue', featu context 'merge request has discussions that need to be resolved' do before do - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) end it 'shows a warning that the merge request contains unresolved discussions' do @@ -64,13 +64,13 @@ feature 'Resolving all open discussions in a merge request from an issue', featu it 'has a link to resolve all discussions by creating an issue' do page.within '.mr-widget-body' do - expect(page).to have_link 'Create an issue to resolve them later', href: new_namespace_project_issue_path(project.namespace, project, merge_request_to_resolve_discussions_of: merge_request.iid) + expect(page).to have_link 'Create an issue to resolve them later', href: new_project_issue_path(project, merge_request_to_resolve_discussions_of: merge_request.iid) end end context 'creating an issue for discussions' do before do - page.click_link 'Create an issue to resolve them later', href: new_namespace_project_issue_path(project.namespace, project, merge_request_to_resolve_discussions_of: merge_request.iid) + page.click_link 'Create an issue to resolve them later', href: new_project_issue_path(project, merge_request_to_resolve_discussions_of: merge_request.iid) end it_behaves_like 'creating an issue for a discussion' @@ -83,7 +83,7 @@ feature 'Resolving all open discussions in a merge request from an issue', featu before do project.team << [user, :reporter] gitlab_sign_in user - visit new_namespace_project_issue_path(project.namespace, project, merge_request_to_resolve_discussions_of: merge_request.iid) + visit new_project_issue_path(project, merge_request_to_resolve_discussions_of: merge_request.iid) end it 'Shows a notice to ask someone else to resolve the discussions' do diff --git a/spec/features/issues/create_issue_for_single_discussion_in_merge_request_spec.rb b/spec/features/issues/create_issue_for_single_discussion_in_merge_request_spec.rb index 9e9e214060f..97d49184920 100644 --- a/spec/features/issues/create_issue_for_single_discussion_in_merge_request_spec.rb +++ b/spec/features/issues/create_issue_for_single_discussion_in_merge_request_spec.rb @@ -10,13 +10,13 @@ feature 'Resolve an open discussion in a merge request by creating an issue', fe before do project.team << [user, :master] gitlab_sign_in user - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) end context 'with the internal tracker disabled' do before do project.project_feature.update_attribute(:issues_access_level, ProjectFeature::DISABLED) - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) end it 'does not show a link to create a new issue' do @@ -43,14 +43,14 @@ feature 'Resolve an open discussion in a merge request by creating an issue', fe end it 'has a link to create a new issue for a discussion' do - new_issue_link = new_namespace_project_issue_path(project.namespace, project, discussion_to_resolve: discussion.id, merge_request_to_resolve_discussions_of: merge_request.iid) + new_issue_link = new_project_issue_path(project, discussion_to_resolve: discussion.id, merge_request_to_resolve_discussions_of: merge_request.iid) expect(page).to have_link 'Resolve this discussion in a new issue', href: new_issue_link end context 'creating the issue' do before do - click_link 'Resolve this discussion in a new issue', href: new_namespace_project_issue_path(project.namespace, project, discussion_to_resolve: discussion.id, merge_request_to_resolve_discussions_of: merge_request.iid) + click_link 'Resolve this discussion in a new issue', href: new_project_issue_path(project, discussion_to_resolve: discussion.id, merge_request_to_resolve_discussions_of: merge_request.iid) end it 'has a hidden field for the discussion' do @@ -67,7 +67,7 @@ feature 'Resolve an open discussion in a merge request by creating an issue', fe before do project.team << [user, :reporter] gitlab_sign_in user - visit new_namespace_project_issue_path(project.namespace, project, + visit new_project_issue_path(project, merge_request_to_resolve_discussions_of: merge_request.iid, discussion_to_resolve: discussion.id) end diff --git a/spec/features/issues/filtered_search/dropdown_assignee_spec.rb b/spec/features/issues/filtered_search/dropdown_assignee_spec.rb index 96f6739af2d..211f7eec560 100644 --- a/spec/features/issues/filtered_search/dropdown_assignee_spec.rb +++ b/spec/features/issues/filtered_search/dropdown_assignee_spec.rb @@ -26,7 +26,7 @@ describe 'Dropdown assignee', :feature, :js do gitlab_sign_in(user) create(:issue, project: project) - visit namespace_project_issues_path(project.namespace, project) + visit project_issues_path(project) end describe 'behavior' do diff --git a/spec/features/issues/filtered_search/dropdown_author_spec.rb b/spec/features/issues/filtered_search/dropdown_author_spec.rb index 5ee824c662a..364c5564a1c 100644 --- a/spec/features/issues/filtered_search/dropdown_author_spec.rb +++ b/spec/features/issues/filtered_search/dropdown_author_spec.rb @@ -34,7 +34,7 @@ describe 'Dropdown author', js: true, feature: true do gitlab_sign_in(user) create(:issue, project: project) - visit namespace_project_issues_path(project.namespace, project) + visit project_issues_path(project) end describe 'behavior' do diff --git a/spec/features/issues/filtered_search/dropdown_hint_spec.rb b/spec/features/issues/filtered_search/dropdown_hint_spec.rb index a05e4394ffd..14c506eead3 100644 --- a/spec/features/issues/filtered_search/dropdown_hint_spec.rb +++ b/spec/features/issues/filtered_search/dropdown_hint_spec.rb @@ -17,7 +17,7 @@ describe 'Dropdown hint', :js, :feature do gitlab_sign_in(user) create(:issue, project: project) - visit namespace_project_issues_path(project.namespace, project) + visit project_issues_path(project) end describe 'behavior' do diff --git a/spec/features/issues/filtered_search/dropdown_label_spec.rb b/spec/features/issues/filtered_search/dropdown_label_spec.rb index aec9d7ceb5d..04d2b39dbf2 100644 --- a/spec/features/issues/filtered_search/dropdown_label_spec.rb +++ b/spec/features/issues/filtered_search/dropdown_label_spec.rb @@ -37,7 +37,7 @@ describe 'Dropdown label', js: true, feature: true do gitlab_sign_in(user) create(:issue, project: project) - visit namespace_project_issues_path(project.namespace, project) + visit project_issues_path(project) end describe 'keyboard navigation' do diff --git a/spec/features/issues/filtered_search/dropdown_milestone_spec.rb b/spec/features/issues/filtered_search/dropdown_milestone_spec.rb index b21f41946b7..1507e9f7616 100644 --- a/spec/features/issues/filtered_search/dropdown_milestone_spec.rb +++ b/spec/features/issues/filtered_search/dropdown_milestone_spec.rb @@ -33,7 +33,7 @@ describe 'Dropdown milestone', :feature, :js do gitlab_sign_in(user) create(:issue, project: project) - visit namespace_project_issues_path(project.namespace, project) + visit project_issues_path(project) end describe 'behavior' do diff --git a/spec/features/issues/filtered_search/filter_issues_spec.rb b/spec/features/issues/filtered_search/filter_issues_spec.rb index 4cb728cc82b..9fc6391fa98 100644 --- a/spec/features/issues/filtered_search/filter_issues_spec.rb +++ b/spec/features/issues/filtered_search/filter_issues_spec.rb @@ -89,7 +89,7 @@ describe 'Filter issues', js: true, feature: true do milestone: future_milestone, project: project) - visit namespace_project_issues_path(project.namespace, project) + visit project_issues_path(project) end describe 'filter issues by author' do @@ -804,7 +804,7 @@ describe 'Filter issues', js: true, feature: true do describe 'RSS feeds' do it 'updates atom feed link for project issues' do - visit namespace_project_issues_path(project.namespace, project, milestone_title: milestone.title, assignee_id: user.id) + visit project_issues_path(project, milestone_title: milestone.title, assignee_id: user.id) link = find_link('Subscribe') params = CGI.parse(URI.parse(link[:href]).query) auto_discovery_link = find('link[type="application/atom+xml"]', visible: false) @@ -836,7 +836,7 @@ describe 'Filter issues', js: true, feature: true do context 'URL has a trailing slash' do before do - visit "#{namespace_project_issues_path(project.namespace, project)}/" + visit "#{project_issues_path(project)}/" end it 'milestone dropdown loads milestones' do diff --git a/spec/features/issues/filtered_search/recent_searches_spec.rb b/spec/features/issues/filtered_search/recent_searches_spec.rb index 09f228bcf49..4a91ce4be07 100644 --- a/spec/features/issues/filtered_search/recent_searches_spec.rb +++ b/spec/features/issues/filtered_search/recent_searches_spec.rb @@ -22,7 +22,7 @@ describe 'Recent searches', js: true, feature: true do end it 'searching adds to recent searches' do - visit namespace_project_issues_path(project_1.namespace, project_1) + visit project_issues_path(project_1) input_filtered_search('foo', submit: true) input_filtered_search('bar', submit: true) @@ -35,8 +35,8 @@ describe 'Recent searches', js: true, feature: true do end it 'visiting URL with search params adds to recent searches' do - visit namespace_project_issues_path(project_1.namespace, project_1, label_name: 'foo', search: 'bar') - visit namespace_project_issues_path(project_1.namespace, project_1, label_name: 'qux', search: 'garply') + visit project_issues_path(project_1, label_name: 'foo', search: 'bar') + visit project_issues_path(project_1, label_name: 'qux', search: 'garply') items = all('.filtered-search-history-dropdown-item', visible: false) @@ -48,7 +48,7 @@ describe 'Recent searches', js: true, feature: true do it 'saved recent searches are restored last on the list' do set_recent_searches(project_1_local_storage_key, '["saved1", "saved2"]') - visit namespace_project_issues_path(project_1.namespace, project_1, search: 'foo') + visit project_issues_path(project_1, search: 'foo') items = all('.filtered-search-history-dropdown-item', visible: false) @@ -59,12 +59,12 @@ describe 'Recent searches', js: true, feature: true do end it 'searches are scoped to projects' do - visit namespace_project_issues_path(project_1.namespace, project_1) + visit project_issues_path(project_1) input_filtered_search('foo', submit: true) input_filtered_search('bar', submit: true) - visit namespace_project_issues_path(project_2.namespace, project_2) + visit project_issues_path(project_2) input_filtered_search('more', submit: true) input_filtered_search('things', submit: true) @@ -78,7 +78,7 @@ describe 'Recent searches', js: true, feature: true do it 'clicking item fills search input' do set_recent_searches(project_1_local_storage_key, '["foo", "bar"]') - visit namespace_project_issues_path(project_1.namespace, project_1) + visit project_issues_path(project_1) all('.filtered-search-history-dropdown-item', visible: false)[0].trigger('click') wait_for_filtered_search('foo') @@ -88,7 +88,7 @@ describe 'Recent searches', js: true, feature: true do it 'clear recent searches button, clears recent searches' do set_recent_searches(project_1_local_storage_key, '["foo"]') - visit namespace_project_issues_path(project_1.namespace, project_1) + visit project_issues_path(project_1) items_before = all('.filtered-search-history-dropdown-item', visible: false) @@ -102,7 +102,7 @@ describe 'Recent searches', js: true, feature: true do it 'shows flash error when failed to parse saved history' do set_recent_searches(project_1_local_storage_key, 'fail') - visit namespace_project_issues_path(project_1.namespace, project_1) + visit project_issues_path(project_1) expect(find('.flash-alert')).to have_text('An error occured while parsing recent searches') end diff --git a/spec/features/issues/filtered_search/search_bar_spec.rb b/spec/features/issues/filtered_search/search_bar_spec.rb index 806c732b935..5b67d062f15 100644 --- a/spec/features/issues/filtered_search/search_bar_spec.rb +++ b/spec/features/issues/filtered_search/search_bar_spec.rb @@ -12,7 +12,7 @@ describe 'Search bar', js: true, feature: true do gitlab_sign_in(user) create(:issue, project: project) - visit namespace_project_issues_path(project.namespace, project) + visit project_issues_path(project) end def get_left_style(style) diff --git a/spec/features/issues/filtered_search/visual_tokens_spec.rb b/spec/features/issues/filtered_search/visual_tokens_spec.rb index 22488f34813..08360bfa641 100644 --- a/spec/features/issues/filtered_search/visual_tokens_spec.rb +++ b/spec/features/issues/filtered_search/visual_tokens_spec.rb @@ -28,7 +28,7 @@ describe 'Visual tokens', js: true, feature: true do gitlab_sign_in(user) create(:issue, project: project) - visit namespace_project_issues_path(project.namespace, project) + visit project_issues_path(project) end describe 'editing author token' do diff --git a/spec/features/issues/form_spec.rb b/spec/features/issues/form_spec.rb index 58f6bd277e4..5c75b0d56b0 100644 --- a/spec/features/issues/form_spec.rb +++ b/spec/features/issues/form_spec.rb @@ -1,7 +1,6 @@ require 'rails_helper' describe 'New/edit issue', :feature, :js do - include GitlabRoutingHelper include ActionView::Helpers::JavaScriptHelper include FormHelper @@ -21,7 +20,7 @@ describe 'New/edit issue', :feature, :js do context 'new issue' do before do - visit new_namespace_project_issue_path(project.namespace, project) + visit new_project_issue_path(project) end describe 'shorten users API pagination limit (CE)' do @@ -39,7 +38,7 @@ describe 'New/edit issue', :feature, :js do options end - visit new_namespace_project_issue_path(project.namespace, project) + visit new_project_issue_path(project) click_button 'Unassigned' @@ -221,7 +220,7 @@ describe 'New/edit issue', :feature, :js do context 'edit issue' do before do - visit edit_namespace_project_issue_path(project.namespace, project, issue) + visit edit_project_issue_path(project, issue) end it 'allows user to update issue' do @@ -282,7 +281,7 @@ describe 'New/edit issue', :feature, :js do before do sub_group_project.add_master(user) - visit new_namespace_project_issue_path(sub_group_project.namespace, sub_group_project) + visit new_project_issue_path(sub_group_project) end it 'creates new label from dropdown' do diff --git a/spec/features/issues/gfm_autocomplete_spec.rb b/spec/features/issues/gfm_autocomplete_spec.rb index e61eb5233d0..a0f26bf9a92 100644 --- a/spec/features/issues/gfm_autocomplete_spec.rb +++ b/spec/features/issues/gfm_autocomplete_spec.rb @@ -9,7 +9,7 @@ feature 'GFM autocomplete', feature: true, js: true do before do project.team << [user, :master] gitlab_sign_in(user) - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) wait_for_requests end diff --git a/spec/features/issues/group_label_sidebar_spec.rb b/spec/features/issues/group_label_sidebar_spec.rb index fc8515cfe9b..5531a662c67 100644 --- a/spec/features/issues/group_label_sidebar_spec.rb +++ b/spec/features/issues/group_label_sidebar_spec.rb @@ -6,13 +6,9 @@ describe 'Group label on issue', :feature do project = create(:empty_project, :public, namespace: group) feature = create(:group_label, group: group, title: 'feature') issue = create(:labeled_issue, project: project, labels: [feature]) - label_link = namespace_project_issues_path( - project.namespace, - project, - label_name: [feature.name] - ) + label_link = project_issues_path(project, label_name: [feature.name]) - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) link = find('.issuable-show-labels a') diff --git a/spec/features/issues/issue_sidebar_spec.rb b/spec/features/issues/issue_sidebar_spec.rb index 09724781a27..8d9bfcdf4e0 100644 --- a/spec/features/issues/issue_sidebar_spec.rb +++ b/spec/features/issues/issue_sidebar_spec.rb @@ -166,7 +166,7 @@ feature 'Issue Sidebar', feature: true do end def visit_issue(project, issue) - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) end def open_issue_sidebar diff --git a/spec/features/issues/markdown_toolbar_spec.rb b/spec/features/issues/markdown_toolbar_spec.rb index 66d823ec9d0..396b53556bf 100644 --- a/spec/features/issues/markdown_toolbar_spec.rb +++ b/spec/features/issues/markdown_toolbar_spec.rb @@ -8,7 +8,7 @@ feature 'Issue markdown toolbar', feature: true, js: true do before do gitlab_sign_in(user) - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) end it "doesn't include first new line when adding bold" do diff --git a/spec/features/issues/move_spec.rb b/spec/features/issues/move_spec.rb index d6e78157e5f..568f2393aef 100644 --- a/spec/features/issues/move_spec.rb +++ b/spec/features/issues/move_spec.rb @@ -95,10 +95,6 @@ feature 'issue move to another project' do end def issue_path(issue) - namespace_project_issue_path(issue.project.namespace, issue.project, issue) - end - - def project_path(project) - namespace_project_path(new_project.namespace, new_project) + project_issue_path(issue.project, issue) end end diff --git a/spec/features/issues/note_polling_spec.rb b/spec/features/issues/note_polling_spec.rb index bd31e44ef33..580b8d03fef 100644 --- a/spec/features/issues/note_polling_spec.rb +++ b/spec/features/issues/note_polling_spec.rb @@ -8,7 +8,7 @@ feature 'Issue notes polling', :feature, :js do describe 'creates' do before do - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) end it 'displays the new comment' do @@ -28,7 +28,7 @@ feature 'Issue notes polling', :feature, :js do before do gitlab_sign_in(user) - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) end it 'has .original-note-content to compare against' do @@ -94,7 +94,7 @@ feature 'Issue notes polling', :feature, :js do before do gitlab_sign_in(user2) - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) end it 'has .original-note-content to compare against' do @@ -115,7 +115,7 @@ feature 'Issue notes polling', :feature, :js do before do gitlab_sign_in(user) - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) end it 'has .original-note-content to compare against' do diff --git a/spec/features/issues/notes_on_issues_spec.rb b/spec/features/issues/notes_on_issues_spec.rb index f648295416f..1871d853a90 100644 --- a/spec/features/issues/notes_on_issues_spec.rb +++ b/spec/features/issues/notes_on_issues_spec.rb @@ -10,7 +10,7 @@ describe 'Create notes on issues', :js, :feature do before do project.team << [user, :developer] gitlab_sign_in(user) - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) fill_in 'note[note]', with: note_text click_button 'Comment' diff --git a/spec/features/issues/spam_issues_spec.rb b/spec/features/issues/spam_issues_spec.rb index 57c783790b5..76dae9212dd 100644 --- a/spec/features/issues/spam_issues_spec.rb +++ b/spec/features/issues/spam_issues_spec.rb @@ -25,7 +25,7 @@ describe 'New issue', feature: true, js: true do before do WebMock.stub_request(:any, /.*akismet.com.*/).to_return(body: "true", status: 200) - visit new_namespace_project_issue_path(project.namespace, project) + visit new_project_issue_path(project) end it 'creates an issue after solving reCaptcha' do @@ -50,7 +50,7 @@ describe 'New issue', feature: true, js: true do before do WebMock.stub_request(:any, /.*akismet.com.*/).to_return(body: 'false', status: 200) - visit new_namespace_project_issue_path(project.namespace, project) + visit new_project_issue_path(project) end it 'creates an issue' do diff --git a/spec/features/issues/todo_spec.rb b/spec/features/issues/todo_spec.rb index a1c00dd64f6..1bcd717e8dd 100644 --- a/spec/features/issues/todo_spec.rb +++ b/spec/features/issues/todo_spec.rb @@ -8,7 +8,7 @@ feature 'Manually create a todo item from issue', feature: true, js: true do before do project.team << [user, :master] gitlab_sign_in(user) - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) end it 'creates todo when clicking button' do @@ -21,7 +21,7 @@ feature 'Manually create a todo item from issue', feature: true, js: true do expect(page).to have_content '1' end - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) page.within '.header-content .todos-count' do expect(page).to have_content '1' @@ -36,7 +36,7 @@ feature 'Manually create a todo item from issue', feature: true, js: true do expect(page).to have_selector('.todos-count', visible: false) - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) expect(page).to have_selector('.todos-count', visible: false) end diff --git a/spec/features/issues/update_issues_spec.rb b/spec/features/issues/update_issues_spec.rb index df704b55839..5a7c4f54cb6 100644 --- a/spec/features/issues/update_issues_spec.rb +++ b/spec/features/issues/update_issues_spec.rb @@ -12,7 +12,7 @@ feature 'Multiple issue updating from issues#index', :js do context 'status' do it 'sets to closed' do - visit namespace_project_issues_path(project.namespace, project) + visit project_issues_path(project) click_button 'Edit Issues' find('#check-all-issues').click @@ -25,7 +25,7 @@ feature 'Multiple issue updating from issues#index', :js do it 'sets to open' do create_closed - visit namespace_project_issues_path(project.namespace, project, state: 'closed') + visit project_issues_path(project, state: 'closed') click_button 'Edit Issues' find('#check-all-issues').click @@ -39,7 +39,7 @@ feature 'Multiple issue updating from issues#index', :js do context 'assignee' do it 'updates to current user' do - visit namespace_project_issues_path(project.namespace, project) + visit project_issues_path(project) click_button 'Edit Issues' find('#check-all-issues').click @@ -55,7 +55,7 @@ feature 'Multiple issue updating from issues#index', :js do it 'updates to unassigned' do create_assigned - visit namespace_project_issues_path(project.namespace, project) + visit project_issues_path(project) click_button 'Edit Issues' find('#check-all-issues').click @@ -71,7 +71,7 @@ feature 'Multiple issue updating from issues#index', :js do let!(:milestone) { create(:milestone, project: project) } it 'updates milestone' do - visit namespace_project_issues_path(project.namespace, project) + visit project_issues_path(project) click_button 'Edit Issues' find('#check-all-issues').click @@ -85,7 +85,7 @@ feature 'Multiple issue updating from issues#index', :js do it 'sets to no milestone' do create_with_milestone - visit namespace_project_issues_path(project.namespace, project) + visit project_issues_path(project) expect(first('.issue')).to have_content milestone.title diff --git a/spec/features/issues/user_uses_slash_commands_spec.rb b/spec/features/issues/user_uses_slash_commands_spec.rb index 168cdd08137..ad28decfc00 100644 --- a/spec/features/issues/user_uses_slash_commands_spec.rb +++ b/spec/features/issues/user_uses_slash_commands_spec.rb @@ -14,7 +14,7 @@ feature 'Issues > User uses quick actions', feature: true, js: true do before do project.team << [user, :master] gitlab_sign_in(user) - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) end after do @@ -43,7 +43,7 @@ feature 'Issues > User uses quick actions', feature: true, js: true do project.team << [guest, :guest] gitlab_sign_out gitlab_sign_in(guest) - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) end it 'does not create a note, and sets the due date accordingly' do @@ -83,7 +83,7 @@ feature 'Issues > User uses quick actions', feature: true, js: true do project.team << [guest, :guest] gitlab_sign_out gitlab_sign_in(guest) - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) end it 'does not create a note, and sets the due date accordingly' do @@ -108,7 +108,7 @@ feature 'Issues > User uses quick actions', feature: true, js: true do context 'Issue' do before do - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) end it_behaves_like 'issuable time tracker' @@ -118,7 +118,7 @@ feature 'Issues > User uses quick actions', feature: true, js: true do let(:merge_request) { create(:merge_request, source_project: project) } before do - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) end it_behaves_like 'issuable time tracker' @@ -134,7 +134,7 @@ feature 'Issues > User uses quick actions', feature: true, js: true do context 'Issue' do before do - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) end it_behaves_like 'issuable time tracker' @@ -144,7 +144,7 @@ feature 'Issues > User uses quick actions', feature: true, js: true do let(:merge_request) { create(:merge_request, source_project: project) } before do - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) end it_behaves_like 'issuable time tracker' diff --git a/spec/features/issues_spec.rb b/spec/features/issues_spec.rb index f47b89fd718..8cb62910e18 100644 --- a/spec/features/issues_spec.rb +++ b/spec/features/issues_spec.rb @@ -24,7 +24,7 @@ describe 'Issues', feature: true do end before do - visit edit_namespace_project_issue_path(project.namespace, project, issue) + visit edit_project_issue_path(project, issue) find('.js-zen-enter').click end @@ -42,7 +42,7 @@ describe 'Issues', feature: true do end it 'allows user to select unassigned', js: true do - visit edit_namespace_project_issue_path(project.namespace, project, issue) + visit edit_project_issue_path(project, issue) expect(page).to have_content "Assignee #{user.name}" @@ -62,7 +62,7 @@ describe 'Issues', feature: true do describe 'due date', js: true do context 'on new form' do before do - visit new_namespace_project_issue_path(project.namespace, project) + visit new_project_issue_path(project) end it 'saves with due date' do @@ -90,7 +90,7 @@ describe 'Issues', feature: true do let(:issue) { create(:issue, author: user, project: project, due_date: Date.today.at_beginning_of_month.to_s) } before do - visit edit_namespace_project_issue_path(project.namespace, project, issue) + visit edit_project_issue_path(project, issue) end it 'saves with due date' do @@ -135,7 +135,7 @@ describe 'Issues', feature: true do issue = create(:issue, author: user, assignees: [user], project: project, title: 'foobar') create(:award_emoji, awardable: issue) - visit namespace_project_issues_path(project.namespace, project, assignee_id: user.id) + visit project_issues_path(project, assignee_id: user.id) expect(page).to have_content 'foobar' expect(page.all('.no-comments').first.text).to eq "0" @@ -161,7 +161,7 @@ describe 'Issues', feature: true do let(:issue) { @issue } it 'allows filtering by issues with no specified assignee' do - visit namespace_project_issues_path(project.namespace, project, assignee_id: IssuableFinder::NONE) + visit project_issues_path(project, assignee_id: IssuableFinder::NONE) expect(page).to have_content 'foobar' expect(page).not_to have_content 'barbaz' @@ -169,7 +169,7 @@ describe 'Issues', feature: true do end it 'allows filtering by a specified assignee' do - visit namespace_project_issues_path(project.namespace, project, assignee_id: user.id) + visit project_issues_path(project, assignee_id: user.id) expect(page).not_to have_content 'foobar' expect(page).to have_content 'barbaz' @@ -190,14 +190,14 @@ describe 'Issues', feature: true do let(:later_due_milestone) { create(:milestone, due_date: '2013-12-12') } it 'sorts by newest' do - visit namespace_project_issues_path(project.namespace, project, sort: sort_value_recently_created) + visit project_issues_path(project, sort: sort_value_recently_created) expect(first_issue).to include('foo') expect(last_issue).to include('baz') end it 'sorts by oldest' do - visit namespace_project_issues_path(project.namespace, project, sort: sort_value_oldest_created) + visit project_issues_path(project, sort: sort_value_oldest_created) expect(first_issue).to include('baz') expect(last_issue).to include('foo') @@ -206,7 +206,7 @@ describe 'Issues', feature: true do it 'sorts by most recently updated' do baz.updated_at = Time.now + 100 baz.save - visit namespace_project_issues_path(project.namespace, project, sort: sort_value_recently_updated) + visit project_issues_path(project, sort: sort_value_recently_updated) expect(first_issue).to include('baz') end @@ -214,7 +214,7 @@ describe 'Issues', feature: true do it 'sorts by least recently updated' do baz.updated_at = Time.now - 100 baz.save - visit namespace_project_issues_path(project.namespace, project, sort: sort_value_oldest_updated) + visit project_issues_path(project, sort: sort_value_oldest_updated) expect(first_issue).to include('baz') end @@ -226,13 +226,13 @@ describe 'Issues', feature: true do end it 'sorts by recently due date' do - visit namespace_project_issues_path(project.namespace, project, sort: sort_value_due_date_soon) + visit project_issues_path(project, sort: sort_value_due_date_soon) expect(first_issue).to include('foo') end it 'sorts by least recently due date' do - visit namespace_project_issues_path(project.namespace, project, sort: sort_value_due_date_later) + visit project_issues_path(project, sort: sort_value_due_date_later) expect(first_issue).to include('bar') end @@ -240,7 +240,7 @@ describe 'Issues', feature: true do it 'sorts by least recently due date by excluding nil due dates' do bar.update(due_date: nil) - visit namespace_project_issues_path(project.namespace, project, sort: sort_value_due_date_later) + visit project_issues_path(project, sort: sort_value_due_date_later) expect(first_issue).to include('foo') end @@ -255,7 +255,7 @@ describe 'Issues', feature: true do it 'sorts by least recently due date by excluding nil due dates' do bar.update(due_date: nil) - visit namespace_project_issues_path(project.namespace, project, label_names: [label.name], sort: sort_value_due_date_later) + visit project_issues_path(project, label_names: [label.name], sort: sort_value_due_date_later) expect(first_issue).to include('foo') end @@ -269,7 +269,7 @@ describe 'Issues', feature: true do end it 'filters by none' do - visit namespace_project_issues_path(project.namespace, project, due_date: Issue::NoDueDate.name) + visit project_issues_path(project, due_date: Issue::NoDueDate.name) expect(page).not_to have_content('foo') expect(page).not_to have_content('bar') @@ -277,7 +277,7 @@ describe 'Issues', feature: true do end it 'filters by any' do - visit namespace_project_issues_path(project.namespace, project, due_date: Issue::AnyDueDate.name) + visit project_issues_path(project, due_date: Issue::AnyDueDate.name) expect(page).to have_content('foo') expect(page).to have_content('bar') @@ -289,7 +289,7 @@ describe 'Issues', feature: true do bar.update(due_date: Date.today.end_of_week) baz.update(due_date: Date.today - 8.days) - visit namespace_project_issues_path(project.namespace, project, due_date: Issue::DueThisWeek.name) + visit project_issues_path(project, due_date: Issue::DueThisWeek.name) expect(page).to have_content('foo') expect(page).to have_content('bar') @@ -301,7 +301,7 @@ describe 'Issues', feature: true do bar.update(due_date: Date.today.end_of_month) baz.update(due_date: Date.today - 50.days) - visit namespace_project_issues_path(project.namespace, project, due_date: Issue::DueThisMonth.name) + visit project_issues_path(project, due_date: Issue::DueThisMonth.name) expect(page).to have_content('foo') expect(page).to have_content('bar') @@ -313,7 +313,7 @@ describe 'Issues', feature: true do bar.update(due_date: Date.today + 20.days) baz.update(due_date: Date.yesterday) - visit namespace_project_issues_path(project.namespace, project, due_date: Issue::Overdue.name) + visit project_issues_path(project, due_date: Issue::Overdue.name) expect(page).not_to have_content('foo') expect(page).not_to have_content('bar') @@ -330,14 +330,14 @@ describe 'Issues', feature: true do end it 'sorts by recently due milestone' do - visit namespace_project_issues_path(project.namespace, project, sort: sort_value_milestone_soon) + visit project_issues_path(project, sort: sort_value_milestone_soon) expect(first_issue).to include('foo') expect(last_issue).to include('baz') end it 'sorts by least recently due milestone' do - visit namespace_project_issues_path(project.namespace, project, sort: sort_value_milestone_later) + visit project_issues_path(project, sort: sort_value_milestone_later) expect(first_issue).to include('bar') expect(last_issue).to include('baz') @@ -355,7 +355,7 @@ describe 'Issues', feature: true do end it 'sorts with a filter applied' do - visit namespace_project_issues_path(project.namespace, project, + visit project_issues_path(project, sort: sort_value_oldest_created, assignee_id: user2.id) @@ -397,7 +397,7 @@ describe 'Issues', feature: true do let!(:label) { create(:label, project: project) } before do - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) end it 'will not send ajax request when no data is changed' do @@ -416,7 +416,7 @@ describe 'Issues', feature: true do context 'by authorized user' do it 'allows user to select unassigned', js: true do - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) page.within('.assignee') do expect(page).to have_content "#{user.name}" @@ -435,7 +435,7 @@ describe 'Issues', feature: true do it 'allows user to select an assignee', js: true do issue2 = create(:issue, project: project, author: user) - visit namespace_project_issue_path(project.namespace, project, issue2) + visit project_issue_path(project, issue2) page.within('.assignee') do expect(page).to have_content "No assignee" @@ -456,7 +456,7 @@ describe 'Issues', feature: true do it 'allows user to unselect themselves', js: true do issue2 = create(:issue, project: project, author: user) - visit namespace_project_issue_path(project.namespace, project, issue2) + visit project_issue_path(project, issue2) page.within '.assignee' do click_link 'Edit' @@ -487,7 +487,7 @@ describe 'Issues', feature: true do sign_out(:user) sign_in(guest) - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) expect(page).to have_content issue.assignees.first.name end end @@ -499,7 +499,7 @@ describe 'Issues', feature: true do context 'by authorized user' do it 'allows user to select unassigned', js: true do - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) page.within('.milestone') do expect(page).to have_content "None" @@ -517,7 +517,7 @@ describe 'Issues', feature: true do end it 'allows user to de-select milestone', js: true do - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) page.within('.milestone') do click_link 'Edit' @@ -550,7 +550,7 @@ describe 'Issues', feature: true do sign_out(:user) sign_in(guest) - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) expect(page).to have_content milestone.title end end @@ -565,7 +565,7 @@ describe 'Issues', feature: true do end it 'redirects to signin then back to new issue after signin' do - visit namespace_project_issues_path(project.namespace, project) + visit project_issues_path(project) click_link 'New issue' @@ -575,13 +575,13 @@ describe 'Issues', feature: true do # need the full login flow gitlab_sign_in(create(:user)) - expect(current_path).to eq new_namespace_project_issue_path(project.namespace, project) + expect(current_path).to eq new_project_issue_path(project) end end context 'dropzone upload file', js: true do before do - visit new_namespace_project_issue_path(project.namespace, project) + visit new_project_issue_path(project) end it 'uploads file when dragging into textarea' do @@ -608,7 +608,7 @@ describe 'Issues', feature: true do message: 'added issue template', branch_name: 'master') - visit new_namespace_project_issue_path(project.namespace, project, issuable_template: 'bug') + visit new_project_issue_path(project, issuable_template: 'bug') end it 'fills in template' do @@ -625,7 +625,7 @@ describe 'Issues', feature: true do project.issues << issue stub_incoming_email_setting(enabled: true, address: "p+%{key}@gl.ab") - visit namespace_project_issues_path(project.namespace, project) + visit project_issues_path(project) click_button('Email a new issue') end @@ -654,7 +654,7 @@ describe 'Issues', feature: true do let(:issue) { create(:issue, project: project, author: user, assignees: [user]) } before do - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) end it 'adds due date to issue' do @@ -698,7 +698,7 @@ describe 'Issues', feature: true do it 'updates the title', js: true do issue = create(:issue, author: user, assignees: [user], project: project, title: 'new title') - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) expect(page).to have_text("new title") diff --git a/spec/features/merge_requests/assign_issues_spec.rb b/spec/features/merge_requests/assign_issues_spec.rb index cb835f533e0..9d9a31ab8e8 100644 --- a/spec/features/merge_requests/assign_issues_spec.rb +++ b/spec/features/merge_requests/assign_issues_spec.rb @@ -14,7 +14,7 @@ feature 'Merge request issue assignment', js: true, feature: true do def visit_merge_request(current_user = nil) gitlab_sign_in(current_user || user) - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) end context 'logged in as author' do diff --git a/spec/features/merge_requests/award_spec.rb b/spec/features/merge_requests/award_spec.rb index e9dd755b6af..ed5a4fa5784 100644 --- a/spec/features/merge_requests/award_spec.rb +++ b/spec/features/merge_requests/award_spec.rb @@ -8,7 +8,7 @@ feature 'Merge request awards', js: true, feature: true do describe 'logged in' do before do gitlab_sign_in(user) - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) end it 'adds award to merge request' do @@ -16,7 +16,7 @@ feature 'Merge request awards', js: true, feature: true do expect(page).to have_selector('.js-emoji-btn.active') expect(first('.js-emoji-btn')).to have_content '1' - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) expect(first('.js-emoji-btn')).to have_content '1' end @@ -25,7 +25,7 @@ feature 'Merge request awards', js: true, feature: true do find('.js-emoji-btn.active').click expect(first('.js-emoji-btn')).to have_content '0' - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) expect(first('.js-emoji-btn')).to have_content '0' end @@ -39,7 +39,7 @@ feature 'Merge request awards', js: true, feature: true do describe 'logged out' do before do - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) end it 'does not see award menu button' do diff --git a/spec/features/merge_requests/check_if_mergeable_with_unresolved_discussions_spec.rb b/spec/features/merge_requests/check_if_mergeable_with_unresolved_discussions_spec.rb index 060cfb8fdd1..0f8ab4cd92b 100644 --- a/spec/features/merge_requests/check_if_mergeable_with_unresolved_discussions_spec.rb +++ b/spec/features/merge_requests/check_if_mergeable_with_unresolved_discussions_spec.rb @@ -64,6 +64,6 @@ feature 'Check if mergeable with unresolved discussions', js: true, feature: tru end def visit_merge_request(merge_request) - visit namespace_project_merge_request_path(merge_request.project.namespace, merge_request.project, merge_request) + visit project_merge_request_path(merge_request.project, merge_request) end end diff --git a/spec/features/merge_requests/cherry_pick_spec.rb b/spec/features/merge_requests/cherry_pick_spec.rb index 6ba96570e3d..5a5f884c6b3 100644 --- a/spec/features/merge_requests/cherry_pick_spec.rb +++ b/spec/features/merge_requests/cherry_pick_spec.rb @@ -28,7 +28,7 @@ describe 'Cherry-pick Merge Requests', js: true do end it "doesn't show a Cherry-pick button" do - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) expect(page).not_to have_link "Cherry-pick" end @@ -36,7 +36,7 @@ describe 'Cherry-pick Merge Requests', js: true do context "With a merge commit" do it "shows a Cherry-pick button" do - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) expect(page).to have_link "Cherry-pick" end diff --git a/spec/features/merge_requests/closes_issues_spec.rb b/spec/features/merge_requests/closes_issues_spec.rb index 365b2555c35..2f639b54637 100644 --- a/spec/features/merge_requests/closes_issues_spec.rb +++ b/spec/features/merge_requests/closes_issues_spec.rb @@ -22,7 +22,7 @@ feature 'Merge Request closing issues message', feature: true, js: true do gitlab_sign_in user - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) wait_for_requests end diff --git a/spec/features/merge_requests/conflicts_spec.rb b/spec/features/merge_requests/conflicts_spec.rb index 9c091befa27..a9947381f46 100644 --- a/spec/features/merge_requests/conflicts_spec.rb +++ b/spec/features/merge_requests/conflicts_spec.rb @@ -86,7 +86,7 @@ feature 'Merge request conflict resolution', js: true, feature: true do let(:merge_request) { create_merge_request('conflict-resolvable') } before do - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) end it 'shows a link to the conflict resolution page' do @@ -117,7 +117,7 @@ feature 'Merge request conflict resolution', js: true, feature: true do let(:merge_request) { create_merge_request('conflict-contains-conflict-markers') } before do - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) click_link('conflicts', href: /\/conflicts\Z/) end @@ -166,7 +166,7 @@ feature 'Merge request conflict resolution', js: true, feature: true do project.team << [user, :developer] gitlab_sign_in(user) - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) end it 'does not show a link to the conflict resolution page' do diff --git a/spec/features/merge_requests/create_new_mr_spec.rb b/spec/features/merge_requests/create_new_mr_spec.rb index 6a08e50bf5e..198fcba4e78 100644 --- a/spec/features/merge_requests/create_new_mr_spec.rb +++ b/spec/features/merge_requests/create_new_mr_spec.rb @@ -11,7 +11,7 @@ feature 'Create New Merge Request', feature: true, js: true do end it 'selects the source branch sha when a tag with the same name exists' do - visit namespace_project_merge_requests_path(project.namespace, project) + visit project_merge_requests_path(project) click_link 'New merge request' expect(page).to have_content('Source branch') @@ -24,7 +24,7 @@ feature 'Create New Merge Request', feature: true, js: true do end it 'selects the target branch sha when a tag with the same name exists' do - visit namespace_project_merge_requests_path(project.namespace, project) + visit project_merge_requests_path(project) click_link 'New merge request' @@ -38,7 +38,7 @@ feature 'Create New Merge Request', feature: true, js: true do end it 'generates a diff for an orphaned branch' do - visit namespace_project_merge_requests_path(project.namespace, project) + visit project_merge_requests_path(project) page.has_link?('New Merge Request') ? click_link("New Merge Request") : click_link('New merge request') expect(page).to have_content('Source branch') @@ -65,7 +65,7 @@ feature 'Create New Merge Request', feature: true, js: true do it 'does not leak the private project name & namespace' do private_project = create(:project, :private) - visit namespace_project_new_merge_request_path(project.namespace, project, merge_request: { target_project_id: private_project.id }) + visit project_new_merge_request_path(project, merge_request: { target_project_id: private_project.id }) expect(page).not_to have_content private_project.path_with_namespace expect(page).to have_content project.path_with_namespace @@ -76,7 +76,7 @@ feature 'Create New Merge Request', feature: true, js: true do it 'does not leak the private project name & namespace' do private_project = create(:project, :private) - visit namespace_project_new_merge_request_path(project.namespace, project, merge_request: { source_project_id: private_project.id }) + visit project_new_merge_request_path(project, merge_request: { source_project_id: private_project.id }) expect(page).not_to have_content private_project.path_with_namespace expect(page).to have_content project.path_with_namespace @@ -84,13 +84,13 @@ feature 'Create New Merge Request', feature: true, js: true do end it 'populates source branch button' do - visit namespace_project_new_merge_request_path(project.namespace, project, change_branches: true, merge_request: { target_branch: 'master', source_branch: 'fix' }) + visit project_new_merge_request_path(project, change_branches: true, merge_request: { target_branch: 'master', source_branch: 'fix' }) expect(find('.js-source-branch')).to have_content('fix') end it 'allows to change the diff view' do - visit namespace_project_new_merge_request_path(project.namespace, project, merge_request: { target_branch: 'master', source_branch: 'fix' }) + visit project_new_merge_request_path(project, merge_request: { target_branch: 'master', source_branch: 'fix' }) click_link 'Changes' @@ -106,7 +106,7 @@ feature 'Create New Merge Request', feature: true, js: true do end it 'does not allow non-existing branches' do - visit namespace_project_new_merge_request_path(project.namespace, project, merge_request: { target_branch: 'non-exist-target', source_branch: 'non-exist-source' }) + visit project_new_merge_request_path(project, merge_request: { target_branch: 'non-exist-target', source_branch: 'non-exist-source' }) expect(page).to have_content('The form contains the following errors') expect(page).to have_content('Source branch "non-exist-source" does not exist') @@ -115,7 +115,7 @@ feature 'Create New Merge Request', feature: true, js: true do context 'when a branch contains commits that both delete and add the same image' do it 'renders the diff successfully' do - visit namespace_project_new_merge_request_path(project.namespace, project, merge_request: { target_branch: 'master', source_branch: 'deleted-image-test' }) + visit project_new_merge_request_path(project, merge_request: { target_branch: 'master', source_branch: 'deleted-image-test' }) click_link "Changes" @@ -125,7 +125,7 @@ feature 'Create New Merge Request', feature: true, js: true do # Isolates a regression (see #24627) it 'does not show error messages on initial form' do - visit namespace_project_new_merge_request_path(project.namespace, project) + visit project_new_merge_request_path(project) expect(page).not_to have_selector('#error_explanation') expect(page).not_to have_content('The form contains the following error') end @@ -138,8 +138,8 @@ feature 'Create New Merge Request', feature: true, js: true do end it 'shows pipelines for a new merge request' do - visit namespace_project_new_merge_request_path( - project.namespace, project, + visit project_new_merge_request_path( + project, merge_request: { target_branch: 'master', source_branch: 'fix' }) page.within('.merge-request') do diff --git a/spec/features/merge_requests/created_from_fork_spec.rb b/spec/features/merge_requests/created_from_fork_spec.rb index 69059dfa562..9f1b6be67d4 100644 --- a/spec/features/merge_requests/created_from_fork_spec.rb +++ b/spec/features/merge_requests/created_from_fork_spec.rb @@ -64,7 +64,6 @@ feature 'Merge request created from fork' do end def visit_merge_request(mr) - visit namespace_project_merge_request_path(project.namespace, - project, mr) + visit project_merge_request_path(project, mr) end end diff --git a/spec/features/merge_requests/deleted_source_branch_spec.rb b/spec/features/merge_requests/deleted_source_branch_spec.rb index f2af3198319..671c17cd9e3 100644 --- a/spec/features/merge_requests/deleted_source_branch_spec.rb +++ b/spec/features/merge_requests/deleted_source_branch_spec.rb @@ -11,11 +11,7 @@ describe 'Deleted source branch', feature: true, js: true do gitlab_sign_in user merge_request.project.team << [user, :master] merge_request.update!(source_branch: 'this-branch-does-not-exist') - visit namespace_project_merge_request_path( - merge_request.project.namespace, - merge_request.project, - merge_request - ) + visit project_merge_request_path(merge_request.project, merge_request) end it 'shows a message about missing source branch' do diff --git a/spec/features/merge_requests/diff_notes_avatars_spec.rb b/spec/features/merge_requests/diff_notes_avatars_spec.rb index 989dfb71d10..1b45bb73863 100644 --- a/spec/features/merge_requests/diff_notes_avatars_spec.rb +++ b/spec/features/merge_requests/diff_notes_avatars_spec.rb @@ -25,7 +25,7 @@ feature 'Diff note avatars', feature: true, js: true do context 'discussion tab' do before do - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) end it 'does not show avatars on discussion tab' do @@ -50,7 +50,7 @@ feature 'Diff note avatars', feature: true, js: true do context 'commit view' do before do - visit namespace_project_commit_path(project.namespace, project, merge_request.commits.first.id) + visit project_commit_path(project, merge_request.commits.first.id) end it 'does not render avatar after commenting' do @@ -65,7 +65,7 @@ feature 'Diff note avatars', feature: true, js: true do wait_for_requests end - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) expect(page).to have_content('test comment') expect(page).not_to have_selector('.js-avatar-container') @@ -76,7 +76,7 @@ feature 'Diff note avatars', feature: true, js: true do %w(inline parallel).each do |view| context "#{view} view" do before do - visit diffs_namespace_project_merge_request_path(project.namespace, project, merge_request, view: view) + visit diffs_project_merge_request_path(project, merge_request, view: view) wait_for_requests end @@ -168,7 +168,7 @@ feature 'Diff note avatars', feature: true, js: true do before do create_list(:diff_note_on_merge_request, 3, project: project, noteable: merge_request, in_reply_to: note) - visit diffs_namespace_project_merge_request_path(project.namespace, project, merge_request, view: view) + visit diffs_project_merge_request_path(project, merge_request, view: view) wait_for_requests end diff --git a/spec/features/merge_requests/diff_notes_resolve_spec.rb b/spec/features/merge_requests/diff_notes_resolve_spec.rb index 0f8ca6f90d1..21dce185085 100644 --- a/spec/features/merge_requests/diff_notes_resolve_spec.rb +++ b/spec/features/merge_requests/diff_notes_resolve_spec.rb @@ -494,6 +494,6 @@ feature 'Diff notes resolve', feature: true, js: true do def visit_merge_request(mr = nil) mr = mr || merge_request - visit namespace_project_merge_request_path(mr.project.namespace, mr.project, mr) + visit project_merge_request_path(mr.project, mr) end end diff --git a/spec/features/merge_requests/diffs_spec.rb b/spec/features/merge_requests/diffs_spec.rb index cb6cd6571a8..35976b615ad 100644 --- a/spec/features/merge_requests/diffs_spec.rb +++ b/spec/features/merge_requests/diffs_spec.rb @@ -12,7 +12,7 @@ feature 'Diffs URL', js: true, feature: true do it 'renders the notes' do create :note_on_merge_request, project: project, noteable: merge_request, note: 'Rebasing with master' - visit diffs_namespace_project_merge_request_path(project.namespace, project, merge_request) + visit diffs_project_merge_request_path(project, merge_request) # Load notes and diff through AJAX expect(page).to have_css('.note-text', visible: false, text: 'Rebasing with master') @@ -26,7 +26,7 @@ feature 'Diffs URL', js: true, feature: true do let(:fragment) { "#note_#{note.id}" } before do - visit "#{diffs_namespace_project_merge_request_path(project.namespace, project, merge_request)}#{fragment}" + visit "#{diffs_project_merge_request_path(project, merge_request)}#{fragment}" end it 'shows expanded note' do @@ -39,7 +39,7 @@ feature 'Diffs URL', js: true, feature: true do let(:fragment) { "#note_#{note.id}" } before do - visit "#{diffs_namespace_project_merge_request_path(project.namespace, project, merge_request)}#{fragment}" + visit "#{diffs_project_merge_request_path(project, merge_request)}#{fragment}" end it 'shows expanded note' do @@ -52,7 +52,7 @@ feature 'Diffs URL', js: true, feature: true do it 'displays warning' do allow(Commit).to receive(:max_diff_options).and_return(max_files: 3) - visit diffs_namespace_project_merge_request_path(project.namespace, project, merge_request) + visit diffs_project_merge_request_path(project, merge_request) page.within('.alert') do expect(page).to have_text("Too many changes to show. Plain diff Email patch To preserve @@ -75,7 +75,7 @@ feature 'Diffs URL', js: true, feature: true do context 'as author' do it 'shows direct edit link' do gitlab_sign_in(author_user) - visit diffs_namespace_project_merge_request_path(project.namespace, project, merge_request) + visit diffs_project_merge_request_path(project, merge_request) # Throws `Capybara::Poltergeist::InvalidSelector` if we try to use `#hash` syntax expect(page).to have_selector("[id=\"#{changelog_id}\"] a.js-edit-blob") @@ -85,7 +85,7 @@ feature 'Diffs URL', js: true, feature: true do context 'as user who needs to fork' do it 'shows fork/cancel confirmation' do gitlab_sign_in(user) - visit diffs_namespace_project_merge_request_path(project.namespace, project, merge_request) + visit diffs_project_merge_request_path(project, merge_request) # Throws `Capybara::Poltergeist::InvalidSelector` if we try to use `#hash` syntax find("[id=\"#{changelog_id}\"] .js-edit-blob").click diff --git a/spec/features/merge_requests/discussion_spec.rb b/spec/features/merge_requests/discussion_spec.rb index 88ae257236c..a50f66cfc64 100644 --- a/spec/features/merge_requests/discussion_spec.rb +++ b/spec/features/merge_requests/discussion_spec.rb @@ -27,13 +27,13 @@ feature 'Merge Request Discussions', feature: true do let(:outdated_diff_refs) { project.commit("874797c3a73b60d2187ed6e2fcabd289ff75171e").diff_refs } before(:each) do - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) end context 'active discussions' do it 'shows a link to the diff' do within(".discussion[data-discussion-id='#{active_discussion.id}']") do - path = diffs_namespace_project_merge_request_path(project.namespace, project, merge_request, anchor: active_discussion.line_code) + path = diffs_project_merge_request_path(project, merge_request, anchor: active_discussion.line_code) expect(page).to have_link('the diff', href: path) end end @@ -42,7 +42,7 @@ feature 'Merge Request Discussions', feature: true do context 'outdated discussions' do it 'shows a link to the outdated diff' do within(".discussion[data-discussion-id='#{outdated_discussion.id}']") do - path = diffs_namespace_project_merge_request_path(project.namespace, project, merge_request, diff_id: old_merge_request_diff.id, anchor: outdated_discussion.line_code) + path = diffs_project_merge_request_path(project, merge_request, diff_id: old_merge_request_diff.id, anchor: outdated_discussion.line_code) expect(page).to have_link('an old version of the diff', href: path) end end @@ -72,7 +72,7 @@ feature 'Merge Request Discussions', feature: true do end before(:each) do - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) end context 'a regular commit comment' do diff --git a/spec/features/merge_requests/edit_mr_spec.rb b/spec/features/merge_requests/edit_mr_spec.rb index 804bf6967d6..8ee78526232 100644 --- a/spec/features/merge_requests/edit_mr_spec.rb +++ b/spec/features/merge_requests/edit_mr_spec.rb @@ -10,7 +10,7 @@ feature 'Edit Merge Request', feature: true do gitlab_sign_in user - visit edit_namespace_project_merge_request_path(project.namespace, project, merge_request) + visit edit_project_merge_request_path(project, merge_request) end context 'editing a MR' do @@ -33,7 +33,7 @@ feature 'Edit Merge Request', feature: true do merge_request.update(merge_params: { 'force_remove_source_branch' => '1' }) expect(merge_request.merge_params['force_remove_source_branch']).to be_truthy - visit edit_namespace_project_merge_request_path(project.namespace, project, merge_request) + visit edit_project_merge_request_path(project, merge_request) uncheck 'Remove source branch when merge request is accepted' click_button 'Save changes' diff --git a/spec/features/merge_requests/filter_by_labels_spec.rb b/spec/features/merge_requests/filter_by_labels_spec.rb index 9b677aeca0a..e3d48128aeb 100644 --- a/spec/features/merge_requests/filter_by_labels_spec.rb +++ b/spec/features/merge_requests/filter_by_labels_spec.rb @@ -28,7 +28,7 @@ feature 'Issue filtering by Labels', feature: true, js: true do project.team << [user, :master] gitlab_sign_in(user) - visit namespace_project_merge_requests_path(project.namespace, project) + visit project_merge_requests_path(project) end context 'filter by label bug' do diff --git a/spec/features/merge_requests/filter_merge_requests_spec.rb b/spec/features/merge_requests/filter_merge_requests_spec.rb index c12edf1fdf3..2a62cda6d84 100644 --- a/spec/features/merge_requests/filter_merge_requests_spec.rb +++ b/spec/features/merge_requests/filter_merge_requests_spec.rb @@ -17,7 +17,7 @@ describe 'Filter merge requests', feature: true do gitlab_sign_in(user) create(:merge_request, source_project: project, target_project: project) - visit namespace_project_merge_requests_path(project.namespace, project) + visit project_merge_requests_path(project) end describe 'for assignee from mr#index' do @@ -191,7 +191,7 @@ describe 'Filter merge requests', feature: true do assignee: user) mr.labels << bug_label - visit namespace_project_merge_requests_path(project.namespace, project) + visit project_merge_requests_path(project) end context 'only text', js: true do @@ -275,7 +275,7 @@ describe 'Filter merge requests', feature: true do mr1.labels << bug_label mr2.labels << bug_label - visit namespace_project_merge_requests_path(project.namespace, project) + visit project_merge_requests_path(project) end it 'is able to filter and sort merge requests' do @@ -297,7 +297,7 @@ describe 'Filter merge requests', feature: true do describe 'filter by assignee id', js: true do it 'filter by current user' do - visit namespace_project_merge_requests_path(project.namespace, project, assignee_id: user.id) + visit project_merge_requests_path(project, assignee_id: user.id) expect_tokens([{ name: 'assignee', value: "@#{user.username}" }]) expect_filtered_search_input_empty @@ -307,7 +307,7 @@ describe 'Filter merge requests', feature: true do new_user = create(:user) project.add_developer(new_user) - visit namespace_project_merge_requests_path(project.namespace, project, assignee_id: new_user.id) + visit project_merge_requests_path(project, assignee_id: new_user.id) expect_tokens([{ name: 'assignee', value: "@#{new_user.username}" }]) expect_filtered_search_input_empty @@ -316,7 +316,7 @@ describe 'Filter merge requests', feature: true do describe 'filter by author id', js: true do it 'filter by current user' do - visit namespace_project_merge_requests_path(project.namespace, project, author_id: user.id) + visit project_merge_requests_path(project, author_id: user.id) expect_tokens([{ name: 'author', value: "@#{user.username}" }]) expect_filtered_search_input_empty @@ -326,7 +326,7 @@ describe 'Filter merge requests', feature: true do new_user = create(:user) project.add_developer(new_user) - visit namespace_project_merge_requests_path(project.namespace, project, author_id: new_user.id) + visit project_merge_requests_path(project, author_id: new_user.id) expect_tokens([{ name: 'author', value: "@#{new_user.username}" }]) expect_filtered_search_input_empty diff --git a/spec/features/merge_requests/form_spec.rb b/spec/features/merge_requests/form_spec.rb index d03d498ce21..8f2857c66f7 100644 --- a/spec/features/merge_requests/form_spec.rb +++ b/spec/features/merge_requests/form_spec.rb @@ -1,8 +1,6 @@ require 'rails_helper' describe 'New/edit merge request', feature: true, js: true do - include GitlabRoutingHelper - let!(:project) { create(:project, visibility_level: Gitlab::VisibilityLevel::PUBLIC) } let(:fork_project) { create(:project, forked_from_project: project) } let!(:user) { create(:user)} @@ -23,8 +21,7 @@ describe 'New/edit merge request', feature: true, js: true do context 'new merge request' do before do - visit namespace_project_new_merge_request_path( - project.namespace, + visit project_new_merge_request_path( project, merge_request: { source_project_id: project.id, @@ -114,7 +111,7 @@ describe 'New/edit merge request', feature: true, js: true do target_branch: 'master' ) - visit edit_namespace_project_merge_request_path(project.namespace, project, merge_request) + visit edit_project_merge_request_path(project, merge_request) end it 'updates merge request' do @@ -182,8 +179,7 @@ describe 'New/edit merge request', feature: true, js: true do context 'new merge request' do before do - visit namespace_project_new_merge_request_path( - fork_project.namespace, + visit project_new_merge_request_path( fork_project, merge_request: { source_project_id: fork_project.id, @@ -251,7 +247,7 @@ describe 'New/edit merge request', feature: true, js: true do target_branch: 'master' ) - visit edit_namespace_project_merge_request_path(project.namespace, project, merge_request) + visit edit_project_merge_request_path(project, merge_request) end it 'should update merge request' do diff --git a/spec/features/merge_requests/merge_commit_message_toggle_spec.rb b/spec/features/merge_requests/merge_commit_message_toggle_spec.rb index 27ba380b005..831c60625f4 100644 --- a/spec/features/merge_requests/merge_commit_message_toggle_spec.rb +++ b/spec/features/merge_requests/merge_commit_message_toggle_spec.rb @@ -36,7 +36,7 @@ feature 'Clicking toggle commit message link', feature: true, js: true do gitlab_sign_in user - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) expect(page).not_to have_selector('.js-commit-message') click_button "Modify commit message" diff --git a/spec/features/merge_requests/merge_immediately_with_pipeline_spec.rb b/spec/features/merge_requests/merge_immediately_with_pipeline_spec.rb index 8af7d985036..716f829295e 100644 --- a/spec/features/merge_requests/merge_immediately_with_pipeline_spec.rb +++ b/spec/features/merge_requests/merge_immediately_with_pipeline_spec.rb @@ -29,7 +29,7 @@ feature 'Merge immediately', :feature, :js do before do gitlab_sign_in user - visit namespace_project_merge_request_path(merge_request.project.namespace, merge_request.project, merge_request) + visit project_merge_request_path(merge_request.project, merge_request) end it 'enables merge immediately' do diff --git a/spec/features/merge_requests/merge_when_pipeline_succeeds_spec.rb b/spec/features/merge_requests/merge_when_pipeline_succeeds_spec.rb index bfadd7cb81a..2a4178a819b 100644 --- a/spec/features/merge_requests/merge_when_pipeline_succeeds_spec.rb +++ b/spec/features/merge_requests/merge_when_pipeline_succeeds_spec.rb @@ -155,6 +155,6 @@ feature 'Merge When Pipeline Succeeds', :feature, :js do end def visit_merge_request(merge_request) - visit namespace_project_merge_request_path(merge_request.project.namespace, merge_request.project, merge_request) + visit project_merge_request_path(merge_request.project, merge_request) end end diff --git a/spec/features/merge_requests/mini_pipeline_graph_spec.rb b/spec/features/merge_requests/mini_pipeline_graph_spec.rb index 7664fbfbb4c..2c0632a4e82 100644 --- a/spec/features/merge_requests/mini_pipeline_graph_spec.rb +++ b/spec/features/merge_requests/mini_pipeline_graph_spec.rb @@ -16,7 +16,7 @@ feature 'Mini Pipeline Graph', :js, :feature do end def visit_merge_request(format = :html) - visit namespace_project_merge_request_path(project.namespace, project, merge_request, format: format) + visit project_merge_request_path(project, merge_request, format: format) end it 'should display a mini pipeline graph' do @@ -111,7 +111,7 @@ feature 'Mini Pipeline Graph', :js, :feature do build_item.click find('.build-page') - expect(current_path).to eql(namespace_project_job_path(project.namespace, project, build)) + expect(current_path).to eql(project_job_path(project, build)) end it 'should show tooltip when hovered' do diff --git a/spec/features/merge_requests/only_allow_merge_if_build_succeeds_spec.rb b/spec/features/merge_requests/only_allow_merge_if_build_succeeds_spec.rb index 5cd9a7fbe26..6bcfef71d25 100644 --- a/spec/features/merge_requests/only_allow_merge_if_build_succeeds_spec.rb +++ b/spec/features/merge_requests/only_allow_merge_if_build_succeeds_spec.rb @@ -145,6 +145,6 @@ feature 'Only allow merge requests to be merged if the pipeline succeeds', featu end def visit_merge_request(merge_request) - visit namespace_project_merge_request_path(merge_request.project.namespace, merge_request.project, merge_request) + visit project_merge_request_path(merge_request.project, merge_request) end end diff --git a/spec/features/merge_requests/pipelines_spec.rb b/spec/features/merge_requests/pipelines_spec.rb index c2241317e04..d55e6329a9f 100644 --- a/spec/features/merge_requests/pipelines_spec.rb +++ b/spec/features/merge_requests/pipelines_spec.rb @@ -19,7 +19,7 @@ feature 'Pipelines for Merge Requests', feature: true, js: true do end before do - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) end scenario 'user visits merge request pipelines tab' do @@ -34,7 +34,7 @@ feature 'Pipelines for Merge Requests', feature: true, js: true do context 'without pipelines' do before do - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) end scenario 'user visits merge request page' do diff --git a/spec/features/merge_requests/target_branch_spec.rb b/spec/features/merge_requests/target_branch_spec.rb index 4328d66c748..c61f817dd9a 100644 --- a/spec/features/merge_requests/target_branch_spec.rb +++ b/spec/features/merge_requests/target_branch_spec.rb @@ -6,10 +6,7 @@ describe 'Target branch', feature: true, js: true do let(:project) { merge_request.project } def path_to_merge_request - namespace_project_merge_request_path( - project.namespace, - project, merge_request - ) + project_merge_request_path(project, merge_request) end before do diff --git a/spec/features/merge_requests/toggle_whitespace_changes_spec.rb b/spec/features/merge_requests/toggle_whitespace_changes_spec.rb index cba9a2cda99..ae7e99d1462 100644 --- a/spec/features/merge_requests/toggle_whitespace_changes_spec.rb +++ b/spec/features/merge_requests/toggle_whitespace_changes_spec.rb @@ -5,7 +5,7 @@ feature 'Toggle Whitespace Changes', js: true, feature: true do gitlab_sign_in :admin merge_request = create(:merge_request) project = merge_request.source_project - visit diffs_namespace_project_merge_request_path(project.namespace, project, merge_request) + visit diffs_project_merge_request_path(project, merge_request) end it 'has a button to toggle whitespace changes' do diff --git a/spec/features/merge_requests/toggler_behavior_spec.rb b/spec/features/merge_requests/toggler_behavior_spec.rb index c4c06e9a7a0..219b9fd8938 100644 --- a/spec/features/merge_requests/toggler_behavior_spec.rb +++ b/spec/features/merge_requests/toggler_behavior_spec.rb @@ -11,7 +11,7 @@ feature 'toggler_behavior', js: true, feature: true do gitlab_sign_in :admin project = merge_request.source_project page.current_window.resize_to(1000, 300) - visit "#{namespace_project_merge_request_path(project.namespace, project, merge_request)}#{fragment_id}" + visit "#{project_merge_request_path(project, merge_request)}#{fragment_id}" end describe 'scroll position' do diff --git a/spec/features/merge_requests/update_merge_requests_spec.rb b/spec/features/merge_requests/update_merge_requests_spec.rb index d0418c74699..f8f3e377198 100644 --- a/spec/features/merge_requests/update_merge_requests_spec.rb +++ b/spec/features/merge_requests/update_merge_requests_spec.rb @@ -13,7 +13,7 @@ feature 'Multiple merge requests updating from merge_requests#index', feature: t context 'status', js: true do describe 'close merge request' do before do - visit namespace_project_merge_requests_path(project.namespace, project) + visit project_merge_requests_path(project) end it 'closes merge request' do @@ -26,7 +26,7 @@ feature 'Multiple merge requests updating from merge_requests#index', feature: t describe 'reopen merge request' do before do merge_request.close - visit namespace_project_merge_requests_path(project.namespace, project, state: 'closed') + visit project_merge_requests_path(project, state: 'closed') end it 'reopens merge request' do @@ -40,7 +40,7 @@ feature 'Multiple merge requests updating from merge_requests#index', feature: t context 'assignee', js: true do describe 'set assignee' do before do - visit namespace_project_merge_requests_path(project.namespace, project) + visit project_merge_requests_path(project) end it "updates merge request with assignee" do @@ -56,7 +56,7 @@ feature 'Multiple merge requests updating from merge_requests#index', feature: t before do merge_request.assignee = user merge_request.save - visit namespace_project_merge_requests_path(project.namespace, project) + visit project_merge_requests_path(project) end it "removes assignee from the merge request" do @@ -72,7 +72,7 @@ feature 'Multiple merge requests updating from merge_requests#index', feature: t describe 'set milestone' do before do - visit namespace_project_merge_requests_path(project.namespace, project) + visit project_merge_requests_path(project) end it "updates merge request with milestone" do @@ -86,7 +86,7 @@ feature 'Multiple merge requests updating from merge_requests#index', feature: t before do merge_request.milestone = milestone merge_request.save - visit namespace_project_merge_requests_path(project.namespace, project) + visit project_merge_requests_path(project) end it "removes milestone from the merge request" do diff --git a/spec/features/merge_requests/user_lists_merge_requests_spec.rb b/spec/features/merge_requests/user_lists_merge_requests_spec.rb index cabb8e455f9..f541f495995 100644 --- a/spec/features/merge_requests/user_lists_merge_requests_spec.rb +++ b/spec/features/merge_requests/user_lists_merge_requests_spec.rb @@ -37,7 +37,7 @@ describe 'Projects > Merge requests > User lists merge requests', feature: true it 'filters on no assignee' do visit_merge_requests(project, assignee_id: IssuableFinder::NONE) - expect(current_path).to eq(namespace_project_merge_requests_path(project.namespace, project)) + expect(current_path).to eq(project_merge_requests_path(project)) expect(page).to have_content 'merge_lfs' expect(page).not_to have_content 'fix' expect(page).not_to have_content 'markdown' @@ -136,7 +136,7 @@ describe 'Projects > Merge requests > User lists merge requests', feature: true end it 'sorts by recently due milestone' do - visit namespace_project_merge_requests_path(project.namespace, project, + visit project_merge_requests_path(project, label_name: [label.name, label2.name], assignee_id: user.id, sort: sort_value_milestone_soon) diff --git a/spec/features/merge_requests/user_posts_diff_notes_spec.rb b/spec/features/merge_requests/user_posts_diff_notes_spec.rb index ac7e0eb2727..7b1ac60231a 100644 --- a/spec/features/merge_requests/user_posts_diff_notes_spec.rb +++ b/spec/features/merge_requests/user_posts_diff_notes_spec.rb @@ -17,7 +17,7 @@ feature 'Merge requests > User posts diff notes', :js do context 'when hovering over a parallel view diff file' do before do - visit diffs_namespace_project_merge_request_path(project.namespace, project, merge_request, view: 'parallel') + visit diffs_project_merge_request_path(project, merge_request, view: 'parallel') end context 'with an old line on the left and no line on the right' do @@ -92,7 +92,7 @@ feature 'Merge requests > User posts diff notes', :js do context 'when hovering over an inline view diff file' do before do - visit diffs_namespace_project_merge_request_path(project.namespace, project, merge_request, view: 'inline') + visit diffs_project_merge_request_path(project, merge_request, view: 'inline') end context 'with a new line' do @@ -136,9 +136,9 @@ feature 'Merge requests > User posts diff notes', :js do context 'when hovering over a diff discussion' do before do - visit diffs_namespace_project_merge_request_path(project.namespace, project, merge_request, view: 'inline') + visit diffs_project_merge_request_path(project, merge_request, view: 'inline') should_allow_commenting(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_7_7"]')) - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) end it 'does not allow commenting' do @@ -149,7 +149,7 @@ feature 'Merge requests > User posts diff notes', :js do context 'when cancelling the comment addition' do before do - visit diffs_namespace_project_merge_request_path(project.namespace, project, merge_request, view: 'inline') + visit diffs_project_merge_request_path(project, merge_request, view: 'inline') end context 'with a new line' do @@ -161,7 +161,7 @@ feature 'Merge requests > User posts diff notes', :js do describe 'with muliple note forms' do before do - visit diffs_namespace_project_merge_request_path(project.namespace, project, merge_request, view: 'inline') + visit diffs_project_merge_request_path(project, merge_request, view: 'inline') click_diff_line(find('[id="2f6fcd96b88b36ce98c38da085c795a27d92a3dd_10_9"]')) click_diff_line(find('[id="6eb14e00385d2fb284765eb1cd8d420d33d63fc9_22_22"]')) end @@ -181,7 +181,7 @@ feature 'Merge requests > User posts diff notes', :js do context 'when the MR only supports legacy diff notes' do before do merge_request.merge_request_diff.update_attributes(start_commit_sha: nil) - visit diffs_namespace_project_merge_request_path(project.namespace, project, merge_request, view: 'inline') + visit diffs_project_merge_request_path(project, merge_request, view: 'inline') end context 'with a new line' do diff --git a/spec/features/merge_requests/user_posts_notes_spec.rb b/spec/features/merge_requests/user_posts_notes_spec.rb index 12f987e12ea..b3c8b0e9c34 100644 --- a/spec/features/merge_requests/user_posts_notes_spec.rb +++ b/spec/features/merge_requests/user_posts_notes_spec.rb @@ -14,7 +14,7 @@ describe 'Merge requests > User posts notes', :js do before do gitlab_sign_in :admin - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) end subject { page } diff --git a/spec/features/merge_requests/user_sees_system_notes_spec.rb b/spec/features/merge_requests/user_sees_system_notes_spec.rb index 0d88a8172b0..385708a28c5 100644 --- a/spec/features/merge_requests/user_sees_system_notes_spec.rb +++ b/spec/features/merge_requests/user_sees_system_notes_spec.rb @@ -15,7 +15,7 @@ feature 'Merge requests > User sees system notes' do end it 'shows the system note' do - visit namespace_project_merge_request_path(public_project.namespace, public_project, merge_request) + visit project_merge_request_path(public_project, merge_request) expect(page).to have_css('.system-note') end @@ -23,7 +23,7 @@ feature 'Merge requests > User sees system notes' do context 'when not logged-in' do it 'hides the system note' do - visit namespace_project_merge_request_path(public_project.namespace, public_project, merge_request) + visit project_merge_request_path(public_project, merge_request) expect(page).not_to have_css('.system-note') end diff --git a/spec/features/merge_requests/user_uses_slash_commands_spec.rb b/spec/features/merge_requests/user_uses_slash_commands_spec.rb index a1f123f15ec..229dcda7ce4 100644 --- a/spec/features/merge_requests/user_uses_slash_commands_spec.rb +++ b/spec/features/merge_requests/user_uses_slash_commands_spec.rb @@ -17,7 +17,7 @@ feature 'Merge Requests > User uses quick actions', feature: true, js: true do before do project.team << [user, :master] gitlab_sign_in(user) - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) end after do @@ -53,7 +53,7 @@ feature 'Merge Requests > User uses quick actions', feature: true, js: true do project.team << [guest, :guest] gitlab_sign_out gitlab_sign_in(guest) - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) end it 'does not change the WIP prefix' do @@ -99,7 +99,7 @@ feature 'Merge Requests > User uses quick actions', feature: true, js: true do project.team << [guest, :guest] gitlab_sign_out gitlab_sign_in(guest) - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) end it 'does not merge the MR' do @@ -131,7 +131,7 @@ feature 'Merge Requests > User uses quick actions', feature: true, js: true do end it 'changes target_branch in new merge_request' do - visit namespace_project_new_merge_request_path(another_project.namespace, another_project, new_url_opts) + visit project_new_merge_request_path(another_project, new_url_opts) fill_in "merge_request_title", with: 'My brand new feature' fill_in "merge_request_description", with: "le feature \n/target_branch fix\nFeature description:" @@ -145,7 +145,7 @@ feature 'Merge Requests > User uses quick actions', feature: true, js: true do it 'does not change target branch when merge request is edited' do new_merge_request = create(:merge_request, source_project: another_project) - visit edit_namespace_project_merge_request_path(another_project.namespace, another_project, new_merge_request) + visit edit_project_merge_request_path(another_project, new_merge_request) fill_in "merge_request_description", with: "Want to update target branch\n/target_branch fix\n" click_button "Save changes" @@ -183,7 +183,7 @@ feature 'Merge Requests > User uses quick actions', feature: true, js: true do project.team << [guest, :guest] gitlab_sign_out gitlab_sign_in(guest) - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) end it 'does not change target branch' do diff --git a/spec/features/merge_requests/versions_spec.rb b/spec/features/merge_requests/versions_spec.rb index 04a72d3be34..94fcfa398c9 100644 --- a/spec/features/merge_requests/versions_spec.rb +++ b/spec/features/merge_requests/versions_spec.rb @@ -9,7 +9,7 @@ feature 'Merge Request versions', js: true, feature: true do before do gitlab_sign_in :admin - visit diffs_namespace_project_merge_request_path(project.namespace, project, merge_request) + visit diffs_project_merge_request_path(project, merge_request) end it 'show the latest version of the diff' do @@ -96,8 +96,7 @@ feature 'Merge Request versions', js: true, feature: true do end it 'has a path with comparison context' do - expect(page).to have_current_path diffs_namespace_project_merge_request_path( - project.namespace, + expect(page).to have_current_path diffs_project_merge_request_path( project, merge_request.iid, diff_id: merge_request_diff3.id, diff --git a/spec/features/merge_requests/widget_deployments_spec.rb b/spec/features/merge_requests/widget_deployments_spec.rb index e82e69c5f4a..c43c7460a08 100644 --- a/spec/features/merge_requests/widget_deployments_spec.rb +++ b/spec/features/merge_requests/widget_deployments_spec.rb @@ -14,7 +14,7 @@ feature 'Widget Deployments Header', feature: true, js: true do background do gitlab_sign_in(user) project.team << [user, role] - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) end scenario 'displays that the environment is deployed' do diff --git a/spec/features/merge_requests/widget_spec.rb b/spec/features/merge_requests/widget_spec.rb index d8e9b949204..8135411fe03 100644 --- a/spec/features/merge_requests/widget_spec.rb +++ b/spec/features/merge_requests/widget_spec.rb @@ -12,8 +12,7 @@ describe 'Merge request', :feature, :js do context 'new merge request' do before do - visit namespace_project_new_merge_request_path( - project.namespace, + visit project_new_merge_request_path( project, merge_request: { source_project_id: project.id, @@ -44,7 +43,7 @@ describe 'Merge request', :feature, :js do end before do - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) end it 'shows environments link' do @@ -71,7 +70,7 @@ describe 'Merge request', :feature, :js do type: 'CiService', category: 'ci') - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) end it 'has danger button while waiting for external CI status' do @@ -92,7 +91,7 @@ describe 'Merge request', :feature, :js do head_pipeline_of: merge_request) create(:ci_build, :pending, pipeline: pipeline) - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) end it 'has danger button when not succeeded' do @@ -112,9 +111,7 @@ describe 'Merge request', :feature, :js do status: :manual, head_pipeline_of: merge_request) - visit namespace_project_merge_request_path(project.namespace, - project, - merge_request) + visit project_merge_request_path(project, merge_request) end it 'shows information about blocked pipeline' do @@ -136,7 +133,7 @@ describe 'Merge request', :feature, :js do head_pipeline_of: merge_request) create(:ci_build, :pending, pipeline: pipeline) - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) end it 'has info button when MWBS button' do @@ -154,7 +151,7 @@ describe 'Merge request', :feature, :js do merge_error: 'Something went wrong' ) - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) end it 'shows information about the merge error' do @@ -175,7 +172,7 @@ describe 'Merge request', :feature, :js do merge_error: 'Something went wrong' ) - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) end it 'shows information about the merge error' do @@ -191,7 +188,7 @@ describe 'Merge request', :feature, :js do context 'merge error' do before do allow_any_instance_of(Repository).to receive(:merge).and_return(false) - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) end it 'updates the MR widget' do @@ -212,7 +209,7 @@ describe 'Merge request', :feature, :js do gitlab_sign_out gitlab_sign_in user2 merge_request.update(target_project: fork_project) - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) end it 'user can merge into the source project' do diff --git a/spec/features/merge_requests/wip_message_spec.rb b/spec/features/merge_requests/wip_message_spec.rb index 0e304ba50af..224723773bf 100644 --- a/spec/features/merge_requests/wip_message_spec.rb +++ b/spec/features/merge_requests/wip_message_spec.rb @@ -11,8 +11,7 @@ feature 'Work In Progress help message', feature: true do context 'with WIP commits' do it 'shows a specific WIP hint' do - visit namespace_project_new_merge_request_path( - project.namespace, + visit project_new_merge_request_path( project, merge_request: { source_project_id: project.id, @@ -32,8 +31,7 @@ feature 'Work In Progress help message', feature: true do context 'without WIP commits' do it 'shows the regular WIP message' do - visit namespace_project_new_merge_request_path( - project.namespace, + visit project_new_merge_request_path( project, merge_request: { source_project_id: project.id, diff --git a/spec/features/milestone_spec.rb b/spec/features/milestone_spec.rb index 58989581ffe..880c53343bc 100644 --- a/spec/features/milestone_spec.rb +++ b/spec/features/milestone_spec.rb @@ -11,7 +11,7 @@ feature 'Milestone', feature: true do feature 'Create a milestone' do scenario 'shows an informative message for a new milestone' do - visit new_namespace_project_milestone_path(project.namespace, project) + visit new_project_milestone_path(project) page.within '.milestone-form' do fill_in "milestone_title", with: '8.7' @@ -31,7 +31,7 @@ feature 'Milestone', feature: true do milestone = create(:milestone, project: project, title: 8.7) create(:issue, title: "Bugfix1", project: project, milestone: milestone, state: "closed") - visit namespace_project_milestone_path(project.namespace, project, milestone) + visit project_milestone_path(project, milestone) expect(find('.alert-success')).to have_content('All issues for this milestone are closed. You may close this milestone now.') end @@ -41,7 +41,7 @@ feature 'Milestone', feature: true do scenario 'displays validation message' do milestone = create(:milestone, project: project, title: 8.7) - visit new_namespace_project_milestone_path(project.namespace, project) + visit new_project_milestone_path(project) page.within '.milestone-form' do fill_in "milestone_title", with: milestone.title end diff --git a/spec/features/milestones/show_spec.rb b/spec/features/milestones/show_spec.rb index cdf6cfba402..fc7d2f9662d 100644 --- a/spec/features/milestones/show_spec.rb +++ b/spec/features/milestones/show_spec.rb @@ -13,7 +13,7 @@ describe 'Milestone show', feature: true do end def visit_milestone - visit namespace_project_milestone_path(project.namespace, project, milestone) + visit project_milestone_path(project, milestone) end it 'avoids N+1 database queries' do diff --git a/spec/features/participants_autocomplete_spec.rb b/spec/features/participants_autocomplete_spec.rb index b8966cf621c..a66d0f4abad 100644 --- a/spec/features/participants_autocomplete_spec.rb +++ b/spec/features/participants_autocomplete_spec.rb @@ -29,7 +29,7 @@ feature 'Member autocomplete', :js do context 'adding a new note on a Issue' do let(:noteable) { create(:issue, author: author, project: project) } before do - visit namespace_project_issue_path(project.namespace, project, noteable) + visit project_issue_path(project, noteable) end include_examples "open suggestions when typing @" @@ -42,7 +42,7 @@ feature 'Member autocomplete', :js do target_project: project, author: author) end before do - visit namespace_project_merge_request_path(project.namespace, project, noteable) + visit project_merge_request_path(project, noteable) end include_examples "open suggestions when typing @" @@ -56,7 +56,7 @@ feature 'Member autocomplete', :js do before do allow_any_instance_of(Commit).to receive(:author).and_return(author) - visit namespace_project_commit_path(project.namespace, project, noteable) + visit project_commit_path(project, noteable) end include_examples "open suggestions when typing @" diff --git a/spec/features/projects/activity/rss_spec.rb b/spec/features/projects/activity/rss_spec.rb index 84c81d43448..97925bc2ebf 100644 --- a/spec/features/projects/activity/rss_spec.rb +++ b/spec/features/projects/activity/rss_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' feature 'Project Activity RSS' do let(:project) { create(:empty_project, visibility_level: Gitlab::VisibilityLevel::PUBLIC) } - let(:path) { activity_namespace_project_path(project.namespace, project) } + let(:path) { activity_project_path(project) } before do create(:issue, project: project) diff --git a/spec/features/projects/artifacts/browse_spec.rb b/spec/features/projects/artifacts/browse_spec.rb index 68375956273..a34c0c4cecd 100644 --- a/spec/features/projects/artifacts/browse_spec.rb +++ b/spec/features/projects/artifacts/browse_spec.rb @@ -6,7 +6,7 @@ feature 'Browse artifact', :js, feature: true do let(:job) { create(:ci_build, :artifacts, pipeline: pipeline) } def browse_path(path) - browse_namespace_project_job_artifacts_path(project.namespace, project, job, path) + browse_project_job_artifacts_path(project, job, path) end context 'when visiting old URL' do diff --git a/spec/features/projects/artifacts/download_spec.rb b/spec/features/projects/artifacts/download_spec.rb index dd9454840ee..b76f2be880e 100644 --- a/spec/features/projects/artifacts/download_spec.rb +++ b/spec/features/projects/artifacts/download_spec.rb @@ -22,7 +22,7 @@ feature 'Download artifact', :js, feature: true do context 'via job id' do let(:download_url) do - download_namespace_project_job_artifacts_path(project.namespace, project, job) + download_project_job_artifacts_path(project, job) end it_behaves_like 'downloading' @@ -30,7 +30,7 @@ feature 'Download artifact', :js, feature: true do context 'via branch name and job name' do let(:download_url) do - latest_succeeded_namespace_project_artifacts_path(project.namespace, project, "#{pipeline.ref}/download", job: job.name) + latest_succeeded_project_artifacts_path(project, "#{pipeline.ref}/download", job: job.name) end it_behaves_like 'downloading' @@ -44,7 +44,7 @@ feature 'Download artifact', :js, feature: true do context 'via job id' do let(:download_url) do - download_namespace_project_job_artifacts_path(project.namespace, project, job) + download_project_job_artifacts_path(project, job) end it_behaves_like 'downloading' @@ -52,7 +52,7 @@ feature 'Download artifact', :js, feature: true do context 'via branch name and job name' do let(:download_url) do - latest_succeeded_namespace_project_artifacts_path(project.namespace, project, "#{pipeline.ref}/download", job: job.name) + latest_succeeded_project_artifacts_path(project, "#{pipeline.ref}/download", job: job.name) end it_behaves_like 'downloading' diff --git a/spec/features/projects/artifacts/file_spec.rb b/spec/features/projects/artifacts/file_spec.rb index 860373e531b..6d48470ca3a 100644 --- a/spec/features/projects/artifacts/file_spec.rb +++ b/spec/features/projects/artifacts/file_spec.rb @@ -10,7 +10,7 @@ feature 'Artifact file', :js, feature: true do end def file_path(path) - file_namespace_project_job_artifacts_path(project.namespace, project, build, path) + file_project_job_artifacts_path(project, build, path) end context 'Text file' do diff --git a/spec/features/projects/artifacts/raw_spec.rb b/spec/features/projects/artifacts/raw_spec.rb index b589701729d..3f38d720a0f 100644 --- a/spec/features/projects/artifacts/raw_spec.rb +++ b/spec/features/projects/artifacts/raw_spec.rb @@ -6,7 +6,7 @@ feature 'Raw artifact', :js, feature: true do let(:job) { create(:ci_build, :artifacts, pipeline: pipeline) } def raw_path(path) - raw_namespace_project_job_artifacts_path(project.namespace, project, job, path) + raw_project_job_artifacts_path(project, job, path) end context 'when visiting old URL' do diff --git a/spec/features/projects/badges/coverage_spec.rb b/spec/features/projects/badges/coverage_spec.rb index 9624e1a71b0..efadb640096 100644 --- a/spec/features/projects/badges/coverage_spec.rb +++ b/spec/features/projects/badges/coverage_spec.rb @@ -70,8 +70,7 @@ feature 'test coverage badge' do end def show_test_coverage_badge(job: nil) - visit coverage_namespace_project_badges_path( - project.namespace, project, ref: :master, job: job, format: :svg) + visit coverage_project_badges_path(project, ref: :master, job: job, format: :svg) end def expect_coverage_badge(coverage) diff --git a/spec/features/projects/badges/list_spec.rb b/spec/features/projects/badges/list_spec.rb index 348748152bb..cbd44c49d04 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) project.team << [user, :master] gitlab_sign_in(user) - visit namespace_project_pipelines_settings_path(project.namespace, project) + visit project_pipelines_settings_path(project) end scenario 'user wants to see build status badge' do diff --git a/spec/features/projects/blobs/blob_line_permalink_updater_spec.rb b/spec/features/projects/blobs/blob_line_permalink_updater_spec.rb index d94204230f6..7564338b301 100644 --- a/spec/features/projects/blobs/blob_line_permalink_updater_spec.rb +++ b/spec/features/projects/blobs/blob_line_permalink_updater_spec.rb @@ -13,14 +13,14 @@ feature 'Blob button line permalinks (BlobLinePermalinkUpdater)', feature: true, end def visit_blob(fragment = nil) - visit namespace_project_blob_path(project.namespace, project, tree_join('master', path), anchor: fragment) + visit project_blob_path(project, tree_join('master', path), anchor: fragment) end describe 'Click "Permalink" button' do it 'works with no initial line number fragment hash' do visit_blob - expect(find('.js-data-file-blob-permalink-url')['href']).to eq(get_absolute_url(namespace_project_blob_path(project.namespace, project, tree_join(sha, path)))) + expect(find('.js-data-file-blob-permalink-url')['href']).to eq(get_absolute_url(project_blob_path(project, tree_join(sha, path)))) end it 'maintains intitial fragment hash' do @@ -28,7 +28,7 @@ feature 'Blob button line permalinks (BlobLinePermalinkUpdater)', feature: true, visit_blob(fragment) - expect(find('.js-data-file-blob-permalink-url')['href']).to eq(get_absolute_url(namespace_project_blob_path(project.namespace, project, tree_join(sha, path), anchor: fragment))) + expect(find('.js-data-file-blob-permalink-url')['href']).to eq(get_absolute_url(project_blob_path(project, tree_join(sha, path), anchor: fragment))) end it 'changes fragment hash if line number clicked' do @@ -39,7 +39,7 @@ feature 'Blob button line permalinks (BlobLinePermalinkUpdater)', feature: true, find('#L3').click find("##{ending_fragment}").click - expect(find('.js-data-file-blob-permalink-url')['href']).to eq(get_absolute_url(namespace_project_blob_path(project.namespace, project, tree_join(sha, path), anchor: ending_fragment))) + expect(find('.js-data-file-blob-permalink-url')['href']).to eq(get_absolute_url(project_blob_path(project, tree_join(sha, path), anchor: ending_fragment))) end it 'with initial fragment hash, changes fragment hash if line number clicked' do @@ -51,7 +51,7 @@ feature 'Blob button line permalinks (BlobLinePermalinkUpdater)', feature: true, find('#L3').click find("##{ending_fragment}").click - expect(find('.js-data-file-blob-permalink-url')['href']).to eq(get_absolute_url(namespace_project_blob_path(project.namespace, project, tree_join(sha, path), anchor: ending_fragment))) + expect(find('.js-data-file-blob-permalink-url')['href']).to eq(get_absolute_url(project_blob_path(project, tree_join(sha, path), anchor: ending_fragment))) end end @@ -59,7 +59,7 @@ feature 'Blob button line permalinks (BlobLinePermalinkUpdater)', feature: true, it 'works with no initial line number fragment hash' do visit_blob - expect(find('.js-blob-blame-link')['href']).to eq(get_absolute_url(namespace_project_blame_path(project.namespace, project, tree_join('master', path)))) + expect(find('.js-blob-blame-link')['href']).to eq(get_absolute_url(project_blame_path(project, tree_join('master', path)))) end it 'maintains intitial fragment hash' do @@ -67,7 +67,7 @@ feature 'Blob button line permalinks (BlobLinePermalinkUpdater)', feature: true, visit_blob(fragment) - expect(find('.js-blob-blame-link')['href']).to eq(get_absolute_url(namespace_project_blame_path(project.namespace, project, tree_join('master', path), anchor: fragment))) + expect(find('.js-blob-blame-link')['href']).to eq(get_absolute_url(project_blame_path(project, tree_join('master', path), anchor: fragment))) end it 'changes fragment hash if line number clicked' do @@ -78,7 +78,7 @@ feature 'Blob button line permalinks (BlobLinePermalinkUpdater)', feature: true, find('#L3').click find("##{ending_fragment}").click - expect(find('.js-blob-blame-link')['href']).to eq(get_absolute_url(namespace_project_blame_path(project.namespace, project, tree_join('master', path), anchor: ending_fragment))) + expect(find('.js-blob-blame-link')['href']).to eq(get_absolute_url(project_blame_path(project, tree_join('master', path), anchor: ending_fragment))) end it 'with initial fragment hash, changes fragment hash if line number clicked' do @@ -90,7 +90,7 @@ feature 'Blob button line permalinks (BlobLinePermalinkUpdater)', feature: true, find('#L3').click find("##{ending_fragment}").click - expect(find('.js-blob-blame-link')['href']).to eq(get_absolute_url(namespace_project_blame_path(project.namespace, project, tree_join('master', path), anchor: ending_fragment))) + expect(find('.js-blob-blame-link')['href']).to eq(get_absolute_url(project_blame_path(project, tree_join('master', path), anchor: ending_fragment))) end end end diff --git a/spec/features/projects/blobs/blob_show_spec.rb b/spec/features/projects/blobs/blob_show_spec.rb index 71ffa352f80..3427f639930 100644 --- a/spec/features/projects/blobs/blob_show_spec.rb +++ b/spec/features/projects/blobs/blob_show_spec.rb @@ -4,7 +4,7 @@ feature 'File blob', :js, feature: true do let(:project) { create(:project, :public) } def visit_blob(path, anchor: nil, ref: 'master') - visit namespace_project_blob_path(project.namespace, project, File.join(ref, path), anchor: anchor) + visit project_blob_path(project, File.join(ref, path), anchor: anchor) wait_for_requests end diff --git a/spec/features/projects/blobs/edit_spec.rb b/spec/features/projects/blobs/edit_spec.rb index d0bc032ee93..c4e53293be0 100644 --- a/spec/features/projects/blobs/edit_spec.rb +++ b/spec/features/projects/blobs/edit_spec.rb @@ -26,7 +26,7 @@ feature 'Editing file blob', feature: true, js: true do context 'from MR diff' do before do - visit diffs_namespace_project_merge_request_path(project.namespace, project, merge_request) + visit diffs_project_merge_request_path(project, merge_request) edit_and_commit end @@ -37,7 +37,7 @@ feature 'Editing file blob', feature: true, js: true do context 'from blob file path' do before do - visit namespace_project_blob_path(project.namespace, project, tree_join(branch, file_path)) + visit project_blob_path(project, tree_join(branch, file_path)) edit_and_commit end @@ -55,7 +55,7 @@ feature 'Editing file blob', feature: true, js: true do before do project.team << [user, :developer] - visit namespace_project_edit_blob_path(project.namespace, project, tree_join(branch, file_path)) + visit project_edit_blob_path(project, tree_join(branch, file_path)) end it 'redirects to sign in and returns' do @@ -63,7 +63,7 @@ feature 'Editing file blob', feature: true, js: true do gitlab_sign_in(user) - expect(page).to have_current_path(namespace_project_edit_blob_path(project.namespace, project, tree_join(branch, file_path))) + expect(page).to have_current_path(project_edit_blob_path(project, tree_join(branch, file_path))) end end @@ -71,7 +71,7 @@ feature 'Editing file blob', feature: true, js: true do let(:user) { create(:user) } before do - visit namespace_project_edit_blob_path(project.namespace, project, tree_join(branch, file_path)) + visit project_edit_blob_path(project, tree_join(branch, file_path)) end it 'redirects to sign in and returns' do @@ -79,7 +79,7 @@ feature 'Editing file blob', feature: true, js: true do gitlab_sign_in(user) - expect(page).to have_current_path(namespace_project_blob_path(project.namespace, project, tree_join(branch, file_path))) + expect(page).to have_current_path(project_blob_path(project, tree_join(branch, file_path))) end end end @@ -97,18 +97,18 @@ feature 'Editing file blob', feature: true, js: true do context 'on some branch' do before do - visit namespace_project_edit_blob_path(project.namespace, project, tree_join(branch, file_path)) + visit project_edit_blob_path(project, tree_join(branch, file_path)) end it 'shows blob editor with same branch' do - expect(page).to have_current_path(namespace_project_edit_blob_path(project.namespace, project, tree_join(branch, file_path))) + expect(page).to have_current_path(project_edit_blob_path(project, tree_join(branch, file_path))) expect(find('.js-branch-name').value).to eq(branch) end end context 'with protected branch' do before do - visit namespace_project_edit_blob_path(project.namespace, project, tree_join(protected_branch, file_path)) + visit project_edit_blob_path(project, tree_join(protected_branch, file_path)) end it 'shows blob editor with patch branch' do @@ -123,11 +123,11 @@ feature 'Editing file blob', feature: true, js: true do before do project.team << [user, :master] gitlab_sign_in(user) - visit namespace_project_edit_blob_path(project.namespace, project, tree_join(branch, file_path)) + visit project_edit_blob_path(project, tree_join(branch, file_path)) end it 'shows blob editor with same branch' do - expect(page).to have_current_path(namespace_project_edit_blob_path(project.namespace, project, tree_join(branch, file_path))) + expect(page).to have_current_path(project_edit_blob_path(project, tree_join(branch, file_path))) expect(find('.js-branch-name').value).to eq(branch) end end diff --git a/spec/features/projects/blobs/shortcuts_blob_spec.rb b/spec/features/projects/blobs/shortcuts_blob_spec.rb index 30e2d587267..9cacda84378 100644 --- a/spec/features/projects/blobs/shortcuts_blob_spec.rb +++ b/spec/features/projects/blobs/shortcuts_blob_spec.rb @@ -12,7 +12,7 @@ feature 'Blob shortcuts', feature: true do end def visit_blob(fragment = nil) - visit namespace_project_blob_path(project.namespace, project, tree_join('master', path), anchor: fragment) + visit project_blob_path(project, tree_join('master', path), anchor: fragment) end describe 'pressing "y"' do @@ -21,7 +21,7 @@ feature 'Blob shortcuts', feature: true do find('body').native.send_key('y') - expect(page).to have_current_path(get_absolute_url(namespace_project_blob_path(project.namespace, project, tree_join(sha, path))), url: true) + expect(page).to have_current_path(get_absolute_url(project_blob_path(project, tree_join(sha, path))), url: true) end it 'maintains fragment hash when redirecting' do @@ -30,7 +30,7 @@ feature 'Blob shortcuts', feature: true do find('body').native.send_key('y') - expect(page).to have_current_path(get_absolute_url(namespace_project_blob_path(project.namespace, project, tree_join(sha, path), anchor: fragment)), url: true) + expect(page).to have_current_path(get_absolute_url(project_blob_path(project, tree_join(sha, path), anchor: fragment)), url: true) end end end diff --git a/spec/features/projects/branches/download_buttons_spec.rb b/spec/features/projects/branches/download_buttons_spec.rb index d8c4d475a2c..52323c21112 100644 --- a/spec/features/projects/branches/download_buttons_spec.rb +++ b/spec/features/projects/branches/download_buttons_spec.rb @@ -29,13 +29,11 @@ feature 'Download buttons in branches page', feature: true do describe 'when checking branches' do context 'with artifacts' do before do - visit namespace_project_branches_path(project.namespace, project) + visit project_branches_path(project) end scenario 'shows download artifacts button' do - href = latest_succeeded_namespace_project_artifacts_path( - project.namespace, project, 'binary-encoding/download', - job: 'build') + href = latest_succeeded_project_artifacts_path(project, 'binary-encoding/download', job: 'build') expect(page).to have_link "Download '#{build.name}'", href: href end diff --git a/spec/features/projects/branches/new_branch_ref_dropdown_spec.rb b/spec/features/projects/branches/new_branch_ref_dropdown_spec.rb index 406fa52e723..ab9af8fa603 100644 --- a/spec/features/projects/branches/new_branch_ref_dropdown_spec.rb +++ b/spec/features/projects/branches/new_branch_ref_dropdown_spec.rb @@ -9,7 +9,7 @@ describe 'New Branch Ref Dropdown', :js, :feature do project.add_master(user) gitlab_sign_in(user) - visit new_namespace_project_branch_path(project.namespace, project) + visit new_project_branch_path(project) end it 'filters a list of branches and tags' do diff --git a/spec/features/projects/branches_spec.rb b/spec/features/projects/branches_spec.rb index 0050864d305..4fae324d8d5 100644 --- a/spec/features/projects/branches_spec.rb +++ b/spec/features/projects/branches_spec.rb @@ -19,7 +19,7 @@ describe 'Branches', feature: true do describe 'Initial branches page' do it 'shows all the branches' do - visit namespace_project_branches_path(project.namespace, project) + visit project_branches_path(project) repository.branches_sorted_by(:name).first(20).each do |branch| expect(page).to have_content("#{branch.name}") @@ -28,7 +28,7 @@ describe 'Branches', feature: true do end it 'sorts the branches by name' do - visit namespace_project_branches_path(project.namespace, project) + visit project_branches_path(project) click_button "Name" # Open sorting dropdown click_link "Name" @@ -40,7 +40,7 @@ describe 'Branches', feature: true do end it 'sorts the branches by last updated' do - visit namespace_project_branches_path(project.namespace, project) + visit project_branches_path(project) click_button "Name" # Open sorting dropdown click_link "Last updated" @@ -52,7 +52,7 @@ describe 'Branches', feature: true do end it 'sorts the branches by oldest updated' do - visit namespace_project_branches_path(project.namespace, project) + visit project_branches_path(project) click_button "Name" # Open sorting dropdown click_link "Oldest updated" @@ -64,17 +64,17 @@ describe 'Branches', feature: true do end it 'avoids a N+1 query in branches index' do - control_count = ActiveRecord::QueryRecorder.new { visit namespace_project_branches_path(project.namespace, project) }.count + control_count = ActiveRecord::QueryRecorder.new { visit project_branches_path(project) }.count %w(one two three four five).each { |ref| repository.add_branch(user, ref, 'master') } - expect { visit namespace_project_branches_path(project.namespace, project) }.not_to exceed_query_limit(control_count) + expect { visit project_branches_path(project) }.not_to exceed_query_limit(control_count) end end describe 'Find branches' do it 'shows filtered branches', js: true do - visit namespace_project_branches_path(project.namespace, project) + visit project_branches_path(project) fill_in 'branch-search', with: 'fix' find('#branch-search').native.send_keys(:enter) @@ -86,7 +86,7 @@ describe 'Branches', feature: true do describe 'Delete unprotected branch' do it 'removes branch after confirmation', js: true do - visit namespace_project_branches_path(project.namespace, project) + visit project_branches_path(project) fill_in 'branch-search', with: 'fix' @@ -104,7 +104,7 @@ describe 'Branches', feature: true do describe 'Delete protected branch' do before do project.add_user(user, :master) - visit namespace_project_protected_branches_path(project.namespace, project) + visit project_protected_branches_path(project) set_protected_branch_name('fix') click_on "Protect" @@ -114,7 +114,7 @@ describe 'Branches', feature: true do end it 'does not allow devleoper to removes protected branch', js: true do - visit namespace_project_branches_path(project.namespace, project) + visit project_branches_path(project) fill_in 'branch-search', with: 'fix' find('#branch-search').native.send_keys(:enter) @@ -132,7 +132,7 @@ describe 'Branches', feature: true do describe 'Delete protected branch' do before do - visit namespace_project_protected_branches_path(project.namespace, project) + visit project_protected_branches_path(project) set_protected_branch_name('fix') click_on "Protect" @@ -141,7 +141,7 @@ describe 'Branches', feature: true do end it 'removes branch after modal confirmation', js: true do - visit namespace_project_branches_path(project.namespace, project) + visit project_branches_path(project) fill_in 'branch-search', with: 'fix' find('#branch-search').native.send_keys(:enter) @@ -164,7 +164,7 @@ describe 'Branches', feature: true do context 'logged out' do before do - visit namespace_project_branches_path(project.namespace, project) + visit project_branches_path(project) end it 'does not show merge request button' do diff --git a/spec/features/projects/commit/builds_spec.rb b/spec/features/projects/commit/builds_spec.rb index e5b1f95f2b9..69eeb8e285e 100644 --- a/spec/features/projects/commit/builds_spec.rb +++ b/spec/features/projects/commit/builds_spec.rb @@ -17,7 +17,7 @@ feature 'project commit pipelines', js: true do end scenario 'user views commit pipelines page' do - visit pipelines_namespace_project_commit_path(project.namespace, project, project.commit.sha) + visit pipelines_project_commit_path(project, project.commit.sha) page.within('.table-holder') do expect(page).to have_content project.pipelines[0].status # pipeline status diff --git a/spec/features/projects/commit/cherry_pick_spec.rb b/spec/features/projects/commit/cherry_pick_spec.rb index 0d3fa72fbf5..2d18add82b5 100644 --- a/spec/features/projects/commit/cherry_pick_spec.rb +++ b/spec/features/projects/commit/cherry_pick_spec.rb @@ -10,7 +10,7 @@ describe 'Cherry-pick Commits' do before do sign_in(user) project.team << [user, :master] - visit namespace_project_commit_path(project.namespace, project, master_pickable_commit.id) + visit project_commit_path(project, master_pickable_commit.id) end context "I cherry-pick a commit" do @@ -43,7 +43,7 @@ describe 'Cherry-pick Commits' do uncheck 'create_merge_request' click_button 'Cherry-pick' end - visit namespace_project_commit_path(project.namespace, project, master_pickable_commit.id) + visit project_commit_path(project, master_pickable_commit.id) find("a[href='#modal-cherry-pick-commit']").click page.within('#modal-cherry-pick-commit') do uncheck 'create_merge_request' diff --git a/spec/features/projects/commit/mini_pipeline_graph_spec.rb b/spec/features/projects/commit/mini_pipeline_graph_spec.rb index 570a7ae7b16..c8222326e91 100644 --- a/spec/features/projects/commit/mini_pipeline_graph_spec.rb +++ b/spec/features/projects/commit/mini_pipeline_graph_spec.rb @@ -22,7 +22,7 @@ feature 'Mini Pipeline Graph in Commit View', :js, :feature do before do build.run - visit namespace_project_commit_path(project.namespace, project, project.commit.id) + visit project_commit_path(project, project.commit.id) end it 'should display a mini pipeline graph' do @@ -43,7 +43,7 @@ feature 'Mini Pipeline Graph in Commit View', :js, :feature do context 'when commit does not have pipelines' do before do - visit namespace_project_commit_path(project.namespace, project, project.commit.id) + visit project_commit_path(project, project.commit.id) end it 'should not display a mini pipeline graph' do diff --git a/spec/features/projects/commit/rss_spec.rb b/spec/features/projects/commit/rss_spec.rb index f7548a56984..152c0d7c8de 100644 --- a/spec/features/projects/commit/rss_spec.rb +++ b/spec/features/projects/commit/rss_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' feature 'Project Commits RSS' do let(:project) { create(:project, :repository, visibility_level: Gitlab::VisibilityLevel::PUBLIC) } - let(:path) { namespace_project_commits_path(project.namespace, project, :master) } + let(:path) { project_commits_path(project, :master) } context 'when signed in' do before do diff --git a/spec/features/projects/compare_spec.rb b/spec/features/projects/compare_spec.rb index 4743d69fb75..c3adfa87c44 100644 --- a/spec/features/projects/compare_spec.rb +++ b/spec/features/projects/compare_spec.rb @@ -7,7 +7,7 @@ describe "Compare", js: true do before do project.team << [user, :master] gitlab_sign_in user - visit namespace_project_compare_index_path(project.namespace, project, from: "master", to: "master") + visit project_compare_index_path(project, from: "master", to: "master") end describe "branches" do diff --git a/spec/features/projects/deploy_keys_spec.rb b/spec/features/projects/deploy_keys_spec.rb index a31960639fe..a310d14be10 100644 --- a/spec/features/projects/deploy_keys_spec.rb +++ b/spec/features/projects/deploy_keys_spec.rb @@ -15,7 +15,7 @@ describe 'Project deploy keys', :js, :feature do end it 'removes association between project and deploy key' do - visit namespace_project_settings_repository_path(project.namespace, project) + visit project_settings_repository_path(project) page.within(find('.deploy-keys')) do expect(page).to have_selector('.deploy-keys li', count: 1) diff --git a/spec/features/projects/developer_views_empty_project_instructions_spec.rb b/spec/features/projects/developer_views_empty_project_instructions_spec.rb index a943f1e6a08..290dc1a2f79 100644 --- a/spec/features/projects/developer_views_empty_project_instructions_spec.rb +++ b/spec/features/projects/developer_views_empty_project_instructions_spec.rb @@ -47,7 +47,7 @@ feature 'Developer views empty project instructions', feature: true do end def visit_project - visit namespace_project_path(project.namespace, project) + visit project_path(project) end def select_protocol(protocol) diff --git a/spec/features/projects/diffs/diff_show_spec.rb b/spec/features/projects/diffs/diff_show_spec.rb index 48b7f1e0f34..b528b283495 100644 --- a/spec/features/projects/diffs/diff_show_spec.rb +++ b/spec/features/projects/diffs/diff_show_spec.rb @@ -4,7 +4,7 @@ feature 'Diff file viewer', :js, feature: true do let(:project) { create(:project, :public, :repository) } def visit_commit(sha, anchor: nil) - visit namespace_project_commit_path(project.namespace, project, sha, anchor: anchor) + visit project_commit_path(project, sha, anchor: anchor) wait_for_requests end diff --git a/spec/features/projects/edit_spec.rb b/spec/features/projects/edit_spec.rb index ca202b95a44..78c1a1f1d1a 100644 --- a/spec/features/projects/edit_spec.rb +++ b/spec/features/projects/edit_spec.rb @@ -8,7 +8,7 @@ feature 'Project edit', feature: true, js: true do project.team << [user, :master] gitlab_sign_in(user) - visit edit_namespace_project_path(project.namespace, project) + visit edit_project_path(project) end context 'feature visibility' do diff --git a/spec/features/projects/environments/environment_metrics_spec.rb b/spec/features/projects/environments/environment_metrics_spec.rb index a98a69a0fd6..841514ac707 100644 --- a/spec/features/projects/environments/environment_metrics_spec.rb +++ b/spec/features/projects/environments/environment_metrics_spec.rb @@ -32,8 +32,6 @@ feature 'Environment > Metrics', :feature do end def visit_environment(environment) - visit namespace_project_environment_path(environment.project.namespace, - environment.project, - environment) + visit project_environment_path(environment.project, environment) end end diff --git a/spec/features/projects/environments/environment_spec.rb b/spec/features/projects/environments/environment_spec.rb index 7d565555f1f..e3f40f8e661 100644 --- a/spec/features/projects/environments/environment_spec.rb +++ b/spec/features/projects/environments/environment_spec.rb @@ -114,7 +114,7 @@ feature 'Environment', :feature do before do # Stub #terminals as it causes js-enabled feature specs to render the page incorrectly allow_any_instance_of(Environment).to receive(:terminals) { nil } - visit terminal_namespace_project_environment_path(project.namespace, project, environment) + visit terminal_project_environment_path(project, environment) end it 'displays a web terminal' do @@ -194,9 +194,7 @@ feature 'Environment', :feature do name: 'staging-1.0/review', state: :available) - visit folder_namespace_project_environments_path(project.namespace, - project, - id: 'staging-1.0') + visit folder_project_environments_path(project, id: 'staging-1.0') end it 'renders a correct environment folder' do @@ -221,7 +219,7 @@ feature 'Environment', :feature do end scenario 'user deletes the branch with running environment' do - visit namespace_project_branches_path(project.namespace, project, search: 'feature') + visit project_branches_path(project, search: 'feature') remove_branch_with_hooks(project, user, 'feature') do page.within('.js-branch-feature') { find('a.btn-remove').click } @@ -249,12 +247,10 @@ feature 'Environment', :feature do end def visit_environment(environment) - visit namespace_project_environment_path(environment.project.namespace, - environment.project, - environment) + visit project_environment_path(environment.project, environment) end def have_terminal_button - have_link(nil, href: terminal_namespace_project_environment_path(project.namespace, project, environment)) + have_link(nil, href: terminal_project_environment_path(project, environment)) end end diff --git a/spec/features/projects/environments/environments_spec.rb b/spec/features/projects/environments/environments_spec.rb index cf4d996a32d..af3af3eb965 100644 --- a/spec/features/projects/environments/environments_spec.rb +++ b/spec/features/projects/environments/environments_spec.rb @@ -29,7 +29,7 @@ feature 'Environments page', :feature, :js do describe 'in available tab page' do it 'should show one environment' do - visit namespace_project_environments_path(project.namespace, project, scope: 'available') + visit project_environments_path(project, scope: 'available') expect(page).to have_css('.environments-container') expect(page.all('.environment-name').length).to eq(1) end @@ -37,7 +37,7 @@ feature 'Environments page', :feature, :js do describe 'in stopped tab page' do it 'should show no environments' do - visit namespace_project_environments_path(project.namespace, project, scope: 'stopped') + visit project_environments_path(project, scope: 'stopped') expect(page).to have_css('.environments-container') expect(page).to have_content('You don\'t have any environments right now') end @@ -49,7 +49,7 @@ feature 'Environments page', :feature, :js do describe 'in available tab page' do it 'should show no environments' do - visit namespace_project_environments_path(project.namespace, project, scope: 'available') + visit project_environments_path(project, scope: 'available') expect(page).to have_css('.environments-container') expect(page).to have_content('You don\'t have any environments right now') end @@ -57,7 +57,7 @@ feature 'Environments page', :feature, :js do describe 'in stopped tab page' do it 'should show one environment' do - visit namespace_project_environments_path(project.namespace, project, scope: 'stopped') + visit project_environments_path(project, scope: 'stopped') expect(page).to have_css('.environments-container') expect(page.all('.environment-name').length).to eq(1) end @@ -277,10 +277,10 @@ feature 'Environments page', :feature, :js do end def have_terminal_button - have_link(nil, href: terminal_namespace_project_environment_path(project.namespace, project, environment)) + have_link(nil, href: terminal_project_environment_path(project, environment)) end def visit_environments(project) - visit namespace_project_environments_path(project.namespace, project) + visit project_environments_path(project) end end diff --git a/spec/features/projects/features_visibility_spec.rb b/spec/features/projects/features_visibility_spec.rb index db2790a4bce..45b0c8d1a18 100644 --- a/spec/features/projects/features_visibility_spec.rb +++ b/spec/features/projects/features_visibility_spec.rb @@ -17,7 +17,7 @@ describe 'Edit Project Settings', feature: true do tools.each do |tool_name, shortcut_name| describe "feature #{tool_name}" do it 'toggles visibility' do - visit edit_namespace_project_path(project.namespace, project) + visit edit_project_path(project) select 'Disabled', from: "project_project_feature_attributes_#{tool_name}_access_level" click_button 'Save changes' @@ -44,7 +44,7 @@ describe 'Edit Project Settings', feature: true do project.project_feature.update(issues_access_level: ProjectFeature::DISABLED) allow_any_instance_of(Project).to receive(:external_issue_tracker).and_return(JiraService.new) - visit namespace_project_path(project.namespace, project) + visit project_path(project) expect(page).to have_selector(".shortcuts-issues") end @@ -52,7 +52,7 @@ describe 'Edit Project Settings', feature: true do context "pipelines subtabs" do it "shows builds when enabled" do - visit namespace_project_pipelines_path(project.namespace, project) + visit project_pipelines_path(project) expect(page).to have_selector(".shortcuts-builds") end @@ -60,7 +60,7 @@ describe 'Edit Project Settings', feature: true do it "hides builds when disabled" do allow(Ability).to receive(:allowed?).with(member, :read_builds, project).and_return(false) - visit namespace_project_pipelines_path(project.namespace, project) + visit project_pipelines_path(project) expect(page).not_to have_selector(".shortcuts-builds") end @@ -73,11 +73,11 @@ describe 'Edit Project Settings', feature: true do let(:tools) do { - builds: namespace_project_job_path(project.namespace, project, job), - issues: namespace_project_issues_path(project.namespace, project), - wiki: namespace_project_wiki_path(project.namespace, project, :home), - snippets: namespace_project_snippets_path(project.namespace, project), - merge_requests: namespace_project_merge_requests_path(project.namespace, project) + builds: project_job_path(project, job), + issues: project_issues_path(project), + wiki: project_wiki_path(project, :home), + snippets: project_snippets_path(project), + merge_requests: project_merge_requests_path(project) } end @@ -157,7 +157,7 @@ describe 'Edit Project Settings', feature: true do before do project.team << [member, :master] gitlab_sign_in(member) - visit edit_namespace_project_path(project.namespace, project) + visit edit_project_path(project) end it "disables repository related features" do @@ -174,7 +174,7 @@ describe 'Edit Project Settings', feature: true do click_button "Save changes" wait_for_requests - visit namespace_project_path(project.namespace, project) + visit project_path(project) expect(page).to have_content "Customize your workflow!" end @@ -187,7 +187,7 @@ describe 'Edit Project Settings', feature: true do click_button "Save changes" wait_for_requests - visit activity_namespace_project_path(project.namespace, project) + visit activity_project_path(project) page.within(".event-filter") do expect(page).to have_selector("a", count: 2) @@ -205,7 +205,7 @@ describe 'Edit Project Settings', feature: true do expect(page).to have_content("Comments") end - visit edit_namespace_project_path(project.namespace, project) + visit edit_project_path(project) select "Disabled", from: "project_project_feature_attributes_merge_requests_access_level" @@ -213,7 +213,7 @@ describe 'Edit Project Settings', feature: true do expect(page).to have_content("Comments") end - visit edit_namespace_project_path(project.namespace, project) + visit edit_project_path(project) select "Disabled", from: "project_project_feature_attributes_repository_access_level" @@ -221,14 +221,14 @@ describe 'Edit Project Settings', feature: true do expect(page).not_to have_content("Comments") end - visit edit_namespace_project_path(project.namespace, project) + visit edit_project_path(project) end def save_changes_and_check_activity_tab click_button "Save changes" wait_for_requests - visit activity_namespace_project_path(project.namespace, project) + visit activity_project_path(project) page.within(".event-filter") do yield @@ -243,7 +243,7 @@ describe 'Edit Project Settings', feature: true do before do project.team << [member, :guest] gitlab_sign_in(member) - visit namespace_project_path(project.namespace, project) + visit project_path(project) end it "does not show project statistic for guest" do diff --git a/spec/features/projects/files/browse_files_spec.rb b/spec/features/projects/files/browse_files_spec.rb index 34aef958ec6..ac2b926f4de 100644 --- a/spec/features/projects/files/browse_files_spec.rb +++ b/spec/features/projects/files/browse_files_spec.rb @@ -7,7 +7,7 @@ feature 'user browses project', feature: true, js: true do before do project.team << [user, :master] gitlab_sign_in(user) - visit namespace_project_tree_path(project.namespace, project, project.default_branch) + visit project_tree_path(project, project.default_branch) end scenario "can see blame of '.gitignore'" do diff --git a/spec/features/projects/files/creating_a_file_spec.rb b/spec/features/projects/files/creating_a_file_spec.rb index 2a1cc01fe68..c31056c3ff7 100644 --- a/spec/features/projects/files/creating_a_file_spec.rb +++ b/spec/features/projects/files/creating_a_file_spec.rb @@ -7,7 +7,7 @@ feature 'User wants to create a file', feature: true do background do project.team << [user, :master] gitlab_sign_in user - visit namespace_project_new_blob_path(project.namespace, project, project.default_branch) + visit project_new_blob_path(project, project.default_branch) end def submit_new_file(options) diff --git a/spec/features/projects/files/dockerfile_dropdown_spec.rb b/spec/features/projects/files/dockerfile_dropdown_spec.rb index 4f1b8588462..783d98dafa7 100644 --- a/spec/features/projects/files/dockerfile_dropdown_spec.rb +++ b/spec/features/projects/files/dockerfile_dropdown_spec.rb @@ -9,7 +9,7 @@ feature 'User wants to add a Dockerfile file', feature: true do gitlab_sign_in user - visit namespace_project_new_blob_path(project.namespace, project, 'master', file_name: 'Dockerfile') + visit project_new_blob_path(project, 'master', file_name: 'Dockerfile') end scenario 'user can see Dockerfile dropdown' do diff --git a/spec/features/projects/files/download_buttons_spec.rb b/spec/features/projects/files/download_buttons_spec.rb index 60182bfebe9..4f4fab8a6e5 100644 --- a/spec/features/projects/files/download_buttons_spec.rb +++ b/spec/features/projects/files/download_buttons_spec.rb @@ -29,14 +29,11 @@ feature 'Download buttons in files tree', feature: true do describe 'when files tree' do context 'with artifacts' do before do - visit namespace_project_tree_path( - project.namespace, project, project.default_branch) + visit project_tree_path(project, project.default_branch) end scenario 'shows download artifacts button' do - href = latest_succeeded_namespace_project_artifacts_path( - project.namespace, project, "#{project.default_branch}/download", - job: 'build') + href = latest_succeeded_project_artifacts_path(project, "#{project.default_branch}/download", job: 'build') expect(page).to have_link "Download '#{build.name}'", href: href 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 6e361ac4312..83aea070901 100644 --- a/spec/features/projects/files/edit_file_soft_wrap_spec.rb +++ b/spec/features/projects/files/edit_file_soft_wrap_spec.rb @@ -6,7 +6,7 @@ feature 'User uses soft wrap whilst editing file', feature: true, js: true do project = create(:project) project.team << [user, :master] gitlab_sign_in user - visit namespace_project_new_blob_path(project.namespace, project, 'master', file_name: 'test_file-name') + visit project_new_blob_path(project, 'master', file_name: 'test_file-name') editor = find('.file-editor.code') editor.click editor.send_keys 'Touch water with paw then recoil in horror chase dog then diff --git a/spec/features/projects/files/editing_a_file_spec.rb b/spec/features/projects/files/editing_a_file_spec.rb index e97ff5fded7..c9b0dbd0ffb 100644 --- a/spec/features/projects/files/editing_a_file_spec.rb +++ b/spec/features/projects/files/editing_a_file_spec.rb @@ -18,7 +18,7 @@ feature 'User wants to edit a file', feature: true do background do project.team << [user, :master] gitlab_sign_in user - visit namespace_project_edit_blob_path(project.namespace, project, + visit project_edit_blob_path(project, File.join(project.default_branch, '.gitignore')) end 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 83a837fba44..07b4aa80f4b 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 @@ -7,7 +7,7 @@ feature 'User views files page', feature: true do before do project.team << [user, :master] gitlab_sign_in user - visit namespace_project_tree_path(project.namespace, project, project.repository.root_ref) + visit project_tree_path(project, project.repository.root_ref) end scenario 'user sees folders and submodules sorted together, followed by files' do diff --git a/spec/features/projects/files/find_file_keyboard_spec.rb b/spec/features/projects/files/find_file_keyboard_spec.rb index 6a914820ac9..087eef5d407 100644 --- a/spec/features/projects/files/find_file_keyboard_spec.rb +++ b/spec/features/projects/files/find_file_keyboard_spec.rb @@ -8,7 +8,7 @@ feature 'Find file keyboard shortcuts', feature: true, js: true do project.team << [user, :master] gitlab_sign_in user - visit namespace_project_find_file_path(project.namespace, project, project.repository.root_ref) + visit project_find_file_path(project, project.repository.root_ref) wait_for_requests end diff --git a/spec/features/projects/files/find_files_spec.rb b/spec/features/projects/files/find_files_spec.rb index 166ec5c921b..d2ccc9a0732 100644 --- a/spec/features/projects/files/find_files_spec.rb +++ b/spec/features/projects/files/find_files_spec.rb @@ -10,20 +10,13 @@ feature 'Find files button in the tree header', feature: true do end scenario 'project main screen' do - visit namespace_project_path( - project.namespace, - project - ) + visit project_path(project) expect(page).to have_selector('.tree-controls .shortcuts-find-file') end scenario 'project tree screen' do - visit namespace_project_tree_path( - project.namespace, - project, - project.default_branch - ) + visit project_tree_path(project, project.default_branch) expect(page).to have_selector('.tree-controls .shortcuts-find-file') end diff --git a/spec/features/projects/files/gitignore_dropdown_spec.rb b/spec/features/projects/files/gitignore_dropdown_spec.rb index 7f02ec6b73d..23c145d0a11 100644 --- a/spec/features/projects/files/gitignore_dropdown_spec.rb +++ b/spec/features/projects/files/gitignore_dropdown_spec.rb @@ -6,7 +6,7 @@ feature 'User wants to add a .gitignore file', feature: true do project = create(:project) project.team << [user, :master] gitlab_sign_in user - visit namespace_project_new_blob_path(project.namespace, project, 'master', file_name: '.gitignore') + visit project_new_blob_path(project, 'master', file_name: '.gitignore') end scenario 'user can see .gitignore dropdown' do 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 f4b17c2518c..0539b77e3dd 100644 --- a/spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb +++ b/spec/features/projects/files/gitlab_ci_yml_dropdown_spec.rb @@ -6,7 +6,7 @@ feature 'User wants to add a .gitlab-ci.yml file', feature: true do project = create(:project) project.team << [user, :master] gitlab_sign_in user - visit namespace_project_new_blob_path(project.namespace, project, 'master', file_name: '.gitlab-ci.yml') + visit project_new_blob_path(project, 'master', file_name: '.gitlab-ci.yml') end scenario 'user can see .gitlab-ci.yml dropdown' do 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 7daf016dd22..3a4ed3d8cf0 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 @@ -8,11 +8,11 @@ feature 'project owner creates a license file', feature: true, js: true do message: 'Remove LICENSE', branch_name: 'master') project.team << [project_master, :master] gitlab_sign_in(project_master) - visit namespace_project_path(project.namespace, project) + visit project_path(project) end scenario 'project master creates a license file manually from a template' do - visit namespace_project_tree_path(project.namespace, project, project.repository.root_ref) + visit project_tree_path(project, project.repository.root_ref) find('.add-to-tree').click click_link 'New file' @@ -30,7 +30,7 @@ feature 'project owner creates a license file', feature: true, js: true do click_button 'Commit changes' expect(current_path).to eq( - namespace_project_blob_path(project.namespace, project, 'master/LICENSE')) + project_blob_path(project, 'master/LICENSE')) expect(page).to have_content('MIT License') expect(page).to have_content("Copyright (c) #{Time.now.year} #{project.namespace.human_name}") end @@ -40,7 +40,7 @@ feature 'project owner creates a license file', feature: true, js: true do expect(page).to have_content('New file') expect(current_path).to eq( - namespace_project_new_blob_path(project.namespace, project, 'master')) + project_new_blob_path(project, 'master')) expect(find('#file_name').value).to eq('LICENSE') expect(page).to have_selector('.license-selector') @@ -54,7 +54,7 @@ feature 'project owner creates a license file', feature: true, js: true do click_button 'Commit changes' expect(current_path).to eq( - namespace_project_blob_path(project.namespace, project, 'master/LICENSE')) + project_blob_path(project, 'master/LICENSE')) expect(page).to have_content('MIT License') expect(page).to have_content("Copyright (c) #{Time.now.year} #{project.namespace.human_name}") end 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 eab19d52030..77f97826427 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 @@ -9,13 +9,13 @@ feature 'project owner sees a link to create a license file in empty project', f end scenario 'project master creates a license file from a template' do - visit namespace_project_path(project.namespace, project) + visit project_path(project) click_link 'Create empty bare repository' click_on 'LICENSE' expect(page).to have_content('New file') expect(current_path).to eq( - namespace_project_new_blob_path(project.namespace, project, 'master')) + project_new_blob_path(project, 'master')) expect(find('#file_name').value).to eq('LICENSE') expect(page).to have_selector('.license-selector') @@ -31,7 +31,7 @@ feature 'project owner sees a link to create a license file in empty project', f click_button 'Commit changes' expect(current_path).to eq( - namespace_project_blob_path(project.namespace, project, 'master/LICENSE')) + project_blob_path(project, 'master/LICENSE')) expect(page).to have_content('MIT License') expect(page).to have_content("Copyright (c) #{Time.now.year} #{project.namespace.human_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 028a0919640..53b673538e5 100644 --- a/spec/features/projects/files/template_type_dropdown_spec.rb +++ b/spec/features/projects/files/template_type_dropdown_spec.rb @@ -31,7 +31,7 @@ feature 'Template type dropdown selector', js: true do context 'editing a matching file' do before do - visit namespace_project_edit_blob_path(project.namespace, project, File.join(project.default_branch, 'LICENSE')) + visit project_edit_blob_path(project, File.join(project.default_branch, 'LICENSE')) end scenario 'displayed' do @@ -61,7 +61,7 @@ feature 'Template type dropdown selector', js: true do context 'creating a matching file' do before do - visit namespace_project_new_blob_path(project.namespace, project, 'master', file_name: '.gitignore') + visit project_new_blob_path(project, 'master', file_name: '.gitignore') end scenario 'is displayed' do @@ -79,7 +79,7 @@ feature 'Template type dropdown selector', js: true do context 'creating a file' do before do - visit namespace_project_new_blob_path(project.namespace, project, project.default_branch) + visit project_new_blob_path(project, project.default_branch) end scenario 'type selector is shown' do @@ -129,7 +129,7 @@ def check_type_selector_toggle_text(template_type) end def create_and_edit_file(file_name) - visit namespace_project_new_blob_path(project.namespace, project, 'master', file_name: file_name) + visit project_new_blob_path(project, 'master', file_name: file_name) click_button "Commit changes" - visit namespace_project_edit_blob_path(project.namespace, project, File.join(project.default_branch, file_name)) + visit project_edit_blob_path(project, File.join(project.default_branch, file_name)) end diff --git a/spec/features/projects/files/undo_template_spec.rb b/spec/features/projects/files/undo_template_spec.rb index 4ccd123f46e..e18ff42942f 100644 --- a/spec/features/projects/files/undo_template_spec.rb +++ b/spec/features/projects/files/undo_template_spec.rb @@ -11,7 +11,7 @@ feature 'Template Undo Button', js: true do context 'editing a matching file and applying a template' do before do - visit namespace_project_edit_blob_path(project.namespace, project, File.join(project.default_branch, "LICENSE")) + visit project_edit_blob_path(project, File.join(project.default_branch, "LICENSE")) select_file_template('.js-license-selector', 'Apache License 2.0') end @@ -22,7 +22,7 @@ feature 'Template Undo Button', js: true do context 'creating a non-matching file' do before do - visit namespace_project_new_blob_path(project.namespace, project, 'master') + visit project_new_blob_path(project, 'master') select_file_template_type('LICENSE') select_file_template('.js-license-selector', 'Apache License 2.0') end diff --git a/spec/features/projects/gfm_autocomplete_load_spec.rb b/spec/features/projects/gfm_autocomplete_load_spec.rb index aa4ed217a34..a8661ad4d24 100644 --- a/spec/features/projects/gfm_autocomplete_load_spec.rb +++ b/spec/features/projects/gfm_autocomplete_load_spec.rb @@ -6,7 +6,7 @@ describe 'GFM autocomplete loading', feature: true, js: true do before do gitlab_sign_in :admin - visit namespace_project_path(project.namespace, project) + visit project_path(project) end it 'does not load on project#show' do @@ -14,7 +14,7 @@ describe 'GFM autocomplete loading', feature: true, js: true do end it 'loads on new issue page' do - visit new_namespace_project_issue_path(project.namespace, project) + visit new_project_issue_path(project) expect(evaluate_script('gl.GfmAutoComplete.dataSources')).not_to eq({}) end diff --git a/spec/features/projects/group_links_spec.rb b/spec/features/projects/group_links_spec.rb index 778f5d61ae3..64415ffe57f 100644 --- a/spec/features/projects/group_links_spec.rb +++ b/spec/features/projects/group_links_spec.rb @@ -14,7 +14,7 @@ feature 'Project group links', :feature, :js do context 'setting an expiration date for a group link' do before do - visit namespace_project_settings_members_path(project.namespace, project) + visit project_settings_members_path(project) click_on 'share-with-group-tab' @@ -43,7 +43,7 @@ feature 'Project group links', :feature, :js do end it 'does not show ancestors', :nested_groups do - visit namespace_project_settings_members_path(project.namespace, project) + visit project_settings_members_path(project) click_on 'share-with-group-tab' click_link 'Search for a group' @@ -61,7 +61,7 @@ feature 'Project group links', :feature, :js do group.add_owner(master) group_two.add_owner(master) - visit namespace_project_settings_members_path(project.namespace, project) + visit project_settings_members_path(project) execute_script 'GroupsSelect.PER_PAGE = 1;' open_select2 '#link_group_id' end diff --git a/spec/features/projects/guest_navigation_menu_spec.rb b/spec/features/projects/guest_navigation_menu_spec.rb index e1f7f06c113..f6e24a0aa31 100644 --- a/spec/features/projects/guest_navigation_menu_spec.rb +++ b/spec/features/projects/guest_navigation_menu_spec.rb @@ -11,7 +11,7 @@ describe 'Guest navigation menu' do end it 'shows allowed tabs only' do - visit namespace_project_path(project.namespace, project) + visit project_path(project) within('.layout-nav') do expect(page).to have_content 'Project' @@ -25,7 +25,7 @@ describe 'Guest navigation menu' do end it 'does not show fork button' do - visit namespace_project_path(project.namespace, project) + visit project_path(project) within('.count-buttons') do expect(page).not_to have_link 'Fork' @@ -33,7 +33,7 @@ describe 'Guest navigation menu' do end it 'does not show clone path' do - visit namespace_project_path(project.namespace, project) + visit project_path(project) within('.project-repo-buttons') do expect(page).not_to have_selector '.project-clone-holder' @@ -49,7 +49,7 @@ describe 'Guest navigation menu' do end it 'does not show the project file list landing page' do - visit namespace_project_path(project.namespace, project) + visit project_path(project) expect(page).not_to have_selector '.project-stats' expect(page).not_to have_selector '.project-last-commit' @@ -58,7 +58,7 @@ describe 'Guest navigation menu' do end it 'shows the customize workflow when issues and wiki are disabled' do - visit namespace_project_path(project.namespace, project) + visit project_path(project) expect(page).to have_selector '.project-show-customize_workflow' end @@ -66,7 +66,7 @@ describe 'Guest navigation menu' do it 'shows the wiki when enabled' do project.project_feature.update!(wiki_access_level: ProjectFeature::PRIVATE) - visit namespace_project_path(project.namespace, project) + visit project_path(project) expect(page).to have_selector '.project-show-wiki' end @@ -74,7 +74,7 @@ describe 'Guest navigation menu' do it 'shows the issues when enabled' do project.project_feature.update!(issues_access_level: ProjectFeature::PRIVATE) - visit namespace_project_path(project.namespace, project) + visit project_path(project) expect(page).to have_selector '.issues-list' end diff --git a/spec/features/projects/import_export/export_file_spec.rb b/spec/features/projects/import_export/export_file_spec.rb index b5c64777934..b7f0ad9197e 100644 --- a/spec/features/projects/import_export/export_file_spec.rb +++ b/spec/features/projects/import_export/export_file_spec.rb @@ -37,13 +37,13 @@ feature 'Import/Export - project export integration test', feature: true, js: tr end scenario 'exports a project successfully' do - visit edit_namespace_project_path(project.namespace, project) + visit edit_project_path(project) expect(page).to have_content('Export project') click_link 'Export project' - visit edit_namespace_project_path(project.namespace, project) + visit edit_project_path(project) expect(page).to have_content('Download export') diff --git a/spec/features/projects/import_export/namespace_export_file_spec.rb b/spec/features/projects/import_export/namespace_export_file_spec.rb index b0a68f0d61f..f12b28f05fc 100644 --- a/spec/features/projects/import_export/namespace_export_file_spec.rb +++ b/spec/features/projects/import_export/namespace_export_file_spec.rb @@ -48,13 +48,13 @@ feature 'Import/Export - Namespace export file cleanup', feature: true, js: true end def setup_export_project - visit edit_namespace_project_path(project.namespace, project) + visit edit_project_path(project) expect(page).to have_content('Export project') click_link 'Export project' - visit edit_namespace_project_path(project.namespace, project) + visit edit_project_path(project) expect(page).to have_content('Download export') end diff --git a/spec/features/projects/issuable_templates_spec.rb b/spec/features/projects/issuable_templates_spec.rb index 26a09985312..83d1dfd91a9 100644 --- a/spec/features/projects/issuable_templates_spec.rb +++ b/spec/features/projects/issuable_templates_spec.rb @@ -28,7 +28,7 @@ feature 'issuable templates', feature: true, js: true do longtemplate_content, message: 'added issue template', branch_name: 'master') - visit edit_namespace_project_issue_path project.namespace, project, issue + visit edit_project_issue_path project, issue fill_in :'issue[title]', with: 'test issue title' end @@ -81,7 +81,7 @@ feature 'issuable templates', feature: true, js: true do template_content, message: 'added issue template', branch_name: 'master') - visit edit_namespace_project_issue_path project.namespace, project, issue + visit edit_project_issue_path project, issue fill_in :'issue[title]', with: 'test issue title' fill_in :'issue[description]', with: prior_description end @@ -105,7 +105,7 @@ feature 'issuable templates', feature: true, js: true do template_content, message: 'added merge request template', branch_name: 'master') - visit edit_namespace_project_merge_request_path project.namespace, project, merge_request + visit edit_project_merge_request_path project, merge_request fill_in :'merge_request[title]', with: 'test merge request title' end @@ -135,7 +135,7 @@ feature 'issuable templates', feature: true, js: true do template_content, message: 'added merge request template', branch_name: 'master') - visit edit_namespace_project_merge_request_path project.namespace, project, merge_request + visit edit_project_merge_request_path project, merge_request fill_in :'merge_request[title]', with: 'test merge request title' end diff --git a/spec/features/projects/issues/list_spec.rb b/spec/features/projects/issues/list_spec.rb index b2db07a75ef..380ade24a32 100644 --- a/spec/features/projects/issues/list_spec.rb +++ b/spec/features/projects/issues/list_spec.rb @@ -13,7 +13,7 @@ feature 'Issues List' do scenario 'user does not see create new list button' do create(:issue, project: project) - visit namespace_project_issues_path(project.namespace, project) + visit project_issues_path(project) expect(page).not_to have_selector('.js-new-board-list') end diff --git a/spec/features/projects/issues/rss_spec.rb b/spec/features/projects/issues/rss_spec.rb index 38733d39932..d68606ab545 100644 --- a/spec/features/projects/issues/rss_spec.rb +++ b/spec/features/projects/issues/rss_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' feature 'Project Issues RSS' do let(:project) { create(:empty_project, visibility_level: Gitlab::VisibilityLevel::PUBLIC) } - let(:path) { namespace_project_issues_path(project.namespace, project) } + let(:path) { project_issues_path(project) } before do create(:issue, project: project) diff --git a/spec/features/projects/jobs_spec.rb b/spec/features/projects/jobs_spec.rb index 070cdbf1cef..e52151e9585 100644 --- a/spec/features/projects/jobs_spec.rb +++ b/spec/features/projects/jobs_spec.rb @@ -5,7 +5,6 @@ feature 'Jobs', :feature do let(:user) { create(:user) } let(:user_access_level) { :developer } let(:project) { create(:project) } - let(:namespace) { project.namespace } let(:pipeline) { create(:ci_pipeline, project: project) } let(:job) { create(:ci_build, :trace, pipeline: pipeline) } @@ -25,7 +24,7 @@ feature 'Jobs', :feature do context "Pending scope" do before do - visit namespace_project_jobs_path(project.namespace, project, scope: :pending) + visit project_jobs_path(project, scope: :pending) end it "shows Pending tab jobs" do @@ -40,7 +39,7 @@ feature 'Jobs', :feature do context "Running scope" do before do job.run! - visit namespace_project_jobs_path(project.namespace, project, scope: :running) + visit project_jobs_path(project, scope: :running) end it "shows Running tab jobs" do @@ -55,7 +54,7 @@ feature 'Jobs', :feature do context "Finished scope" do before do job.run! - visit namespace_project_jobs_path(project.namespace, project, scope: :finished) + visit project_jobs_path(project, scope: :finished) end it "shows Finished tab jobs" do @@ -68,7 +67,7 @@ feature 'Jobs', :feature do context "All jobs" do before do project.builds.running_or_pending.each(&:success) - visit namespace_project_jobs_path(project.namespace, project) + visit project_jobs_path(project) end it "shows All tab jobs" do @@ -82,7 +81,7 @@ feature 'Jobs', :feature do context "when visiting old URL" do let(:jobs_url) do - namespace_project_jobs_path(project.namespace, project) + project_jobs_path(project) end before do @@ -98,7 +97,7 @@ feature 'Jobs', :feature do describe "POST /:project/jobs/:id/cancel_all" do before do job.run! - visit namespace_project_jobs_path(project.namespace, project) + visit project_jobs_path(project) click_link "Cancel running" end @@ -117,7 +116,7 @@ feature 'Jobs', :feature do let(:job) { create(:ci_build, :success, pipeline: pipeline) } before do - visit namespace_project_job_path(project.namespace, project, job) + visit project_job_path(project, job) end it 'shows status name', :js do @@ -140,7 +139,7 @@ feature 'Jobs', :feature do let(:job) { create(:ci_build, :success, pipeline: pipeline) } before do - visit namespace_project_job_path(project.namespace, project, job) + visit project_job_path(project, job) end it 'shows retry button' do @@ -157,7 +156,7 @@ feature 'Jobs', :feature do let(:job) { create(:ci_build, :failed, pipeline: pipeline) } before do - visit namespace_project_job_path(namespace, project, job) + visit project_job_path(project, job) end it 'shows New issue button' do @@ -166,10 +165,10 @@ feature 'Jobs', :feature do it 'links to issues/new with the title and description filled in' do button_title = "Build Failed ##{job.id}" - job_path = namespace_project_job_path(namespace, project, job) + job_path = project_job_path(project, job) options = { issue: { title: button_title, description: job_path } } - href = new_namespace_project_issue_path(namespace, project, options) + href = new_project_issue_path(project, options) page.within('.header-action-buttons') do expect(find('.js-new-issue')['href']).to include(href) @@ -180,7 +179,7 @@ feature 'Jobs', :feature do context "Job from other project" do before do - visit namespace_project_job_path(project.namespace, project, job2) + visit project_job_path(project, job2) end it { expect(page.status_code).to eq(404) } @@ -189,7 +188,7 @@ feature 'Jobs', :feature do context "Download artifacts" do before do job.update_attributes(artifacts_file: artifacts_file) - visit namespace_project_job_path(project.namespace, project, job) + visit project_job_path(project, job) end it 'has button to download artifacts' do @@ -202,7 +201,7 @@ feature 'Jobs', :feature do job.update_attributes(artifacts_file: artifacts_file, artifacts_expire_at: expire_at) - visit namespace_project_job_path(project.namespace, project, job) + visit project_job_path(project, job) end context 'no expire date defined' do @@ -248,7 +247,7 @@ feature 'Jobs', :feature do context "when visiting old URL" do let(:job_url) do - namespace_project_job_path(project.namespace, project, job) + project_job_path(project, job) end before do @@ -264,7 +263,7 @@ feature 'Jobs', :feature do before do job.run! - visit namespace_project_job_path(project.namespace, project, job) + visit project_job_path(project, job) end it do @@ -276,7 +275,7 @@ feature 'Jobs', :feature do before do job.run! - visit namespace_project_job_path(project.namespace, project, job) + visit project_job_path(project, job) end context 'when job has an initial trace' do @@ -300,7 +299,7 @@ feature 'Jobs', :feature do end before do - visit namespace_project_job_path(project.namespace, project, job) + visit project_job_path(project, job) end it 'shows variable key and value after click', js: true do @@ -325,7 +324,7 @@ feature 'Jobs', :feature do let(:job) { create(:ci_build, :success, environment: environment.name, deployments: [deployment], pipeline: pipeline) } it 'shows a link for the job' do - visit namespace_project_job_path(project.namespace, project, job) + visit project_job_path(project, job) expect(page).to have_link environment.name end @@ -335,7 +334,7 @@ feature 'Jobs', :feature do let(:job) { create(:ci_build, :failed, environment: environment.name, pipeline: pipeline) } it 'shows a link for the job' do - visit namespace_project_job_path(project.namespace, project, job) + visit project_job_path(project, job) expect(page).to have_link environment.name end @@ -346,7 +345,7 @@ feature 'Jobs', :feature do let(:job) { create(:ci_build, :success, environment: environment.name, pipeline: pipeline) } it 'shows a link to latest deployment' do - visit namespace_project_job_path(project.namespace, project, job) + visit project_job_path(project, job) expect(page).to have_link('latest deployment') end @@ -358,7 +357,7 @@ feature 'Jobs', :feature do context "Job from project" do before do job.run! - visit namespace_project_job_path(project.namespace, project, job) + visit project_job_path(project, job) find('.js-cancel-job').click() end @@ -373,7 +372,7 @@ feature 'Jobs', :feature do context "Job from project", :js do before do job.run! - visit namespace_project_job_path(project.namespace, project, job) + visit project_job_path(project, job) find('.js-cancel-job').click() find('.js-retry-button').trigger('click') end @@ -394,7 +393,7 @@ feature 'Jobs', :feature do gitlab_sign_out_direct gitlab_sign_in(create(:user)) - visit namespace_project_job_path(project.namespace, project, job) + visit project_job_path(project, job) end it 'does not show the Retry button' do @@ -408,14 +407,14 @@ feature 'Jobs', :feature do describe "GET /:project/jobs/:id/download" do before do job.update_attributes(artifacts_file: artifacts_file) - visit namespace_project_job_path(project.namespace, project, job) + visit project_job_path(project, job) click_link 'Download' end context "Build from other project" do before do job2.update_attributes(artifacts_file: artifacts_file) - visit download_namespace_project_job_artifacts_path(project.namespace, project, job2) + visit download_project_job_artifacts_path(project, job2) end it { expect(page.status_code).to eq(404) } @@ -428,7 +427,7 @@ feature 'Jobs', :feature do before do Capybara.current_session.driver.headers = { 'X-Sendfile-Type' => 'X-Sendfile' } job.run! - visit namespace_project_job_path(project.namespace, project, job) + visit project_job_path(project, job) find('.js-raw-link-controller').click() end @@ -443,7 +442,7 @@ feature 'Jobs', :feature do before do Capybara.current_session.driver.headers = { 'X-Sendfile-Type' => 'X-Sendfile' } job2.run! - visit raw_namespace_project_job_path(project.namespace, project, job2) + visit raw_project_job_path(project, job2) end it 'sends the right headers' do @@ -467,7 +466,7 @@ feature 'Jobs', :feature do .to receive(:paths) .and_return([existing_file]) - visit namespace_project_job_path(namespace, project, job) + visit project_job_path(project, job) find('.js-raw-link-controller').click end @@ -485,7 +484,7 @@ feature 'Jobs', :feature do .to receive(:paths) .and_return([]) - visit namespace_project_job_path(namespace, project, job) + visit project_job_path(project, job) end it 'sends the right headers' do @@ -496,7 +495,7 @@ feature 'Jobs', :feature do context "when visiting old URL" do let(:raw_job_url) do - raw_namespace_project_job_path(project.namespace, project, job) + raw_project_job_path(project, job) end before do @@ -512,7 +511,7 @@ feature 'Jobs', :feature do describe "GET /:project/jobs/:id/trace.json" do context "Job from project" do before do - visit trace_namespace_project_job_path(project.namespace, project, job, format: :json) + visit trace_project_job_path(project, job, format: :json) end it { expect(page.status_code).to eq(200) } @@ -520,7 +519,7 @@ feature 'Jobs', :feature do context "Job from other project" do before do - visit trace_namespace_project_job_path(project.namespace, project, job2, format: :json) + visit trace_project_job_path(project, job2, format: :json) end it { expect(page.status_code).to eq(404) } @@ -530,7 +529,7 @@ feature 'Jobs', :feature do describe "GET /:project/jobs/:id/status" do context "Job from project" do before do - visit status_namespace_project_job_path(project.namespace, project, job) + visit status_project_job_path(project, job) end it { expect(page.status_code).to eq(200) } @@ -538,7 +537,7 @@ feature 'Jobs', :feature do context "Job from other project" do before do - visit status_namespace_project_job_path(project.namespace, project, job2) + visit status_project_job_path(project, job2) end it { expect(page.status_code).to eq(404) } diff --git a/spec/features/projects/labels/issues_sorted_by_priority_spec.rb b/spec/features/projects/labels/issues_sorted_by_priority_spec.rb index 2c47758f30e..89e31a72869 100644 --- a/spec/features/projects/labels/issues_sorted_by_priority_spec.rb +++ b/spec/features/projects/labels/issues_sorted_by_priority_spec.rb @@ -29,7 +29,7 @@ feature 'Issue prioritization', feature: true do issue_1.labels << label_5 gitlab_sign_in user - visit namespace_project_issues_path(project.namespace, project, sort: 'label_priority') + visit project_issues_path(project, sort: 'label_priority') # Ensure we are indicating that issues are sorted by priority expect(page).to have_selector('.dropdown-toggle', text: 'Label priority') @@ -68,7 +68,7 @@ feature 'Issue prioritization', feature: true do issue_6.labels << label_5 # 8 - No priority gitlab_sign_in user - visit namespace_project_issues_path(project.namespace, project, sort: 'label_priority') + visit project_issues_path(project, sort: 'label_priority') expect(page).to have_selector('.dropdown-toggle', text: 'Label priority') diff --git a/spec/features/projects/labels/subscription_spec.rb b/spec/features/projects/labels/subscription_spec.rb index 584dc294f05..04617bfe03e 100644 --- a/spec/features/projects/labels/subscription_spec.rb +++ b/spec/features/projects/labels/subscription_spec.rb @@ -14,7 +14,7 @@ feature 'Labels subscription', feature: true do end scenario 'users can subscribe/unsubscribe to labels', js: true do - visit namespace_project_labels_path(project.namespace, project) + visit project_labels_path(project) expect(page).to have_content('bug') expect(page).to have_content('feature') @@ -55,7 +55,7 @@ feature 'Labels subscription', feature: true do context 'when not signed in' do it 'users can not subscribe/unsubscribe to labels' do - visit namespace_project_labels_path(project.namespace, project) + visit project_labels_path(project) expect(page).to have_content 'bug' expect(page).to have_content 'feature' diff --git a/spec/features/projects/labels/update_prioritization_spec.rb b/spec/features/projects/labels/update_prioritization_spec.rb index 589bfb9fbc9..034613ea6be 100644 --- a/spec/features/projects/labels/update_prioritization_spec.rb +++ b/spec/features/projects/labels/update_prioritization_spec.rb @@ -18,7 +18,7 @@ feature 'Prioritize labels', feature: true do end scenario 'user can prioritize a group label', js: true do - visit namespace_project_labels_path(project.namespace, project) + visit project_labels_path(project) expect(page).to have_content('Star labels to start sorting by priority') @@ -37,7 +37,7 @@ feature 'Prioritize labels', feature: true do scenario 'user can unprioritize a group label', js: true do create(:label_priority, project: project, label: feature, priority: 1) - visit namespace_project_labels_path(project.namespace, project) + visit project_labels_path(project) page.within('.prioritized-labels') do expect(page).to have_content('feature') @@ -53,7 +53,7 @@ feature 'Prioritize labels', feature: true do end scenario 'user can prioritize a project label', js: true do - visit namespace_project_labels_path(project.namespace, project) + visit project_labels_path(project) expect(page).to have_content('Star labels to start sorting by priority') @@ -72,7 +72,7 @@ feature 'Prioritize labels', feature: true do scenario 'user can unprioritize a project label', js: true do create(:label_priority, project: project, label: bug, priority: 1) - visit namespace_project_labels_path(project.namespace, project) + visit project_labels_path(project) page.within('.prioritized-labels') do expect(page).to have_content('bug') @@ -92,7 +92,7 @@ feature 'Prioritize labels', feature: true do create(:label_priority, project: project, label: bug, priority: 1) create(:label_priority, project: project, label: feature, priority: 2) - visit namespace_project_labels_path(project.namespace, project) + visit project_labels_path(project) expect(page).to have_content 'bug' expect(page).to have_content 'feature' @@ -122,7 +122,7 @@ feature 'Prioritize labels', feature: true do gitlab_sign_in guest - visit namespace_project_labels_path(project.namespace, project) + visit project_labels_path(project) expect(page).to have_content 'bug' expect(page).to have_content 'wontfix' @@ -133,7 +133,7 @@ feature 'Prioritize labels', feature: true do context 'as a non signed in user' do it 'does not prioritize labels' do - visit namespace_project_labels_path(project.namespace, project) + visit project_labels_path(project) expect(page).to have_content 'bug' expect(page).to have_content 'wontfix' diff --git a/spec/features/projects/main/download_buttons_spec.rb b/spec/features/projects/main/download_buttons_spec.rb index 514453db472..b14e0f089f0 100644 --- a/spec/features/projects/main/download_buttons_spec.rb +++ b/spec/features/projects/main/download_buttons_spec.rb @@ -29,13 +29,11 @@ feature 'Download buttons in project main page', feature: true do describe 'when checking project main page' do context 'with artifacts' do before do - visit namespace_project_path(project.namespace, project) + visit project_path(project) end scenario 'shows download artifacts button' do - href = latest_succeeded_namespace_project_artifacts_path( - project.namespace, project, "#{project.default_branch}/download", - job: 'build') + href = latest_succeeded_project_artifacts_path(project, "#{project.default_branch}/download", job: 'build') expect(page).to have_link "Download '#{build.name}'", href: href end diff --git a/spec/features/projects/main/rss_spec.rb b/spec/features/projects/main/rss_spec.rb index fee8cfe2c33..5f48253dd06 100644 --- a/spec/features/projects/main/rss_spec.rb +++ b/spec/features/projects/main/rss_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' feature 'Project RSS' do let(:project) { create(:project, :repository, visibility_level: Gitlab::VisibilityLevel::PUBLIC) } - let(:path) { namespace_project_path(project.namespace, project) } + let(:path) { project_path(project) } context 'when signed in' do before do diff --git a/spec/features/projects/members/anonymous_user_sees_members_spec.rb b/spec/features/projects/members/anonymous_user_sees_members_spec.rb index d82cf53c690..4958d5594ac 100644 --- a/spec/features/projects/members/anonymous_user_sees_members_spec.rb +++ b/spec/features/projects/members/anonymous_user_sees_members_spec.rb @@ -11,10 +11,10 @@ feature 'Projects > Members > Anonymous user sees members', feature: true do end scenario "anonymous user visits the project's members page and sees the list of members" do - visit namespace_project_settings_members_path(project.namespace, project) + visit project_settings_members_path(project) expect(current_path).to eq( - namespace_project_settings_members_path(project.namespace, project)) + project_settings_members_path(project)) expect(page).to have_content(user.name) end end diff --git a/spec/features/projects/members/group_links_spec.rb b/spec/features/projects/members/group_links_spec.rb index 00d2a27597b..61cd7db15f5 100644 --- a/spec/features/projects/members/group_links_spec.rb +++ b/spec/features/projects/members/group_links_spec.rb @@ -10,7 +10,7 @@ feature 'Projects > Members > Anonymous user sees members', feature: true, js: t @group_link = create(:project_group_link, project: project, group: group) gitlab_sign_in(user) - visit namespace_project_settings_members_path(project.namespace, project) + visit project_settings_members_path(project) end it 'updates group access level' do @@ -22,7 +22,7 @@ feature 'Projects > Members > Anonymous user sees members', feature: true, js: t wait_for_requests - visit namespace_project_settings_members_path(project.namespace, project) + visit project_settings_members_path(project) expect(first('.group_member')).to have_content('Guest') end diff --git a/spec/features/projects/members/group_member_cannot_leave_group_project_spec.rb b/spec/features/projects/members/group_member_cannot_leave_group_project_spec.rb index 7e71dbc24c0..1c429202aba 100644 --- a/spec/features/projects/members/group_member_cannot_leave_group_project_spec.rb +++ b/spec/features/projects/members/group_member_cannot_leave_group_project_spec.rb @@ -8,7 +8,7 @@ feature 'Projects > Members > Group member cannot leave group project', feature: background do group.add_developer(user) gitlab_sign_in(user) - visit namespace_project_path(project.namespace, project) + visit project_path(project) end scenario 'user does not see a "Leave project" link' do 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 60a5cd9ec63..7250a0d26fc 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 @@ -42,6 +42,6 @@ feature 'Projects > Members > Group member cannot request access to his group pr def login_and_visit_project_page(user) gitlab_sign_in(user) - visit namespace_project_path(project.namespace, project) + visit project_path(project) end end diff --git a/spec/features/projects/members/group_members_spec.rb b/spec/features/projects/members/group_members_spec.rb index 76fe6a00dab..0acf5134cce 100644 --- a/spec/features/projects/members/group_members_spec.rb +++ b/spec/features/projects/members/group_members_spec.rb @@ -19,7 +19,7 @@ feature 'Projects members', feature: true do context 'with a group invitee' do before do group_invitee - visit namespace_project_settings_members_path(project.namespace, project) + visit project_settings_members_path(project) end scenario 'does not appear in the project members page' do @@ -33,7 +33,7 @@ feature 'Projects members', feature: true do before do group_invitee project_invitee - visit namespace_project_settings_members_path(project.namespace, project) + visit project_settings_members_path(project) end scenario 'shows the project invitee, the project developer, and the group owner' do @@ -54,7 +54,7 @@ feature 'Projects members', feature: true do context 'with a group requester' do before do group.request_access(group_requester) - visit namespace_project_settings_members_path(project.namespace, project) + visit project_settings_members_path(project) end scenario 'does not appear in the project members page' do @@ -68,7 +68,7 @@ feature 'Projects members', feature: true do before do group.request_access(group_requester) project.request_access(project_requester) - visit namespace_project_settings_members_path(project.namespace, project) + visit project_settings_members_path(project) end scenario 'shows the project requester, the project developer, and the group owner' do diff --git a/spec/features/projects/members/group_requester_cannot_request_access_to_project_spec.rb b/spec/features/projects/members/group_requester_cannot_request_access_to_project_spec.rb index 66da28b07fe..5a28a7538f8 100644 --- a/spec/features/projects/members/group_requester_cannot_request_access_to_project_spec.rb +++ b/spec/features/projects/members/group_requester_cannot_request_access_to_project_spec.rb @@ -11,7 +11,7 @@ feature 'Projects > Members > Group requester cannot request access to project', gitlab_sign_in(user) visit group_path(group) perform_enqueued_jobs { click_link 'Request Access' } - visit namespace_project_path(project.namespace, project) + visit project_path(project) end scenario 'group requester does not see the request access / withdraw access request button' do diff --git a/spec/features/projects/members/list_spec.rb b/spec/features/projects/members/list_spec.rb index 9fdd7df0ee5..b62bf2f6293 100644 --- a/spec/features/projects/members/list_spec.rb +++ b/spec/features/projects/members/list_spec.rb @@ -85,6 +85,6 @@ feature 'Project members list', feature: true do end def visit_members_page - visit namespace_project_settings_members_path(project.namespace, project) + visit project_settings_members_path(project) end end diff --git a/spec/features/projects/members/master_adds_member_with_expiration_date_spec.rb b/spec/features/projects/members/master_adds_member_with_expiration_date_spec.rb index 21b48b7fdd1..ca2172bb905 100644 --- a/spec/features/projects/members/master_adds_member_with_expiration_date_spec.rb +++ b/spec/features/projects/members/master_adds_member_with_expiration_date_spec.rb @@ -16,7 +16,7 @@ feature 'Projects > Members > Master adds member with expiration date', feature: scenario 'expiration date is displayed in the members list' do travel_to Time.zone.parse('2016-08-06 08:00') do date = 4.days.from_now - visit namespace_project_project_members_path(project.namespace, project) + visit project_project_members_path(project) page.within '.users-project-form' do select2(new_member.id, from: '#user_ids', multiple: true) @@ -34,7 +34,7 @@ feature 'Projects > Members > Master adds member with expiration date', feature: travel_to Time.zone.parse('2016-08-06 08:00') do date = 3.days.from_now project.team.add_users([new_member.id], :developer, expires_at: Date.today.to_s(:medium)) - visit namespace_project_project_members_path(project.namespace, project) + visit project_project_members_path(project) page.within "#project_member_#{new_member.project_members.first.id}" do find('.js-access-expiration-date').set date.to_s(:medium) diff --git a/spec/features/projects/members/master_manages_access_requests_spec.rb b/spec/features/projects/members/master_manages_access_requests_spec.rb index bd445e27243..69c5927428c 100644 --- a/spec/features/projects/members/master_manages_access_requests_spec.rb +++ b/spec/features/projects/members/master_manages_access_requests_spec.rb @@ -12,13 +12,13 @@ feature 'Projects > Members > Master manages access requests', feature: true do end scenario 'master can see access requests' do - visit namespace_project_project_members_path(project.namespace, project) + visit project_project_members_path(project) expect_visible_access_request(project, user) end scenario 'master can grant access' do - visit namespace_project_project_members_path(project.namespace, project) + visit project_project_members_path(project) expect_visible_access_request(project, user) @@ -29,7 +29,7 @@ feature 'Projects > Members > Master manages access requests', feature: true do end scenario 'master can deny access' do - visit namespace_project_project_members_path(project.namespace, project) + visit project_project_members_path(project) expect_visible_access_request(project, user) 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 703f5dff6b5..f0da201da85 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 @@ -7,7 +7,7 @@ feature 'Projects > Members > Member cannot request access to his project', feat background do project.team << [member, :developer] gitlab_sign_in(member) - visit namespace_project_path(project.namespace, project) + visit project_path(project) end scenario 'member does not see the request access button' do diff --git a/spec/features/projects/members/member_leaves_project_spec.rb b/spec/features/projects/members/member_leaves_project_spec.rb index 8e1788f7f2a..31d8bbdc0b6 100644 --- a/spec/features/projects/members/member_leaves_project_spec.rb +++ b/spec/features/projects/members/member_leaves_project_spec.rb @@ -7,7 +7,7 @@ feature 'Projects > Members > Member leaves project', feature: true do background do project.team << [user, :developer] gitlab_sign_in(user) - visit namespace_project_path(project.namespace, project) + visit project_path(project) end scenario 'user leaves project' do diff --git a/spec/features/projects/members/owner_cannot_leave_project_spec.rb b/spec/features/projects/members/owner_cannot_leave_project_spec.rb index 70e4bb19c0f..a1ccc6ddf65 100644 --- a/spec/features/projects/members/owner_cannot_leave_project_spec.rb +++ b/spec/features/projects/members/owner_cannot_leave_project_spec.rb @@ -5,7 +5,7 @@ feature 'Projects > Members > Owner cannot leave project', feature: true do background do gitlab_sign_in(project.owner) - visit namespace_project_path(project.namespace, project) + visit project_path(project) end scenario 'user does not see a "Leave project" link' do 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 0cd7e3afeda..54f5d0d165b 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 @@ -5,7 +5,7 @@ feature 'Projects > Members > Owner cannot request access to his project', featu background do gitlab_sign_in(project.owner) - visit namespace_project_path(project.namespace, project) + visit project_path(project) end scenario 'owner does not see the request access button' do diff --git a/spec/features/projects/members/sorting_spec.rb b/spec/features/projects/members/sorting_spec.rb index 66d98ef8b90..7c02b49a0ab 100644 --- a/spec/features/projects/members/sorting_spec.rb +++ b/spec/features/projects/members/sorting_spec.rb @@ -84,7 +84,7 @@ feature 'Projects > Members > Sorting', feature: true do end def visit_members_list(sort:) - visit namespace_project_project_members_path(project.namespace.to_param, project, sort: sort) + visit project_project_members_path(project, sort: sort) end def first_member diff --git a/spec/features/projects/members/user_requests_access_spec.rb b/spec/features/projects/members/user_requests_access_spec.rb index 081009f2325..247cc0e6f2c 100644 --- a/spec/features/projects/members/user_requests_access_spec.rb +++ b/spec/features/projects/members/user_requests_access_spec.rb @@ -7,12 +7,12 @@ feature 'Projects > Members > User requests access', feature: true do background do gitlab_sign_in(user) - visit namespace_project_path(project.namespace, project) + visit project_path(project) end scenario 'request access feature is disabled' do project.update_attributes(request_access_enabled: false) - visit namespace_project_path(project.namespace, project) + visit project_path(project) expect(page).not_to have_content 'Request Access' end @@ -35,7 +35,7 @@ feature 'Projects > Members > User requests access', feature: true do project.project_feature.update!(repository_access_level: ProjectFeature::PRIVATE, builds_access_level: ProjectFeature::PRIVATE, merge_requests_access_level: ProjectFeature::PRIVATE) - visit namespace_project_path(project.namespace, project) + visit project_path(project) expect(page).to have_content 'Request Access' end @@ -49,7 +49,7 @@ feature 'Projects > Members > User requests access', feature: true do open_project_settings_menu click_link 'Members' - visit namespace_project_settings_members_path(project.namespace, project) + visit project_settings_members_path(project) page.within('.content') do expect(page).not_to have_content(user.name) end diff --git a/spec/features/projects/merge_request_button_spec.rb b/spec/features/projects/merge_request_button_spec.rb index 58054bbbbed..771dd7d3208 100644 --- a/spec/features/projects/merge_request_button_spec.rb +++ b/spec/features/projects/merge_request_button_spec.rb @@ -23,10 +23,9 @@ feature 'Merge Request button', feature: true do end it 'shows Create merge request button' do - href = namespace_project_new_merge_request_path(project.namespace, - project, - merge_request: { source_branch: 'feature', - target_branch: 'master' }) + href = project_new_merge_request_path(project, + merge_request: { source_branch: 'feature', + target_branch: 'master' }) visit url @@ -67,10 +66,9 @@ feature 'Merge Request button', feature: true do let(:user) { forked_project.owner } it 'shows Create merge request button' do - href = namespace_project_new_merge_request_path(forked_project.namespace, - forked_project, - merge_request: { source_branch: 'feature', - target_branch: 'master' }) + href = project_new_merge_request_path(forked_project, + merge_request: { source_branch: 'feature', + target_branch: 'master' }) visit fork_url @@ -85,24 +83,24 @@ feature 'Merge Request button', feature: true do context 'on branches page' do it_behaves_like 'Merge request button only shown when allowed' do let(:label) { 'Merge request' } - let(:url) { namespace_project_branches_path(project.namespace, project, search: 'feature') } - let(:fork_url) { namespace_project_branches_path(forked_project.namespace, forked_project, search: 'feature') } + let(:url) { project_branches_path(project, search: 'feature') } + let(:fork_url) { project_branches_path(forked_project, search: 'feature') } end end context 'on compare page' do it_behaves_like 'Merge request button only shown when allowed' do let(:label) { 'Create merge request' } - let(:url) { namespace_project_compare_path(project.namespace, project, from: 'master', to: 'feature') } - let(:fork_url) { namespace_project_compare_path(forked_project.namespace, forked_project, from: 'master', to: 'feature') } + let(:url) { project_compare_path(project, from: 'master', to: 'feature') } + let(:fork_url) { project_compare_path(forked_project, from: 'master', to: 'feature') } end end context 'on commits page' do it_behaves_like 'Merge request button only shown when allowed' do let(:label) { 'Create merge request' } - let(:url) { namespace_project_commits_path(project.namespace, project, 'feature') } - let(:fork_url) { namespace_project_commits_path(forked_project.namespace, forked_project, 'feature') } + let(:url) { project_commits_path(project, 'feature') } + let(:fork_url) { project_commits_path(forked_project, 'feature') } end end end diff --git a/spec/features/projects/merge_requests/list_spec.rb b/spec/features/projects/merge_requests/list_spec.rb index 7ce3156215a..ff4d22b3881 100644 --- a/spec/features/projects/merge_requests/list_spec.rb +++ b/spec/features/projects/merge_requests/list_spec.rb @@ -13,28 +13,28 @@ feature 'Merge Requests List' do scenario 'user does not see create new list button' do create(:merge_request, source_project: project) - visit namespace_project_merge_requests_path(project.namespace, project) + visit project_merge_requests_path(project) expect(page).not_to have_selector('.js-new-board-list') end it 'should show an empty state' do - visit namespace_project_merge_requests_path(project.namespace, project) + visit project_merge_requests_path(project) expect(page).to have_selector('.empty-state') end it 'empty state should have a create merge request button' do - visit namespace_project_merge_requests_path(project.namespace, project) + visit project_merge_requests_path(project) - expect(page).to have_link 'New merge request', href: namespace_project_new_merge_request_path(project.namespace, project) + expect(page).to have_link 'New merge request', href: project_new_merge_request_path(project) end context 'if there are merge requests' do before do create(:merge_request, assignee: user, source_project: project) - visit namespace_project_merge_requests_path(project.namespace, project) + visit project_merge_requests_path(project) end it 'should not show an empty state' do diff --git a/spec/features/projects/milestones/milestone_spec.rb b/spec/features/projects/milestones/milestone_spec.rb index a02e4118784..1913ef728d3 100644 --- a/spec/features/projects/milestones/milestone_spec.rb +++ b/spec/features/projects/milestones/milestone_spec.rb @@ -11,7 +11,7 @@ feature 'Project milestone', :feature do context 'when project has enabled issues' do before do - visit namespace_project_milestone_path(project.namespace, project, milestone) + visit project_milestone_path(project, milestone) end it 'shows issues tab' do @@ -38,7 +38,7 @@ feature 'Project milestone', :feature do context 'when project has disabled issues' do before do project.project_feature.update_attribute(:issues_access_level, ProjectFeature::DISABLED) - visit namespace_project_milestone_path(project.namespace, project, milestone) + visit project_milestone_path(project, milestone) end it 'hides issues tab' do @@ -68,7 +68,7 @@ feature 'Project milestone', :feature do before do create(:issue, project: project, milestone: milestone) - visit namespace_project_milestone_path(project.namespace, project, milestone) + visit project_milestone_path(project, milestone) end describe 'the collapsed sidebar' do diff --git a/spec/features/projects/milestones/milestones_sorting_spec.rb b/spec/features/projects/milestones/milestones_sorting_spec.rb index 2350089255d..1b74758445b 100644 --- a/spec/features/projects/milestones/milestones_sorting_spec.rb +++ b/spec/features/projects/milestones/milestones_sorting_spec.rb @@ -19,7 +19,7 @@ feature 'Milestones sorting', :feature, :js do end scenario 'visit project milestones and sort by due_date_asc' do - visit namespace_project_milestones_path(project.namespace, project) + visit project_milestones_path(project) expect(page).to have_button('Due soon') diff --git a/spec/features/projects/milestones/new_spec.rb b/spec/features/projects/milestones/new_spec.rb index 7403822c7fb..3c81db502bc 100644 --- a/spec/features/projects/milestones/new_spec.rb +++ b/spec/features/projects/milestones/new_spec.rb @@ -6,7 +6,7 @@ feature 'Creating a new project milestone', :feature, :js do before do login_as(user) - visit new_namespace_project_milestone_path(project.namespace, project) + visit new_project_milestone_path(project) end it 'description has autocomplete' do diff --git a/spec/features/projects/no_password_spec.rb b/spec/features/projects/no_password_spec.rb index 30a16e38e3c..53ac18fa7cc 100644 --- a/spec/features/projects/no_password_spec.rb +++ b/spec/features/projects/no_password_spec.rb @@ -6,7 +6,7 @@ feature 'No Password Alert' do context 'with internal auth enabled' do before do sign_in(user) - visit namespace_project_path(project.namespace, project) + visit project_path(project) end context 'when user has a password' do @@ -37,7 +37,7 @@ feature 'No Password Alert' do context 'when user has no personal access tokens' do it 'has a personal access token alert' do gitlab_sign_in_via('saml', user, 'my-uid') - visit namespace_project_path(project.namespace, project) + visit project_path(project) expect(page).to have_content "You won't be able to pull or push project code via HTTP until you create a personal access token on your account" end @@ -47,7 +47,7 @@ feature 'No Password Alert' do it 'shows no alert' do create(:personal_access_token, user: user) gitlab_sign_in_via('saml', user, 'my-uid') - visit namespace_project_path(project.namespace, project) + visit project_path(project) expect(page).not_to have_content "You won't be able to pull or push project code via HTTP until you create a personal access token on your account" end @@ -59,7 +59,7 @@ feature 'No Password Alert' do before do sign_in(user) - visit namespace_project_path(project.namespace, project) + visit project_path(project) end it 'shows no alert' do diff --git a/spec/features/projects/pages_spec.rb b/spec/features/projects/pages_spec.rb index e9a3cfb7f60..e2cc38e276f 100644 --- a/spec/features/projects/pages_spec.rb +++ b/spec/features/projects/pages_spec.rb @@ -15,7 +15,7 @@ feature 'Pages', feature: true do shared_examples 'no pages deployed' do scenario 'does not see anything to destroy' do - visit namespace_project_pages_path(project.namespace, project) + visit project_pages_path(project) expect(page).not_to have_link('Remove pages') expect(page).not_to have_text('Only the project owner can remove pages') @@ -33,7 +33,7 @@ feature 'Pages', feature: true do end scenario 'sees "Remove pages" link' do - visit namespace_project_pages_path(project.namespace, project) + visit project_pages_path(project) expect(page).to have_link('Remove pages') end @@ -49,7 +49,7 @@ feature 'Pages', feature: true do end scenario 'sees "Only the project owner can remove pages" text' do - visit namespace_project_pages_path(project.namespace, project) + visit project_pages_path(project) expect(page).to have_text('Only the project owner can remove pages') end diff --git a/spec/features/projects/pipeline_schedules_spec.rb b/spec/features/projects/pipeline_schedules_spec.rb index dfb973c37e5..d8bb7ca9a83 100644 --- a/spec/features/projects/pipeline_schedules_spec.rb +++ b/spec/features/projects/pipeline_schedules_spec.rb @@ -135,15 +135,15 @@ feature 'Pipeline Schedules', :feature do end def visit_new_pipeline_schedule - visit new_namespace_project_pipeline_schedule_path(project.namespace, project, pipeline_schedule) + visit new_project_pipeline_schedule_path(project, pipeline_schedule) end def edit_pipeline_schedule - visit edit_namespace_project_pipeline_schedule_path(project.namespace, project, pipeline_schedule) + visit edit_project_pipeline_schedule_path(project, pipeline_schedule) end def visit_pipelines_schedules - visit namespace_project_pipeline_schedules_path(project.namespace, project, scope: scope) + visit project_pipeline_schedules_path(project, scope: scope) end def select_timezone diff --git a/spec/features/projects/pipelines/pipeline_spec.rb b/spec/features/projects/pipelines/pipeline_spec.rb index e182995922d..bd6750d2208 100644 --- a/spec/features/projects/pipelines/pipeline_spec.rb +++ b/spec/features/projects/pipelines/pipeline_spec.rb @@ -1,8 +1,6 @@ require 'spec_helper' describe 'Pipeline', :feature, :js do - include GitlabRoutingHelper - let(:project) { create(:empty_project) } let(:user) { create(:user) } @@ -48,7 +46,7 @@ describe 'Pipeline', :feature, :js do let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id, user: user) } before do - visit namespace_project_pipeline_path(project.namespace, project, pipeline) + visit project_pipeline_path(project, pipeline) end it 'shows the pipeline graph' do @@ -194,7 +192,7 @@ describe 'Pipeline', :feature, :js do let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id) } before do - visit builds_namespace_project_pipeline_path(project.namespace, project, pipeline) + visit builds_project_pipeline_path(project, pipeline) end it 'shows a list of jobs' do @@ -266,7 +264,7 @@ describe 'Pipeline', :feature, :js do describe 'GET /:project/pipelines/:id/failures' do let(:project) { create(:project) } let(:pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id) } - let(:pipeline_failures_page) { failures_namespace_project_pipeline_path(project.namespace, project, pipeline) } + let(:pipeline_failures_page) { failures_project_pipeline_path(project, pipeline) } let!(:failed_build) { create(:ci_build, :failed, pipeline: pipeline) } context 'with failed build' do diff --git a/spec/features/projects/pipelines/pipelines_spec.rb b/spec/features/projects/pipelines/pipelines_spec.rb index d36d073e022..a82a804e4c1 100644 --- a/spec/features/projects/pipelines/pipelines_spec.rb +++ b/spec/features/projects/pipelines/pipelines_spec.rb @@ -51,7 +51,7 @@ describe 'Pipelines', :feature, :js do context 'header tabs' do before do - visit namespace_project_pipelines_path(project.namespace, project) + visit project_pipelines_path(project) wait_for_requests end @@ -369,14 +369,14 @@ describe 'Pipelines', :feature, :js do end it 'should render pagination' do - visit namespace_project_pipelines_path(project.namespace, project) + visit project_pipelines_path(project) wait_for_requests expect(page).to have_selector('.gl-pagination') end it 'should render second page of pipelines' do - visit namespace_project_pipelines_path(project.namespace, project, page: '2') + visit project_pipelines_path(project, page: '2') wait_for_requests expect(page).to have_selector('.gl-pagination .page', count: 2) @@ -405,7 +405,7 @@ describe 'Pipelines', :feature, :js do create(:generic_commit_status, pipeline: pipeline, stage: 'external', name: 'jenkins', stage_idx: 3) - visit namespace_project_pipeline_path(project.namespace, project, pipeline) + visit project_pipeline_path(project, pipeline) wait_for_requests end @@ -440,7 +440,7 @@ describe 'Pipelines', :feature, :js do let(:project) { create(:project) } before do - visit new_namespace_project_pipeline_path(project.namespace, project) + visit new_project_pipeline_path(project) end context 'for valid commit', js: true do @@ -479,7 +479,7 @@ describe 'Pipelines', :feature, :js do let(:project) { create(:project) } before do - visit new_namespace_project_pipeline_path(project.namespace, project) + visit new_project_pipeline_path(project) end describe 'new pipeline page' do @@ -508,7 +508,7 @@ describe 'Pipelines', :feature, :js do context 'when user is not logged in' do before do - visit namespace_project_pipelines_path(project.namespace, project) + visit project_pipelines_path(project) end context 'when project is public' do @@ -526,7 +526,7 @@ describe 'Pipelines', :feature, :js do end def visit_project_pipelines(**query) - visit namespace_project_pipelines_path(project.namespace, project, query) + visit project_pipelines_path(project, query) wait_for_requests end end diff --git a/spec/features/projects/project_settings_spec.rb b/spec/features/projects/project_settings_spec.rb index baa38ff8cca..1f78f242399 100644 --- a/spec/features/projects/project_settings_spec.rb +++ b/spec/features/projects/project_settings_spec.rb @@ -12,7 +12,7 @@ describe 'Edit Project Settings', feature: true do describe 'Project settings section', js: true do it 'shows errors for invalid project name' do - visit edit_namespace_project_path(project.namespace, project) + visit edit_project_path(project) fill_in 'project_name_edit', with: 'foo&bar' click_button 'Save changes' expect(page).to have_field 'project_name_edit', with: 'foo&bar' @@ -21,7 +21,7 @@ describe 'Edit Project Settings', feature: true do end it 'shows a successful notice when the project is updated' do - visit edit_namespace_project_path(project.namespace, project) + visit edit_project_path(project) fill_in 'project_name_edit', with: 'hello world' click_button 'Save changes' expect(page).to have_content "Project 'hello world' was successfully updated." @@ -75,7 +75,7 @@ describe 'Edit Project Settings', feature: true do end specify 'the project is accessible via a redirect from the old path' do - old_path = namespace_project_path(project.namespace, project) + old_path = project_path(project) rename_project(project, path: 'bar') new_path = namespace_project_path(project.namespace, 'bar') visit old_path @@ -85,7 +85,7 @@ describe 'Edit Project Settings', feature: true do context 'and a new project is added with the same path' do it 'overrides the redirect' do - old_path = namespace_project_path(project.namespace, project) + old_path = project_path(project) rename_project(project, path: 'bar') new_project = create(:empty_project, namespace: user.namespace, path: 'gitlabhq', name: 'quz') visit old_path @@ -122,7 +122,7 @@ describe 'Edit Project Settings', feature: true do end specify 'the project is accessible via a redirect from the old path' do - old_path = namespace_project_path(project.namespace, project) + old_path = project_path(project) transfer_project(project, group) new_path = namespace_project_path(group, project) visit old_path @@ -132,7 +132,7 @@ describe 'Edit Project Settings', feature: true do context 'and a new project is added with the same path' do it 'overrides the redirect' do - old_path = namespace_project_path(project.namespace, project) + old_path = project_path(project) transfer_project(project, group) new_project = create(:empty_project, namespace: user.namespace, path: 'gitlabhq', name: 'quz') visit old_path @@ -144,7 +144,7 @@ describe 'Edit Project Settings', feature: true do end def rename_project(project, name: nil, path: nil) - visit edit_namespace_project_path(project.namespace, project) + visit edit_project_path(project) fill_in('project_name', with: name) if name fill_in('Path', with: path) if path click_button('Rename project') @@ -153,7 +153,7 @@ def rename_project(project, name: nil, path: nil) end def transfer_project(project, namespace) - visit edit_namespace_project_path(project.namespace, project) + visit edit_project_path(project) select2(namespace.id, from: '#new_namespace_id') click_button('Transfer project') confirm_transfer_modal diff --git a/spec/features/projects/ref_switcher_spec.rb b/spec/features/projects/ref_switcher_spec.rb index 016a992bdcf..342f083f25a 100644 --- a/spec/features/projects/ref_switcher_spec.rb +++ b/spec/features/projects/ref_switcher_spec.rb @@ -7,7 +7,7 @@ feature 'Ref switcher', feature: true, js: true do before do project.team << [user, :master] gitlab_sign_in(user) - visit namespace_project_tree_path(project.namespace, project, 'master') + visit project_tree_path(project, 'master') end it 'allow user to change ref by enter key' do diff --git a/spec/features/projects/services/jira_service_spec.rb b/spec/features/projects/services/jira_service_spec.rb index 8cd216c8fdb..9e4f420689c 100644 --- a/spec/features/projects/services/jira_service_spec.rb +++ b/spec/features/projects/services/jira_service_spec.rb @@ -26,7 +26,7 @@ feature 'Setup Jira service', :feature, :js do project.team << [user, :master] gitlab_sign_in(user) - visit namespace_project_settings_integrations_path(project.namespace, project) + visit project_settings_integrations_path(project) end describe 'user sets and activates Jira Service' do @@ -42,7 +42,7 @@ feature 'Setup Jira service', :feature, :js do wait_for_requests expect(page).to have_content('JIRA activated.') - expect(current_path).to eq(namespace_project_settings_integrations_path(project.namespace, project)) + expect(current_path).to eq(project_settings_integrations_path(project)) end end @@ -76,7 +76,7 @@ feature 'Setup Jira service', :feature, :js do wait_for_requests expect(page).to have_content('JIRA activated.') - expect(current_path).to eq(namespace_project_settings_integrations_path(project.namespace, project)) + expect(current_path).to eq(project_settings_integrations_path(project)) end end end @@ -89,7 +89,7 @@ feature 'Setup Jira service', :feature, :js do click_button('Save changes') expect(page).to have_content('JIRA settings saved, but not activated.') - expect(current_path).to eq(namespace_project_settings_integrations_path(project.namespace, project)) + expect(current_path).to eq(project_settings_integrations_path(project)) end end end diff --git a/spec/features/projects/services/mattermost_slash_command_spec.rb b/spec/features/projects/services/mattermost_slash_command_spec.rb index d87985f1c92..aaa354903aa 100644 --- a/spec/features/projects/services/mattermost_slash_command_spec.rb +++ b/spec/features/projects/services/mattermost_slash_command_spec.rb @@ -10,7 +10,7 @@ feature 'Setup Mattermost slash commands', :feature, :js do stub_mattermost_setting(enabled: mattermost_enabled) project.team << [user, :master] gitlab_sign_in(user) - visit edit_namespace_project_service_path(project.namespace, project, service) + visit edit_project_service_path(project, service) end describe 'user visits the mattermost slash command config page' do @@ -30,7 +30,7 @@ feature 'Setup Mattermost slash commands', :feature, :js do fill_in 'service_token', with: token click_on 'Save changes' - expect(current_path).to eq(namespace_project_settings_integrations_path(project.namespace, project)) + expect(current_path).to eq(project_settings_integrations_path(project)) expect(page).to have_content('Mattermost slash commands settings saved, but not activated.') end @@ -41,7 +41,7 @@ feature 'Setup Mattermost slash commands', :feature, :js do check 'service_active' click_on 'Save changes' - expect(current_path).to eq(namespace_project_settings_integrations_path(project.namespace, project)) + expect(current_path).to eq(project_settings_integrations_path(project)) expect(page).to have_content('Mattermost slash commands activated.') end diff --git a/spec/features/projects/services/slack_service_spec.rb b/spec/features/projects/services/slack_service_spec.rb index 50707e6a49f..5e3c3b00476 100644 --- a/spec/features/projects/services/slack_service_spec.rb +++ b/spec/features/projects/services/slack_service_spec.rb @@ -13,7 +13,7 @@ feature 'Projects > Slack service > Setup events', feature: true do end scenario 'user can filter events by channel' do - visit edit_namespace_project_service_path(project.namespace, project, service) + visit edit_project_service_path(project, service) expect(page.find_field("service_push_channel").value).to have_content '1' expect(page.find_field("service_issue_channel").value).to have_content '2' diff --git a/spec/features/projects/services/slack_slash_command_spec.rb b/spec/features/projects/services/slack_slash_command_spec.rb index 3fae38c1799..aaa775ce51f 100644 --- a/spec/features/projects/services/slack_slash_command_spec.rb +++ b/spec/features/projects/services/slack_slash_command_spec.rb @@ -8,7 +8,7 @@ feature 'Slack slash commands', feature: true do background do project.team << [user, :master] gitlab_sign_in(user) - visit edit_namespace_project_service_path(project.namespace, project, service) + visit edit_project_service_path(project, service) end it 'shows a token placeholder' do @@ -25,7 +25,7 @@ feature 'Slack slash commands', feature: true do fill_in 'service_token', with: 'token' click_on 'Save' - expect(current_path).to eq(namespace_project_settings_integrations_path(project.namespace, project)) + expect(current_path).to eq(project_settings_integrations_path(project)) expect(page).to have_content('Slack slash commands settings saved, but not activated.') end @@ -34,7 +34,7 @@ feature 'Slack slash commands', feature: true do check 'service_active' click_on 'Save' - expect(current_path).to eq(namespace_project_settings_integrations_path(project.namespace, project)) + expect(current_path).to eq(project_settings_integrations_path(project)) expect(page).to have_content('Slack slash commands activated.') end diff --git a/spec/features/projects/settings/integration_settings_spec.rb b/spec/features/projects/settings/integration_settings_spec.rb index a59374b37ea..f708a3009f1 100644 --- a/spec/features/projects/settings/integration_settings_spec.rb +++ b/spec/features/projects/settings/integration_settings_spec.rb @@ -4,7 +4,7 @@ feature 'Integration settings', feature: true do let(:project) { create(:empty_project) } let(:user) { create(:user) } let(:role) { :developer } - let(:integrations_path) { namespace_project_settings_integrations_path(project.namespace, project) } + let(:integrations_path) { project_settings_integrations_path(project) } background do gitlab_sign_in(user) @@ -109,7 +109,7 @@ feature 'Integration settings', feature: true do scenario 'show list of hook logs' do hook_log - visit edit_namespace_project_hook_path(project.namespace, project, hook) + visit edit_project_hook_path(project, hook) expect(page).to have_content('Recent Deliveries') expect(page).to have_content(hook_log.url) @@ -117,7 +117,7 @@ feature 'Integration settings', feature: true do scenario 'show hook log details' do hook_log - visit edit_namespace_project_hook_path(project.namespace, project, hook) + visit edit_project_hook_path(project, hook) click_link 'View details' expect(page).to have_content("POST #{hook_log.url}") @@ -129,11 +129,11 @@ feature 'Integration settings', feature: true do WebMock.stub_request(:post, hook.url) hook_log - visit edit_namespace_project_hook_path(project.namespace, project, hook) + visit edit_project_hook_path(project, hook) click_link 'View details' click_link 'Resend Request' - expect(current_path).to eq(edit_namespace_project_hook_path(project.namespace, project, hook)) + expect(current_path).to eq(edit_project_hook_path(project, hook)) end end end diff --git a/spec/features/projects/settings/merge_requests_settings_spec.rb b/spec/features/projects/settings/merge_requests_settings_spec.rb index f2af14ceab2..451e2f3e04e 100644 --- a/spec/features/projects/settings/merge_requests_settings_spec.rb +++ b/spec/features/projects/settings/merge_requests_settings_spec.rb @@ -1,8 +1,6 @@ require 'spec_helper' feature 'Project settings > Merge Requests', feature: true, js: true do - include GitlabRoutingHelper - let(:project) { create(:empty_project, :public) } let(:user) { create(:user) } diff --git a/spec/features/projects/settings/pipelines_settings_spec.rb b/spec/features/projects/settings/pipelines_settings_spec.rb index c33fbd49d21..0d78feb2b93 100644 --- a/spec/features/projects/settings/pipelines_settings_spec.rb +++ b/spec/features/projects/settings/pipelines_settings_spec.rb @@ -1,8 +1,6 @@ require 'spec_helper' feature "Pipelines settings", feature: true do - include GitlabRoutingHelper - let(:project) { create(:empty_project) } let(:user) { create(:user) } let(:role) { :developer } @@ -10,7 +8,7 @@ feature "Pipelines settings", feature: true do background do gitlab_sign_in(user) project.team << [user, role] - visit namespace_project_pipelines_settings_path(project.namespace, project) + visit project_pipelines_settings_path(project) end context 'for developer' do diff --git a/spec/features/projects/settings/repository_settings_spec.rb b/spec/features/projects/settings/repository_settings_spec.rb index 35cd0d6e832..9cc04925a0a 100644 --- a/spec/features/projects/settings/repository_settings_spec.rb +++ b/spec/features/projects/settings/repository_settings_spec.rb @@ -14,7 +14,7 @@ feature 'Repository settings', feature: true do given(:role) { :developer } scenario 'is not allowed to view' do - visit namespace_project_settings_repository_path(project.namespace, project) + visit project_settings_repository_path(project) expect(page.status_code).to eq(404) end @@ -32,7 +32,7 @@ feature 'Repository settings', feature: true do project.deploy_keys << private_deploy_key project.deploy_keys << public_deploy_key - visit namespace_project_settings_repository_path(project.namespace, project) + visit project_settings_repository_path(project) expect(page.status_code).to eq(200) expect(page).to have_content('private_deploy_key') @@ -40,7 +40,7 @@ feature 'Repository settings', feature: true do end scenario 'add a new deploy key' do - visit namespace_project_settings_repository_path(project.namespace, project) + visit project_settings_repository_path(project) fill_in 'deploy_key_title', with: 'new_deploy_key' fill_in 'deploy_key_key', with: new_ssh_key @@ -53,7 +53,7 @@ feature 'Repository settings', feature: true do scenario 'edit an existing deploy key' do project.deploy_keys << private_deploy_key - visit namespace_project_settings_repository_path(project.namespace, project) + visit project_settings_repository_path(project) find('li', text: private_deploy_key.title).click_link('Edit') @@ -70,7 +70,7 @@ feature 'Repository settings', feature: true do project2.team << [user, role] project2.deploy_keys << private_deploy_key - visit namespace_project_settings_repository_path(project.namespace, project) + visit project_settings_repository_path(project) find('li', text: private_deploy_key.title).click_link('Edit') @@ -84,7 +84,7 @@ feature 'Repository settings', feature: true do scenario 'remove an existing deploy key' do project.deploy_keys << private_deploy_key - visit namespace_project_settings_repository_path(project.namespace, project) + visit project_settings_repository_path(project) find('li', text: private_deploy_key.title).click_button('Remove') diff --git a/spec/features/projects/settings/visibility_settings_spec.rb b/spec/features/projects/settings/visibility_settings_spec.rb index 18c71dee41b..a9a6441d4e8 100644 --- a/spec/features/projects/settings/visibility_settings_spec.rb +++ b/spec/features/projects/settings/visibility_settings_spec.rb @@ -7,7 +7,7 @@ feature 'Visibility settings', feature: true, js: true do context 'as owner' do before do gitlab_sign_in(user) - visit edit_namespace_project_path(project.namespace, project) + visit edit_project_path(project) end scenario 'project visibility select is available' do @@ -33,7 +33,7 @@ feature 'Visibility settings', feature: true, js: true do before do project.team << [master_user, :master] gitlab_sign_in(master_user) - visit edit_namespace_project_path(project.namespace, project) + visit edit_project_path(project) end scenario 'project visibility is locked' do diff --git a/spec/features/projects/shortcuts_spec.rb b/spec/features/projects/shortcuts_spec.rb index cec79277c33..682bea87c8a 100644 --- a/spec/features/projects/shortcuts_spec.rb +++ b/spec/features/projects/shortcuts_spec.rb @@ -8,7 +8,7 @@ feature 'Project shortcuts', feature: true do before do project.team << [user, :master] gitlab_sign_in user - visit namespace_project_path(project.namespace, project) + visit project_path(project) end describe 'pressing "i"' do diff --git a/spec/features/projects/snippets/create_snippet_spec.rb b/spec/features/projects/snippets/create_snippet_spec.rb index c75d6dbc307..37c11c0e88d 100644 --- a/spec/features/projects/snippets/create_snippet_spec.rb +++ b/spec/features/projects/snippets/create_snippet_spec.rb @@ -19,7 +19,7 @@ feature 'Create Snippet', :js, feature: true do project.team << [user, :master] gitlab_sign_in(user) - visit namespace_project_snippets_path(project.namespace, project) + visit project_snippets_path(project) click_on('New snippet') end @@ -77,7 +77,7 @@ feature 'Create Snippet', :js, feature: true do it 'shows a public snippet on the index page but not the New snippet button' do snippet = create(:project_snippet, :public, project: project) - visit namespace_project_snippets_path(project.namespace, project) + visit project_snippets_path(project) expect(page).to have_content(snippet.title) expect(page).not_to have_content('New snippet') diff --git a/spec/features/projects/snippets/show_spec.rb b/spec/features/projects/snippets/show_spec.rb index 9e73ba4123b..d401d09497f 100644 --- a/spec/features/projects/snippets/show_spec.rb +++ b/spec/features/projects/snippets/show_spec.rb @@ -15,7 +15,7 @@ feature 'Project snippet', :js, feature: true do let(:content) { project.repository.blob_at('master', 'files/ruby/popen.rb').data } before do - visit namespace_project_snippet_path(project.namespace, project, snippet) + visit project_snippet_path(project, snippet) wait_for_requests end @@ -46,7 +46,7 @@ feature 'Project snippet', :js, feature: true do context 'visiting directly' do before do - visit namespace_project_snippet_path(project.namespace, project, snippet) + visit project_snippet_path(project, snippet) wait_for_requests end @@ -118,7 +118,7 @@ feature 'Project snippet', :js, feature: true do context 'visiting with a line number anchor' do before do - visit namespace_project_snippet_path(project.namespace, project, snippet, anchor: 'L1') + visit project_snippet_path(project, snippet, anchor: 'L1') wait_for_requests end diff --git a/spec/features/projects/snippets_spec.rb b/spec/features/projects/snippets_spec.rb index 80dbffaffc7..8edef2eba13 100644 --- a/spec/features/projects/snippets_spec.rb +++ b/spec/features/projects/snippets_spec.rb @@ -10,7 +10,7 @@ describe 'Project snippets', :js, feature: true do before do allow(Snippet).to receive(:default_per_page).and_return(1) - visit namespace_project_snippets_path(project.namespace, project) + visit project_snippets_path(project) end it_behaves_like 'paginated snippets' @@ -18,7 +18,7 @@ describe 'Project snippets', :js, feature: true do context 'list content' do it 'contains all project snippets' do - visit namespace_project_snippets_path(project.namespace, project) + visit project_snippets_path(project) expect(page).to have_selector('.snippet-row', count: 2) @@ -30,7 +30,7 @@ describe 'Project snippets', :js, feature: true do context 'when submitting a note' do before do gitlab_sign_in :admin - visit namespace_project_snippet_path(project.namespace, project, snippets[0]) + visit project_snippet_path(project, snippets[0]) end it 'should have autocomplete' do diff --git a/spec/features/projects/sub_group_issuables_spec.rb b/spec/features/projects/sub_group_issuables_spec.rb index 63eb97d5a92..5bbad78d0bb 100644 --- a/spec/features/projects/sub_group_issuables_spec.rb +++ b/spec/features/projects/sub_group_issuables_spec.rb @@ -12,13 +12,13 @@ describe 'Subgroup Issuables', :feature, :js, :nested_groups do end it 'shows the full subgroup title when issues index page is empty' do - visit namespace_project_issues_path(project.namespace.to_param, project.to_param) + visit project_issues_path(project) expect_to_have_full_subgroup_title end it 'shows the full subgroup title when merge requests index page is empty' do - visit namespace_project_merge_requests_path(project.namespace.to_param, project.to_param) + visit project_merge_requests_path(project) expect_to_have_full_subgroup_title end diff --git a/spec/features/projects/tags/download_buttons_spec.rb b/spec/features/projects/tags/download_buttons_spec.rb index ca00a51aa3c..186876e454f 100644 --- a/spec/features/projects/tags/download_buttons_spec.rb +++ b/spec/features/projects/tags/download_buttons_spec.rb @@ -30,13 +30,11 @@ feature 'Download buttons in tags page', feature: true do describe 'when checking tags' do context 'with artifacts' do before do - visit namespace_project_tags_path(project.namespace, project) + visit project_tags_path(project) end scenario 'shows download artifacts button' do - href = latest_succeeded_namespace_project_artifacts_path( - project.namespace, project, "#{tag}/download", - job: 'build') + href = latest_succeeded_project_artifacts_path(project, "#{tag}/download", job: 'build') expect(page).to have_link "Download '#{build.name}'", href: href end diff --git a/spec/features/projects/tree/rss_spec.rb b/spec/features/projects/tree/rss_spec.rb index 135584e5bf8..4583374c931 100644 --- a/spec/features/projects/tree/rss_spec.rb +++ b/spec/features/projects/tree/rss_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' feature 'Project Tree RSS' do let(:project) { create(:project, :repository, visibility_level: Gitlab::VisibilityLevel::PUBLIC) } - let(:path) { namespace_project_tree_path(project.namespace, project, :master) } + let(:path) { project_tree_path(project, :master) } context 'when signed in' do before do diff --git a/spec/features/projects/user_create_dir_spec.rb b/spec/features/projects/user_create_dir_spec.rb index 5d0acad3832..01f288934bf 100644 --- a/spec/features/projects/user_create_dir_spec.rb +++ b/spec/features/projects/user_create_dir_spec.rb @@ -8,7 +8,7 @@ feature 'New directory creation', feature: true, js: true do background do gitlab_sign_in(user) project.team << [user, role] - visit namespace_project_tree_path(project.namespace, project, 'master') + visit project_tree_path(project, 'master') open_new_directory_modal fill_in 'dir_name', with: 'new_directory' end @@ -51,7 +51,7 @@ feature 'New directory creation', feature: true, js: true do expect(page).to have_content 'New Merge Request' expect(page).to have_content "From #{new_branch_name} into master" expect(page).to have_content 'Add new directory' - expect(current_path).to eq(namespace_project_new_merge_request_path(project.namespace, project)) + expect(current_path).to eq(project_new_merge_request_path(project)) end end end diff --git a/spec/features/projects/user_creates_project_spec.rb b/spec/features/projects/user_creates_project_spec.rb index 29f1eb8d73e..1c3791f63ac 100644 --- a/spec/features/projects/user_creates_project_spec.rb +++ b/spec/features/projects/user_creates_project_spec.rb @@ -18,7 +18,7 @@ feature 'User creates a project', js: true do project = Project.last - expect(current_path).to eq(namespace_project_path(project.namespace, project)) + expect(current_path).to eq(project_path(project)) expect(page).to have_content('Empty') expect(page).to have_content('git init') expect(page).to have_content('git remote') diff --git a/spec/features/projects/view_on_env_spec.rb b/spec/features/projects/view_on_env_spec.rb index f6a640b90b4..0c06aa25c06 100644 --- a/spec/features/projects/view_on_env_spec.rb +++ b/spec/features/projects/view_on_env_spec.rb @@ -52,7 +52,7 @@ describe 'View on environment', js: true do before do gitlab_sign_in(user) - visit diffs_namespace_project_merge_request_path(project.namespace, project, merge_request) + visit diffs_project_merge_request_path(project, merge_request) wait_for_requests end @@ -68,7 +68,7 @@ describe 'View on environment', js: true do before do gitlab_sign_in(user) - visit namespace_project_compare_path(project.namespace, project, from: 'master', to: branch_name) + visit project_compare_path(project, from: 'master', to: branch_name) wait_for_requests end @@ -82,7 +82,7 @@ describe 'View on environment', js: true do before do gitlab_sign_in(user) - visit namespace_project_compare_path(project.namespace, project, from: 'master', to: sha) + visit project_compare_path(project, from: 'master', to: sha) wait_for_requests end @@ -96,7 +96,7 @@ describe 'View on environment', js: true do before do gitlab_sign_in(user) - visit namespace_project_blob_path(project.namespace, project, File.join(branch_name, file_path)) + visit project_blob_path(project, File.join(branch_name, file_path)) wait_for_requests end @@ -110,7 +110,7 @@ describe 'View on environment', js: true do before do gitlab_sign_in(user) - visit namespace_project_blob_path(project.namespace, project, File.join(sha, file_path)) + visit project_blob_path(project, File.join(sha, file_path)) wait_for_requests end @@ -124,7 +124,7 @@ describe 'View on environment', js: true do before do gitlab_sign_in(user) - visit namespace_project_commit_path(project.namespace, project, sha) + visit project_commit_path(project, sha) wait_for_requests end diff --git a/spec/features/projects/wiki/markdown_preview_spec.rb b/spec/features/projects/wiki/markdown_preview_spec.rb index fd6c09943e3..d79ab809c7d 100644 --- a/spec/features/projects/wiki/markdown_preview_spec.rb +++ b/spec/features/projects/wiki/markdown_preview_spec.rb @@ -18,7 +18,7 @@ feature 'Projects > Wiki > User previews markdown changes', feature: true, js: t gitlab_sign_in(user) - visit namespace_project_path(project.namespace, project) + visit project_path(project) find('.shortcuts-wiki').trigger('click') end diff --git a/spec/features/projects/wiki/shortcuts_spec.rb b/spec/features/projects/wiki/shortcuts_spec.rb index ab0ed9b8204..d189f84da0e 100644 --- a/spec/features/projects/wiki/shortcuts_spec.rb +++ b/spec/features/projects/wiki/shortcuts_spec.rb @@ -9,7 +9,7 @@ feature 'Wiki shortcuts', :feature, :js do before do gitlab_sign_in(user) - visit namespace_project_wiki_path(project.namespace, project, wiki_page) + visit project_wiki_path(project, wiki_page) end scenario 'Visit edit wiki page using "e" keyboard shortcut' do diff --git a/spec/features/projects/wiki/user_creates_wiki_page_spec.rb b/spec/features/projects/wiki/user_creates_wiki_page_spec.rb index a477dcf7ee9..86b31057a55 100644 --- a/spec/features/projects/wiki/user_creates_wiki_page_spec.rb +++ b/spec/features/projects/wiki/user_creates_wiki_page_spec.rb @@ -7,7 +7,7 @@ feature 'Projects > Wiki > User creates wiki page', js: true, feature: true do project.team << [user, :master] gitlab_sign_in(user) - visit namespace_project_path(project.namespace, project) + visit project_path(project) find('.shortcuts-wiki').trigger('click') end diff --git a/spec/features/projects/wiki/user_git_access_wiki_page_spec.rb b/spec/features/projects/wiki/user_git_access_wiki_page_spec.rb index 7d31122af35..749721b97eb 100644 --- a/spec/features/projects/wiki/user_git_access_wiki_page_spec.rb +++ b/spec/features/projects/wiki/user_git_access_wiki_page_spec.rb @@ -17,7 +17,7 @@ describe 'Projects > Wiki > User views Git access wiki page', :feature do end scenario 'Visit Wiki Page Current Commit' do - visit namespace_project_wiki_path(project.namespace, project, wiki_page) + visit project_wiki_path(project, wiki_page) click_link 'Clone repository' expect(page).to have_text("Clone repository #{project.wiki.path_with_namespace}") diff --git a/spec/features/projects/wiki/user_updates_wiki_page_spec.rb b/spec/features/projects/wiki/user_updates_wiki_page_spec.rb index 64a30438681..3b9f7ff96fb 100644 --- a/spec/features/projects/wiki/user_updates_wiki_page_spec.rb +++ b/spec/features/projects/wiki/user_updates_wiki_page_spec.rb @@ -8,7 +8,7 @@ feature 'Projects > Wiki > User updates wiki page', feature: true do WikiPages::CreateService.new(project, user, title: 'home', content: 'Home page').execute gitlab_sign_in(user) - visit namespace_project_wikis_path(project.namespace, project) + visit project_wikis_path(project) end context 'in the user namespace' do diff --git a/spec/features/projects/wiki/user_views_project_wiki_page_spec.rb b/spec/features/projects/wiki/user_views_project_wiki_page_spec.rb index 8a88ab247f3..8e3912d994e 100644 --- a/spec/features/projects/wiki/user_views_project_wiki_page_spec.rb +++ b/spec/features/projects/wiki/user_views_project_wiki_page_spec.rb @@ -26,18 +26,13 @@ feature 'Projects > Wiki > User views the wiki page', feature: true do end scenario 'Visit Wiki Page Current Commit' do - visit namespace_project_wiki_path(project.namespace, project, wiki_page) + visit project_wiki_path(project, wiki_page) expect(page).to have_selector('a.btn', text: 'Edit') end scenario 'Visit Wiki Page Historical Commit' do - visit namespace_project_wiki_path( - project.namespace, - project, - wiki_page, - version_id: old_page_version_id - ) + visit project_wiki_path(project, wiki_page, version_id: old_page_version_id) expect(page).not_to have_selector('a.btn', text: 'Edit') end diff --git a/spec/features/projects/wiki/user_views_wiki_in_project_page_spec.rb b/spec/features/projects/wiki/user_views_wiki_in_project_page_spec.rb index 36799925167..a305d27c7ec 100644 --- a/spec/features/projects/wiki/user_views_wiki_in_project_page_spec.rb +++ b/spec/features/projects/wiki/user_views_wiki_in_project_page_spec.rb @@ -27,14 +27,10 @@ describe 'Projects > Wiki > User views wiki in project page', feature: true do end it 'displays the correct URL for the link' do - visit namespace_project_path(project.namespace, project) + visit project_path(project) expect(page).to have_link( 'some link', - href: namespace_project_wiki_path( - project.namespace, - project, - 'other-page' - ) + href: project_wiki_path(project, 'other-page') ) end end diff --git a/spec/features/projects_spec.rb b/spec/features/projects_spec.rb index 7e8a703db93..361e3a6d8e5 100644 --- a/spec/features/projects_spec.rb +++ b/spec/features/projects_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' feature 'Project', feature: true do describe 'description' do let(:project) { create(:project, :repository) } - let(:path) { namespace_project_path(project.namespace, project) } + let(:path) { project_path(project) } before do gitlab_sign_in(:admin) @@ -41,7 +41,7 @@ feature 'Project', feature: true do before do gitlab_sign_in user create(:forked_project_link, forked_to_project: project) - visit edit_namespace_project_path(project.namespace, project) + visit edit_project_path(project) end it 'removes fork' do @@ -62,7 +62,7 @@ feature 'Project', feature: true do before do gitlab_sign_in(user) project.team << [user, :master] - visit edit_namespace_project_path(project.namespace, project) + visit edit_project_path(project) end it 'removes a project' do @@ -81,7 +81,7 @@ feature 'Project', feature: true do before do gitlab_sign_in(user) project.add_user(user, Gitlab::Access::MASTER) - visit namespace_project_path(project.namespace, project) + visit project_path(project) end it 'clicks toggle and shows dropdown', js: true do @@ -101,7 +101,7 @@ feature 'Project', feature: true do gitlab_sign_in(user) project.add_user(user, Gitlab::Access::MASTER) project2.add_user(user, Gitlab::Access::MASTER) - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) end it 'clicks toggle and shows dropdown' do @@ -124,7 +124,7 @@ feature 'Project', feature: true do before do project.team << [user, :master] gitlab_sign_in user - visit namespace_project_path(project.namespace, project) + visit project_path(project) end it 'has working links to files' do diff --git a/spec/features/protected_branches_spec.rb b/spec/features/protected_branches_spec.rb index 20b8e10f0f7..952eb6c3643 100644 --- a/spec/features/protected_branches_spec.rb +++ b/spec/features/protected_branches_spec.rb @@ -16,7 +16,7 @@ feature 'Protected Branches', feature: true, js: true do describe "explicit protected branches" do it "allows creating explicit protected branches" do - visit namespace_project_protected_branches_path(project.namespace, project) + visit project_protected_branches_path(project) set_protected_branch_name('some-branch') click_on "Protect" @@ -29,7 +29,7 @@ feature 'Protected Branches', feature: true, js: true do commit = create(:commit, project: project) project.repository.add_branch(user, 'some-branch', commit.id) - visit namespace_project_protected_branches_path(project.namespace, project) + visit project_protected_branches_path(project) set_protected_branch_name('some-branch') click_on "Protect" @@ -37,7 +37,7 @@ feature 'Protected Branches', feature: true, js: true do end it "displays an error message if the named branch does not exist" do - visit namespace_project_protected_branches_path(project.namespace, project) + visit project_protected_branches_path(project) set_protected_branch_name('some-branch') click_on "Protect" @@ -47,7 +47,7 @@ feature 'Protected Branches', feature: true, js: true do describe "wildcard protected branches" do it "allows creating protected branches with a wildcard" do - visit namespace_project_protected_branches_path(project.namespace, project) + visit project_protected_branches_path(project) set_protected_branch_name('*-stable') click_on "Protect" @@ -60,7 +60,7 @@ feature 'Protected Branches', feature: true, js: true do project.repository.add_branch(user, 'production-stable', 'master') project.repository.add_branch(user, 'staging-stable', 'master') - visit namespace_project_protected_branches_path(project.namespace, project) + visit project_protected_branches_path(project) set_protected_branch_name('*-stable') click_on "Protect" @@ -72,11 +72,11 @@ feature 'Protected Branches', feature: true, js: true do project.repository.add_branch(user, 'staging-stable', 'master') project.repository.add_branch(user, 'development', 'master') - visit namespace_project_protected_branches_path(project.namespace, project) + visit project_protected_branches_path(project) set_protected_branch_name('*-stable') click_on "Protect" - visit namespace_project_protected_branches_path(project.namespace, project) + visit project_protected_branches_path(project) click_on "2 matching branches" within(".protected-branches-list") do diff --git a/spec/features/protected_tags_spec.rb b/spec/features/protected_tags_spec.rb index 73a80692154..4ffd97fb221 100644 --- a/spec/features/protected_tags_spec.rb +++ b/spec/features/protected_tags_spec.rb @@ -17,7 +17,7 @@ feature 'Projected Tags', feature: true, js: true do describe "explicit protected tags" do it "allows creating explicit protected tags" do - visit namespace_project_protected_tags_path(project.namespace, project) + visit project_protected_tags_path(project) set_protected_tag_name('some-tag') click_on "Protect" @@ -30,7 +30,7 @@ feature 'Projected Tags', feature: true, js: true do commit = create(:commit, project: project) project.repository.add_tag(user, 'some-tag', commit.id) - visit namespace_project_protected_tags_path(project.namespace, project) + visit project_protected_tags_path(project) set_protected_tag_name('some-tag') click_on "Protect" @@ -38,7 +38,7 @@ feature 'Projected Tags', feature: true, js: true do end it "displays an error message if the named tag does not exist" do - visit namespace_project_protected_tags_path(project.namespace, project) + visit project_protected_tags_path(project) set_protected_tag_name('some-tag') click_on "Protect" @@ -48,7 +48,7 @@ feature 'Projected Tags', feature: true, js: true do describe "wildcard protected tags" do it "allows creating protected tags with a wildcard" do - visit namespace_project_protected_tags_path(project.namespace, project) + visit project_protected_tags_path(project) set_protected_tag_name('*-stable') click_on "Protect" @@ -61,7 +61,7 @@ feature 'Projected Tags', feature: true, js: true do project.repository.add_tag(user, 'production-stable', 'master') project.repository.add_tag(user, 'staging-stable', 'master') - visit namespace_project_protected_tags_path(project.namespace, project) + visit project_protected_tags_path(project) set_protected_tag_name('*-stable') click_on "Protect" @@ -73,11 +73,11 @@ feature 'Projected Tags', feature: true, js: true do project.repository.add_tag(user, 'staging-stable', 'master') project.repository.add_tag(user, 'development', 'master') - visit namespace_project_protected_tags_path(project.namespace, project) + visit project_protected_tags_path(project) set_protected_tag_name('*-stable') click_on "Protect" - visit namespace_project_protected_tags_path(project.namespace, project) + visit project_protected_tags_path(project) click_on "2 matching tags" within(".protected-tags-list") do diff --git a/spec/features/reportable_note/commit_spec.rb b/spec/features/reportable_note/commit_spec.rb index 12049822753..2486f779753 100644 --- a/spec/features/reportable_note/commit_spec.rb +++ b/spec/features/reportable_note/commit_spec.rb @@ -15,7 +15,7 @@ describe 'Reportable note on commit', :feature, :js do let!(:note) { create(:note_on_commit, commit_id: sample_commit.id, project: project) } before do - visit namespace_project_commit_path(project.namespace, project, sample_commit.id) + visit project_commit_path(project, sample_commit.id) end it_behaves_like 'reportable note' @@ -25,7 +25,7 @@ describe 'Reportable note on commit', :feature, :js do let!(:note) { create(:diff_note_on_commit, commit_id: sample_commit.id, project: project) } before do - visit namespace_project_commit_path(project.namespace, project, sample_commit.id) + visit project_commit_path(project, sample_commit.id) end it_behaves_like 'reportable note' diff --git a/spec/features/reportable_note/issue_spec.rb b/spec/features/reportable_note/issue_spec.rb index ca2a7f41496..d283c2d3c8f 100644 --- a/spec/features/reportable_note/issue_spec.rb +++ b/spec/features/reportable_note/issue_spec.rb @@ -10,7 +10,7 @@ describe 'Reportable note on issue', :feature, :js do project.add_master(user) gitlab_sign_in(user) - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) end it_behaves_like 'reportable note' diff --git a/spec/features/reportable_note/merge_request_spec.rb b/spec/features/reportable_note/merge_request_spec.rb index 8e75b4af3eb..fe25c894b85 100644 --- a/spec/features/reportable_note/merge_request_spec.rb +++ b/spec/features/reportable_note/merge_request_spec.rb @@ -9,7 +9,7 @@ describe 'Reportable note on merge request', :feature, :js do project.add_master(user) gitlab_sign_in(user) - visit namespace_project_merge_request_path(project.namespace, project, merge_request) + visit project_merge_request_path(project, merge_request) end context 'a normal note' do diff --git a/spec/features/reportable_note/snippets_spec.rb b/spec/features/reportable_note/snippets_spec.rb index 5bee4a31379..b3044d3d048 100644 --- a/spec/features/reportable_note/snippets_spec.rb +++ b/spec/features/reportable_note/snippets_spec.rb @@ -14,7 +14,7 @@ describe 'Reportable note on snippets', :feature, :js do let!(:note) { create(:note_on_project_snippet, noteable: snippet, project: project) } before do - visit namespace_project_snippet_path(project.namespace, project, snippet) + visit project_snippet_path(project, snippet) end it_behaves_like 'reportable note' diff --git a/spec/features/runners_spec.rb b/spec/features/runners_spec.rb index ea18879b4bf..00f59f8f197 100644 --- a/spec/features/runners_spec.rb +++ b/spec/features/runners_spec.rb @@ -1,8 +1,6 @@ require 'spec_helper' describe "Runners" do - include GitlabRoutingHelper - let(:user) { create(:user) } before do @@ -124,7 +122,7 @@ describe "Runners" do end scenario 'user checks default configuration' do - visit namespace_project_runner_path(project.namespace, project, runner) + visit project_runner_path(project, runner) expect(page).to have_content 'Can run untagged jobs Yes' end diff --git a/spec/features/search_spec.rb b/spec/features/search_spec.rb index 64469f999af..69b42193955 100644 --- a/spec/features/search_spec.rb +++ b/spec/features/search_spec.rb @@ -88,7 +88,7 @@ describe "Search", feature: true do end it 'finds comment' do - visit namespace_project_path(project.namespace, project) + visit project_path(project) page.within '.search' do fill_in 'search', with: note.note @@ -111,7 +111,7 @@ describe "Search", feature: true do project: project) # Must visit project dashboard since global search won't search # everything (e.g. comments, snippets, etc.) - visit namespace_project_path(project.namespace, project) + visit project_path(project) page.within '.search' do fill_in 'search', with: note.note @@ -125,7 +125,7 @@ describe "Search", feature: true do it 'finds a commit' do project = create(:project, :repository) { |p| p.add_reporter(user) } - visit namespace_project_path(project.namespace, project) + visit project_path(project) page.within '.search' do fill_in 'search', with: 'add' @@ -139,7 +139,7 @@ describe "Search", feature: true do it 'finds a code' do project = create(:project, :repository) { |p| p.add_reporter(user) } - visit namespace_project_path(project.namespace, project) + visit project_path(project) page.within '.search' do fill_in 'search', with: 'application.js' @@ -156,7 +156,7 @@ describe "Search", feature: true do describe 'Right header search field', feature: true do it 'allows enter key to search', js: true do - visit namespace_project_path(project.namespace, project) + visit project_path(project) fill_in 'search', with: 'gitlab' find('#search').native.send_keys(:enter) @@ -167,7 +167,7 @@ describe "Search", feature: true do describe 'Search in project page' do before do - visit namespace_project_path(project.namespace, project) + visit project_path(project) end it 'shows top right search form' do @@ -256,7 +256,7 @@ describe "Search", feature: true do click_button 'Search' - expect(page).to have_current_path(namespace_project_commit_path(project.namespace, project, '6d394385cf567f80a8fd85055db1ab4c5295806f')) + expect(page).to have_current_path(project_commit_path(project, '6d394385cf567f80a8fd85055db1ab4c5295806f')) end it 'redirects to single commit regardless of query case' do @@ -264,7 +264,7 @@ describe "Search", feature: true do click_button 'Search' - expect(page).to have_current_path(namespace_project_commit_path(project.namespace, project, '6d394385cf567f80a8fd85055db1ab4c5295806f')) + expect(page).to have_current_path(project_commit_path(project, '6d394385cf567f80a8fd85055db1ab4c5295806f')) end it 'holds on /search page when the only commit is found by message' do diff --git a/spec/features/security/project/internal_access_spec.rb b/spec/features/security/project/internal_access_spec.rb index 5e26b8bbed6..1000a0bdd89 100644 --- a/spec/features/security/project/internal_access_spec.rb +++ b/spec/features/security/project/internal_access_spec.rb @@ -13,7 +13,7 @@ describe "Internal Project Access", feature: true do end describe "GET /:project_path" do - subject { namespace_project_path(project.namespace, project) } + subject { project_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -27,7 +27,7 @@ describe "Internal Project Access", feature: true do end describe "GET /:project_path/tree/master" do - subject { namespace_project_tree_path(project.namespace, project, project.repository.root_ref) } + subject { project_tree_path(project, project.repository.root_ref) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -41,7 +41,7 @@ describe "Internal Project Access", feature: true do end describe "GET /:project_path/commits/master" do - subject { namespace_project_commits_path(project.namespace, project, project.repository.root_ref, limit: 1) } + subject { project_commits_path(project, project.repository.root_ref, limit: 1) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -55,7 +55,7 @@ describe "Internal Project Access", feature: true do end describe "GET /:project_path/commit/:sha" do - subject { namespace_project_commit_path(project.namespace, project, project.repository.commit) } + subject { project_commit_path(project, project.repository.commit) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -69,7 +69,7 @@ describe "Internal Project Access", feature: true do end describe "GET /:project_path/compare" do - subject { namespace_project_compare_index_path(project.namespace, project) } + subject { project_compare_index_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -83,7 +83,7 @@ describe "Internal Project Access", feature: true do end describe "GET /:project_path/settings/members" do - subject { namespace_project_settings_members_path(project.namespace, project) } + subject { project_settings_members_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -97,7 +97,7 @@ describe "Internal Project Access", feature: true do end describe "GET /:project_path/settings/ci_cd" do - subject { namespace_project_settings_ci_cd_path(project.namespace, project) } + subject { project_settings_ci_cd_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -111,7 +111,7 @@ describe "Internal Project Access", feature: true do end describe "GET /:project_path/settings/repository" do - subject { namespace_project_settings_repository_path(project.namespace, project) } + subject { project_settings_repository_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -126,7 +126,7 @@ describe "Internal Project Access", feature: true do describe "GET /:project_path/blob" do let(:commit) { project.repository.commit } - subject { namespace_project_blob_path(project.namespace, project, File.join(commit.id, '.gitignore')) } + subject { project_blob_path(project, File.join(commit.id, '.gitignore')) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -140,7 +140,7 @@ describe "Internal Project Access", feature: true do end describe "GET /:project_path/edit" do - subject { edit_namespace_project_path(project.namespace, project) } + subject { edit_project_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -154,7 +154,7 @@ describe "Internal Project Access", feature: true do end describe "GET /:project_path/deploy_keys" do - subject { namespace_project_deploy_keys_path(project.namespace, project) } + subject { project_deploy_keys_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -168,7 +168,7 @@ describe "Internal Project Access", feature: true do end describe "GET /:project_path/issues" do - subject { namespace_project_issues_path(project.namespace, project) } + subject { project_issues_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -183,7 +183,7 @@ describe "Internal Project Access", feature: true do describe "GET /:project_path/issues/:id/edit" do let(:issue) { create(:issue, project: project) } - subject { edit_namespace_project_issue_path(project.namespace, project, issue) } + subject { edit_project_issue_path(project, issue) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -197,7 +197,7 @@ describe "Internal Project Access", feature: true do end describe "GET /:project_path/snippets" do - subject { namespace_project_snippets_path(project.namespace, project) } + subject { project_snippets_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -211,7 +211,7 @@ describe "Internal Project Access", feature: true do end describe "GET /:project_path/snippets/new" do - subject { new_namespace_project_snippet_path(project.namespace, project) } + subject { new_project_snippet_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -225,7 +225,7 @@ describe "Internal Project Access", feature: true do end describe "GET /:project_path/merge_requests" do - subject { namespace_project_merge_requests_path(project.namespace, project) } + subject { project_merge_requests_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -239,7 +239,7 @@ describe "Internal Project Access", feature: true do end describe "GET /:project_path/merge_requests/new" do - subject { namespace_project_new_merge_request_path(project.namespace, project) } + subject { project_new_merge_request_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -253,7 +253,7 @@ describe "Internal Project Access", feature: true do end describe "GET /:project_path/branches" do - subject { namespace_project_branches_path(project.namespace, project) } + subject { project_branches_path(project) } before do # Speed increase @@ -272,7 +272,7 @@ describe "Internal Project Access", feature: true do end describe "GET /:project_path/tags" do - subject { namespace_project_tags_path(project.namespace, project) } + subject { project_tags_path(project) } before do # Speed increase @@ -291,7 +291,7 @@ describe "Internal Project Access", feature: true do end describe "GET /:project_path/settings/integrations" do - subject { namespace_project_settings_integrations_path(project.namespace, project) } + subject { project_settings_integrations_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -305,7 +305,7 @@ describe "Internal Project Access", feature: true do end describe "GET /:project_path/pipelines" do - subject { namespace_project_pipelines_path(project.namespace, project) } + subject { project_pipelines_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -320,7 +320,7 @@ describe "Internal Project Access", feature: true do describe "GET /:project_path/pipelines/:id" do let(:pipeline) { create(:ci_pipeline, project: project) } - subject { namespace_project_pipeline_path(project.namespace, project, pipeline) } + subject { project_pipeline_path(project, pipeline) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -334,7 +334,7 @@ describe "Internal Project Access", feature: true do end describe "GET /:project_path/builds" do - subject { namespace_project_jobs_path(project.namespace, project) } + subject { project_jobs_path(project) } context "when allowed for public and internal" do before do @@ -372,7 +372,7 @@ describe "Internal Project Access", feature: true do describe "GET /:project_path/builds/:id" do let(:pipeline) { create(:ci_pipeline, project: project) } let(:build) { create(:ci_build, pipeline: pipeline) } - subject { namespace_project_job_path(project.namespace, project, build.id) } + subject { project_job_path(project, build.id) } context "when allowed for public and internal" do before do @@ -410,7 +410,7 @@ describe "Internal Project Access", feature: true do describe 'GET /:project_path/builds/:id/trace' do let(:pipeline) { create(:ci_pipeline, project: project) } let(:build) { create(:ci_build, pipeline: pipeline) } - subject { trace_namespace_project_job_path(project.namespace, project, build.id) } + subject { trace_project_job_path(project, build.id) } context 'when allowed for public and internal' do before do @@ -446,7 +446,7 @@ describe "Internal Project Access", feature: true do end describe "GET /:project_path/pipeline_schedules" do - subject { namespace_project_pipeline_schedules_path(project.namespace, project) } + subject { project_pipeline_schedules_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -460,7 +460,7 @@ describe "Internal Project Access", feature: true do end describe "GET /:project_path/environments" do - subject { namespace_project_environments_path(project.namespace, project) } + subject { project_environments_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -475,7 +475,7 @@ describe "Internal Project Access", feature: true do describe "GET /:project_path/environments/:id" do let(:environment) { create(:environment, project: project) } - subject { namespace_project_environment_path(project.namespace, project, environment) } + subject { project_environment_path(project, environment) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -490,7 +490,7 @@ describe "Internal Project Access", feature: true do describe "GET /:project_path/environments/:id/deployments" do let(:environment) { create(:environment, project: project) } - subject { namespace_project_environment_deployments_path(project.namespace, project, environment) } + subject { project_environment_deployments_path(project, environment) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -504,7 +504,7 @@ describe "Internal Project Access", feature: true do end describe "GET /:project_path/environments/new" do - subject { new_namespace_project_environment_path(project.namespace, project) } + subject { new_project_environment_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -526,7 +526,7 @@ describe "Internal Project Access", feature: true do project.container_repositories << container_repository end - subject { namespace_project_container_registry_index_path(project.namespace, project) } + subject { project_container_registry_index_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } diff --git a/spec/features/security/project/private_access_spec.rb b/spec/features/security/project/private_access_spec.rb index b676c236758..94d759393ca 100644 --- a/spec/features/security/project/private_access_spec.rb +++ b/spec/features/security/project/private_access_spec.rb @@ -13,7 +13,7 @@ describe "Private Project Access", feature: true do end describe "GET /:project_path" do - subject { namespace_project_path(project.namespace, project) } + subject { project_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -27,7 +27,7 @@ describe "Private Project Access", feature: true do end describe "GET /:project_path/tree/master" do - subject { namespace_project_tree_path(project.namespace, project, project.repository.root_ref) } + subject { project_tree_path(project, project.repository.root_ref) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -41,7 +41,7 @@ describe "Private Project Access", feature: true do end describe "GET /:project_path/commits/master" do - subject { namespace_project_commits_path(project.namespace, project, project.repository.root_ref, limit: 1) } + subject { project_commits_path(project, project.repository.root_ref, limit: 1) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -55,7 +55,7 @@ describe "Private Project Access", feature: true do end describe "GET /:project_path/commit/:sha" do - subject { namespace_project_commit_path(project.namespace, project, project.repository.commit) } + subject { project_commit_path(project, project.repository.commit) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -69,7 +69,7 @@ describe "Private Project Access", feature: true do end describe "GET /:project_path/compare" do - subject { namespace_project_compare_index_path(project.namespace, project) } + subject { project_compare_index_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -83,7 +83,7 @@ describe "Private Project Access", feature: true do end describe "GET /:project_path/settings/members" do - subject { namespace_project_settings_members_path(project.namespace, project) } + subject { project_settings_members_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -97,7 +97,7 @@ describe "Private Project Access", feature: true do end describe "GET /:project_path/settings/ci_cd" do - subject { namespace_project_settings_ci_cd_path(project.namespace, project) } + subject { project_settings_ci_cd_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -111,7 +111,7 @@ describe "Private Project Access", feature: true do end describe "GET /:project_path/settings/repository" do - subject { namespace_project_settings_repository_path(project.namespace, project) } + subject { project_settings_repository_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -126,7 +126,7 @@ describe "Private Project Access", feature: true do describe "GET /:project_path/blob" do let(:commit) { project.repository.commit } - subject { namespace_project_blob_path(project.namespace, project, File.join(commit.id, '.gitignore'))} + subject { project_blob_path(project, File.join(commit.id, '.gitignore'))} it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -140,7 +140,7 @@ describe "Private Project Access", feature: true do end describe "GET /:project_path/edit" do - subject { edit_namespace_project_path(project.namespace, project) } + subject { edit_project_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -154,7 +154,7 @@ describe "Private Project Access", feature: true do end describe "GET /:project_path/deploy_keys" do - subject { namespace_project_deploy_keys_path(project.namespace, project) } + subject { project_deploy_keys_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -168,7 +168,7 @@ describe "Private Project Access", feature: true do end describe "GET /:project_path/issues" do - subject { namespace_project_issues_path(project.namespace, project) } + subject { project_issues_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -183,7 +183,7 @@ describe "Private Project Access", feature: true do describe "GET /:project_path/issues/:id/edit" do let(:issue) { create(:issue, project: project) } - subject { edit_namespace_project_issue_path(project.namespace, project, issue) } + subject { edit_project_issue_path(project, issue) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -197,7 +197,7 @@ describe "Private Project Access", feature: true do end describe "GET /:project_path/snippets" do - subject { namespace_project_snippets_path(project.namespace, project) } + subject { project_snippets_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -211,7 +211,7 @@ describe "Private Project Access", feature: true do end describe "GET /:project_path/merge_requests" do - subject { namespace_project_merge_requests_path(project.namespace, project) } + subject { project_merge_requests_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -225,7 +225,7 @@ describe "Private Project Access", feature: true do end describe "GET /:project_path/branches" do - subject { namespace_project_branches_path(project.namespace, project) } + subject { project_branches_path(project) } before do # Speed increase @@ -244,7 +244,7 @@ describe "Private Project Access", feature: true do end describe "GET /:project_path/tags" do - subject { namespace_project_tags_path(project.namespace, project) } + subject { project_tags_path(project) } before do # Speed increase @@ -263,7 +263,7 @@ describe "Private Project Access", feature: true do end describe "GET /:project_path/namespace/hooks" do - subject { namespace_project_settings_integrations_path(project.namespace, project) } + subject { project_settings_integrations_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -277,7 +277,7 @@ describe "Private Project Access", feature: true do end describe "GET /:project_path/pipelines" do - subject { namespace_project_pipelines_path(project.namespace, project) } + subject { project_pipelines_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -304,7 +304,7 @@ describe "Private Project Access", feature: true do describe "GET /:project_path/pipelines/:id" do let(:pipeline) { create(:ci_pipeline, project: project) } - subject { namespace_project_pipeline_path(project.namespace, project, pipeline) } + subject { project_pipeline_path(project, pipeline) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -330,7 +330,7 @@ describe "Private Project Access", feature: true do end describe "GET /:project_path/builds" do - subject { namespace_project_jobs_path(project.namespace, project) } + subject { project_jobs_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -358,7 +358,7 @@ describe "Private Project Access", feature: true do describe "GET /:project_path/builds/:id" do let(:pipeline) { create(:ci_pipeline, project: project) } let(:build) { create(:ci_build, pipeline: pipeline) } - subject { namespace_project_job_path(project.namespace, project, build.id) } + subject { project_job_path(project, build.id) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -391,7 +391,7 @@ describe "Private Project Access", feature: true do describe 'GET /:project_path/builds/:id/trace' do let(:pipeline) { create(:ci_pipeline, project: project) } let(:build) { create(:ci_build, pipeline: pipeline) } - subject { trace_namespace_project_job_path(project.namespace, project, build.id) } + subject { trace_project_job_path(project, build.id) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -421,7 +421,7 @@ describe "Private Project Access", feature: true do end describe "GET /:project_path/environments" do - subject { namespace_project_environments_path(project.namespace, project) } + subject { project_environments_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -436,7 +436,7 @@ describe "Private Project Access", feature: true do describe "GET /:project_path/environments/:id" do let(:environment) { create(:environment, project: project) } - subject { namespace_project_environment_path(project.namespace, project, environment) } + subject { project_environment_path(project, environment) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -451,7 +451,7 @@ describe "Private Project Access", feature: true do describe "GET /:project_path/environments/:id/deployments" do let(:environment) { create(:environment, project: project) } - subject { namespace_project_environment_deployments_path(project.namespace, project, environment) } + subject { project_environment_deployments_path(project, environment) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -465,7 +465,7 @@ describe "Private Project Access", feature: true do end describe "GET /:project_path/environments/new" do - subject { new_namespace_project_environment_path(project.namespace, project) } + subject { new_project_environment_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -479,7 +479,7 @@ describe "Private Project Access", feature: true do end describe "GET /:project_path/pipeline_schedules" do - subject { namespace_project_pipeline_schedules_path(project.namespace, project) } + subject { project_pipeline_schedules_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -493,7 +493,7 @@ describe "Private Project Access", feature: true do end describe "GET /:project_path/pipeline_schedules/new" do - subject { new_namespace_project_pipeline_schedule_path(project.namespace, project) } + subject { new_project_pipeline_schedule_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -507,7 +507,7 @@ describe "Private Project Access", feature: true do end describe "GET /:project_path/environments/new" do - subject { new_namespace_project_pipeline_schedule_path(project.namespace, project) } + subject { new_project_pipeline_schedule_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -529,7 +529,7 @@ describe "Private Project Access", feature: true do project.container_repositories << container_repository end - subject { namespace_project_container_registry_index_path(project.namespace, project) } + subject { project_container_registry_index_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } diff --git a/spec/features/security/project/public_access_spec.rb b/spec/features/security/project/public_access_spec.rb index 59655b0c31a..d45e1dbc09b 100644 --- a/spec/features/security/project/public_access_spec.rb +++ b/spec/features/security/project/public_access_spec.rb @@ -13,7 +13,7 @@ describe "Public Project Access", feature: true do end describe "GET /:project_path" do - subject { namespace_project_path(project.namespace, project) } + subject { project_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -27,7 +27,7 @@ describe "Public Project Access", feature: true do end describe "GET /:project_path/tree/master" do - subject { namespace_project_tree_path(project.namespace, project, project.repository.root_ref) } + subject { project_tree_path(project, project.repository.root_ref) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -41,7 +41,7 @@ describe "Public Project Access", feature: true do end describe "GET /:project_path/commits/master" do - subject { namespace_project_commits_path(project.namespace, project, project.repository.root_ref, limit: 1) } + subject { project_commits_path(project, project.repository.root_ref, limit: 1) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -55,7 +55,7 @@ describe "Public Project Access", feature: true do end describe "GET /:project_path/commit/:sha" do - subject { namespace_project_commit_path(project.namespace, project, project.repository.commit) } + subject { project_commit_path(project, project.repository.commit) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -69,7 +69,7 @@ describe "Public Project Access", feature: true do end describe "GET /:project_path/compare" do - subject { namespace_project_compare_index_path(project.namespace, project) } + subject { project_compare_index_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -83,7 +83,7 @@ describe "Public Project Access", feature: true do end describe "GET /:project_path/settings/members" do - subject { namespace_project_settings_members_path(project.namespace, project) } + subject { project_settings_members_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -97,7 +97,7 @@ describe "Public Project Access", feature: true do end describe "GET /:project_path/settings/ci_cd" do - subject { namespace_project_settings_ci_cd_path(project.namespace, project) } + subject { project_settings_ci_cd_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -111,7 +111,7 @@ describe "Public Project Access", feature: true do end describe "GET /:project_path/settings/repository" do - subject { namespace_project_settings_repository_path(project.namespace, project) } + subject { project_settings_repository_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -125,7 +125,7 @@ describe "Public Project Access", feature: true do end describe "GET /:project_path/pipelines" do - subject { namespace_project_pipelines_path(project.namespace, project) } + subject { project_pipelines_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -140,7 +140,7 @@ describe "Public Project Access", feature: true do describe "GET /:project_path/pipelines/:id" do let(:pipeline) { create(:ci_pipeline, project: project) } - subject { namespace_project_pipeline_path(project.namespace, project, pipeline) } + subject { project_pipeline_path(project, pipeline) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -154,7 +154,7 @@ describe "Public Project Access", feature: true do end describe "GET /:project_path/builds" do - subject { namespace_project_jobs_path(project.namespace, project) } + subject { project_jobs_path(project) } context "when allowed for public" do before do @@ -192,7 +192,7 @@ describe "Public Project Access", feature: true do describe "GET /:project_path/builds/:id" do let(:pipeline) { create(:ci_pipeline, project: project) } let(:build) { create(:ci_build, pipeline: pipeline) } - subject { namespace_project_job_path(project.namespace, project, build.id) } + subject { project_job_path(project, build.id) } context "when allowed for public" do before do @@ -230,7 +230,7 @@ describe "Public Project Access", feature: true do describe 'GET /:project_path/builds/:id/trace' do let(:pipeline) { create(:ci_pipeline, project: project) } let(:build) { create(:ci_build, pipeline: pipeline) } - subject { trace_namespace_project_job_path(project.namespace, project, build.id) } + subject { trace_project_job_path(project, build.id) } context 'when allowed for public' do before do @@ -266,7 +266,7 @@ describe "Public Project Access", feature: true do end describe "GET /:project_path/pipeline_schedules" do - subject { namespace_project_pipeline_schedules_path(project.namespace, project) } + subject { project_pipeline_schedules_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -280,7 +280,7 @@ describe "Public Project Access", feature: true do end describe "GET /:project_path/environments" do - subject { namespace_project_environments_path(project.namespace, project) } + subject { project_environments_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -295,7 +295,7 @@ describe "Public Project Access", feature: true do describe "GET /:project_path/environments/:id" do let(:environment) { create(:environment, project: project) } - subject { namespace_project_environment_path(project.namespace, project, environment) } + subject { project_environment_path(project, environment) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -310,7 +310,7 @@ describe "Public Project Access", feature: true do describe "GET /:project_path/environments/:id/deployments" do let(:environment) { create(:environment, project: project) } - subject { namespace_project_environment_deployments_path(project.namespace, project, environment) } + subject { project_environment_deployments_path(project, environment) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -324,7 +324,7 @@ describe "Public Project Access", feature: true do end describe "GET /:project_path/environments/new" do - subject { new_namespace_project_environment_path(project.namespace, project) } + subject { new_project_environment_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -340,7 +340,7 @@ describe "Public Project Access", feature: true do describe "GET /:project_path/blob" do let(:commit) { project.repository.commit } - subject { namespace_project_blob_path(project.namespace, project, File.join(commit.id, '.gitignore')) } + subject { project_blob_path(project, File.join(commit.id, '.gitignore')) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -353,7 +353,7 @@ describe "Public Project Access", feature: true do end describe "GET /:project_path/edit" do - subject { edit_namespace_project_path(project.namespace, project) } + subject { edit_project_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -367,7 +367,7 @@ describe "Public Project Access", feature: true do end describe "GET /:project_path/deploy_keys" do - subject { namespace_project_deploy_keys_path(project.namespace, project) } + subject { project_deploy_keys_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -381,7 +381,7 @@ describe "Public Project Access", feature: true do end describe "GET /:project_path/issues" do - subject { namespace_project_issues_path(project.namespace, project) } + subject { project_issues_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -396,7 +396,7 @@ describe "Public Project Access", feature: true do describe "GET /:project_path/issues/:id/edit" do let(:issue) { create(:issue, project: project) } - subject { edit_namespace_project_issue_path(project.namespace, project, issue) } + subject { edit_project_issue_path(project, issue) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -410,7 +410,7 @@ describe "Public Project Access", feature: true do end describe "GET /:project_path/snippets" do - subject { namespace_project_snippets_path(project.namespace, project) } + subject { project_snippets_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -424,7 +424,7 @@ describe "Public Project Access", feature: true do end describe "GET /:project_path/snippets/new" do - subject { new_namespace_project_snippet_path(project.namespace, project) } + subject { new_project_snippet_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -438,7 +438,7 @@ describe "Public Project Access", feature: true do end describe "GET /:project_path/merge_requests" do - subject { namespace_project_merge_requests_path(project.namespace, project) } + subject { project_merge_requests_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -452,7 +452,7 @@ describe "Public Project Access", feature: true do end describe "GET /:project_path/merge_requests/new" do - subject { namespace_project_new_merge_request_path(project.namespace, project) } + subject { project_new_merge_request_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -466,7 +466,7 @@ describe "Public Project Access", feature: true do end describe "GET /:project_path/branches" do - subject { namespace_project_branches_path(project.namespace, project) } + subject { project_branches_path(project) } before do # Speed increase @@ -485,7 +485,7 @@ describe "Public Project Access", feature: true do end describe "GET /:project_path/tags" do - subject { namespace_project_tags_path(project.namespace, project) } + subject { project_tags_path(project) } before do # Speed increase @@ -504,7 +504,7 @@ describe "Public Project Access", feature: true do end describe "GET /:project_path/settings/integrations" do - subject { namespace_project_settings_integrations_path(project.namespace, project) } + subject { project_settings_integrations_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -526,7 +526,7 @@ describe "Public Project Access", feature: true do project.container_repositories << container_repository end - subject { namespace_project_container_registry_index_path(project.namespace, project) } + subject { project_container_registry_index_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } diff --git a/spec/features/security/project/snippet/internal_access_spec.rb b/spec/features/security/project/snippet/internal_access_spec.rb index 2659b3ee3ec..2420caa88c4 100644 --- a/spec/features/security/project/snippet/internal_access_spec.rb +++ b/spec/features/security/project/snippet/internal_access_spec.rb @@ -9,7 +9,7 @@ describe "Internal Project Snippets Access", feature: true do let(:private_snippet) { create(:project_snippet, :private, project: project, author: project.owner) } describe "GET /:project_path/snippets" do - subject { namespace_project_snippets_path(project.namespace, project) } + subject { project_snippets_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -23,7 +23,7 @@ describe "Internal Project Snippets Access", feature: true do end describe "GET /:project_path/snippets/new" do - subject { new_namespace_project_snippet_path(project.namespace, project) } + subject { new_project_snippet_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -38,7 +38,7 @@ describe "Internal Project Snippets Access", feature: true do describe "GET /:project_path/snippets/:id" do context "for an internal snippet" do - subject { namespace_project_snippet_path(project.namespace, project, internal_snippet) } + subject { project_snippet_path(project, internal_snippet) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -52,7 +52,7 @@ describe "Internal Project Snippets Access", feature: true do end context "for a private snippet" do - subject { namespace_project_snippet_path(project.namespace, project, private_snippet) } + subject { project_snippet_path(project, private_snippet) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -68,7 +68,7 @@ describe "Internal Project Snippets Access", feature: true do describe "GET /:project_path/snippets/:id/raw" do context "for an internal snippet" do - subject { raw_namespace_project_snippet_path(project.namespace, project, internal_snippet) } + subject { raw_project_snippet_path(project, internal_snippet) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -82,7 +82,7 @@ describe "Internal Project Snippets Access", feature: true do end context "for a private snippet" do - subject { raw_namespace_project_snippet_path(project.namespace, project, private_snippet) } + subject { raw_project_snippet_path(project, private_snippet) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } diff --git a/spec/features/security/project/snippet/private_access_spec.rb b/spec/features/security/project/snippet/private_access_spec.rb index 6eb9f163bd5..0b8548a675b 100644 --- a/spec/features/security/project/snippet/private_access_spec.rb +++ b/spec/features/security/project/snippet/private_access_spec.rb @@ -8,7 +8,7 @@ describe "Private Project Snippets Access", feature: true do let(:private_snippet) { create(:project_snippet, :private, project: project, author: project.owner) } describe "GET /:project_path/snippets" do - subject { namespace_project_snippets_path(project.namespace, project) } + subject { project_snippets_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -22,7 +22,7 @@ describe "Private Project Snippets Access", feature: true do end describe "GET /:project_path/snippets/new" do - subject { new_namespace_project_snippet_path(project.namespace, project) } + subject { new_project_snippet_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -36,7 +36,7 @@ describe "Private Project Snippets Access", feature: true do end describe "GET /:project_path/snippets/:id for a private snippet" do - subject { namespace_project_snippet_path(project.namespace, project, private_snippet) } + subject { project_snippet_path(project, private_snippet) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -50,7 +50,7 @@ describe "Private Project Snippets Access", feature: true do end describe "GET /:project_path/snippets/:id/raw for a private snippet" do - subject { raw_namespace_project_snippet_path(project.namespace, project, private_snippet) } + subject { raw_project_snippet_path(project, private_snippet) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } diff --git a/spec/features/security/project/snippet/public_access_spec.rb b/spec/features/security/project/snippet/public_access_spec.rb index f3329d0bc96..153f8f964a6 100644 --- a/spec/features/security/project/snippet/public_access_spec.rb +++ b/spec/features/security/project/snippet/public_access_spec.rb @@ -10,7 +10,7 @@ describe "Public Project Snippets Access", feature: true do let(:private_snippet) { create(:project_snippet, :private, project: project, author: project.owner) } describe "GET /:project_path/snippets" do - subject { namespace_project_snippets_path(project.namespace, project) } + subject { project_snippets_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -24,7 +24,7 @@ describe "Public Project Snippets Access", feature: true do end describe "GET /:project_path/snippets/new" do - subject { new_namespace_project_snippet_path(project.namespace, project) } + subject { new_project_snippet_path(project) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -39,7 +39,7 @@ describe "Public Project Snippets Access", feature: true do describe "GET /:project_path/snippets/:id" do context "for a public snippet" do - subject { namespace_project_snippet_path(project.namespace, project, public_snippet) } + subject { project_snippet_path(project, public_snippet) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -53,7 +53,7 @@ describe "Public Project Snippets Access", feature: true do end context "for an internal snippet" do - subject { namespace_project_snippet_path(project.namespace, project, internal_snippet) } + subject { project_snippet_path(project, internal_snippet) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -67,7 +67,7 @@ describe "Public Project Snippets Access", feature: true do end context "for a private snippet" do - subject { namespace_project_snippet_path(project.namespace, project, private_snippet) } + subject { project_snippet_path(project, private_snippet) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -83,7 +83,7 @@ describe "Public Project Snippets Access", feature: true do describe "GET /:project_path/snippets/:id/raw" do context "for a public snippet" do - subject { raw_namespace_project_snippet_path(project.namespace, project, public_snippet) } + subject { raw_project_snippet_path(project, public_snippet) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -97,7 +97,7 @@ describe "Public Project Snippets Access", feature: true do end context "for an internal snippet" do - subject { raw_namespace_project_snippet_path(project.namespace, project, internal_snippet) } + subject { raw_project_snippet_path(project, internal_snippet) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } @@ -111,7 +111,7 @@ describe "Public Project Snippets Access", feature: true do end context "for a private snippet" do - subject { raw_namespace_project_snippet_path(project.namespace, project, private_snippet) } + subject { raw_project_snippet_path(project, private_snippet) } it { is_expected.to be_allowed_for(:admin) } it { is_expected.to be_allowed_for(:owner).of(project) } diff --git a/spec/features/tags/master_creates_tag_spec.rb b/spec/features/tags/master_creates_tag_spec.rb index 52db3583dac..3bf5544a837 100644 --- a/spec/features/tags/master_creates_tag_spec.rb +++ b/spec/features/tags/master_creates_tag_spec.rb @@ -11,7 +11,7 @@ feature 'Master creates tag', feature: true do context 'from tag list' do before do - visit namespace_project_tags_path(project.namespace, project) + visit project_tags_path(project) end scenario 'with an invalid name displays an error' do @@ -36,7 +36,7 @@ feature 'Master creates tag', feature: true do create_tag_in_form(tag: 'v3.0', ref: 'master', message: "Awesome tag message\n\n- hello\n- world") expect(current_path).to eq( - namespace_project_tag_path(project.namespace, project, 'v3.0')) + project_tag_path(project, 'v3.0')) expect(page).to have_content 'v3.0' page.within 'pre.wrap' do expect(page).to have_content "Awesome tag message\n\n- hello\n- world" @@ -47,7 +47,7 @@ feature 'Master creates tag', feature: true do create_tag_in_form(tag: 'v4.0', ref: 'master', desc: "Awesome release notes\n\n- hello\n- world") expect(current_path).to eq( - namespace_project_tag_path(project.namespace, project, 'v4.0')) + project_tag_path(project, 'v4.0')) expect(page).to have_content 'v4.0' page.within '.description' do expect(page).to have_content 'Awesome release notes' @@ -72,7 +72,7 @@ feature 'Master creates tag', feature: true do context 'from new tag page' do before do - visit new_namespace_project_tag_path(project.namespace, project) + visit new_project_tag_path(project) end it 'description has autocomplete', :js do diff --git a/spec/features/tags/master_deletes_tag_spec.rb b/spec/features/tags/master_deletes_tag_spec.rb index 58f33e954f9..04f9cecd46d 100644 --- a/spec/features/tags/master_deletes_tag_spec.rb +++ b/spec/features/tags/master_deletes_tag_spec.rb @@ -7,7 +7,7 @@ feature 'Master deletes tag', feature: true do before do project.team << [user, :master] gitlab_sign_in(user) - visit namespace_project_tags_path(project.namespace, project) + visit project_tags_path(project) end context 'from the tags list page', js: true do @@ -24,12 +24,12 @@ feature 'Master deletes tag', feature: true do scenario 'deletes the tag' do click_on 'v1.0.0' expect(current_path).to eq( - namespace_project_tag_path(project.namespace, project, 'v1.0.0')) + project_tag_path(project, 'v1.0.0')) click_on 'Delete tag' expect(current_path).to eq( - namespace_project_tags_path(project.namespace, project)) + project_tags_path(project)) expect(page).not_to have_content 'v1.0.0' end end diff --git a/spec/features/tags/master_updates_tag_spec.rb b/spec/features/tags/master_updates_tag_spec.rb index 18c8c4c511c..092ffbb6d23 100644 --- a/spec/features/tags/master_updates_tag_spec.rb +++ b/spec/features/tags/master_updates_tag_spec.rb @@ -7,7 +7,7 @@ feature 'Master updates tag', feature: true do before do project.team << [user, :master] gitlab_sign_in(user) - visit namespace_project_tags_path(project.namespace, project) + visit project_tags_path(project) end context 'from the tags list page' do @@ -20,7 +20,7 @@ feature 'Master updates tag', feature: true do click_button 'Save changes' expect(current_path).to eq( - namespace_project_tag_path(project.namespace, project, 'v1.1.0')) + project_tag_path(project, 'v1.1.0')) expect(page).to have_content 'v1.1.0' expect(page).to have_content 'Awesome release notes' end @@ -45,7 +45,7 @@ feature 'Master updates tag', feature: true do click_button 'Save changes' expect(current_path).to eq( - namespace_project_tag_path(project.namespace, project, 'v1.1.0')) + project_tag_path(project, 'v1.1.0')) expect(page).to have_content 'v1.1.0' expect(page).to have_content 'Awesome release notes' end diff --git a/spec/features/tags/master_views_tags_spec.rb b/spec/features/tags/master_views_tags_spec.rb index 3c21fa06694..b1f3207eeea 100644 --- a/spec/features/tags/master_views_tags_spec.rb +++ b/spec/features/tags/master_views_tags_spec.rb @@ -11,13 +11,13 @@ feature 'Master views tags', feature: true do context 'when project has no tags' do let(:project) { create(:project_empty_repo) } before do - visit namespace_project_path(project.namespace, project) + visit project_path(project) click_on 'README' fill_in :commit_message, with: 'Add a README file', visible: true # Remove pre-receive hook so we can push without auth FileUtils.rm_f(File.join(project.repository.path, 'hooks', 'pre-receive')) click_button 'Commit changes' - visit namespace_project_tags_path(project.namespace, project) + visit project_tags_path(project) end scenario 'displays a specific message' do @@ -30,15 +30,15 @@ feature 'Master views tags', feature: true do let(:repository) { project.repository } before do - visit namespace_project_tags_path(project.namespace, project) + visit project_tags_path(project) end scenario 'avoids a N+1 query in branches index' do - control_count = ActiveRecord::QueryRecorder.new { visit namespace_project_tags_path(project.namespace, project) }.count + control_count = ActiveRecord::QueryRecorder.new { visit project_tags_path(project) }.count %w(one two three four five).each { |tag| repository.add_tag(user, tag, 'master', 'foo') } - expect { visit namespace_project_tags_path(project.namespace, project) }.not_to exceed_query_limit(control_count) + expect { visit project_tags_path(project) }.not_to exceed_query_limit(control_count) end scenario 'views the tags list page' do @@ -49,7 +49,7 @@ feature 'Master views tags', feature: true do click_on 'v1.0.0' expect(current_path).to eq( - namespace_project_tag_path(project.namespace, project, 'v1.0.0')) + project_tag_path(project, 'v1.0.0')) expect(page).to have_content 'v1.0.0' expect(page).to have_content 'This tag has no release notes.' end @@ -59,24 +59,24 @@ feature 'Master views tags', feature: true do click_on 'v1.0.0' expect(current_path).to eq( - namespace_project_tag_path(project.namespace, project, 'v1.0.0')) + project_tag_path(project, 'v1.0.0')) click_on 'Browse files' expect(current_path).to eq( - namespace_project_tree_path(project.namespace, project, 'v1.0.0')) + project_tree_path(project, 'v1.0.0')) end scenario 'has a button to browse commits' do click_on 'v1.0.0' expect(current_path).to eq( - namespace_project_tag_path(project.namespace, project, 'v1.0.0')) + project_tag_path(project, 'v1.0.0')) click_on 'Browse commits' expect(current_path).to eq( - namespace_project_commits_path(project.namespace, project, 'v1.0.0')) + project_commits_path(project, 'v1.0.0')) end end end diff --git a/spec/features/task_lists_spec.rb b/spec/features/task_lists_spec.rb index 51b1b8e2328..dfc362321aa 100644 --- a/spec/features/task_lists_spec.rb +++ b/spec/features/task_lists_spec.rb @@ -59,7 +59,7 @@ feature 'Task Lists', feature: true do end def visit_issue(project, issue) - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) end describe 'for Issues', feature: true do @@ -98,7 +98,7 @@ feature 'Task Lists', feature: true do end it 'provides a summary on Issues#index' do - visit namespace_project_issues_path(project.namespace, project) + visit project_issues_path(project) expect(page).to have_content("2 of 6 tasks completed") end end @@ -116,7 +116,7 @@ feature 'Task Lists', feature: true do end it 'provides a summary on Issues#index' do - visit namespace_project_issues_path(project.namespace, project) + visit project_issues_path(project) expect(page).to have_content("0 of 1 task completed") end @@ -135,7 +135,7 @@ feature 'Task Lists', feature: true do end it 'provides a summary on Issues#index' do - visit namespace_project_issues_path(project.namespace, project) + visit project_issues_path(project) expect(page).to have_content("1 of 1 task completed") end @@ -242,7 +242,7 @@ feature 'Task Lists', feature: true do describe 'for Merge Requests' do def visit_merge_request(project, merge) - visit namespace_project_merge_request_path(project.namespace, project, merge) + visit project_merge_request_path(project, merge) end describe 'multiple tasks' do @@ -281,7 +281,7 @@ feature 'Task Lists', feature: true do end it 'provides a summary on MergeRequests#index' do - visit namespace_project_merge_requests_path(project.namespace, project) + visit project_merge_requests_path(project) expect(page).to have_content("2 of 6 tasks completed") end end @@ -298,7 +298,7 @@ feature 'Task Lists', feature: true do end it 'provides a summary on MergeRequests#index' do - visit namespace_project_merge_requests_path(project.namespace, project) + visit project_merge_requests_path(project) expect(page).to have_content("0 of 1 task completed") end end @@ -315,7 +315,7 @@ feature 'Task Lists', feature: true do end it 'provides a summary on MergeRequests#index' do - visit namespace_project_merge_requests_path(project.namespace, project) + visit project_merge_requests_path(project) expect(page).to have_content("1 of 1 task completed") end end diff --git a/spec/features/triggers_spec.rb b/spec/features/triggers_spec.rb index 5af2c0e9035..47d5f94f54e 100644 --- a/spec/features/triggers_spec.rb +++ b/spec/features/triggers_spec.rb @@ -14,7 +14,7 @@ feature 'Triggers', feature: true, js: true do @project.team << [user2, :master] @project.team << [guest_user, :guest] - visit namespace_project_settings_ci_cd_path(@project.namespace, @project) + visit project_settings_ci_cd_path(@project) end describe 'create trigger workflow' do @@ -42,7 +42,7 @@ feature 'Triggers', feature: true, js: true do scenario 'click on edit trigger opens edit trigger page' do create(:ci_trigger, owner: user, project: @project, description: trigger_title) - visit namespace_project_settings_ci_cd_path(@project.namespace, @project) + visit project_settings_ci_cd_path(@project) # See if edit page has correct descrption find('a[title="Edit"]').click @@ -51,7 +51,7 @@ feature 'Triggers', feature: true, js: true do scenario 'edit trigger and save' do create(:ci_trigger, owner: user, project: @project, description: trigger_title) - visit namespace_project_settings_ci_cd_path(@project.namespace, @project) + visit project_settings_ci_cd_path(@project) # See if edit page opens, then fill in new description and save find('a[title="Edit"]').click @@ -67,7 +67,7 @@ feature 'Triggers', feature: true, js: true do scenario 'edit "legacy" trigger and save' do # Create new trigger without owner association, i.e. Legacy trigger create(:ci_trigger, owner: nil, project: @project) - visit namespace_project_settings_ci_cd_path(@project.namespace, @project) + visit project_settings_ci_cd_path(@project) # See if the trigger can be edited and description is blank find('a[title="Edit"]').click @@ -84,7 +84,7 @@ feature 'Triggers', feature: true, js: true do describe 'trigger "Take ownership" workflow' do before(:each) do create(:ci_trigger, owner: user2, project: @project, description: trigger_title) - visit namespace_project_settings_ci_cd_path(@project.namespace, @project) + visit project_settings_ci_cd_path(@project) end scenario 'button "Take ownership" has correct alert' do @@ -106,7 +106,7 @@ feature 'Triggers', feature: true, js: true do describe 'trigger "Revoke" workflow' do before(:each) do create(:ci_trigger, owner: user2, project: @project, description: trigger_title) - visit namespace_project_settings_ci_cd_path(@project.namespace, @project) + visit project_settings_ci_cd_path(@project) end scenario 'button "Revoke" has correct alert' do @@ -131,7 +131,7 @@ feature 'Triggers', feature: true, js: true do scenario 'show "legacy" badge for legacy trigger' do create(:ci_trigger, owner: nil, project: @project) - visit namespace_project_settings_ci_cd_path(@project.namespace, @project) + visit project_settings_ci_cd_path(@project) # See if trigger without owner (i.e. legacy) shows "legacy" badge and is editable expect(page.find('.triggers-list')).to have_content 'legacy' @@ -140,7 +140,7 @@ feature 'Triggers', feature: true, js: true do scenario 'show "invalid" badge for trigger with owner having insufficient permissions' do create(:ci_trigger, owner: guest_user, project: @project, description: trigger_title) - visit namespace_project_settings_ci_cd_path(@project.namespace, @project) + visit project_settings_ci_cd_path(@project) # See if trigger without owner (i.e. legacy) shows "legacy" badge and is non-editable expect(page.find('.triggers-list')).to have_content 'invalid' @@ -150,7 +150,7 @@ feature 'Triggers', feature: true, js: true do scenario 'do not show "Edit" or full token for not owned trigger' do # Create trigger with user different from current_user create(:ci_trigger, owner: user2, project: @project, description: trigger_title) - visit namespace_project_settings_ci_cd_path(@project.namespace, @project) + visit project_settings_ci_cd_path(@project) # See if trigger not owned by current_user shows only first few token chars and doesn't have copy-to-clipboard button expect(page.find('.triggers-list')).to have_content(@project.triggers.first.token[0..3]) @@ -163,7 +163,7 @@ feature 'Triggers', feature: true, js: true do scenario 'show "Edit" and full token for owned trigger' do create(:ci_trigger, owner: user, project: @project, description: trigger_title) - visit namespace_project_settings_ci_cd_path(@project.namespace, @project) + visit project_settings_ci_cd_path(@project) # See if trigger shows full token and has copy-to-clipboard button expect(page.find('.triggers-list')).to have_content @project.triggers.first.token diff --git a/spec/features/uploads/user_uploads_file_to_note_spec.rb b/spec/features/uploads/user_uploads_file_to_note_spec.rb index 77a1012762d..736178897a6 100644 --- a/spec/features/uploads/user_uploads_file_to_note_spec.rb +++ b/spec/features/uploads/user_uploads_file_to_note_spec.rb @@ -9,7 +9,7 @@ feature 'User uploads file to note', feature: true do before do gitlab_sign_in(user) - visit namespace_project_issue_path(project.namespace, project, issue) + visit project_issue_path(project, issue) end context 'before uploading' do diff --git a/spec/features/variables_spec.rb b/spec/features/variables_spec.rb index 85085bf305a..1a2dedf27eb 100644 --- a/spec/features/variables_spec.rb +++ b/spec/features/variables_spec.rb @@ -10,7 +10,7 @@ describe 'Project variables', js: true do project.team << [user, :master] project.variables << variable - visit namespace_project_settings_ci_cd_path(project.namespace, project) + visit project_settings_ci_cd_path(project) end it 'shows list of variables' do diff --git a/spec/fixtures/markdown.md.erb b/spec/fixtures/markdown.md.erb index 51a3e91d201..58b43805705 100644 --- a/spec/fixtures/markdown.md.erb +++ b/spec/fixtures/markdown.md.erb @@ -166,9 +166,9 @@ References should be parseable even inside _<%= merge_request.to_reference %>_ e - Issue in another project: <%= xissue.to_reference(project) %> - Ignored in code: `<%= issue.to_reference %>` - Ignored in links: [Link to <%= issue.to_reference %>](#issue-link) -- Issue by URL: <%= urls.namespace_project_issue_url(issue.project.namespace, issue.project, issue) %> +- Issue by URL: <%= urls.project_issue_url(issue.project, issue) %> - Link to issue by reference: [Issue](<%= issue.to_reference %>) -- Link to issue by URL: [Issue](<%= urls.namespace_project_issue_url(issue.project.namespace, issue.project, issue) %>) +- Link to issue by URL: [Issue](<%= urls.project_issue_url(issue.project, issue) %>) #### MergeRequestReferenceFilter @@ -176,9 +176,9 @@ References should be parseable even inside _<%= merge_request.to_reference %>_ e - Merge request in another project: <%= xmerge_request.to_reference(project) %> - Ignored in code: `<%= merge_request.to_reference %>` - Ignored in links: [Link to <%= merge_request.to_reference %>](#merge-request-link) -- Merge request by URL: <%= urls.namespace_project_merge_request_url(merge_request.project.namespace, merge_request.project, merge_request) %> +- Merge request by URL: <%= urls.project_merge_request_url(merge_request.project, merge_request) %> - Link to merge request by reference: [Merge request](<%= merge_request.to_reference %>) -- Link to merge request by URL: [Merge request](<%= urls.namespace_project_merge_request_url(merge_request.project.namespace, merge_request.project, merge_request) %>) +- Link to merge request by URL: [Merge request](<%= urls.project_merge_request_url(merge_request.project, merge_request) %>) #### SnippetReferenceFilter @@ -186,9 +186,9 @@ References should be parseable even inside _<%= merge_request.to_reference %>_ e - Snippet in another project: <%= xsnippet.to_reference(project) %> - Ignored in code: `<%= snippet.to_reference %>` - Ignored in links: [Link to <%= snippet.to_reference %>](#snippet-link) -- Snippet by URL: <%= urls.namespace_project_snippet_url(snippet.project.namespace, snippet.project, snippet) %> +- Snippet by URL: <%= urls.project_snippet_url(snippet.project, snippet) %> - Link to snippet by reference: [Snippet](<%= snippet.to_reference %>) -- Link to snippet by URL: [Snippet](<%= urls.namespace_project_snippet_url(snippet.project.namespace, snippet.project, snippet) %>) +- Link to snippet by URL: [Snippet](<%= urls.project_snippet_url(snippet.project, snippet) %>) #### CommitRangeReferenceFilter @@ -196,9 +196,9 @@ References should be parseable even inside _<%= merge_request.to_reference %>_ e - Range in another project: <%= xcommit_range.to_reference(project) %> - Ignored in code: `<%= commit_range.to_reference %>` - Ignored in links: [Link to <%= commit_range.to_reference %>](#commit-range-link) -- Range by URL: <%= urls.namespace_project_compare_url(commit_range.project.namespace, commit_range.project, commit_range.to_param) %> +- Range by URL: <%= urls.project_compare_url(commit_range.project, commit_range.to_param) %> - Link to range by reference: [Range](<%= commit_range.to_reference %>) -- Link to range by URL: [Range](<%= urls.namespace_project_compare_url(commit_range.project.namespace, commit_range.project, commit_range.to_param) %>) +- Link to range by URL: [Range](<%= urls.project_compare_url(commit_range.project, commit_range.to_param) %>) #### CommitReferenceFilter @@ -206,9 +206,9 @@ References should be parseable even inside _<%= merge_request.to_reference %>_ e - Commit in another project: <%= xcommit.to_reference(project) %> - Ignored in code: `<%= commit.to_reference %>` - Ignored in links: [Link to <%= commit.to_reference %>](#commit-link) -- Commit by URL: <%= urls.namespace_project_commit_url(commit.project.namespace, commit.project, commit) %> +- Commit by URL: <%= urls.project_commit_url(commit.project, commit) %> - Link to commit by reference: [Commit](<%= commit.to_reference %>) -- Link to commit by URL: [Commit](<%= urls.namespace_project_commit_url(commit.project.namespace, commit.project, commit) %>) +- Link to commit by URL: [Commit](<%= urls.project_commit_url(commit.project, commit) %>) #### LabelReferenceFilter @@ -227,7 +227,7 @@ References should be parseable even inside _<%= merge_request.to_reference %>_ e - Milestone in another project: <%= xmilestone.to_reference(project) %> - Ignored in code: `<%= simple_milestone.to_reference %>` - Ignored in links: [Link to <%= simple_milestone.to_reference %>](#milestone-link) -- Milestone by URL: <%= urls.namespace_project_milestone_url(milestone.project.namespace, milestone.project, milestone) %> +- Milestone by URL: <%= urls.project_milestone_url(milestone.project, milestone) %> - Link to milestone by URL: [Milestone](<%= milestone.to_reference %>) ### Task Lists diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index f161dbb4cf0..e0cad1da86a 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -76,7 +76,7 @@ describe ApplicationHelper do allow_any_instance_of(Project).to receive(:avatar_in_git).and_return(true) - avatar_url = "#{gitlab_host}#{namespace_project_avatar_path(project.namespace, project)}" + avatar_url = "#{gitlab_host}#{project_avatar_path(project)}" expect(helper.project_icon(project.full_path).to_s).to match(image_tag(avatar_url)) end end diff --git a/spec/helpers/gitlab_routing_helper_spec.rb b/spec/helpers/gitlab_routing_helper_spec.rb index 14847d0a49e..7a522487a74 100644 --- a/spec/helpers/gitlab_routing_helper_spec.rb +++ b/spec/helpers/gitlab_routing_helper_spec.rb @@ -5,37 +5,37 @@ describe GitlabRoutingHelper do describe '#project_members_url' do let(:project) { build_stubbed(:empty_project) } - it { expect(project_members_url(project)).to eq namespace_project_project_members_url(project.namespace, project) } + it { expect(project_members_url(project)).to eq project_project_members_url(project) } end describe '#project_member_path' do let(:project_member) { create(:project_member) } - it { expect(project_member_path(project_member)).to eq namespace_project_project_member_path(project_member.source.namespace, project_member.source, project_member) } + it { expect(project_member_path(project_member)).to eq project_project_member_path(project_member.source, project_member) } end describe '#request_access_project_members_path' do let(:project) { build_stubbed(:empty_project) } - it { expect(request_access_project_members_path(project)).to eq request_access_namespace_project_project_members_path(project.namespace, project) } + it { expect(request_access_project_members_path(project)).to eq request_access_project_project_members_path(project) } end describe '#leave_project_members_path' do let(:project) { build_stubbed(:empty_project) } - it { expect(leave_project_members_path(project)).to eq leave_namespace_project_project_members_path(project.namespace, project) } + it { expect(leave_project_members_path(project)).to eq leave_project_project_members_path(project) } end describe '#approve_access_request_project_member_path' do let(:project_member) { create(:project_member) } - it { expect(approve_access_request_project_member_path(project_member)).to eq approve_access_request_namespace_project_project_member_path(project_member.source.namespace, project_member.source, project_member) } + it { expect(approve_access_request_project_member_path(project_member)).to eq approve_access_request_project_project_member_path(project_member.source, project_member) } end describe '#resend_invite_project_member_path' do let(:project_member) { create(:project_member) } - it { expect(resend_invite_project_member_path(project_member)).to eq resend_invite_namespace_project_project_member_path(project_member.source.namespace, project_member.source, project_member) } + it { expect(resend_invite_project_member_path(project_member)).to eq resend_invite_project_project_member_path(project_member.source, project_member) } end end diff --git a/spec/helpers/issues_helper_spec.rb b/spec/helpers/issues_helper_spec.rb index 00db98fd9d2..8f7f17a484f 100644 --- a/spec/helpers/issues_helper_spec.rb +++ b/spec/helpers/issues_helper_spec.rb @@ -137,7 +137,7 @@ describe IssuesHelper do let(:merge_request) { create(:merge_request) } it "links just the merge request" do - expected_path = namespace_project_merge_request_path(merge_request.project.namespace, merge_request.project, merge_request) + expected_path = project_merge_request_path(merge_request.project, merge_request) expect(link_to_discussions_to_resolve(merge_request, nil)).to include(expected_path) end diff --git a/spec/helpers/markup_helper_spec.rb b/spec/helpers/markup_helper_spec.rb index b4226f96a04..4b6a351cf70 100644 --- a/spec/helpers/markup_helper_spec.rb +++ b/spec/helpers/markup_helper_spec.rb @@ -25,17 +25,17 @@ describe MarkupHelper do let(:actual) { "#{merge_request.to_reference} -> #{commit.to_reference} -> #{issue.to_reference}" } it "links to the merge request" do - expected = namespace_project_merge_request_path(project.namespace, project, merge_request) + expected = project_merge_request_path(project, merge_request) expect(helper.markdown(actual)).to match(expected) end it "links to the commit" do - expected = namespace_project_commit_path(project.namespace, project, commit) + expected = project_commit_path(project, commit) expect(helper.markdown(actual)).to match(expected) end it "links to the issue" do - expected = namespace_project_issue_path(project.namespace, project, issue) + expected = project_issue_path(project, issue) expect(helper.markdown(actual)).to match(expected) end end @@ -46,7 +46,7 @@ describe MarkupHelper do let(:second_issue) { create(:issue, project: second_project) } it 'links to the issue' do - expected = namespace_project_issue_path(second_project.namespace, second_project, second_issue) + expected = project_issue_path(second_project, second_issue) expect(markdown(actual, project: second_project)).to match(expected) end end @@ -69,7 +69,7 @@ describe MarkupHelper do # First issue link expect(doc.css('a')[1].attr('href')) - .to eq namespace_project_issue_path(project.namespace, project, issues[0]) + .to eq project_issue_path(project, issues[0]) expect(doc.css('a')[1].text).to eq issues[0].to_reference # Internal commit link @@ -78,7 +78,7 @@ describe MarkupHelper do # Second issue link expect(doc.css('a')[3].attr('href')) - .to eq namespace_project_issue_path(project.namespace, project, issues[1]) + .to eq project_issue_path(project, issues[1]) expect(doc.css('a')[3].text).to eq issues[1].to_reference # Trailing commit link diff --git a/spec/helpers/milestones_helper_spec.rb b/spec/helpers/milestones_helper_spec.rb index 24d4f1b4938..b8f9c02a486 100644 --- a/spec/helpers/milestones_helper_spec.rb +++ b/spec/helpers/milestones_helper_spec.rb @@ -10,7 +10,7 @@ describe MilestonesHelper do it 'returns project milestones JSON URL' do assign(:project, project) - expect(helper.milestones_filter_dropdown_path).to eq(namespace_project_milestones_path(project.namespace, project, :json)) + expect(helper.milestones_filter_dropdown_path).to eq(project_milestones_path(project, :json)) end end @@ -18,7 +18,7 @@ describe MilestonesHelper do it 'returns targeted project milestones JSON URL' do assign(:target_project, project2) - expect(helper.milestones_filter_dropdown_path).to eq(namespace_project_milestones_path(project2.namespace, project2, :json)) + expect(helper.milestones_filter_dropdown_path).to eq(project_milestones_path(project2, :json)) end end diff --git a/spec/helpers/notes_helper_spec.rb b/spec/helpers/notes_helper_spec.rb index cc861af8533..56f252ba273 100644 --- a/spec/helpers/notes_helper_spec.rb +++ b/spec/helpers/notes_helper_spec.rb @@ -53,7 +53,7 @@ describe NotesHelper do let(:discussion) { create(:diff_note_on_merge_request, noteable: merge_request, project: project).to_discussion } it 'returns the diff path with the line code' do - expect(helper.discussion_path(discussion)).to eq(diffs_namespace_project_merge_request_path(project.namespace, project, merge_request, anchor: discussion.line_code)) + expect(helper.discussion_path(discussion)).to eq(diffs_project_merge_request_path(project, merge_request, anchor: discussion.line_code)) end end @@ -77,7 +77,7 @@ describe NotesHelper do end it 'returns the diff version path with the line code' do - expect(helper.discussion_path(discussion)).to eq(diffs_namespace_project_merge_request_path(project.namespace, project, merge_request, diff_id: merge_request_diff1, anchor: discussion.line_code)) + expect(helper.discussion_path(discussion)).to eq(diffs_project_merge_request_path(project, merge_request, diff_id: merge_request_diff1, anchor: discussion.line_code)) end end @@ -101,7 +101,7 @@ describe NotesHelper do end it 'returns the diff version comparison path with the line code' do - expect(helper.discussion_path(discussion)).to eq(diffs_namespace_project_merge_request_path(project.namespace, project, merge_request, diff_id: merge_request_diff3, start_sha: merge_request_diff1.head_commit_sha, anchor: discussion.line_code)) + expect(helper.discussion_path(discussion)).to eq(diffs_project_merge_request_path(project, merge_request, diff_id: merge_request_diff3, start_sha: merge_request_diff1.head_commit_sha, anchor: discussion.line_code)) end end @@ -129,7 +129,7 @@ describe NotesHelper do end it 'returns the diff path with the line code' do - expect(helper.discussion_path(discussion)).to eq(diffs_namespace_project_merge_request_path(project.namespace, project, merge_request, anchor: discussion.line_code)) + expect(helper.discussion_path(discussion)).to eq(diffs_project_merge_request_path(project, merge_request, anchor: discussion.line_code)) end end @@ -160,7 +160,7 @@ describe NotesHelper do let(:discussion) { create(:diff_note_on_commit, project: project).to_discussion } it 'returns the commit path with the line code' do - expect(helper.discussion_path(discussion)).to eq(namespace_project_commit_path(project.namespace, project, commit, anchor: discussion.line_code)) + expect(helper.discussion_path(discussion)).to eq(project_commit_path(project, commit, anchor: discussion.line_code)) end end @@ -168,7 +168,7 @@ describe NotesHelper do let(:discussion) { create(:legacy_diff_note_on_commit, project: project).to_discussion } it 'returns the commit path with the line code' do - expect(helper.discussion_path(discussion)).to eq(namespace_project_commit_path(project.namespace, project, commit, anchor: discussion.line_code)) + expect(helper.discussion_path(discussion)).to eq(project_commit_path(project, commit, anchor: discussion.line_code)) end end @@ -176,7 +176,7 @@ describe NotesHelper do let(:discussion) { create(:discussion_note_on_commit, project: project).to_discussion } it 'returns the commit path' do - expect(helper.discussion_path(discussion)).to eq(namespace_project_commit_path(project.namespace, project, commit)) + expect(helper.discussion_path(discussion)).to eq(project_commit_path(project, commit)) end end end diff --git a/spec/lib/banzai/filter/commit_range_reference_filter_spec.rb b/spec/lib/banzai/filter/commit_range_reference_filter_spec.rb index fc67c7ec3c4..60c27bc0d3c 100644 --- a/spec/lib/banzai/filter/commit_range_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/commit_range_reference_filter_spec.rb @@ -29,14 +29,14 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true do doc = reference_filter("See #{reference2}") expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_compare_url(project.namespace, project, range2.to_param) + .to eq urls.project_compare_url(project, range2.to_param) end it 'links to a valid three-dot reference' do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_compare_url(project.namespace, project, range.to_param) + .to eq urls.project_compare_url(project, range.to_param) end it 'links to a valid short ID' do @@ -94,7 +94,7 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true do link = doc.css('a').first.attr('href') expect(link).not_to match %r(https?://) - expect(link).to eq urls.namespace_project_compare_url(project.namespace, project, from: commit1.id, to: commit2.id, only_path: true) + expect(link).to eq urls.project_compare_url(project, from: commit1.id, to: commit2.id, only_path: true) end end @@ -106,7 +106,7 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_compare_url(project2.namespace, project2, range.to_param) + .to eq urls.project_compare_url(project2, range.to_param) end it 'link has valid text' do @@ -141,7 +141,7 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_compare_url(project2.namespace, project2, range.to_param) + .to eq urls.project_compare_url(project2, range.to_param) end it 'link has valid text' do @@ -176,7 +176,7 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_compare_url(project2.namespace, project2, range.to_param) + .to eq urls.project_compare_url(project2, range.to_param) end it 'link has valid text' do @@ -205,7 +205,7 @@ describe Banzai::Filter::CommitRangeReferenceFilter, lib: true do let(:namespace) { create(:namespace) } let(:project2) { create(:project, :public, :repository, namespace: namespace) } let(:range) { CommitRange.new("#{commit1.id}...master", project) } - let(:reference) { urls.namespace_project_compare_url(project2.namespace, project2, from: commit1.id, to: 'master') } + let(:reference) { urls.project_compare_url(project2, from: commit1.id, to: 'master') } before do range.project = project2 diff --git a/spec/lib/banzai/filter/commit_reference_filter_spec.rb b/spec/lib/banzai/filter/commit_reference_filter_spec.rb index c4d8d3b6682..f6893641481 100644 --- a/spec/lib/banzai/filter/commit_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/commit_reference_filter_spec.rb @@ -27,7 +27,7 @@ describe Banzai::Filter::CommitReferenceFilter, lib: true do expect(doc.css('a').first.text).to eq commit.short_id expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_commit_url(project.namespace, project, reference) + .to eq urls.project_commit_url(project, reference) end end @@ -90,7 +90,7 @@ describe Banzai::Filter::CommitReferenceFilter, lib: true do link = doc.css('a').first.attr('href') expect(link).not_to match %r(https?://) - expect(link).to eq urls.namespace_project_commit_url(project.namespace, project, reference, only_path: true) + expect(link).to eq urls.project_commit_url(project, reference, only_path: true) end end @@ -175,13 +175,13 @@ describe Banzai::Filter::CommitReferenceFilter, lib: true do let(:namespace) { create(:namespace) } let(:project2) { create(:project, :public, :repository, namespace: namespace) } let(:commit) { project2.commit } - let(:reference) { urls.namespace_project_commit_url(project2.namespace, project2, commit.id) } + let(:reference) { urls.project_commit_url(project2, commit.id) } it 'links to a valid reference' do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_commit_url(project2.namespace, project2, commit.id) + .to eq urls.project_commit_url(project2, commit.id) end it 'links with adjacent text' do diff --git a/spec/lib/banzai/filter/label_reference_filter_spec.rb b/spec/lib/banzai/filter/label_reference_filter_spec.rb index cb3cf982351..8daef3ca691 100644 --- a/spec/lib/banzai/filter/label_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/label_reference_filter_spec.rb @@ -45,7 +45,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do link = doc.css('a').first.attr('href') expect(link).not_to match %r(https?://) - expect(link).to eq urls.namespace_project_issues_path(project.namespace, project, label_name: label.name) + expect(link).to eq urls.project_issues_path(project, label_name: label.name) end context 'project that does not exist referenced' do @@ -73,7 +73,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_issues_url(project.namespace, project, label_name: label.name) + .project_issues_url(project, label_name: label.name) end it 'links with adjacent text' do @@ -96,7 +96,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_issues_url(project.namespace, project, label_name: label.name) + .project_issues_url(project, label_name: label.name) expect(doc.text).to eq 'See gfm' end @@ -120,7 +120,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_issues_url(project.namespace, project, label_name: label.name) + .project_issues_url(project, label_name: label.name) expect(doc.text).to eq 'See 2fa' end @@ -144,7 +144,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_issues_url(project.namespace, project, label_name: label.name) + .project_issues_url(project, label_name: label.name) expect(doc.text).to eq 'See ?g.fm&' end @@ -169,7 +169,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_issues_url(project.namespace, project, label_name: label.name) + .project_issues_url(project, label_name: label.name) expect(doc.text).to eq 'See gfm references' end @@ -193,7 +193,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_issues_url(project.namespace, project, label_name: label.name) + .project_issues_url(project, label_name: label.name) expect(doc.text).to eq 'See 2 factor authentication' end @@ -217,7 +217,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_issues_url(project.namespace, project, label_name: label.name) + .project_issues_url(project, label_name: label.name) expect(doc.text).to eq 'See g.fm & references?' end @@ -250,9 +250,9 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do doc = reference_filter("See #{references}") expect(doc.css('a').map { |a| a.attr('href') }).to match_array([ - urls.namespace_project_issues_url(project.namespace, project, label_name: bug.name), - urls.namespace_project_issues_url(project.namespace, project, label_name: feature_proposal.name), - urls.namespace_project_issues_url(project.namespace, project, label_name: technical_debt.name) + urls.project_issues_url(project, label_name: bug.name), + urls.project_issues_url(project, label_name: feature_proposal.name), + urls.project_issues_url(project, label_name: technical_debt.name) ]) expect(doc.text).to eq 'See bug, feature proposal, technical debt' end @@ -265,9 +265,9 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do doc = reference_filter("See #{references}") expect(doc.css('a').map { |a| a.attr('href') }).to match_array([ - urls.namespace_project_issues_url(project.namespace, project, label_name: bug.name), - urls.namespace_project_issues_url(project.namespace, project, label_name: feature_proposal.name), - urls.namespace_project_issues_url(project.namespace, project, label_name: technical_debt.name) + urls.project_issues_url(project, label_name: bug.name), + urls.project_issues_url(project, label_name: feature_proposal.name), + urls.project_issues_url(project, label_name: technical_debt.name) ]) expect(doc.text).to eq 'See bug feature proposal technical debt' end @@ -288,7 +288,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_issues_url(project.namespace, project, label_name: label.name) + .project_issues_url(project, label_name: label.name) end it 'links with adjacent text' do @@ -325,7 +325,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do doc = reference_filter("See #{reference}", project: project) expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_issues_url(project.namespace, project, label_name: group_label.name) + .project_issues_url(project, label_name: group_label.name) expect(doc.text).to eq 'See gfm references' end @@ -348,7 +348,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do doc = reference_filter("See #{reference}", project: project) expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_issues_url(project.namespace, project, label_name: group_label.name) + .project_issues_url(project, label_name: group_label.name) expect(doc.text).to eq "See gfm references" end @@ -373,9 +373,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links to a valid reference' do expect(result.css('a').first.attr('href')) - .to eq urls.namespace_project_issues_url(project2.namespace, - project2, - label_name: label.name) + .to eq urls.project_issues_url(project2, label_name: label.name) end it 'has valid color' do @@ -407,9 +405,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links to a valid reference' do expect(result.css('a').first.attr('href')) - .to eq urls.namespace_project_issues_url(project2.namespace, - project2, - label_name: label.name) + .to eq urls.project_issues_url(project2, label_name: label.name) end it 'has valid color' do @@ -441,9 +437,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'links to a valid reference' do expect(result.css('a').first.attr('href')) - .to eq urls.namespace_project_issues_url(project2.namespace, - project2, - label_name: label.name) + .to eq urls.project_issues_url(project2, label_name: label.name) end it 'has valid color' do @@ -477,9 +471,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'points to referenced project issues page' do expect(result.css('a').first.attr('href')) - .to eq urls.namespace_project_issues_url(another_project.namespace, - another_project, - label_name: group_label.name) + .to eq urls.project_issues_url(another_project, label_name: group_label.name) end it 'has valid color' do @@ -514,9 +506,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'points to referenced project issues page' do expect(result.css('a').first.attr('href')) - .to eq urls.namespace_project_issues_url(another_project.namespace, - another_project, - label_name: group_label.name) + .to eq urls.project_issues_url(another_project, label_name: group_label.name) end it 'has valid color' do @@ -550,9 +540,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'points to referenced project issues page' do expect(result.css('a').first.attr('href')) - .to eq urls.namespace_project_issues_url(project.namespace, - project, - label_name: group_label.name) + .to eq urls.project_issues_url(project, label_name: group_label.name) end it 'has valid color' do @@ -584,9 +572,7 @@ describe Banzai::Filter::LabelReferenceFilter, lib: true do it 'points to referenced project issues page' do expect(result.css('a').first.attr('href')) - .to eq urls.namespace_project_issues_url(project.namespace, - project, - label_name: group_label.name) + .to eq urls.project_issues_url(project, label_name: group_label.name) end it 'has valid color' do 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 cd91681551e..1ad329b6452 100644 --- a/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/merge_request_reference_filter_spec.rb @@ -37,7 +37,7 @@ describe Banzai::Filter::MergeRequestReferenceFilter, lib: true do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_merge_request_url(project.namespace, project, merge) + .project_merge_request_url(project, merge) end it 'links with adjacent text' do @@ -95,7 +95,7 @@ describe Banzai::Filter::MergeRequestReferenceFilter, lib: true do link = doc.css('a').first.attr('href') expect(link).not_to match %r(https?://) - expect(link).to eq urls.namespace_project_merge_request_url(project.namespace, project, merge, only_path: true) + expect(link).to eq urls.project_merge_request_url(project, merge, only_path: true) end end @@ -108,8 +108,7 @@ describe Banzai::Filter::MergeRequestReferenceFilter, lib: true do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_merge_request_url(project2.namespace, - project2, merge) + .to eq urls.project_merge_request_url(project2, merge) end it 'link has valid text' do @@ -142,8 +141,7 @@ describe Banzai::Filter::MergeRequestReferenceFilter, lib: true do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_merge_request_url(project2.namespace, - project2, merge) + .to eq urls.project_merge_request_url(project2, merge) end it 'link has valid text' do @@ -176,8 +174,7 @@ describe Banzai::Filter::MergeRequestReferenceFilter, lib: true do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_merge_request_url(project2.namespace, - project2, merge) + .to eq urls.project_merge_request_url(project2, merge) end it 'link has valid text' do @@ -203,7 +200,7 @@ describe Banzai::Filter::MergeRequestReferenceFilter, lib: true do let(:namespace) { create(:namespace, name: 'cross-reference') } let(:project2) { create(:empty_project, :public, namespace: namespace) } let(:merge) { create(:merge_request, source_project: project2, target_project: project2) } - let(:reference) { urls.namespace_project_merge_request_url(project2.namespace, project2, merge) + '/diffs#note_123' } + let(:reference) { urls.project_merge_request_url(project2, merge) + '/diffs#note_123' } it 'links to a valid reference' do doc = reference_filter("See #{reference}") diff --git a/spec/lib/banzai/filter/milestone_reference_filter_spec.rb b/spec/lib/banzai/filter/milestone_reference_filter_spec.rb index fe88b9cb73e..7fab5613afc 100644 --- a/spec/lib/banzai/filter/milestone_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/milestone_reference_filter_spec.rb @@ -45,7 +45,7 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do expect(link).not_to match %r(https?://) expect(link).to eq urls - .namespace_project_milestone_path(project.namespace, project, milestone) + .project_milestone_path(project, milestone) end context 'Integer-based references' do @@ -53,7 +53,7 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_milestone_url(project.namespace, project, milestone) + .project_milestone_url(project, milestone) end it 'links with adjacent text' do @@ -76,7 +76,7 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_milestone_url(project.namespace, project, milestone) + .project_milestone_url(project, milestone) expect(doc.text).to eq 'See gfm' end @@ -100,7 +100,7 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_milestone_url(project.namespace, project, milestone) + .project_milestone_url(project, milestone) expect(doc.text).to eq 'See gfm references' end @@ -123,7 +123,7 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_milestone_url(project.namespace, project, milestone) + .project_milestone_url(project, milestone) end it 'links with adjacent text' do @@ -157,9 +157,7 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do it 'points to referenced project milestone page' do expect(result.css('a').first.attr('href')).to eq urls - .namespace_project_milestone_url(another_project.namespace, - another_project, - milestone) + .project_milestone_url(another_project, milestone) end it 'link has valid text' do @@ -196,9 +194,7 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do it 'points to referenced project milestone page' do expect(result.css('a').first.attr('href')).to eq urls - .namespace_project_milestone_url(another_project.namespace, - another_project, - milestone) + .project_milestone_url(another_project, milestone) end it 'link has valid text' do @@ -235,9 +231,7 @@ describe Banzai::Filter::MilestoneReferenceFilter, lib: true do it 'points to referenced project milestone page' do expect(result.css('a').first.attr('href')).to eq urls - .namespace_project_milestone_url(another_project.namespace, - another_project, - milestone) + .project_milestone_url(another_project, milestone) end it 'link has valid text' do diff --git a/spec/lib/banzai/filter/snippet_reference_filter_spec.rb b/spec/lib/banzai/filter/snippet_reference_filter_spec.rb index e851120bc3a..9704db0c221 100644 --- a/spec/lib/banzai/filter/snippet_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/snippet_reference_filter_spec.rb @@ -23,7 +23,7 @@ describe Banzai::Filter::SnippetReferenceFilter, lib: true do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')).to eq urls - .namespace_project_snippet_url(project.namespace, project, snippet) + .project_snippet_url(project, snippet) end it 'links with adjacent text' do @@ -75,7 +75,7 @@ describe Banzai::Filter::SnippetReferenceFilter, lib: true do link = doc.css('a').first.attr('href') expect(link).not_to match %r(https?://) - expect(link).to eq urls.namespace_project_snippet_url(project.namespace, project, snippet, only_path: true) + expect(link).to eq urls.project_snippet_url(project, snippet, only_path: true) end end @@ -89,7 +89,7 @@ describe Banzai::Filter::SnippetReferenceFilter, lib: true do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_snippet_url(project2.namespace, project2, snippet) + .to eq urls.project_snippet_url(project2, snippet) end it 'link has valid text' do @@ -122,7 +122,7 @@ describe Banzai::Filter::SnippetReferenceFilter, lib: true do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_snippet_url(project2.namespace, project2, snippet) + .to eq urls.project_snippet_url(project2, snippet) end it 'link has valid text' do @@ -155,7 +155,7 @@ describe Banzai::Filter::SnippetReferenceFilter, lib: true do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_snippet_url(project2.namespace, project2, snippet) + .to eq urls.project_snippet_url(project2, snippet) end it 'link has valid text' do @@ -181,13 +181,13 @@ describe Banzai::Filter::SnippetReferenceFilter, lib: true do let(:namespace) { create(:namespace, name: 'cross-reference') } let(:project2) { create(:empty_project, :public, namespace: namespace) } let(:snippet) { create(:project_snippet, project: project2) } - let(:reference) { urls.namespace_project_snippet_url(project2.namespace, project2, snippet) } + let(:reference) { urls.project_snippet_url(project2, snippet) } it 'links to a valid reference' do doc = reference_filter("See #{reference}") expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_snippet_url(project2.namespace, project2, snippet) + .to eq urls.project_snippet_url(project2, snippet) end it 'links with adjacent text' do diff --git a/spec/lib/banzai/filter/user_reference_filter_spec.rb b/spec/lib/banzai/filter/user_reference_filter_spec.rb index edf3846b742..77561e00573 100644 --- a/spec/lib/banzai/filter/user_reference_filter_spec.rb +++ b/spec/lib/banzai/filter/user_reference_filter_spec.rb @@ -43,7 +43,7 @@ describe Banzai::Filter::UserReferenceFilter, lib: true do expect(doc.css('a').length).to eq 1 expect(doc.css('a').first.attr('href')) - .to eq urls.namespace_project_url(project.namespace, project) + .to eq urls.project_url(project) end it 'includes a data-author attribute when there is an author' do diff --git a/spec/lib/banzai/pipeline/gfm_pipeline_spec.rb b/spec/lib/banzai/pipeline/gfm_pipeline_spec.rb index 2b8c76f2bb8..1eb90dc1847 100644 --- a/spec/lib/banzai/pipeline/gfm_pipeline_spec.rb +++ b/spec/lib/banzai/pipeline/gfm_pipeline_spec.rb @@ -22,11 +22,7 @@ describe Banzai::Pipeline::GfmPipeline do link = result.css('a').first expect(link['href']).to eq( - Gitlab::Routing.url_helpers.namespace_project_issue_path( - other_project.namespace, - other_project, - issue - ) + Gitlab::Routing.url_helpers.project_issue_path(other_project, issue) ) end end diff --git a/spec/lib/gitlab/closing_issue_extractor_spec.rb b/spec/lib/gitlab/closing_issue_extractor_spec.rb index ca68010cb89..fe988266ae3 100644 --- a/spec/lib/gitlab/closing_issue_extractor_spec.rb +++ b/spec/lib/gitlab/closing_issue_extractor_spec.rb @@ -276,7 +276,7 @@ describe Gitlab::ClosingIssueExtractor, lib: true do context "with a cross-project URL" do it do - message = "Closes #{urls.namespace_project_issue_url(issue2.project.namespace, issue2.project, issue2)}" + message = "Closes #{urls.project_issue_url(issue2.project, issue2)}" expect(subject.closed_by_message(message)).to eq([issue2]) end end @@ -292,7 +292,7 @@ describe Gitlab::ClosingIssueExtractor, lib: true do context "with an invalid URL" do it do - message = "Closes https://google.com#{urls.namespace_project_issue_path(issue2.project.namespace, issue2.project, issue2)}" + message = "Closes https://google.com#{urls.project_issue_path(issue2.project, issue2)}" expect(subject.closed_by_message(message)).to eq([]) end end @@ -347,14 +347,14 @@ describe Gitlab::ClosingIssueExtractor, lib: true do end it "fetches cross-project URL references" do - message = "Closes #{urls.namespace_project_issue_url(issue2.project.namespace, issue2.project, issue2)} and #{reference}" + message = "Closes #{urls.project_issue_url(issue2.project, issue2)} and #{reference}" expect(subject.closed_by_message(message)) .to match_array([issue, issue2]) end it "ignores invalid cross-project URL references" do - message = "Closes https://google.com#{urls.namespace_project_issue_path(issue2.project.namespace, issue2.project, issue2)} and #{reference}" + message = "Closes https://google.com#{urls.project_issue_path(issue2.project, issue2)} and #{reference}" expect(subject.closed_by_message(message)) .to match_array([issue]) diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index 980b24370d0..683e893968b 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -52,7 +52,7 @@ describe Notify do it 'has the correct subject and body' do aggregate_failures do is_expected.to have_referable_subject(issue) - is_expected.to have_body_text(namespace_project_issue_path(project.namespace, project, issue)) + is_expected.to have_body_text(project_issue_path(project, issue)) end end @@ -99,7 +99,7 @@ describe Notify do is_expected.to have_referable_subject(issue, reply: true) is_expected.to have_html_escaped_body_text(previous_assignee.name) is_expected.to have_html_escaped_body_text(assignee.name) - is_expected.to have_body_text(namespace_project_issue_path(project.namespace, project, issue)) + is_expected.to have_body_text(project_issue_path(project, issue)) end end end @@ -125,7 +125,7 @@ describe Notify do aggregate_failures do is_expected.to have_referable_subject(issue, reply: true) is_expected.to have_body_text('foo, bar, and baz') - is_expected.to have_body_text(namespace_project_issue_path(project.namespace, project, issue)) + is_expected.to have_body_text(project_issue_path(project, issue)) end end @@ -165,7 +165,7 @@ describe Notify do is_expected.to have_referable_subject(issue, reply: true) is_expected.to have_body_text(status) is_expected.to have_html_escaped_body_text(current_user.name) - is_expected.to have_body_text(namespace_project_issue_path project.namespace, project, issue) + is_expected.to have_body_text(project_issue_path project, issue) end end end @@ -185,13 +185,12 @@ describe Notify do end it 'has the correct subject and body' do - new_issue_url = namespace_project_issue_path(new_issue.project.namespace, - new_issue.project, new_issue) + new_issue_url = project_issue_path(new_issue.project, new_issue) aggregate_failures do is_expected.to have_referable_subject(issue, reply: true) is_expected.to have_body_text(new_issue_url) - is_expected.to have_body_text(namespace_project_issue_path(project.namespace, project, issue)) + is_expected.to have_body_text(project_issue_path(project, issue)) end end end @@ -216,7 +215,7 @@ describe Notify do it 'has the correct subject and body' do aggregate_failures do is_expected.to have_referable_subject(merge_request) - is_expected.to have_body_text(namespace_project_merge_request_path(project.namespace, project, merge_request)) + is_expected.to have_body_text(project_merge_request_path(project, merge_request)) is_expected.to have_body_text(merge_request.source_branch) is_expected.to have_body_text(merge_request.target_branch) end @@ -265,7 +264,7 @@ describe Notify do aggregate_failures do is_expected.to have_referable_subject(merge_request, reply: true) is_expected.to have_html_escaped_body_text(previous_assignee.name) - is_expected.to have_body_text(namespace_project_merge_request_path(project.namespace, project, merge_request)) + is_expected.to have_body_text(project_merge_request_path(project, merge_request)) is_expected.to have_html_escaped_body_text(assignee.name) end end @@ -291,7 +290,7 @@ describe Notify do it 'has the correct subject and body' do is_expected.to have_referable_subject(merge_request, reply: true) is_expected.to have_body_text('foo, bar, and baz') - is_expected.to have_body_text(namespace_project_merge_request_path(project.namespace, project, merge_request)) + is_expected.to have_body_text(project_merge_request_path(project, merge_request)) end end @@ -316,7 +315,7 @@ describe Notify do is_expected.to have_referable_subject(merge_request, reply: true) is_expected.to have_body_text(status) is_expected.to have_html_escaped_body_text(current_user.name) - is_expected.to have_body_text(namespace_project_merge_request_path(project.namespace, project, merge_request)) + is_expected.to have_body_text(project_merge_request_path(project, merge_request)) end end end @@ -341,7 +340,7 @@ describe Notify do aggregate_failures do is_expected.to have_referable_subject(merge_request, reply: true) is_expected.to have_body_text('merged') - is_expected.to have_body_text(namespace_project_merge_request_path(project.namespace, project, merge_request)) + is_expected.to have_body_text(project_merge_request_path(project, merge_request)) end end end @@ -390,7 +389,7 @@ describe Notify do is_expected.to have_subject "Request to join the #{project.name_with_namespace} project" is_expected.to have_html_escaped_body_text project.name_with_namespace - is_expected.to have_body_text namespace_project_project_members_url(project.namespace, project) + is_expected.to have_body_text project_project_members_url(project) is_expected.to have_body_text project_member.human_access end end @@ -417,7 +416,7 @@ describe Notify do is_expected.to have_subject "Request to join the #{project.name_with_namespace} project" is_expected.to have_html_escaped_body_text project.name_with_namespace - is_expected.to have_body_text namespace_project_project_members_url(project.namespace, project) + is_expected.to have_body_text project_project_members_url(project) is_expected.to have_body_text project_member.human_access end end @@ -609,7 +608,7 @@ describe Notify do describe 'on a merge request' do let(:merge_request) { create(:merge_request, source_project: project, target_project: project) } - let(:note_on_merge_request_path) { namespace_project_merge_request_path(project.namespace, project, merge_request, anchor: "note_#{note.id}") } + let(:note_on_merge_request_path) { project_merge_request_path(project, merge_request, anchor: "note_#{note.id}") } before do allow(note).to receive(:noteable).and_return(merge_request) @@ -634,7 +633,7 @@ describe Notify do describe 'on an issue' do let(:issue) { create(:issue, project: project) } - let(:note_on_issue_path) { namespace_project_issue_path(project.namespace, project, issue, anchor: "note_#{note.id}") } + let(:note_on_issue_path) { project_issue_path(project, issue, anchor: "note_#{note.id}") } before do allow(note).to receive(:noteable).and_return(issue) @@ -725,7 +724,7 @@ describe Notify do describe 'on a merge request' do let(:merge_request) { create(:merge_request, source_project: project, target_project: project) } let(:note) { create(:discussion_note_on_merge_request, noteable: merge_request, project: project, author: note_author) } - let(:note_on_merge_request_path) { namespace_project_merge_request_path(project.namespace, project, merge_request, anchor: "note_#{note.id}") } + let(:note_on_merge_request_path) { project_merge_request_path(project, merge_request, anchor: "note_#{note.id}") } before do allow(note).to receive(:noteable).and_return(merge_request) @@ -752,7 +751,7 @@ describe Notify do describe 'on an issue' do let(:issue) { create(:issue, project: project) } let(:note) { create(:discussion_note_on_issue, noteable: issue, project: project, author: note_author) } - let(:note_on_issue_path) { namespace_project_issue_path(project.namespace, project, issue, anchor: "note_#{note.id}") } + let(:note_on_issue_path) { project_issue_path(project, issue, anchor: "note_#{note.id}") } before do allow(note).to receive(:noteable).and_return(issue) @@ -1022,7 +1021,7 @@ describe Notify do describe 'email on push for a created branch' do let(:example_site_path) { root_path } let(:user) { create(:user) } - let(:tree_path) { namespace_project_tree_path(project.namespace, project, "empty-branch") } + let(:tree_path) { project_tree_path(project, "empty-branch") } subject { described_class.repository_push_email(project.id, author_id: user.id, ref: 'refs/heads/empty-branch', action: :create) } @@ -1048,7 +1047,7 @@ describe Notify do describe 'email on push for a created tag' do let(:example_site_path) { root_path } let(:user) { create(:user) } - let(:tree_path) { namespace_project_tree_path(project.namespace, project, "v1.0") } + let(:tree_path) { project_tree_path(project, "v1.0") } subject { described_class.repository_push_email(project.id, author_id: user.id, ref: 'refs/tags/v1.0', action: :create) } @@ -1122,7 +1121,7 @@ describe Notify do let(:raw_compare) { Gitlab::Git::Compare.new(project.repository.raw_repository, sample_image_commit.id, sample_commit.id) } let(:compare) { Compare.decorate(raw_compare, project) } let(:commits) { compare.commits } - let(:diff_path) { namespace_project_compare_path(project.namespace, project, from: Commit.new(compare.base, project), to: Commit.new(compare.head, project)) } + let(:diff_path) { project_compare_path(project, from: Commit.new(compare.base, project), to: Commit.new(compare.head, project)) } let(:send_from_committer_email) { false } let(:diff_refs) { Gitlab::Diff::DiffRefs.new(base_sha: project.merge_base_commit(sample_image_commit.id, sample_commit.id).id, head_sha: sample_commit.id) } @@ -1216,7 +1215,7 @@ describe Notify do let(:raw_compare) { Gitlab::Git::Compare.new(project.repository.raw_repository, sample_commit.parent_id, sample_commit.id) } let(:compare) { Compare.decorate(raw_compare, project) } let(:commits) { compare.commits } - let(:diff_path) { namespace_project_commit_path(project.namespace, project, commits.first) } + let(:diff_path) { project_commit_path(project, commits.first) } let(:diff_refs) { Gitlab::Diff::DiffRefs.new(base_sha: project.merge_base_commit(sample_image_commit.id, sample_commit.id).id, head_sha: sample_commit.id) } subject { described_class.repository_push_email(project.id, author_id: user.id, ref: 'refs/heads/master', action: :push, compare: compare, diff_refs: diff_refs) } diff --git a/spec/requests/projects/cycle_analytics_events_spec.rb b/spec/requests/projects/cycle_analytics_events_spec.rb index d4d3c9478a0..e78d2cfdb33 100644 --- a/spec/requests/projects/cycle_analytics_events_spec.rb +++ b/spec/requests/projects/cycle_analytics_events_spec.rb @@ -21,7 +21,7 @@ describe 'cycle analytics events', api: true do end it 'lists the issue events' do - get namespace_project_cycle_analytics_issue_path(project.namespace, project, format: :json) + get project_cycle_analytics_issue_path(project, format: :json) first_issue_iid = project.issues.sort(:created_desc).pluck(:iid).first.to_s @@ -30,7 +30,7 @@ describe 'cycle analytics events', api: true do end it 'lists the plan events' do - get namespace_project_cycle_analytics_plan_path(project.namespace, project, format: :json) + get project_cycle_analytics_plan_path(project, format: :json) first_mr_short_sha = project.merge_requests.sort(:created_asc).first.commits.first.short_id @@ -39,7 +39,7 @@ describe 'cycle analytics events', api: true do end it 'lists the code events' do - get namespace_project_cycle_analytics_code_path(project.namespace, project, format: :json) + get project_cycle_analytics_code_path(project, format: :json) expect(json_response['events']).not_to be_empty @@ -49,14 +49,14 @@ describe 'cycle analytics events', api: true do end it 'lists the test events' do - get namespace_project_cycle_analytics_test_path(project.namespace, project, format: :json) + get project_cycle_analytics_test_path(project, format: :json) expect(json_response['events']).not_to be_empty expect(json_response['events'].first['date']).not_to be_empty end it 'lists the review events' do - get namespace_project_cycle_analytics_review_path(project.namespace, project, format: :json) + get project_cycle_analytics_review_path(project, format: :json) first_mr_iid = project.merge_requests.sort(:created_desc).pluck(:iid).first.to_s @@ -65,14 +65,14 @@ describe 'cycle analytics events', api: true do end it 'lists the staging events' do - get namespace_project_cycle_analytics_staging_path(project.namespace, project, format: :json) + get project_cycle_analytics_staging_path(project, format: :json) expect(json_response['events']).not_to be_empty expect(json_response['events'].first['date']).not_to be_empty end it 'lists the production events' do - get namespace_project_cycle_analytics_production_path(project.namespace, project, format: :json) + get project_cycle_analytics_production_path(project, format: :json) first_issue_iid = project.issues.sort(:created_desc).pluck(:iid).first.to_s @@ -84,7 +84,7 @@ describe 'cycle analytics events', api: true do it 'lists the test events' do branch = project.merge_requests.first.source_branch - get namespace_project_cycle_analytics_test_path(project.namespace, project, format: :json, branch: branch) + get project_cycle_analytics_test_path(project, format: :json, branch: branch) expect(json_response['events']).not_to be_empty expect(json_response['events'].first['date']).not_to be_empty @@ -97,19 +97,19 @@ describe 'cycle analytics events', api: true do end it 'does not list the test events' do - get namespace_project_cycle_analytics_test_path(project.namespace, project, format: :json) + get project_cycle_analytics_test_path(project, format: :json) expect(response).to have_http_status(:not_found) end it 'does not list the staging events' do - get namespace_project_cycle_analytics_staging_path(project.namespace, project, format: :json) + get project_cycle_analytics_staging_path(project, format: :json) expect(response).to have_http_status(:not_found) end it 'lists the issue events' do - get namespace_project_cycle_analytics_issue_path(project.namespace, project, format: :json) + get project_cycle_analytics_issue_path(project, format: :json) expect(response).to have_http_status(:ok) end diff --git a/spec/serializers/deploy_key_entity_spec.rb b/spec/serializers/deploy_key_entity_spec.rb index ed89fccc3d0..9620f9665cf 100644 --- a/spec/serializers/deploy_key_entity_spec.rb +++ b/spec/serializers/deploy_key_entity_spec.rb @@ -29,7 +29,7 @@ describe DeployKeyEntity do { id: project.id, name: project.name, - full_path: namespace_project_path(project.namespace, project), + full_path: project_path(project), full_name: project.full_name } ] diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb index 8d3dafafab2..e35e4c1d631 100644 --- a/spec/services/system_note_service_spec.rb +++ b/spec/services/system_note_service_spec.rb @@ -807,7 +807,7 @@ describe SystemNoteService, services: true do body: hash_including( GlobalID: "GitLab", object: { - url: namespace_project_commit_url(project.namespace, project, commit), + url: project_commit_url(project, commit), title: "GitLab: Mentioned on commit - #{commit.title}", icon: { title: "GitLab", url16x16: "https://gitlab.com/favicon.ico" }, status: { resolved: false } @@ -833,7 +833,7 @@ describe SystemNoteService, services: true do body: hash_including( GlobalID: "GitLab", object: { - url: namespace_project_issue_url(project.namespace, project, issue), + url: project_issue_url(project, issue), title: "GitLab: Mentioned on issue - #{issue.title}", icon: { title: "GitLab", url16x16: "https://gitlab.com/favicon.ico" }, status: { resolved: false } @@ -859,7 +859,7 @@ describe SystemNoteService, services: true do body: hash_including( GlobalID: "GitLab", object: { - url: namespace_project_snippet_url(project.namespace, project, snippet), + url: project_snippet_url(project, snippet), title: "GitLab: Mentioned on snippet - #{snippet.title}", icon: { title: "GitLab", url16x16: "https://gitlab.com/favicon.ico" }, status: { resolved: false } @@ -1098,7 +1098,7 @@ describe SystemNoteService, services: true do diff_id = merge_request.merge_request_diff.id line_code = change_position.line_code(project.repository) - expect(subject.note).to include(diffs_namespace_project_merge_request_url(project.namespace, project, merge_request, diff_id: diff_id, anchor: line_code)) + expect(subject.note).to include(diffs_project_merge_request_url(project, merge_request, diff_id: diff_id, anchor: line_code)) end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index fdef6fd5221..3e90a642d56 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -57,7 +57,7 @@ RSpec.configure do |config| config.include StubGitlabCalls config.include StubGitlabData config.include ApiHelpers, :api - config.include Rails.application.routes.url_helpers, type: :routing + config.include Gitlab::Routing.url_helpers, type: :routing config.include MigrationsHelpers, :migration config.infer_spec_type_from_file_location! diff --git a/spec/support/issue_helpers.rb b/spec/support/issue_helpers.rb index 85241793743..ffd72515f37 100644 --- a/spec/support/issue_helpers.rb +++ b/spec/support/issue_helpers.rb @@ -1,6 +1,6 @@ module IssueHelpers def visit_issues(project, opts = {}) - visit namespace_project_issues_path project.namespace, project, opts + visit project_issues_path project, opts end def first_issue diff --git a/spec/support/merge_request_helpers.rb b/spec/support/merge_request_helpers.rb index 326b85eabd0..772adff4626 100644 --- a/spec/support/merge_request_helpers.rb +++ b/spec/support/merge_request_helpers.rb @@ -1,6 +1,6 @@ module MergeRequestHelpers def visit_merge_requests(project, opts = {}) - visit namespace_project_merge_requests_path project.namespace, project, opts + visit project_merge_requests_path project, opts end def first_merge_request diff --git a/spec/support/protected_tags/access_control_ce_shared_examples.rb b/spec/support/protected_tags/access_control_ce_shared_examples.rb index 1d11512ef82..421a51fc336 100644 --- a/spec/support/protected_tags/access_control_ce_shared_examples.rb +++ b/spec/support/protected_tags/access_control_ce_shared_examples.rb @@ -1,7 +1,7 @@ RSpec.shared_examples "protected tags > access control > CE" do ProtectedTag::CreateAccessLevel.human_access_levels.each do |(access_type_id, access_type_name)| it "allows creating protected tags that #{access_type_name} can create" do - visit namespace_project_protected_tags_path(project.namespace, project) + visit project_protected_tags_path(project) set_protected_tag_name('master') @@ -22,7 +22,7 @@ RSpec.shared_examples "protected tags > access control > CE" do end it "allows updating protected tags so that #{access_type_name} can create them" do - visit namespace_project_protected_tags_path(project.namespace, project) + visit project_protected_tags_path(project) set_protected_tag_name('master') diff --git a/spec/support/routing_helpers.rb b/spec/support/routing_helpers.rb new file mode 100644 index 00000000000..af1f4760804 --- /dev/null +++ b/spec/support/routing_helpers.rb @@ -0,0 +1,3 @@ +RSpec.configure do |config| + config.include GitlabRoutingHelper +end diff --git a/spec/support/shared_examples/features/protected_branches_access_control_ce.rb b/spec/support/shared_examples/features/protected_branches_access_control_ce.rb index b6341127a76..66e598e2691 100644 --- a/spec/support/shared_examples/features/protected_branches_access_control_ce.rb +++ b/spec/support/shared_examples/features/protected_branches_access_control_ce.rb @@ -1,7 +1,7 @@ shared_examples "protected branches > access control > CE" do ProtectedBranch::PushAccessLevel.human_access_levels.each do |(access_type_id, access_type_name)| it "allows creating protected branches that #{access_type_name} can push to" do - visit namespace_project_protected_branches_path(project.namespace, project) + visit project_protected_branches_path(project) set_protected_branch_name('master') @@ -21,7 +21,7 @@ shared_examples "protected branches > access control > CE" do end it "allows updating protected branches so that #{access_type_name} can push to them" do - visit namespace_project_protected_branches_path(project.namespace, project) + visit project_protected_branches_path(project) set_protected_branch_name('master') @@ -46,7 +46,7 @@ shared_examples "protected branches > access control > CE" do ProtectedBranch::MergeAccessLevel.human_access_levels.each do |(access_type_id, access_type_name)| it "allows creating protected branches that #{access_type_name} can merge to" do - visit namespace_project_protected_branches_path(project.namespace, project) + visit project_protected_branches_path(project) set_protected_branch_name('master') @@ -66,7 +66,7 @@ shared_examples "protected branches > access control > CE" do end it "allows updating protected branches so that #{access_type_name} can merge to them" do - visit namespace_project_protected_branches_path(project.namespace, project) + visit project_protected_branches_path(project) set_protected_branch_name('master') diff --git a/spec/views/ci/status/_badge.html.haml_spec.rb b/spec/views/ci/status/_badge.html.haml_spec.rb index 72323da2838..6a4738ba443 100644 --- a/spec/views/ci/status/_badge.html.haml_spec.rb +++ b/spec/views/ci/status/_badge.html.haml_spec.rb @@ -16,8 +16,7 @@ describe 'ci/status/_badge', :view do end it 'has link to build details page' do - details_path = namespace_project_job_path( - project.namespace, project, build) + details_path = project_job_path(project, build) render_status(build) 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 3e17fe2104b..98c7de9b709 100644 --- a/spec/views/projects/merge_requests/_commits.html.haml_spec.rb +++ b/spec/views/projects/merge_requests/_commits.html.haml_spec.rb @@ -25,10 +25,7 @@ describe 'projects/merge_requests/_commits.html.haml' do render commit = source_project.commit(merge_request.source_branch) - href = namespace_project_commit_path( - source_project.namespace, - source_project, - commit) + href = project_commit_path(source_project, commit) expect(rendered).to have_link(Commit.truncate_sha(commit.sha), href: href) end -- cgit v1.2.3 From 873b40555b582638992e7cdeb2081c29d08cae05 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Tue, 4 Jul 2017 18:57:13 -0500 Subject: Add ProjectPathHelper cop --- spec/rubocop/cop/project_path_helper_spec.rb | 41 ++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 spec/rubocop/cop/project_path_helper_spec.rb (limited to 'spec') diff --git a/spec/rubocop/cop/project_path_helper_spec.rb b/spec/rubocop/cop/project_path_helper_spec.rb new file mode 100644 index 00000000000..bc47b45cad7 --- /dev/null +++ b/spec/rubocop/cop/project_path_helper_spec.rb @@ -0,0 +1,41 @@ +require 'spec_helper' + +require 'rubocop' +require 'rubocop/rspec/support' + +require_relative '../../../rubocop/cop/project_path_helper' + +describe RuboCop::Cop::ProjectPathHelper do + include CopHelper + + subject(:cop) { described_class.new } + + context "when using namespace_project with the project's namespace" do + let(:source) { 'edit_namespace_project_issue_path(@issue.project.namespace, @issue.project, @issue)' } + let(:correct_source) { 'edit_project_issue_path(@issue.project, @issue)' } + + it 'registers an offense' do + inspect_source(cop, source) + + aggregate_failures do + expect(cop.offenses.size).to eq(1) + expect(cop.offenses.map(&:line)).to eq([1]) + expect(cop.highlights).to eq(['edit_namespace_project_issue_path']) + end + end + + it 'autocorrects to the right version' do + autocorrected = autocorrect_source(cop, source) + + expect(autocorrected).to eq(correct_source) + end + end + + context 'when using namespace_project with a different namespace' do + it 'registers no offense' do + inspect_source(cop, 'edit_namespace_project_issue_path(namespace, project)') + + expect(cop.offenses.size).to eq(0) + end + end +end -- cgit v1.2.3 From 1207d451ed934f3ce2d8c02130a8e6b2cac88a70 Mon Sep 17 00:00:00 2001 From: Tiago Botelho Date: Wed, 5 Jul 2017 17:01:38 +0100 Subject: Removes file_name_regex from Gitlab::Regex --- spec/features/projects/files/creating_a_file_spec.rb | 5 ----- spec/lib/gitlab/git/index_spec.rb | 19 ------------------- spec/lib/gitlab/regex_spec.rb | 6 ------ spec/models/repository_spec.rb | 9 +++++---- 4 files changed, 5 insertions(+), 34 deletions(-) (limited to 'spec') diff --git a/spec/features/projects/files/creating_a_file_spec.rb b/spec/features/projects/files/creating_a_file_spec.rb index 2a1cc01fe68..f67cb46eaaa 100644 --- a/spec/features/projects/files/creating_a_file_spec.rb +++ b/spec/features/projects/files/creating_a_file_spec.rb @@ -30,11 +30,6 @@ feature 'User wants to create a file', feature: true do expect(page).to have_content 'The file has been successfully created' end - scenario 'file name contains invalid characters' do - submit_new_file(file_name: '\\') - expect(page).to have_content 'Path can contain only' - 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' diff --git a/spec/lib/gitlab/git/index_spec.rb b/spec/lib/gitlab/git/index_spec.rb index 8d63f81e4fd..21b71654251 100644 --- a/spec/lib/gitlab/git/index_spec.rb +++ b/spec/lib/gitlab/git/index_spec.rb @@ -25,16 +25,6 @@ describe Gitlab::Git::Index, seed_helper: true do expect(entry).not_to be_nil expect(repository.lookup(entry[:oid]).content).to eq(options[:content]) end - - it 'creates the file if file_path has spaces in between words' do - options[:file_path] = 'new file.txt' - - index.create(options) - entry = index.get(options[:file_path]) - - expect(entry).not_to be_nil - expect(repository.lookup(entry[:oid]).content).to eq(options[:content]) - end end context 'when a file at that path exists' do @@ -91,15 +81,6 @@ describe Gitlab::Git::Index, seed_helper: true do expect(entry).not_to be_nil end - - it 'creates the dir if it has spaces in between words' do - options[:file_path] = 'new dir' - - index.create_dir(options) - entry = index.get(options[:file_path] + '/.gitkeep') - - expect(entry).not_to be_nil - end end context 'when a file at that path exists' do diff --git a/spec/lib/gitlab/regex_spec.rb b/spec/lib/gitlab/regex_spec.rb index 979f4fefcb6..51e2c3c38c6 100644 --- a/spec/lib/gitlab/regex_spec.rb +++ b/spec/lib/gitlab/regex_spec.rb @@ -14,12 +14,6 @@ describe Gitlab::Regex, lib: true do it { is_expected.not_to match('?gitlab') } end - describe '.file_name_regex' do - subject { described_class.file_name_regex } - - it { is_expected.to match('foo@bar') } - end - describe '.environment_slug_regex' do subject { described_class.environment_name_regex } diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 80b363355da..af305e9b234 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -347,14 +347,15 @@ describe Repository, models: true do expect(blob.data).to eq('Changelog!') end - it 'creates new file with spaces in between successfully' do + it 'creates new file and dir when file_path has a forward slash' do expect do - repository.create_file(user, 'NEW FILE', 'File!', - message: 'Create NEW FILE', + repository.create_file(user, 'new_dir/new_file.txt', 'File!', + message: 'Create new_file with new_dir', branch_name: 'master') end.to change { repository.commits('master').count }.by(1) - expect(repository.blob_at('master', 'NEW FILE').data).to eq('File!') + expect(repository.tree('master', 'new_dir').path).to eq('new_dir') + expect(repository.blob_at('master', 'new_dir/new_file.txt').data).to eq('File!') end it 'respects the autocrlf setting' do -- cgit v1.2.3 From 197a5df42aa65821aaa8fa628244e27ee8e1b016 Mon Sep 17 00:00:00 2001 From: Tiago Botelho Date: Wed, 5 Jul 2017 11:45:58 +0100 Subject: Allow admin to disable all restricted visibility levels --- spec/features/admin/admin_settings_spec.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'spec') diff --git a/spec/features/admin/admin_settings_spec.rb b/spec/features/admin/admin_settings_spec.rb index 2d6565e6d3b..59a50ff9264 100644 --- a/spec/features/admin/admin_settings_spec.rb +++ b/spec/features/admin/admin_settings_spec.rb @@ -16,6 +16,19 @@ feature 'Admin updates settings', feature: true do expect(page).to have_content "Application settings saved successfully" end + scenario 'Uncheck all restricted visibility levels' do + find('#application_setting_visibility_level_0').set(false) + find('#application_setting_visibility_level_10').set(false) + find('#application_setting_visibility_level_20').set(false) + + click_button 'Save' + + expect(page).to have_content "Application settings saved successfully" + expect(find('#application_setting_visibility_level_0')).not_to be_checked + expect(find('#application_setting_visibility_level_10')).not_to be_checked + expect(find('#application_setting_visibility_level_20')).not_to be_checked + end + scenario 'Change application settings' do uncheck 'Gravatar enabled' fill_in 'Home page URL', with: 'https://about.gitlab.com/' -- cgit v1.2.3 From ec697bcc3415e7d26e473313ad01f5fc56eb7a13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Wed, 5 Jul 2017 21:16:40 +0200 Subject: Fix a nasty transient failure happening is a subsequent spec MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://gitlab.com/gitlab-org/gitlab-ce/issues/34698#note_34276286 for the thorough explanation. Signed-off-by: Rémy Coutable --- .../projects/wiki/user_creates_wiki_page_spec.rb | 27 ++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'spec') diff --git a/spec/features/projects/wiki/user_creates_wiki_page_spec.rb b/spec/features/projects/wiki/user_creates_wiki_page_spec.rb index 86b31057a55..2d80039c974 100644 --- a/spec/features/projects/wiki/user_creates_wiki_page_spec.rb +++ b/spec/features/projects/wiki/user_creates_wiki_page_spec.rb @@ -1,20 +1,23 @@ require 'spec_helper' -feature 'Projects > Wiki > User creates wiki page', js: true, feature: true do +feature 'Projects > Wiki > User creates wiki page', :js do let(:user) { create(:user) } background do project.team << [user, :master] - gitlab_sign_in(user) + sign_in(user) - visit project_path(project) - find('.shortcuts-wiki').trigger('click') + visit project_path(project.namespace, project) end context 'in the user namespace' do let(:project) { create(:project, namespace: user.namespace) } context 'when wiki is empty' do + before do + find('.shortcuts-wiki').trigger('click') + end + scenario 'commit message field has value "Create home"' do expect(page).to have_field('wiki[message]', with: 'Create home') end @@ -67,10 +70,11 @@ feature 'Projects > Wiki > User creates wiki page', js: true, feature: true do context 'when wiki is not empty' do before do WikiPages::CreateService.new(project, user, title: 'home', content: 'Home page').execute + find('.shortcuts-wiki').trigger('click') end context 'via the "new wiki page" page' do - scenario 'when the wiki page has a single word name', js: true do + scenario 'when the wiki page has a single word name' do click_link 'New page' page.within '#modal-new-wiki' do @@ -91,7 +95,7 @@ feature 'Projects > Wiki > User creates wiki page', js: true, feature: true do expect(page).to have_content('My awesome wiki!') end - scenario 'when the wiki page has spaces in the name', js: true do + scenario 'when the wiki page has spaces in the name' do click_link 'New page' page.within '#modal-new-wiki' do @@ -112,7 +116,7 @@ feature 'Projects > Wiki > User creates wiki page', js: true, feature: true do expect(page).to have_content('My awesome wiki!') end - scenario 'when the wiki page has hyphens in the name', js: true do + scenario 'when the wiki page has hyphens in the name' do click_link 'New page' page.within '#modal-new-wiki' do @@ -134,7 +138,7 @@ feature 'Projects > Wiki > User creates wiki page', js: true, feature: true do end end - scenario 'content has autocomplete', :js do + scenario 'content has autocomplete' do click_link 'New page' page.within '#modal-new-wiki' do @@ -156,6 +160,10 @@ feature 'Projects > Wiki > User creates wiki page', js: true, feature: true do let(:project) { create(:project, namespace: create(:group, :public)) } context 'when wiki is empty' do + before do + find('.shortcuts-wiki').trigger('click') + end + scenario 'commit message field has value "Create home"' do expect(page).to have_field('wiki[message]', with: 'Create home') end @@ -175,9 +183,10 @@ feature 'Projects > Wiki > User creates wiki page', js: true, feature: true do context 'when wiki is not empty' do before do WikiPages::CreateService.new(project, user, title: 'home', content: 'Home page').execute + find('.shortcuts-wiki').trigger('click') end - scenario 'via the "new wiki page" page', js: true do + scenario 'via the "new wiki page" page' do click_link 'New page' page.within '#modal-new-wiki' do -- cgit v1.2.3 From 1a581a6afcc3ac94dcc2208412bd80861dba84ab Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Wed, 5 Jul 2017 21:23:10 +0200 Subject: Use a previous approach for cycle analytics dummy pipeline --- spec/models/project_spec.rb | 2 +- spec/support/cycle_analytics_helpers.rb | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'spec') diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index ae16b497c2f..751ffb2220a 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -1523,7 +1523,7 @@ describe Project, models: true do expect(project.ci_config_path).to eq('foo/.gitlab_ci.yml') end - it 'sets a string but remove all leading slashes and null characters' do + it 'sets a string but removes all leading slashes and null characters' do project.update!(ci_config_path: "///f\0oo/\0/.gitlab_ci.yml") expect(project.ci_config_path).to eq('foo//.gitlab_ci.yml') diff --git a/spec/support/cycle_analytics_helpers.rb b/spec/support/cycle_analytics_helpers.rb index 0bbb7e23079..c0a5491a430 100644 --- a/spec/support/cycle_analytics_helpers.rb +++ b/spec/support/cycle_analytics_helpers.rb @@ -74,10 +74,9 @@ module CycleAnalyticsHelpers def dummy_pipeline @dummy_pipeline ||= - project.pipelines.build( + Ci::Pipeline.new( sha: project.repository.commit('master').sha, - ref: 'master', - source: :push) + project: project) end def new_dummy_job(environment) -- cgit v1.2.3 From 49c121e31aef127c5f04a0c197899a4cb15fa39c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Coutable?= Date: Wed, 5 Jul 2017 22:12:10 +0200 Subject: Fix Rubocop offense MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rémy Coutable --- spec/lib/gitlab/gitaly_client/ref_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'spec') diff --git a/spec/lib/gitlab/gitaly_client/ref_spec.rb b/spec/lib/gitlab/gitaly_client/ref_spec.rb index df22fcad902..7c090460764 100644 --- a/spec/lib/gitlab/gitaly_client/ref_spec.rb +++ b/spec/lib/gitlab/gitaly_client/ref_spec.rb @@ -77,7 +77,7 @@ describe Gitlab::GitalyClient::Ref do let(:client) { described_class.new(repository) } subject { client.find_ref_name(SeedRepo::Commit::ID, 'refs/heads/master') } - it { should be_utf8 } - it { should eq('refs/heads/master') } + it { is_expected.to be_utf8 } + it { is_expected.to eq('refs/heads/master') } end end -- cgit v1.2.3 From 8d44d5142ae8a5e00b8417d2db8a7627fea0ef57 Mon Sep 17 00:00:00 2001 From: vanadium23 Date: Thu, 29 Jun 2017 20:20:59 +0300 Subject: Add user projects API --- spec/requests/api/projects_spec.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'spec') diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 14dec3d45b1..049daee0ece 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -475,6 +475,26 @@ describe API::Projects do end end + describe 'GET /users/:user_id/projects/' do + let!(:public_project) { create(:empty_project, :public, name: 'public_project', creator_id: user4.id, namespace: user4.namespace) } + + it 'returns error when user not found' do + get api('/users/9999/projects/') + + expect(response).to have_http_status(404) + expect(json_response['message']).to eq('404 User Not Found') + end + + it 'returns projects filtered by user' do + get api("/users/#{user4.id}/projects/", user) + + expect(response).to have_http_status(200) + expect(response).to include_pagination_headers + expect(json_response).to be_an Array + expect(json_response.map { |project| project['id'] }).to contain_exactly(public_project.id) + end + end + describe 'POST /projects/user/:id' do before do expect(project).to be_persisted -- cgit v1.2.3 From e936db963e2adb549533cfedcac6f342d7e5e32e Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Wed, 14 Jun 2017 04:30:07 +0000 Subject: Add integration tests around OAuth login. - There was previously a test for `saml` login in `login_spec`, but this didn't seem to be passing. A lot of things didn't seem right here, and I suspect that this test hasn't been running. I'll investigate this further. - It took almost a whole working day to figure out this line: OmniAuth.config.full_host = ->(request) { request['REQUEST_URI'].sub(request['REQUEST_PATH'], '') } As always, it's obvious in retrospect, but it took some digging to figure out tests were failing and returning 404s during the callback phase. - Test all OAuth providers - github, twitter, bitbucket, gitlab, google, and facebook --- spec/features/oauth_login_spec.rb | 58 +++++++++++++++++++++++++++++++++++++++ spec/support/login_helpers.rb | 7 +++++ 2 files changed, 65 insertions(+) create mode 100644 spec/features/oauth_login_spec.rb (limited to 'spec') diff --git a/spec/features/oauth_login_spec.rb b/spec/features/oauth_login_spec.rb new file mode 100644 index 00000000000..f960dacdcac --- /dev/null +++ b/spec/features/oauth_login_spec.rb @@ -0,0 +1,58 @@ +require 'spec_helper' + +feature 'OAuth Login', feature: true, js: true do + def enter_code(code) + fill_in 'user_otp_attempt', with: code + click_button 'Verify code' + end + + def provider_config(provider) + OpenStruct.new(name: provider.to_s, app_id: 'app_id', app_secret: 'app_secret') + end + + def stub_omniauth_config(provider) + OmniAuth.config.add_mock(provider, OmniAuth::AuthHash.new({ provider: provider.to_s, uid: "12345" })) + Rails.application.env_config['devise.mapping'] = Devise.mappings[:user] + Rails.application.env_config["omniauth.auth"] = OmniAuth.config.mock_auth[provider] + end + + providers = [:github, :twitter, :bitbucket, :gitlab, :google_oauth2, :facebook] + + before do + OmniAuth.config.full_host = ->(request) { request['REQUEST_URI'].sub(request['REQUEST_PATH'], '') } + + messages = { + enabled: true, + allow_single_sign_on: providers.map(&:to_s), + providers: providers.map { |provider| provider_config(provider) } + } + + allow(Gitlab.config.omniauth).to receive_messages(messages) + end + + providers.each do |provider| + context "when the user logs in using the #{provider} provider" do + context "when two-factor authentication is disabled" do + it 'logs the user in' do + stub_omniauth_config(provider) + user = create(:omniauth_user, extern_uid: 'my-uid', provider: provider.to_s) + login_via(provider.to_s, user, 'my-uid') + + expect(current_path).to eq root_path + save_screenshot + end + end + + context "when two-factor authentication is enabled" do + it 'logs the user in' do + stub_omniauth_config(provider) + user = create(:omniauth_user, :two_factor, extern_uid: 'my-uid', provider: provider.to_s) + login_via(provider.to_s, user, 'my-uid') + + enter_code(user.current_otp) + expect(current_path).to eq root_path + end + end + end + end +end diff --git a/spec/support/login_helpers.rb b/spec/support/login_helpers.rb index 4c88958264b..27f12cacc62 100644 --- a/spec/support/login_helpers.rb +++ b/spec/support/login_helpers.rb @@ -62,6 +62,13 @@ module LoginHelpers Thread.current[:current_user] = user end + def login_via(provider, user, uid) + mock_auth_hash(provider, uid, user.email) + visit new_user_session_path + expect(page).to have_content('Sign in with') + click_link "oauth-login-#{provider}" + end + def mock_auth_hash(provider, uid, email) # The mock_auth configuration allows you to set per-provider (or default) # authentication hashes to return during integration testing. -- cgit v1.2.3 From 43337c120de9f88b8141b0f8073bfa04a4e23776 Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Thu, 15 Jun 2017 04:40:47 +0000 Subject: Test the "Remember Me" flow for OAuth-based login. --- spec/features/oauth_login_spec.rb | 61 +++++++++++++++++++++++++++++++++++++-- spec/support/capybara_helpers.rb | 5 ++++ spec/support/login_helpers.rb | 5 +++- 3 files changed, 68 insertions(+), 3 deletions(-) (limited to 'spec') diff --git a/spec/features/oauth_login_spec.rb b/spec/features/oauth_login_spec.rb index f960dacdcac..2d51abd0e97 100644 --- a/spec/features/oauth_login_spec.rb +++ b/spec/features/oauth_login_spec.rb @@ -19,7 +19,7 @@ feature 'OAuth Login', feature: true, js: true do providers = [:github, :twitter, :bitbucket, :gitlab, :google_oauth2, :facebook] before do - OmniAuth.config.full_host = ->(request) { request['REQUEST_URI'].sub(request['REQUEST_PATH'], '') } + OmniAuth.config.full_host = ->(request) { request['REQUEST_URI'].sub(/#{request['REQUEST_PATH']}.*/, '') } messages = { enabled: true, @@ -39,7 +39,6 @@ feature 'OAuth Login', feature: true, js: true do login_via(provider.to_s, user, 'my-uid') expect(current_path).to eq root_path - save_screenshot end end @@ -53,6 +52,64 @@ feature 'OAuth Login', feature: true, js: true do expect(current_path).to eq root_path end end + + context 'when "remember me" is checked' do + context "when two-factor authentication is disabled" do + it 'remembers the user after a browser restart' do + stub_omniauth_config(provider) + user = create(:omniauth_user, extern_uid: 'my-uid', provider: provider.to_s) + login_via(provider.to_s, user, 'my-uid', remember_me: true) + + restart_browser + + visit(root_path) + expect(current_path).to eq root_path + end + end + + context "when two-factor authentication is enabled" do + it 'remembers the user after a browser restart' do + stub_omniauth_config(provider) + user = create(:omniauth_user, :two_factor, extern_uid: 'my-uid', provider: provider.to_s) + login_via(provider.to_s, user, 'my-uid', remember_me: true) + enter_code(user.current_otp) + + restart_browser + + visit(root_path) + expect(current_path).to eq root_path + end + end + end + + context 'when "remember me" is not checked' do + context "when two-factor authentication is disabled" do + it 'does not remember the user after a browser restart' do + stub_omniauth_config(provider) + user = create(:omniauth_user, extern_uid: 'my-uid', provider: provider.to_s) + login_via(provider.to_s, user, 'my-uid', remember_me: false) + + restart_browser + + visit(root_path) + expect(current_path).to eq new_user_session_path + end + end + + context "when two-factor authentication is enabled" do + it 'remembers the user after a browser restart' do + stub_omniauth_config(provider) + user = create(:omniauth_user, :two_factor, extern_uid: 'my-uid', provider: provider.to_s) + login_via(provider.to_s, user, 'my-uid', remember_me: false) + enter_code(user.current_otp) + + restart_browser + + visit(root_path) + expect(current_path).to eq new_user_session_path + end + end + end end end end diff --git a/spec/support/capybara_helpers.rb b/spec/support/capybara_helpers.rb index b57a3493aff..1037e9def8c 100644 --- a/spec/support/capybara_helpers.rb +++ b/spec/support/capybara_helpers.rb @@ -35,6 +35,11 @@ module CapybaraHelpers visit 'about:blank' visit url end + + # Simulate a browser restart by clearing the session cookie. + def restart_browser + page.driver.remove_cookie('_gitlab_session') + end end RSpec.configure do |config| diff --git a/spec/support/login_helpers.rb b/spec/support/login_helpers.rb index 27f12cacc62..789cf9baae2 100644 --- a/spec/support/login_helpers.rb +++ b/spec/support/login_helpers.rb @@ -62,10 +62,13 @@ module LoginHelpers Thread.current[:current_user] = user end - def login_via(provider, user, uid) + def login_via(provider, user, uid, remember_me: false) mock_auth_hash(provider, uid, user.email) visit new_user_session_path expect(page).to have_content('Sign in with') + + check "Remember Me" if remember_me + click_link "oauth-login-#{provider}" end -- cgit v1.2.3 From fd94855893b96ccab2227330ffd3134a92f4cb45 Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Mon, 19 Jun 2017 04:40:24 +0000 Subject: Add more providers to the OAuth login integration tests. - Added saml, authentiq, cas3, and auth0 - Crowd seems to be a special case that will be handled separately. --- spec/features/oauth_login_spec.rb | 43 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) (limited to 'spec') diff --git a/spec/features/oauth_login_spec.rb b/spec/features/oauth_login_spec.rb index 2d51abd0e97..b37c14bd638 100644 --- a/spec/features/oauth_login_spec.rb +++ b/spec/features/oauth_login_spec.rb @@ -7,7 +7,20 @@ feature 'OAuth Login', feature: true, js: true do end def provider_config(provider) - OpenStruct.new(name: provider.to_s, app_id: 'app_id', app_secret: 'app_secret') + if provider == :saml + OpenStruct.new( + name: 'saml', label: 'saml', + args: { + assertion_consumer_service_url: 'https://localhost:3443/users/auth/saml/callback', + idp_cert_fingerprint: '26:43:2C:47:AF:F0:6B:D0:07:9C:AD:A3:74:FE:5D:94:5F:4E:9E:52', + idp_sso_target_url: 'https://idp.example.com/sso/saml', + issuer: 'https://localhost:3443/', + name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient' + } + ) + else + OpenStruct.new(name: provider.to_s, app_id: 'app_id', app_secret: 'app_secret') + end end def stub_omniauth_config(provider) @@ -16,7 +29,8 @@ feature 'OAuth Login', feature: true, js: true do Rails.application.env_config["omniauth.auth"] = OmniAuth.config.mock_auth[provider] end - providers = [:github, :twitter, :bitbucket, :gitlab, :google_oauth2, :facebook] + providers = [:github, :twitter, :bitbucket, :gitlab, :google_oauth2, + :facebook, :authentiq, :cas3, :auth0] before do OmniAuth.config.full_host = ->(request) { request['REQUEST_URI'].sub(/#{request['REQUEST_PATH']}.*/, '') } @@ -24,12 +38,37 @@ feature 'OAuth Login', feature: true, js: true do messages = { enabled: true, allow_single_sign_on: providers.map(&:to_s), + auto_link_saml_user: true, providers: providers.map { |provider| provider_config(provider) } } allow(Gitlab.config.omniauth).to receive_messages(messages) end + # context 'logging in via OAuth' do + # def saml_config + + # end + # def stub_omniauth_config(messages) + # Rails.application.env_config['devise.mapping'] = Devise.mappings[:user] + # Rails.application.routes.disable_clear_and_finalize = true + # Rails.application.routes.draw do + # post '/users/auth/saml' => 'omniauth_callbacks#saml' + # end + # allow(Gitlab::OAuth::Provider).to receive_messages(providers: [:saml], config_for: saml_config) + # allow(Gitlab.config.omniauth).to receive_messages(messages) + # expect_any_instance_of(Object).to receive(:omniauth_authorize_path).with(:user, "saml").and_return('/users/auth/saml') + # end + # it 'shows 2FA prompt after OAuth login' do + # stub_omniauth_config(enabled: true, auto_link_saml_user: true, allow_single_sign_on: ['saml'], providers: [saml_config]) + # user = create(:omniauth_user, :two_factor, extern_uid: 'my-uid', provider: 'saml') + # login_via('saml', user, 'my-uid') + # expect(page).to have_content('Two-Factor Authentication') + # enter_code(user.current_otp) + # expect(current_path).to eq root_path + # end + # end + providers.each do |provider| context "when the user logs in using the #{provider} provider" do context "when two-factor authentication is disabled" do -- cgit v1.2.3 From 15dba34c9a469c95ea6112419dca33c2c63c6247 Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Mon, 19 Jun 2017 07:55:09 +0000 Subject: Add Omniauth OAuth config to the test section of `gitlab.yml` - I tried to get this to work by stubbing out portions of the config within the test. This didn't work as expected because Devise/Omniauth loaded before the stub could run, and the stubbed config was ignored. - I attempted to fix this by reloading Devise/Omniauth after stubbing the config. This successfully got Devise to load the stubbed providers, but failed while trying to access a route such as `user_gitlab_omniauth_authorize_path`. - I spent a while trying to figure this out (even trying `Rails.application.reload_routes!`), but nothing seemed to work. - I settled for adding this config directly to `gitlab.yml` rather than go down this path any further. --- spec/features/oauth_login_spec.rb | 52 +-------------------------------------- 1 file changed, 1 insertion(+), 51 deletions(-) (limited to 'spec') diff --git a/spec/features/oauth_login_spec.rb b/spec/features/oauth_login_spec.rb index b37c14bd638..8e02bc88fad 100644 --- a/spec/features/oauth_login_spec.rb +++ b/spec/features/oauth_login_spec.rb @@ -6,23 +6,6 @@ feature 'OAuth Login', feature: true, js: true do click_button 'Verify code' end - def provider_config(provider) - if provider == :saml - OpenStruct.new( - name: 'saml', label: 'saml', - args: { - assertion_consumer_service_url: 'https://localhost:3443/users/auth/saml/callback', - idp_cert_fingerprint: '26:43:2C:47:AF:F0:6B:D0:07:9C:AD:A3:74:FE:5D:94:5F:4E:9E:52', - idp_sso_target_url: 'https://idp.example.com/sso/saml', - issuer: 'https://localhost:3443/', - name_identifier_format: 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient' - } - ) - else - OpenStruct.new(name: provider.to_s, app_id: 'app_id', app_secret: 'app_secret') - end - end - def stub_omniauth_config(provider) OmniAuth.config.add_mock(provider, OmniAuth::AuthHash.new({ provider: provider.to_s, uid: "12345" })) Rails.application.env_config['devise.mapping'] = Devise.mappings[:user] @@ -32,43 +15,10 @@ feature 'OAuth Login', feature: true, js: true do providers = [:github, :twitter, :bitbucket, :gitlab, :google_oauth2, :facebook, :authentiq, :cas3, :auth0] - before do + before(:all) do OmniAuth.config.full_host = ->(request) { request['REQUEST_URI'].sub(/#{request['REQUEST_PATH']}.*/, '') } - - messages = { - enabled: true, - allow_single_sign_on: providers.map(&:to_s), - auto_link_saml_user: true, - providers: providers.map { |provider| provider_config(provider) } - } - - allow(Gitlab.config.omniauth).to receive_messages(messages) end - # context 'logging in via OAuth' do - # def saml_config - - # end - # def stub_omniauth_config(messages) - # Rails.application.env_config['devise.mapping'] = Devise.mappings[:user] - # Rails.application.routes.disable_clear_and_finalize = true - # Rails.application.routes.draw do - # post '/users/auth/saml' => 'omniauth_callbacks#saml' - # end - # allow(Gitlab::OAuth::Provider).to receive_messages(providers: [:saml], config_for: saml_config) - # allow(Gitlab.config.omniauth).to receive_messages(messages) - # expect_any_instance_of(Object).to receive(:omniauth_authorize_path).with(:user, "saml").and_return('/users/auth/saml') - # end - # it 'shows 2FA prompt after OAuth login' do - # stub_omniauth_config(enabled: true, auto_link_saml_user: true, allow_single_sign_on: ['saml'], providers: [saml_config]) - # user = create(:omniauth_user, :two_factor, extern_uid: 'my-uid', provider: 'saml') - # login_via('saml', user, 'my-uid') - # expect(page).to have_content('Two-Factor Authentication') - # enter_code(user.current_otp) - # expect(current_path).to eq root_path - # end - # end - providers.each do |provider| context "when the user logs in using the #{provider} provider" do context "when two-factor authentication is disabled" do -- cgit v1.2.3 From 8fa08ea3cd81e906c4f4951c70e3571defeab7c7 Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Fri, 30 Jun 2017 16:36:36 +0000 Subject: Implement review comments for !11963 from @adamniedzielski. - Change double quotes to single quotes. - Why is `OmniAuth.config.full_host` being reassigned in the integration test? - Use `map` over `map!` to avoid `dup` in the `gitlab:info` rake task - Other minor changes --- spec/features/oauth_login_spec.rb | 36 ++++++++++++++++++++++-------------- spec/support/capybara_helpers.rb | 2 +- spec/support/login_helpers.rb | 2 +- 3 files changed, 24 insertions(+), 16 deletions(-) (limited to 'spec') diff --git a/spec/features/oauth_login_spec.rb b/spec/features/oauth_login_spec.rb index 8e02bc88fad..452b920307c 100644 --- a/spec/features/oauth_login_spec.rb +++ b/spec/features/oauth_login_spec.rb @@ -1,27 +1,35 @@ require 'spec_helper' -feature 'OAuth Login', feature: true, js: true do +feature 'OAuth Login', js: true do def enter_code(code) fill_in 'user_otp_attempt', with: code click_button 'Verify code' end def stub_omniauth_config(provider) - OmniAuth.config.add_mock(provider, OmniAuth::AuthHash.new({ provider: provider.to_s, uid: "12345" })) + OmniAuth.config.add_mock(provider, OmniAuth::AuthHash.new(provider: provider.to_s, uid: "12345")) Rails.application.env_config['devise.mapping'] = Devise.mappings[:user] - Rails.application.env_config["omniauth.auth"] = OmniAuth.config.mock_auth[provider] + Rails.application.env_config['omniauth.auth'] = OmniAuth.config.mock_auth[provider] end providers = [:github, :twitter, :bitbucket, :gitlab, :google_oauth2, :facebook, :authentiq, :cas3, :auth0] before(:all) do + # The OmniAuth `full_host` parameter doesn't get set correctly (it gets set to something like `http://localhost` + # here), and causes integration tests to fail with 404s. We set the `full_host` by removing the request path (and + # anything after it) from the request URI. + @omniauth_config_full_host = OmniAuth.config.full_host OmniAuth.config.full_host = ->(request) { request['REQUEST_URI'].sub(/#{request['REQUEST_PATH']}.*/, '') } end + after(:all) do + OmniAuth.config.full_host = @omniauth_config_full_host + end + providers.each do |provider| context "when the user logs in using the #{provider} provider" do - context "when two-factor authentication is disabled" do + context 'when two-factor authentication is disabled' do it 'logs the user in' do stub_omniauth_config(provider) user = create(:omniauth_user, extern_uid: 'my-uid', provider: provider.to_s) @@ -31,7 +39,7 @@ feature 'OAuth Login', feature: true, js: true do end end - context "when two-factor authentication is enabled" do + context 'when two-factor authentication is enabled' do it 'logs the user in' do stub_omniauth_config(provider) user = create(:omniauth_user, :two_factor, extern_uid: 'my-uid', provider: provider.to_s) @@ -43,27 +51,27 @@ feature 'OAuth Login', feature: true, js: true do end context 'when "remember me" is checked' do - context "when two-factor authentication is disabled" do + context 'when two-factor authentication is disabled' do it 'remembers the user after a browser restart' do stub_omniauth_config(provider) user = create(:omniauth_user, extern_uid: 'my-uid', provider: provider.to_s) login_via(provider.to_s, user, 'my-uid', remember_me: true) - restart_browser + clear_browser_session visit(root_path) expect(current_path).to eq root_path end end - context "when two-factor authentication is enabled" do + context 'when two-factor authentication is enabled' do it 'remembers the user after a browser restart' do stub_omniauth_config(provider) user = create(:omniauth_user, :two_factor, extern_uid: 'my-uid', provider: provider.to_s) login_via(provider.to_s, user, 'my-uid', remember_me: true) enter_code(user.current_otp) - restart_browser + clear_browser_session visit(root_path) expect(current_path).to eq root_path @@ -72,27 +80,27 @@ feature 'OAuth Login', feature: true, js: true do end context 'when "remember me" is not checked' do - context "when two-factor authentication is disabled" do + context 'when two-factor authentication is disabled' do it 'does not remember the user after a browser restart' do stub_omniauth_config(provider) user = create(:omniauth_user, extern_uid: 'my-uid', provider: provider.to_s) login_via(provider.to_s, user, 'my-uid', remember_me: false) - restart_browser + clear_browser_session visit(root_path) expect(current_path).to eq new_user_session_path end end - context "when two-factor authentication is enabled" do - it 'remembers the user after a browser restart' do + context 'when two-factor authentication is enabled' do + it 'does not remember the user after a browser restart' do stub_omniauth_config(provider) user = create(:omniauth_user, :two_factor, extern_uid: 'my-uid', provider: provider.to_s) login_via(provider.to_s, user, 'my-uid', remember_me: false) enter_code(user.current_otp) - restart_browser + clear_browser_session visit(root_path) expect(current_path).to eq new_user_session_path diff --git a/spec/support/capybara_helpers.rb b/spec/support/capybara_helpers.rb index 1037e9def8c..3eb7bea3227 100644 --- a/spec/support/capybara_helpers.rb +++ b/spec/support/capybara_helpers.rb @@ -37,7 +37,7 @@ module CapybaraHelpers end # Simulate a browser restart by clearing the session cookie. - def restart_browser + def clear_browser_session page.driver.remove_cookie('_gitlab_session') end end diff --git a/spec/support/login_helpers.rb b/spec/support/login_helpers.rb index 789cf9baae2..184c7b5125a 100644 --- a/spec/support/login_helpers.rb +++ b/spec/support/login_helpers.rb @@ -67,7 +67,7 @@ module LoginHelpers visit new_user_session_path expect(page).to have_content('Sign in with') - check "Remember Me" if remember_me + check 'Remember Me' if remember_me click_link "oauth-login-#{provider}" end -- cgit v1.2.3 From 7c2f5bb48d98426b8458782216311f24aa705209 Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Mon, 3 Jul 2017 19:37:37 +0000 Subject: Fix build for !11963. - Don't use `request.env['omniauth.params']` if it isn't present. - Remove the `saml` section from the `gitlab.yml` test section. Some tests depend on this section not being initially present, so it can be overridden in the test. This MR doesn't add any tests for SAML, so we didn't really need this in the first place anyway. - Clean up the test -> omniauth section of `gitlab.yml` --- spec/support/login_helpers.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/support/login_helpers.rb b/spec/support/login_helpers.rb index 184c7b5125a..99e7806353d 100644 --- a/spec/support/login_helpers.rb +++ b/spec/support/login_helpers.rb @@ -118,6 +118,7 @@ module LoginHelpers end allow(Gitlab::OAuth::Provider).to receive_messages(providers: [:saml], config_for: mock_saml_config) stub_omniauth_setting(messages) - expect_any_instance_of(Object).to receive(:omniauth_authorize_path).with(:user, "saml").and_return('/users/auth/saml') + 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 end -- cgit v1.2.3 From 8d49a9fd580212b12bd719e6b310646e285c36b7 Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Tue, 4 Jul 2017 11:59:41 +0000 Subject: Add Jasmine tests for `OAuthRememberMe` --- .../fixtures/oauth_remember_me.html.haml | 5 +++++ spec/javascripts/oauth_remember_me_spec.js | 26 ++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 spec/javascripts/fixtures/oauth_remember_me.html.haml create mode 100644 spec/javascripts/oauth_remember_me_spec.js (limited to 'spec') diff --git a/spec/javascripts/fixtures/oauth_remember_me.html.haml b/spec/javascripts/fixtures/oauth_remember_me.html.haml new file mode 100644 index 00000000000..7886e995e57 --- /dev/null +++ b/spec/javascripts/fixtures/oauth_remember_me.html.haml @@ -0,0 +1,5 @@ +#oauth-container + %input#remember_me{ type: "checkbox" } + + %a.oauth-login.twitter{ href: "http://example.com/" } + %a.oauth-login.github{ href: "http://example.com/" } diff --git a/spec/javascripts/oauth_remember_me_spec.js b/spec/javascripts/oauth_remember_me_spec.js new file mode 100644 index 00000000000..f90e0093d25 --- /dev/null +++ b/spec/javascripts/oauth_remember_me_spec.js @@ -0,0 +1,26 @@ +import OAuthRememberMe from '~/oauth_remember_me'; + +describe('OAuthRememberMe', () => { + preloadFixtures('static/oauth_remember_me.html.raw'); + + beforeEach(() => { + loadFixtures('static/oauth_remember_me.html.raw'); + + new OAuthRememberMe({ container: $('#oauth-container') }).bindEvents(); + }); + + it('adds the "remember_me" query parameter to all OAuth login buttons', () => { + $('#oauth-container #remember_me').click(); + + expect($('#oauth-container .oauth-login.twitter').attr('href')).toBe('http://example.com/?remember_me=1'); + expect($('#oauth-container .oauth-login.github').attr('href')).toBe('http://example.com/?remember_me=1'); + }); + + it('removes the "remember_me" query parameter from all OAuth login buttons', () => { + $('#oauth-container #remember_me').click(); + $('#oauth-container #remember_me').click(); + + expect($('#oauth-container .oauth-login.twitter').attr('href')).toBe('http://example.com/'); + expect($('#oauth-container .oauth-login.github').attr('href')).toBe('http://example.com/'); + }); +}); -- cgit v1.2.3 From 89b0c987fcba5692842f83cfaba90a9004ac91de Mon Sep 17 00:00:00 2001 From: Timothy Andrew Date: Thu, 6 Jul 2017 06:23:20 +0000 Subject: Remove Authentiq from the OAuth login integration tests. - This is causing autoload-related errors in the `migration:path` builds. We need to find a better way of testing this provider. --- spec/features/oauth_login_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/features/oauth_login_spec.rb b/spec/features/oauth_login_spec.rb index 452b920307c..1b6d1f3415f 100644 --- a/spec/features/oauth_login_spec.rb +++ b/spec/features/oauth_login_spec.rb @@ -13,7 +13,7 @@ feature 'OAuth Login', js: true do end providers = [:github, :twitter, :bitbucket, :gitlab, :google_oauth2, - :facebook, :authentiq, :cas3, :auth0] + :facebook, :cas3, :auth0] before(:all) do # The OmniAuth `full_host` parameter doesn't get set correctly (it gets set to something like `http://localhost` -- cgit v1.2.3 From 320ad563b52556c10945eeb9bba8dbf9dc47724d Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Thu, 6 Jul 2017 09:14:49 +0200 Subject: Fix Rubocop offenses in gitaly client ref specs --- spec/lib/gitlab/gitaly_client/ref_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'spec') diff --git a/spec/lib/gitlab/gitaly_client/ref_spec.rb b/spec/lib/gitlab/gitaly_client/ref_spec.rb index df22fcad902..7c090460764 100644 --- a/spec/lib/gitlab/gitaly_client/ref_spec.rb +++ b/spec/lib/gitlab/gitaly_client/ref_spec.rb @@ -77,7 +77,7 @@ describe Gitlab::GitalyClient::Ref do let(:client) { described_class.new(repository) } subject { client.find_ref_name(SeedRepo::Commit::ID, 'refs/heads/master') } - it { should be_utf8 } - it { should eq('refs/heads/master') } + it { is_expected.to be_utf8 } + it { is_expected.to eq('refs/heads/master') } end end -- cgit v1.2.3 From a99083424b80345d0be89d5393b7980fcfea2264 Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Thu, 6 Jul 2017 09:15:41 +0200 Subject: Fix project_path helper arguments in wiki specs --- spec/features/projects/wiki/user_creates_wiki_page_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/features/projects/wiki/user_creates_wiki_page_spec.rb b/spec/features/projects/wiki/user_creates_wiki_page_spec.rb index 2d80039c974..9d66f482c8d 100644 --- a/spec/features/projects/wiki/user_creates_wiki_page_spec.rb +++ b/spec/features/projects/wiki/user_creates_wiki_page_spec.rb @@ -7,7 +7,7 @@ feature 'Projects > Wiki > User creates wiki page', :js do project.team << [user, :master] sign_in(user) - visit project_path(project.namespace, project) + visit project_path(project) end context 'in the user namespace' do -- cgit v1.2.3 From e7acc88156116bbfc20d13b5d897492cc415ee38 Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Thu, 6 Jul 2017 15:55:40 +0800 Subject: Rename KUBECONFIG_FILE to KUBECONFIG --- spec/models/project_services/kubernetes_service_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'spec') diff --git a/spec/models/project_services/kubernetes_service_spec.rb b/spec/models/project_services/kubernetes_service_spec.rb index d4feae231bc..7ec2ea5ba95 100644 --- a/spec/models/project_services/kubernetes_service_spec.rb +++ b/spec/models/project_services/kubernetes_service_spec.rb @@ -221,7 +221,7 @@ describe KubernetesService, models: true, caching: true do { key: 'KUBE_URL', value: 'https://kube.domain.com', public: true }, { key: 'KUBE_TOKEN', value: 'token', public: false }, { key: 'KUBE_NAMESPACE', value: namespace, public: true }, - { key: 'KUBECONFIG_FILE', value: kubeconfig, public: false, file: true }, + { key: 'KUBECONFIG', value: kubeconfig, public: false, file: true }, { key: 'KUBE_CA_PEM', value: 'CA PEM DATA', public: true }, { key: 'KUBE_CA_PEM_FILE', value: 'CA PEM DATA', public: true, file: true } ) -- cgit v1.2.3 From d9435d61218f677395f3b53976a41ac5f361f24b Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Thu, 6 Jul 2017 15:45:38 +0800 Subject: Backports for ee-2112 https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/2112 --- spec/lib/gitlab/sql/glob_spec.rb | 53 ++++++++++++++++++++++++++++++++++++++++ spec/models/ci/build_spec.rb | 7 +++--- spec/models/ci/variable_spec.rb | 4 --- spec/models/project_spec.rb | 12 ++++----- 4 files changed, 63 insertions(+), 13 deletions(-) create mode 100644 spec/lib/gitlab/sql/glob_spec.rb (limited to 'spec') diff --git a/spec/lib/gitlab/sql/glob_spec.rb b/spec/lib/gitlab/sql/glob_spec.rb new file mode 100644 index 00000000000..451c583310d --- /dev/null +++ b/spec/lib/gitlab/sql/glob_spec.rb @@ -0,0 +1,53 @@ +require 'spec_helper' + +describe Gitlab::SQL::Glob, lib: true do + describe '.to_like' do + it 'matches * as %' do + expect(glob('apple', '*')).to be(true) + expect(glob('apple', 'app*')).to be(true) + expect(glob('apple', 'apple*')).to be(true) + expect(glob('apple', '*pple')).to be(true) + expect(glob('apple', 'ap*le')).to be(true) + + expect(glob('apple', '*a')).to be(false) + expect(glob('apple', 'app*a')).to be(false) + expect(glob('apple', 'ap*l')).to be(false) + end + + it 'matches % literally' do + expect(glob('100%', '100%')).to be(true) + + expect(glob('100%', '%')).to be(false) + end + + it 'matches _ literally' do + expect(glob('^_^', '^_^')).to be(true) + + expect(glob('^A^', '^_^')).to be(false) + end + end + + def glob(string, pattern) + match(string, subject.to_like(quote(pattern))) + end + + def match(string, pattern) + value = query("SELECT #{quote(string)} LIKE #{pattern}") + .rows.flatten.first + + case value + when 't', 1 + true + else + false + end + end + + def query(sql) + ActiveRecord::Base.connection.select_all(sql) + end + + def quote(string) + ActiveRecord::Base.connection.quote(string) + end +end diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index a7ba3a7c43e..2b10791ad6d 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -1496,9 +1496,10 @@ describe Ci::Build, :models do allow(pipeline).to receive(:predefined_variables) { [pipeline_pre_var] } allow(build).to receive(:yaml_variables) { [build_yaml_var] } - allow(project).to receive(:secret_variables_for).with(build.ref) do - [create(:ci_variable, key: 'secret', value: 'value')] - end + allow(project).to receive(:secret_variables_for) + .with(ref: 'master', environment: nil) do + [create(:ci_variable, key: 'secret', value: 'value')] + end end it do diff --git a/spec/models/ci/variable_spec.rb b/spec/models/ci/variable_spec.rb index 50f7c029af8..4ffbfa6c130 100644 --- a/spec/models/ci/variable_spec.rb +++ b/spec/models/ci/variable_spec.rb @@ -8,10 +8,6 @@ describe Ci::Variable, models: true do describe 'validations' do it { is_expected.to include_module(HasVariable) } it { is_expected.to validate_uniqueness_of(:key).scoped_to(:project_id, :environment_scope) } - it { is_expected.to validate_length_of(:key).is_at_most(255) } - it { is_expected.to allow_value('foo').for(:key) } - it { is_expected.not_to allow_value('foo bar').for(:key) } - it { is_expected.not_to allow_value('foo/bar').for(:key) } end describe '.unprotected' do diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index f50b4aea411..a9855cf343b 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -1875,7 +1875,12 @@ describe Project, models: true do create(:ci_variable, :protected, value: 'protected', project: project) end - subject { project.secret_variables_for('ref') } + subject { project.secret_variables_for(ref: 'ref') } + + before do + stub_application_setting( + default_branch_protection: Gitlab::Access::PROTECTION_NONE) + end shared_examples 'ref is protected' do it 'contains all the variables' do @@ -1884,11 +1889,6 @@ describe Project, models: true do end context 'when the ref is not protected' do - before do - stub_application_setting( - default_branch_protection: Gitlab::Access::PROTECTION_NONE) - end - it 'contains only the secret variables' do is_expected.to contain_exactly(secret_variable) end -- cgit v1.2.3 From c63e3221587daf9e7464f7d2079ca8ed3111f6ff Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Tue, 30 May 2017 13:54:59 +0200 Subject: Add many foreign keys to the projects table This removes the need for relying on Rails' "dependent" option for data removal, which is _incredibly_ slow (even when using :delete_all) when deleting large amounts of data. This also ensures data consistency is enforced on DB level and not on application level (something Rails is really bad at). This commit also includes various migrations to add foreign keys to tables that eventually point to "projects" to ensure no rows get orphaned upon removing a project. --- spec/models/concerns/issuable_spec.rb | 2 +- spec/models/forked_project_link_spec.rb | 6 +- spec/models/merge_request_spec.rb | 2 +- spec/models/project_spec.rb | 121 ++++++++++++--------- spec/presenters/ci/build_presenter_spec.rb | 4 +- .../expire_build_instance_artifacts_worker_spec.rb | 14 --- 6 files changed, 76 insertions(+), 73 deletions(-) (limited to 'spec') diff --git a/spec/models/concerns/issuable_spec.rb b/spec/models/concerns/issuable_spec.rb index ac9303370ab..505039c9d88 100644 --- a/spec/models/concerns/issuable_spec.rb +++ b/spec/models/concerns/issuable_spec.rb @@ -155,7 +155,7 @@ describe Issuable do end describe "#sort" do - let(:project) { build_stubbed(:empty_project) } + let(:project) { create(:empty_project) } context "by milestone due date" do # Correct order is: diff --git a/spec/models/forked_project_link_spec.rb b/spec/models/forked_project_link_spec.rb index 5c13cf584f9..38fbdd2536a 100644 --- a/spec/models/forked_project_link_spec.rb +++ b/spec/models/forked_project_link_spec.rb @@ -42,7 +42,7 @@ describe ForkedProjectLink, "add link on fork" do describe '#forked?' do let(:project_to) { create(:project, forked_project_link: forked_project_link) } - let(:forked_project_link) { build(:forked_project_link) } + let(:forked_project_link) { create(:forked_project_link) } before do forked_project_link.forked_from_project = project_from @@ -59,9 +59,9 @@ describe ForkedProjectLink, "add link on fork" do end it "project_to.destroy destroys fork_link" do - expect(forked_project_link).to receive(:destroy) - project_to.destroy + + expect(ForkedProjectLink.exists?(id: forked_project_link.id)).to eq(false) end end diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 587d4b83cb4..d91f1f1a11c 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -10,7 +10,7 @@ describe MergeRequest, models: true do it { is_expected.to belong_to(:source_project).class_name('Project') } it { is_expected.to belong_to(:merge_user).class_name("User") } it { is_expected.to belong_to(:assignee) } - it { is_expected.to have_many(:merge_request_diffs).dependent(:destroy) } + it { is_expected.to have_many(:merge_request_diffs) } end describe 'modules' do diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index f50b4aea411..75fa2d2eb46 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -7,50 +7,50 @@ describe Project, models: true do it { is_expected.to belong_to(:creator).class_name('User') } it { is_expected.to have_many(:users) } it { is_expected.to have_many(:services) } - it { is_expected.to have_many(:events).dependent(:destroy) } - it { is_expected.to have_many(:merge_requests).dependent(:destroy) } - it { is_expected.to have_many(:issues).dependent(:destroy) } - it { is_expected.to have_many(:milestones).dependent(:destroy) } - it { is_expected.to have_many(:project_members).dependent(:destroy) } + it { is_expected.to have_many(:events) } + it { is_expected.to have_many(:merge_requests) } + it { is_expected.to have_many(:issues) } + it { is_expected.to have_many(:milestones) } + it { is_expected.to have_many(:project_members).dependent(:delete_all) } it { is_expected.to have_many(:users).through(:project_members) } - it { is_expected.to have_many(:requesters).dependent(:destroy) } - it { is_expected.to have_many(:notes).dependent(:destroy) } - it { is_expected.to have_many(:snippets).class_name('ProjectSnippet').dependent(:destroy) } - it { is_expected.to have_many(:deploy_keys_projects).dependent(:destroy) } + it { is_expected.to have_many(:requesters).dependent(:delete_all) } + it { is_expected.to have_many(:notes) } + it { is_expected.to have_many(:snippets).class_name('ProjectSnippet') } + it { is_expected.to have_many(:deploy_keys_projects) } it { is_expected.to have_many(:deploy_keys) } - it { is_expected.to have_many(:hooks).dependent(:destroy) } - it { is_expected.to have_many(:protected_branches).dependent(:destroy) } - it { is_expected.to have_one(:forked_project_link).dependent(:destroy) } - it { is_expected.to have_one(:slack_service).dependent(:destroy) } - it { is_expected.to have_one(:microsoft_teams_service).dependent(:destroy) } - it { is_expected.to have_one(:mattermost_service).dependent(:destroy) } - it { is_expected.to have_one(:pushover_service).dependent(:destroy) } - it { is_expected.to have_one(:asana_service).dependent(:destroy) } - it { is_expected.to have_many(:boards).dependent(:destroy) } - it { is_expected.to have_one(:campfire_service).dependent(:destroy) } - it { is_expected.to have_one(:drone_ci_service).dependent(:destroy) } - it { is_expected.to have_one(:emails_on_push_service).dependent(:destroy) } - it { is_expected.to have_one(:pipelines_email_service).dependent(:destroy) } - it { is_expected.to have_one(:irker_service).dependent(:destroy) } - it { is_expected.to have_one(:pivotaltracker_service).dependent(:destroy) } - it { is_expected.to have_one(:hipchat_service).dependent(:destroy) } - it { is_expected.to have_one(:flowdock_service).dependent(:destroy) } - it { is_expected.to have_one(:assembla_service).dependent(:destroy) } - it { is_expected.to have_one(:slack_slash_commands_service).dependent(:destroy) } - it { is_expected.to have_one(:mattermost_slash_commands_service).dependent(:destroy) } - it { is_expected.to have_one(:gemnasium_service).dependent(:destroy) } - it { is_expected.to have_one(:buildkite_service).dependent(:destroy) } - it { is_expected.to have_one(:bamboo_service).dependent(:destroy) } - it { is_expected.to have_one(:teamcity_service).dependent(:destroy) } - it { is_expected.to have_one(:jira_service).dependent(:destroy) } - it { is_expected.to have_one(:redmine_service).dependent(:destroy) } - it { is_expected.to have_one(:custom_issue_tracker_service).dependent(:destroy) } - it { is_expected.to have_one(:bugzilla_service).dependent(:destroy) } - it { is_expected.to have_one(:gitlab_issue_tracker_service).dependent(:destroy) } - it { is_expected.to have_one(:external_wiki_service).dependent(:destroy) } - it { is_expected.to have_one(:project_feature).dependent(:destroy) } - it { is_expected.to have_one(:statistics).class_name('ProjectStatistics').dependent(:delete) } - it { is_expected.to have_one(:import_data).class_name('ProjectImportData').dependent(:delete) } + it { is_expected.to have_many(:hooks) } + it { is_expected.to have_many(:protected_branches) } + it { is_expected.to have_one(:forked_project_link) } + it { is_expected.to have_one(:slack_service) } + it { is_expected.to have_one(:microsoft_teams_service) } + it { is_expected.to have_one(:mattermost_service) } + it { is_expected.to have_one(:pushover_service) } + it { is_expected.to have_one(:asana_service) } + it { is_expected.to have_many(:boards) } + it { is_expected.to have_one(:campfire_service) } + it { is_expected.to have_one(:drone_ci_service) } + it { is_expected.to have_one(:emails_on_push_service) } + it { is_expected.to have_one(:pipelines_email_service) } + it { is_expected.to have_one(:irker_service) } + it { is_expected.to have_one(:pivotaltracker_service) } + it { is_expected.to have_one(:hipchat_service) } + it { is_expected.to have_one(:flowdock_service) } + it { is_expected.to have_one(:assembla_service) } + it { is_expected.to have_one(:slack_slash_commands_service) } + it { is_expected.to have_one(:mattermost_slash_commands_service) } + it { is_expected.to have_one(:gemnasium_service) } + it { is_expected.to have_one(:buildkite_service) } + it { is_expected.to have_one(:bamboo_service) } + it { is_expected.to have_one(:teamcity_service) } + it { is_expected.to have_one(:jira_service) } + it { is_expected.to have_one(:redmine_service) } + it { is_expected.to have_one(:custom_issue_tracker_service) } + it { is_expected.to have_one(:bugzilla_service) } + it { is_expected.to have_one(:gitlab_issue_tracker_service) } + it { is_expected.to have_one(:external_wiki_service) } + it { is_expected.to have_one(:project_feature) } + it { is_expected.to have_one(:statistics).class_name('ProjectStatistics') } + it { is_expected.to have_one(:import_data).class_name('ProjectImportData') } it { is_expected.to have_one(:last_event).class_name('Event') } it { is_expected.to have_one(:forked_from_project).through(:forked_project_link) } it { is_expected.to have_many(:commit_statuses) } @@ -62,18 +62,18 @@ describe Project, models: true do it { is_expected.to have_many(:variables) } it { is_expected.to have_many(:triggers) } it { is_expected.to have_many(:pages_domains) } - it { is_expected.to have_many(:labels).class_name('ProjectLabel').dependent(:destroy) } - it { is_expected.to have_many(:users_star_projects).dependent(:destroy) } - it { is_expected.to have_many(:environments).dependent(:destroy) } - it { is_expected.to have_many(:deployments).dependent(:destroy) } - it { is_expected.to have_many(:todos).dependent(:destroy) } - it { is_expected.to have_many(:releases).dependent(:destroy) } - it { is_expected.to have_many(:lfs_objects_projects).dependent(:destroy) } - it { is_expected.to have_many(:project_group_links).dependent(:destroy) } - it { is_expected.to have_many(:notification_settings).dependent(:destroy) } + it { is_expected.to have_many(:labels).class_name('ProjectLabel') } + it { is_expected.to have_many(:users_star_projects) } + it { is_expected.to have_many(:environments) } + it { is_expected.to have_many(:deployments) } + it { is_expected.to have_many(:todos) } + it { is_expected.to have_many(:releases) } + it { is_expected.to have_many(:lfs_objects_projects) } + it { is_expected.to have_many(:project_group_links) } + it { is_expected.to have_many(:notification_settings).dependent(:delete_all) } it { is_expected.to have_many(:forks).through(:forked_project_links) } it { is_expected.to have_many(:uploads).dependent(:destroy) } - it { is_expected.to have_many(:pipeline_schedules).dependent(:destroy) } + it { is_expected.to have_many(:pipeline_schedules) } context 'after initialized' do it "has a project_feature" do @@ -2199,4 +2199,21 @@ describe Project, models: true do end end end + + describe '#remove_private_deploy_keys' do + it 'removes the private deploy keys of a project' do + project = create(:empty_project) + + private_key = create(:deploy_key, public: false) + public_key = create(:deploy_key, public: true) + + create(:deploy_keys_project, deploy_key: private_key, project: project) + create(:deploy_keys_project, deploy_key: public_key, project: project) + + project.remove_private_deploy_keys + + expect(project.deploy_keys.where(public: false).any?).to eq(false) + expect(project.deploy_keys.where(public: true).any?).to eq(true) + end + end end diff --git a/spec/presenters/ci/build_presenter_spec.rb b/spec/presenters/ci/build_presenter_spec.rb index 518e97d17a1..f05d5c7fce5 100644 --- a/spec/presenters/ci/build_presenter_spec.rb +++ b/spec/presenters/ci/build_presenter_spec.rb @@ -85,7 +85,7 @@ describe Ci::BuildPresenter do describe 'quack like a Ci::Build permission-wise' do context 'user is not allowed' do - let(:project) { build_stubbed(:empty_project, public_builds: false) } + let(:project) { create(:empty_project, public_builds: false) } it 'returns false' do expect(presenter.can?(nil, :read_build)).to be_falsy @@ -93,7 +93,7 @@ describe Ci::BuildPresenter do end context 'user is allowed' do - let(:project) { build_stubbed(:empty_project, :public) } + let(:project) { create(:empty_project, :public) } it 'returns true' do expect(presenter.can?(nil, :read_build)).to be_truthy diff --git a/spec/workers/expire_build_instance_artifacts_worker_spec.rb b/spec/workers/expire_build_instance_artifacts_worker_spec.rb index 1d8da68883b..bed5c5e2ecb 100644 --- a/spec/workers/expire_build_instance_artifacts_worker_spec.rb +++ b/spec/workers/expire_build_instance_artifacts_worker_spec.rb @@ -30,20 +30,6 @@ describe ExpireBuildInstanceArtifactsWorker do expect(build.reload.artifacts_file_identifier).to be_nil end end - - context 'when associated project was removed' do - let(:build) do - create(:ci_build, :artifacts, artifacts_expiry) do |build| - build.project.pending_delete = true - end - end - - it 'does not remove artifacts' do - expect do - build.reload.artifacts_file - end.not_to raise_error - end - end end context 'with not yet expired artifacts' do -- cgit v1.2.3 From 8fbbf41e29f5e0f56b7eb9d37aadba856b68bcce Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Thu, 8 Jun 2017 17:16:27 +0200 Subject: Added Cop to blacklist the use of `dependent:` This is allowed for existing instances so we don't end up 76 offenses right away, but for new code one should _only_ use this if they _have_ to remove non database data. Even then it's usually better to do this in a service class as this gives you more control over how to remove the data (e.g. in bulk). --- spec/rubocop/cop/active_record_dependent_spec.rb | 33 ++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 spec/rubocop/cop/active_record_dependent_spec.rb (limited to 'spec') diff --git a/spec/rubocop/cop/active_record_dependent_spec.rb b/spec/rubocop/cop/active_record_dependent_spec.rb new file mode 100644 index 00000000000..599a032bfc5 --- /dev/null +++ b/spec/rubocop/cop/active_record_dependent_spec.rb @@ -0,0 +1,33 @@ +require 'spec_helper' +require 'rubocop' +require 'rubocop/rspec/support' +require_relative '../../../rubocop/cop/active_record_dependent' + +describe RuboCop::Cop::ActiveRecordDependent do + include CopHelper + + subject(:cop) { described_class.new } + + context 'inside the app/models directory' do + it 'registers an offense when dependent: is used' do + allow(cop).to receive(:in_model?).and_return(true) + + inspect_source(cop, 'belongs_to :foo, dependent: :destroy') + + aggregate_failures do + expect(cop.offenses.size).to eq(1) + expect(cop.offenses.map(&:line)).to eq([1]) + end + end + end + + context 'outside the app/models directory' do + it 'does nothing' do + allow(cop).to receive(:in_model?).and_return(false) + + inspect_source(cop, 'belongs_to :foo, dependent: :destroy') + + expect(cop.offenses).to be_empty + end + end +end -- cgit v1.2.3 From 6f1e00ea36bdcc39da955f7aa2add6a21432d190 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Fri, 9 Jun 2017 00:59:50 +0200 Subject: Update CI runner factories to not use invalid IDs These IDs point to non-existing rows, causing the foreign key constraints to fail. --- spec/factories/ci/runner_projects.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'spec') diff --git a/spec/factories/ci/runner_projects.rb b/spec/factories/ci/runner_projects.rb index 6712dd5d82e..33a17cf7ed5 100644 --- a/spec/factories/ci/runner_projects.rb +++ b/spec/factories/ci/runner_projects.rb @@ -1,6 +1,6 @@ FactoryGirl.define do factory :ci_runner_project, class: Ci::RunnerProject do - runner_id 1 - project_id 1 + runner factory: :ci_runner + project factory: :empty_project end end -- cgit v1.2.3 From e1a3bf30b6ea04f2c658729f65a0eb09847dd341 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Mon, 3 Jul 2017 16:01:41 +0200 Subject: Rename ActiverecordSerialize cop This cop has been renamed to ActiveRecordSerialize to match the way "ActiveRecord" is usually written. --- spec/rubocop/cop/active_record_serialize_spec.rb | 33 ++++++++++++++++++++++++ spec/rubocop/cop/activerecord_serialize_spec.rb | 33 ------------------------ 2 files changed, 33 insertions(+), 33 deletions(-) create mode 100644 spec/rubocop/cop/active_record_serialize_spec.rb delete mode 100644 spec/rubocop/cop/activerecord_serialize_spec.rb (limited to 'spec') diff --git a/spec/rubocop/cop/active_record_serialize_spec.rb b/spec/rubocop/cop/active_record_serialize_spec.rb new file mode 100644 index 00000000000..b94b25cecd0 --- /dev/null +++ b/spec/rubocop/cop/active_record_serialize_spec.rb @@ -0,0 +1,33 @@ +require 'spec_helper' +require 'rubocop' +require 'rubocop/rspec/support' +require_relative '../../../rubocop/cop/active_record_serialize' + +describe RuboCop::Cop::ActiveRecordSerialize do + include CopHelper + + subject(:cop) { described_class.new } + + context 'inside the app/models directory' do + it 'registers an offense when serialize is used' do + allow(cop).to receive(:in_model?).and_return(true) + + inspect_source(cop, 'serialize :foo') + + aggregate_failures do + expect(cop.offenses.size).to eq(1) + expect(cop.offenses.map(&:line)).to eq([1]) + end + end + end + + context 'outside the app/models directory' do + it 'does nothing' do + allow(cop).to receive(:in_model?).and_return(false) + + inspect_source(cop, 'serialize :foo') + + expect(cop.offenses).to be_empty + end + end +end diff --git a/spec/rubocop/cop/activerecord_serialize_spec.rb b/spec/rubocop/cop/activerecord_serialize_spec.rb deleted file mode 100644 index 5bd7e5fa926..00000000000 --- a/spec/rubocop/cop/activerecord_serialize_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'spec_helper' -require 'rubocop' -require 'rubocop/rspec/support' -require_relative '../../../rubocop/cop/activerecord_serialize' - -describe RuboCop::Cop::ActiverecordSerialize do - include CopHelper - - subject(:cop) { described_class.new } - - context 'inside the app/models directory' do - it 'registers an offense when serialize is used' do - allow(cop).to receive(:in_model?).and_return(true) - - inspect_source(cop, 'serialize :foo') - - aggregate_failures do - expect(cop.offenses.size).to eq(1) - expect(cop.offenses.map(&:line)).to eq([1]) - end - end - end - - context 'outside the app/models directory' do - it 'does nothing' do - allow(cop).to receive(:in_model?).and_return(false) - - inspect_source(cop, 'serialize :foo') - - expect(cop.offenses).to be_empty - end - end -end -- cgit v1.2.3 From 9786e4fb0a35f65b48c0f13b66783fb8bb8f8bc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Trzci=C5=84ski?= Date: Thu, 6 Jul 2017 10:45:24 +0000 Subject: Revert "Merge branch 'winh-mr-widget-no-pipeline' into 'master'" This reverts merge request !12127 --- .../components/mr_widget_pipeline_spec.js | 66 ++++++---------------- 1 file changed, 18 insertions(+), 48 deletions(-) (limited to 'spec') 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 4b6f171c8d6..647b59520f8 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 @@ -76,28 +76,6 @@ describe('MRWidgetPipeline', () => { el = vm.$el; }); - afterEach(() => { - vm.$destroy(); - }); - - describe('without a pipeline', () => { - beforeEach(() => { - vm.mr = { pipeline: null }; - }); - - it('should render message with spinner', (done) => { - Vue.nextTick() - .then(() => { - expect(el.querySelector('.pipeline-id')).toBe(null); - expect(el.innerText.trim()).toBe('Waiting for pipeline...'); - expect(el.querySelectorAll('i.fa.fa-spinner.fa-spin').length).toBe(1); - done(); - }) - .then(done) - .catch(done.fail); - }); - }); - it('should render template elements correctly', () => { expect(el.classList.contains('mr-widget-heading')).toBeTruthy(); expect(el.querySelectorAll('.ci-status-icon.ci-status-icon-success').length).toEqual(1); @@ -115,47 +93,39 @@ describe('MRWidgetPipeline', () => { it('should list single stage', (done) => { pipeline.details.stages.splice(0, 1); - Vue.nextTick() - .then(() => { - expect(el.querySelectorAll('.stage-container button').length).toEqual(1); - expect(el.innerText).toContain('with stage'); - }) - .then(done) - .catch(done.fail); + Vue.nextTick(() => { + expect(el.querySelectorAll('.stage-container button').length).toEqual(1); + expect(el.innerText).toContain('with stage'); + done(); + }); }); it('should not have stages when there is no stage', (done) => { vm.mr.pipeline.details.stages = []; - Vue.nextTick() - .then(() => { - expect(el.querySelectorAll('.stage-container button').length).toEqual(0); - }) - .then(done) - .catch(done.fail); + Vue.nextTick(() => { + expect(el.querySelectorAll('.stage-container button').length).toEqual(0); + done(); + }); }); it('should not have coverage text when pipeline has no coverage info', (done) => { vm.mr.pipeline.coverage = null; - Vue.nextTick() - .then(() => { - expect(el.querySelector('.js-mr-coverage')).toEqual(null); - }) - .then(done) - .catch(done.fail); + Vue.nextTick(() => { + expect(el.querySelector('.js-mr-coverage')).toEqual(null); + done(); + }); }); it('should show CI error when there is a CI error', (done) => { vm.mr.ciStatus = null; - Vue.nextTick() - .then(() => { - expect(el.querySelectorAll('.js-ci-error').length).toEqual(1); - expect(el.innerText).toContain('Could not connect to the CI server'); - }) - .then(done) - .catch(done.fail); + Vue.nextTick(() => { + expect(el.querySelectorAll('.js-ci-error').length).toEqual(1); + expect(el.innerText).toContain('Could not connect to the CI server'); + done(); + }); }); }); }); -- cgit v1.2.3 From dbb313c26f79e5bebf197af8eba24411fced51bb Mon Sep 17 00:00:00 2001 From: Lin Jen-Shin Date: Thu, 6 Jul 2017 19:38:41 +0800 Subject: Encode certificate-authority-data in base64 --- spec/fixtures/config/kubeconfig.yml | 2 +- spec/models/project_services/kubernetes_service_spec.rb | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) (limited to 'spec') diff --git a/spec/fixtures/config/kubeconfig.yml b/spec/fixtures/config/kubeconfig.yml index 4fa52818fee..c4e8e573c32 100644 --- a/spec/fixtures/config/kubeconfig.yml +++ b/spec/fixtures/config/kubeconfig.yml @@ -4,7 +4,7 @@ clusters: - name: gitlab-deploy cluster: server: https://kube.domain.com - certificate-authority-data: PEM + certificate-authority-data: "UEVN\n" contexts: - name: gitlab-deploy context: diff --git a/spec/models/project_services/kubernetes_service_spec.rb b/spec/models/project_services/kubernetes_service_spec.rb index 7ec2ea5ba95..5ba523a478a 100644 --- a/spec/models/project_services/kubernetes_service_spec.rb +++ b/spec/models/project_services/kubernetes_service_spec.rb @@ -202,10 +202,19 @@ describe KubernetesService, models: true, caching: true do describe '#predefined_variables' do let(:kubeconfig) do - File.read(expand_fixture_path('config/kubeconfig.yml')) - .gsub('TOKEN', 'token') - .gsub('PEM', 'CA PEM DATA') - .gsub('NAMESPACE', namespace) + config = + YAML.load(File.read(expand_fixture_path('config/kubeconfig.yml'))) + + config.dig('users', 0, 'user')['token'] = + 'token' + + config.dig('clusters', 0, 'cluster')['certificate-authority-data'] = + Base64.encode64('CA PEM DATA') + + config.dig('contexts', 0, 'context')['namespace'] = + namespace + + YAML.dump(config) end before do -- cgit v1.2.3 From 03976c8f626863b7fa2a15211595774ab8f45360 Mon Sep 17 00:00:00 2001 From: Filipa Lacerda Date: Thu, 6 Jul 2017 14:31:24 +0100 Subject: Re-enable polling for environments --- spec/controllers/projects/environments_controller_spec.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'spec') diff --git a/spec/controllers/projects/environments_controller_spec.rb b/spec/controllers/projects/environments_controller_spec.rb index 9db8ff5bbaa..f88f50c3cc6 100644 --- a/spec/controllers/projects/environments_controller_spec.rb +++ b/spec/controllers/projects/environments_controller_spec.rb @@ -58,11 +58,9 @@ describe Projects::EnvironmentsController do expect(json_response['stopped_count']).to eq 1 end - it 'does not set the polling interval header' do - # TODO, this is a temporary fix, see follow up issue: - # https://gitlab.com/gitlab-org/gitlab-ee/issues/2677 + it 'sets the polling interval header' do expect(response).to have_http_status(:ok) - expect(response.headers['Poll-Interval']).to be_nil + expect(response.headers['Poll-Interval']).to eq("3000") end end -- cgit v1.2.3