Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/helpers/projects')
-rw-r--r--spec/helpers/projects/google_cloud/cloudsql_helper_spec.rb25
-rw-r--r--spec/helpers/projects/pages_helper_spec.rb68
-rw-r--r--spec/helpers/projects/pipeline_helper_spec.rb8
3 files changed, 97 insertions, 4 deletions
diff --git a/spec/helpers/projects/google_cloud/cloudsql_helper_spec.rb b/spec/helpers/projects/google_cloud/cloudsql_helper_spec.rb
new file mode 100644
index 00000000000..6b82518592f
--- /dev/null
+++ b/spec/helpers/projects/google_cloud/cloudsql_helper_spec.rb
@@ -0,0 +1,25 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Projects::GoogleCloud::CloudsqlHelper do
+ describe '#TIERS' do
+ it 'is an array' do
+ expect(described_class::TIERS).to be_an_instance_of(Array)
+ end
+ end
+
+ describe '#VERSIONS' do
+ it 'returns versions for :postgres' do
+ expect(described_class::VERSIONS[:postgres]).to be_an_instance_of(Array)
+ end
+
+ it 'returns versions for :mysql' do
+ expect(described_class::VERSIONS[:mysql]).to be_an_instance_of(Array)
+ end
+
+ it 'returns versions for :sqlserver' do
+ expect(described_class::VERSIONS[:sqlserver]).to be_an_instance_of(Array)
+ end
+ end
+end
diff --git a/spec/helpers/projects/pages_helper_spec.rb b/spec/helpers/projects/pages_helper_spec.rb
new file mode 100644
index 00000000000..4a4cebc9d70
--- /dev/null
+++ b/spec/helpers/projects/pages_helper_spec.rb
@@ -0,0 +1,68 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+RSpec.describe Projects::PagesHelper do
+ let(:user) { create(:user) }
+ let(:project) { create(:project) }
+
+ before do
+ stub_config(pages: {
+ access_control: true,
+ external_http: true,
+ external_https: true,
+ host: "new.domain.com"
+ })
+ end
+
+ context 'when the user have permission' do
+ before do
+ project.add_maintainer(user)
+ end
+
+ context 'on custom domain' do
+ using RSpec::Parameterized::TableSyntax
+
+ where(:external_http, :external_https, :can_create) do
+ false | false | false
+ false | true | true
+ true | false | true
+ true | true | true
+ end
+
+ with_them do
+ it do
+ stub_config(pages: { external_http: external_http, external_https: external_https })
+
+ expect(can_create_pages_custom_domains?(user, project)).to be can_create
+ end
+ end
+ end
+
+ context 'on domain limit' do
+ it 'can create new domains when the limit is 0' do
+ Gitlab::CurrentSettings.update!(max_pages_custom_domains_per_project: 0)
+
+ expect(can_create_pages_custom_domains?(user, project)).to be true
+ end
+
+ it 'validates custom domain creation is only allowed upto max value' do
+ Gitlab::CurrentSettings.update!(max_pages_custom_domains_per_project: 1)
+
+ expect(can_create_pages_custom_domains?(user, project)).to be true
+ create(:pages_domain, project: project)
+ expect(can_create_pages_custom_domains?(user, project)).to be false
+ end
+ end
+ end
+
+ context 'when the user does not have permission' do
+ before do
+ project.add_guest(user)
+ end
+
+ it 'validates user cannot create domain' do
+ expect(can_create_pages_custom_domains?(user, project)).to be false
+ end
+ end
+end
diff --git a/spec/helpers/projects/pipeline_helper_spec.rb b/spec/helpers/projects/pipeline_helper_spec.rb
index 8ce4e9f5293..a70544ace1a 100644
--- a/spec/helpers/projects/pipeline_helper_spec.rb
+++ b/spec/helpers/projects/pipeline_helper_spec.rb
@@ -8,7 +8,7 @@ RSpec.describe Projects::PipelineHelper do
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project, :repository) }
let_it_be(:raw_pipeline) { create(:ci_pipeline, project: project, ref: 'master', sha: project.commit.id) }
- let_it_be(:pipeline) { Ci::PipelinePresenter.new(raw_pipeline, current_user: user)}
+ let_it_be(:pipeline) { Ci::PipelinePresenter.new(raw_pipeline, current_user: user) }
describe '#js_pipeline_tabs_data' do
before do
@@ -19,7 +19,6 @@ RSpec.describe Projects::PipelineHelper do
it 'returns pipeline tabs data' do
expect(pipeline_tabs_data).to include({
- can_generate_codequality_reports: pipeline.can_generate_codequality_reports?.to_json,
failed_jobs_count: pipeline.failed_builds.count,
failed_jobs_summary: prepare_failed_jobs_summary_data(pipeline.failed_builds),
full_path: project.full_path,
@@ -31,9 +30,10 @@ RSpec.describe Projects::PipelineHelper do
summary_endpoint: summary_project_pipeline_tests_path(project, pipeline, format: :json),
suite_endpoint: project_pipeline_test_path(project, pipeline, suite_name: 'suite', format: :json),
blob_path: project_blob_path(project, pipeline.sha),
- has_test_report: pipeline.has_reports?(Ci::JobArtifact.test_reports),
+ has_test_report: pipeline.complete_and_has_reports?(Ci::JobArtifact.of_report_type(:test)),
empty_state_image_path: match_asset_path('illustrations/empty-state/empty-test-cases-lg.svg'),
- artifacts_expired_image_path: match_asset_path('illustrations/pipeline.svg')
+ artifacts_expired_image_path: match_asset_path('illustrations/pipeline.svg'),
+ tests_count: pipeline.test_report_summary.total[:count]
})
end
end