summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-05-15 15:49:40 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-05-15 15:49:40 +0000
commitb04b1e12c5847f7d366e08af47115d985b73e185 (patch)
tree5077e33eedbf1e99b9ef9b87395f9acce844b234 /spec
parenta5b9fb9abc2b83304f45392642801b28f52b3f48 (diff)
downloadgitlab-ce-b04b1e12c5847f7d366e08af47115d985b73e185.tar.gz
Add latest changes from gitlab-org/gitlab@12-10-stable-ee
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/projects/pages_domains_controller_spec.rb16
-rw-r--r--spec/features/projects/pages_spec.rb11
-rw-r--r--spec/lib/gitlab/graphql/pagination/externally_paginated_array_connection_spec.rb14
-rw-r--r--spec/uploaders/file_uploader_spec.rb64
-rw-r--r--spec/views/projects/pages_domains/show.html.haml_spec.rb2
5 files changed, 73 insertions, 34 deletions
diff --git a/spec/controllers/projects/pages_domains_controller_spec.rb b/spec/controllers/projects/pages_domains_controller_spec.rb
index c78c5fe2886..40a6f77f0d6 100644
--- a/spec/controllers/projects/pages_domains_controller_spec.rb
+++ b/spec/controllers/projects/pages_domains_controller_spec.rb
@@ -148,16 +148,10 @@ describe Projects::PagesDomainsController do
describe 'POST verify' do
let(:params) { request_params.merge(id: pages_domain.domain) }
- def stub_service
- service = double(:service)
-
- expect(VerifyPagesDomainService).to receive(:new) { service }
-
- service
- end
-
it 'handles verification success' do
- expect(stub_service).to receive(:execute).and_return(status: :success)
+ expect_next_instance_of(VerifyPagesDomainService, pages_domain) do |service|
+ expect(service).to receive(:execute).and_return(status: :success)
+ end
post :verify, params: params
@@ -166,7 +160,9 @@ describe Projects::PagesDomainsController do
end
it 'handles verification failure' do
- expect(stub_service).to receive(:execute).and_return(status: :failed)
+ expect_next_instance_of(VerifyPagesDomainService, pages_domain) do |service|
+ expect(service).to receive(:execute).and_return(status: :failed)
+ end
post :verify, params: params
diff --git a/spec/features/projects/pages_spec.rb b/spec/features/projects/pages_spec.rb
index f4f70e7efbc..faa2b3c9424 100644
--- a/spec/features/projects/pages_spec.rb
+++ b/spec/features/projects/pages_spec.rb
@@ -158,6 +158,17 @@ shared_examples 'pages settings editing' do
expect(page).to have_content('my.test.domain.com')
end
+ it 'shows validation error if domain is duplicated' do
+ project.pages_domains.create!(domain: 'my.test.domain.com')
+
+ visit new_project_pages_domain_path(project)
+
+ fill_in 'Domain', with: 'my.test.domain.com'
+ click_button 'Create New Domain'
+
+ expect(page).to have_content('Domain has already been taken')
+ end
+
describe 'with dns verification enabled' do
before do
stub_application_setting(pages_domain_verification_enabled: true)
diff --git a/spec/lib/gitlab/graphql/pagination/externally_paginated_array_connection_spec.rb b/spec/lib/gitlab/graphql/pagination/externally_paginated_array_connection_spec.rb
index 85a5b1dacc7..11cf14523c2 100644
--- a/spec/lib/gitlab/graphql/pagination/externally_paginated_array_connection_spec.rb
+++ b/spec/lib/gitlab/graphql/pagination/externally_paginated_array_connection_spec.rb
@@ -19,6 +19,20 @@ describe Gitlab::Graphql::Pagination::ExternallyPaginatedArrayConnection do
it_behaves_like 'connection with paged nodes' do
let(:paged_nodes_size) { values.size }
end
+
+ context 'when after or before is specified, they are ignored' do
+ # after and before are not used to filter the array, as they
+ # were already used to directly fetch the external array
+ it_behaves_like 'connection with paged nodes' do
+ let(:arguments) { { after: next_cursor } }
+ let(:paged_nodes_size) { values.size }
+ end
+
+ it_behaves_like 'connection with paged nodes' do
+ let(:arguments) { { before: prev_cursor } }
+ let(:paged_nodes_size) { values.size }
+ end
+ end
end
describe '#start_cursor' do
diff --git a/spec/uploaders/file_uploader_spec.rb b/spec/uploaders/file_uploader_spec.rb
index 5fd64da6328..629c84778b9 100644
--- a/spec/uploaders/file_uploader_spec.rb
+++ b/spec/uploaders/file_uploader_spec.rb
@@ -145,39 +145,57 @@ describe FileUploader do
end
describe '.extract_dynamic_path' do
- context 'with a 32-byte hexadecimal secret in the path' do
- let(:secret) { SecureRandom.hex }
- let(:path) { "export/4b227777d4dd1fc61c6f884f48641d02b4d121d3fd328cb08b5531fcacdabf8a/test/uploads/#{secret}/dummy.txt" }
+ shared_examples 'a valid secret' do |root_path|
+ context 'with a 32-byte hexadecimal secret' do
+ let(:secret) { SecureRandom.hex }
+ let(:path) { File.join(*[root_path, secret, 'dummy.txt'].compact) }
- it 'extracts the secret' do
- expect(described_class.extract_dynamic_path(path)[:secret]).to eq(secret)
- end
+ it 'extracts the secret' do
+ expect(described_class.extract_dynamic_path(path)[:secret]).to eq(secret)
+ end
- it 'extracts the identifier' do
- expect(described_class.extract_dynamic_path(path)[:identifier]).to eq('dummy.txt')
+ it 'extracts the identifier' do
+ expect(described_class.extract_dynamic_path(path)[:identifier]).to eq('dummy.txt')
+ end
end
- end
- context 'with a 10-byte hexadecimal secret in the path' do
- let(:secret) { SecureRandom.hex(10) }
- let(:path) { "export/4b227777d4dd1fc61c6f884f48641d02b4d121d3fd328cb08b5531fcacdabf8a/test/uploads/#{secret}/dummy.txt" }
+ context 'with a 10-byte hexadecimal secret' do
+ let(:secret) { SecureRandom.hex[0, 10] }
+ let(:path) { File.join(*[root_path, secret, 'dummy.txt'].compact) }
+
+ it 'extracts the secret' do
+ expect(described_class.extract_dynamic_path(path)[:secret]).to eq(secret)
+ end
- it 'extracts the secret' do
- expect(described_class.extract_dynamic_path(path)[:secret]).to eq(secret)
+ it 'extracts the identifier' do
+ expect(described_class.extract_dynamic_path(path)[:identifier]).to eq('dummy.txt')
+ end
end
- it 'extracts the identifier' do
- expect(described_class.extract_dynamic_path(path)[:identifier]).to eq('dummy.txt')
+ context 'with an invalid secret' do
+ let(:secret) { 'foo' }
+ let(:path) { File.join(*[root_path, secret, 'dummy.txt'].compact) }
+
+ it 'returns nil' do
+ expect(described_class.extract_dynamic_path(path)).to be_nil
+ end
end
end
- context 'with an invalid secret in the path' do
- let(:secret) { 'foo' }
- let(:path) { "export/4b227777d4dd1fc61c6f884f48641d02b4d121d3fd328cb08b5531fcacdabf8a/test/uploads/#{secret}/dummy.txt" }
+ context 'with an absolute path without a slash in the beginning' do
+ it_behaves_like 'a valid secret', 'export/4b227777d4dd1fc61c6f884f48641d02b4d121d3fd328cb08b5531fcacdabf8a/test/uploads'
+ end
- it 'returns nil' do
- expect(described_class.extract_dynamic_path(path)).to be_nil
- end
+ context 'with an absolute path with a slash in the beginning' do
+ it_behaves_like 'a valid secret', '/export/4b227777d4dd1fc61c6f884f48641d02b4d121d3fd328cb08b5531fcacdabf8a/test/uploads'
+ end
+
+ context 'with an relative path without a slash in the beginning' do
+ it_behaves_like 'a valid secret', nil
+ end
+
+ context 'with an relative path with a slash in the beginning' do
+ it_behaves_like 'a valid secret', '/'
end
end
@@ -202,7 +220,7 @@ describe FileUploader do
end
context "10-byte hexadecimal" do
- let(:secret) { SecureRandom.hex(10) }
+ let(:secret) { SecureRandom.hex[0, 10] }
it "returns the secret" do
expect(uploader.secret).to eq(secret)
diff --git a/spec/views/projects/pages_domains/show.html.haml_spec.rb b/spec/views/projects/pages_domains/show.html.haml_spec.rb
index 7d502e74d10..2de82a63560 100644
--- a/spec/views/projects/pages_domains/show.html.haml_spec.rb
+++ b/spec/views/projects/pages_domains/show.html.haml_spec.rb
@@ -7,7 +7,7 @@ describe 'projects/pages_domains/show' do
before do
assign(:project, project)
- assign(:domain, domain.present)
+ allow(view).to receive(:domain_presenter).and_return(domain.present)
stub_pages_setting(external_https: true)
end