diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 18:25:58 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 18:25:58 +0000 |
commit | a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch) | |
tree | fb69158581673816a8cd895f9d352dcb3c678b1e /spec/presenters | |
parent | d16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff) | |
download | gitlab-ce-a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4.tar.gz |
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'spec/presenters')
-rw-r--r-- | spec/presenters/clusters/cluster_presenter_spec.rb | 4 | ||||
-rw-r--r-- | spec/presenters/merge_request_presenter_spec.rb | 2 | ||||
-rw-r--r-- | spec/presenters/packages/detail/package_presenter_spec.rb | 3 | ||||
-rw-r--r-- | spec/presenters/packages/pypi/package_presenter_spec.rb | 55 | ||||
-rw-r--r-- | spec/presenters/project_presenter_spec.rb | 2 | ||||
-rw-r--r-- | spec/presenters/release_presenter_spec.rb | 40 | ||||
-rw-r--r-- | spec/presenters/service_hook_presenter_spec.rb | 8 | ||||
-rw-r--r-- | spec/presenters/web_hook_log_presenter_spec.rb | 12 |
8 files changed, 47 insertions, 79 deletions
diff --git a/spec/presenters/clusters/cluster_presenter_spec.rb b/spec/presenters/clusters/cluster_presenter_spec.rb index 2e8364b2987..c8da8a54f16 100644 --- a/spec/presenters/clusters/cluster_presenter_spec.rb +++ b/spec/presenters/clusters/cluster_presenter_spec.rb @@ -304,9 +304,9 @@ RSpec.describe Clusters::ClusterPresenter do expect(presenter.gitlab_managed_apps_logs_path).to eq k8s_project_logs_path(project, cluster_id: cluster.id, format: :json) end - context 'cluster has elastic stack application installed' do + context 'cluster has elastic stack integration enabled' do before do - create(:clusters_applications_elastic_stack, :installed, cluster: cluster) + create(:clusters_integrations_elastic_stack, cluster: cluster) end it 'returns path to logs' do diff --git a/spec/presenters/merge_request_presenter_spec.rb b/spec/presenters/merge_request_presenter_spec.rb index 76b77ee0de2..c64f9e8465f 100644 --- a/spec/presenters/merge_request_presenter_spec.rb +++ b/spec/presenters/merge_request_presenter_spec.rb @@ -12,7 +12,7 @@ RSpec.describe MergeRequestPresenter do context 'when no head pipeline' do it 'return status using CiService' do - ci_service = double(MockCiService) + ci_service = double(Integrations::MockCi) ci_status = double allow(resource.source_project) diff --git a/spec/presenters/packages/detail/package_presenter_spec.rb b/spec/presenters/packages/detail/package_presenter_spec.rb index d8f1c98e762..3009f2bd56d 100644 --- a/spec/presenters/packages/detail/package_presenter_spec.rb +++ b/spec/presenters/packages/detail/package_presenter_spec.rb @@ -19,7 +19,8 @@ RSpec.describe ::Packages::Detail::PackagePresenter do size: file.size, file_md5: file.file_md5, file_sha1: file.file_sha1, - file_sha256: file.file_sha256 + file_sha256: file.file_sha256, + id: file.id } end end diff --git a/spec/presenters/packages/pypi/package_presenter_spec.rb b/spec/presenters/packages/pypi/package_presenter_spec.rb index e4d234a4688..25aa5c31034 100644 --- a/spec/presenters/packages/pypi/package_presenter_spec.rb +++ b/spec/presenters/packages/pypi/package_presenter_spec.rb @@ -5,45 +5,52 @@ require 'spec_helper' RSpec.describe ::Packages::Pypi::PackagePresenter do using RSpec::Parameterized::TableSyntax - let_it_be(:project) { create(:project) } + let_it_be(:group) { create(:group) } + let_it_be(:project) { create(:project, group: group) } let_it_be(:package_name) { 'sample-project' } let_it_be(:package1) { create(:pypi_package, project: project, name: package_name, version: '1.0.0') } let_it_be(:package2) { create(:pypi_package, project: project, name: package_name, version: '2.0.0') } let(:packages) { [package1, package2] } - let(:presenter) { described_class.new(packages, project) } - describe '#body' do - subject { presenter.body} + let(:file) { package.package_files.first } + let(:filename) { file.file_name } - shared_examples_for "pypi package presenter" do - let(:file) { package.package_files.first } - let(:filename) { file.file_name } - let(:expected_file) { "<a href=\"http://localhost/api/v4/projects/#{project.id}/packages/pypi/files/#{file.file_sha256}/#{filename}#sha256=#{file.file_sha256}\" data-requires-python=\"#{expected_python_version}\">#{filename}</a><br>" } + subject(:presenter) { described_class.new(packages, project_or_group).body} - before do - package.pypi_metadatum.required_python = python_version + describe '#body' do + shared_examples_for "pypi package presenter" do + where(:version, :expected_version, :with_package1) do + '>=2.7' | '>=2.7' | true + '"><script>alert(1)</script>' | '"><script>alert(1)</script>' | true + '>=2.7, !=3.0' | '>=2.7, !=3.0' | false end - it { is_expected.to include expected_file } - end + with_them do + let(:python_version) { version } + let(:expected_python_version) { expected_version } + let(:package) { with_package1 ? package1 : package2 } - it_behaves_like "pypi package presenter" do - let(:python_version) { '>=2.7' } - let(:expected_python_version) { '>=2.7' } - let(:package) { package1 } + before do + package.pypi_metadatum.required_python = python_version + end + + it { is_expected.to include expected_file } + end end - it_behaves_like "pypi package presenter" do - let(:python_version) { '"><script>alert(1)</script>' } - let(:expected_python_version) { '"><script>alert(1)</script>' } - let(:package) { package1 } + context 'for project' do + let(:project_or_group) { project } + let(:expected_file) { "<a href=\"http://localhost/api/v4/projects/#{project.id}/packages/pypi/files/#{file.file_sha256}/#{filename}#sha256=#{file.file_sha256}\" data-requires-python=\"#{expected_python_version}\">#{filename}</a><br>" } + + it_behaves_like 'pypi package presenter' end - it_behaves_like "pypi package presenter" do - let(:python_version) { '>=2.7, !=3.0' } - let(:expected_python_version) { '>=2.7, !=3.0' } - let(:package) { package2 } + context 'for group' do + let(:project_or_group) { group } + let(:expected_file) { "<a href=\"http://localhost/api/v4/groups/#{group.id}/-/packages/pypi/files/#{file.file_sha256}/#{filename}#sha256=#{file.file_sha256}\" data-requires-python=\"#{expected_python_version}\">#{filename}</a><br>" } + + it_behaves_like 'pypi package presenter' end end end diff --git a/spec/presenters/project_presenter_spec.rb b/spec/presenters/project_presenter_spec.rb index c834e183e5e..fd75c8411d5 100644 --- a/spec/presenters/project_presenter_spec.rb +++ b/spec/presenters/project_presenter_spec.rb @@ -585,7 +585,7 @@ RSpec.describe ProjectPresenter do "can_push_code" => "true", "original_branch" => "master", "path" => "/#{project.full_path}/-/create/master", - "project_path" => project.path, + "project_path" => project.full_path, "target_branch" => "master" } ) diff --git a/spec/presenters/release_presenter_spec.rb b/spec/presenters/release_presenter_spec.rb index 97c05a1b7a2..b2e7b684644 100644 --- a/spec/presenters/release_presenter_spec.rb +++ b/spec/presenters/release_presenter_spec.rb @@ -77,14 +77,6 @@ RSpec.describe ReleasePresenter do it 'returns merge requests url with state=open' do is_expected.to eq(project_merge_requests_url(project, opened_url_params)) end - - context 'when release_mr_issue_urls feature flag is disabled' do - before do - stub_feature_flags(release_mr_issue_urls: false) - end - - it { is_expected.to be_nil } - end end describe '#merged_merge_requests_url' do @@ -93,14 +85,6 @@ RSpec.describe ReleasePresenter do it 'returns merge requests url with state=merged' do is_expected.to eq(project_merge_requests_url(project, merged_url_params)) end - - context 'when release_mr_issue_urls feature flag is disabled' do - before do - stub_feature_flags(release_mr_issue_urls: false) - end - - it { is_expected.to be_nil } - end end describe '#closed_merge_requests_url' do @@ -109,14 +93,6 @@ RSpec.describe ReleasePresenter do it 'returns merge requests url with state=closed' do is_expected.to eq(project_merge_requests_url(project, closed_url_params)) end - - context 'when release_mr_issue_urls feature flag is disabled' do - before do - stub_feature_flags(release_mr_issue_urls: false) - end - - it { is_expected.to be_nil } - end end describe '#opened_issues_url' do @@ -125,14 +101,6 @@ RSpec.describe ReleasePresenter do it 'returns issues url with state=open' do is_expected.to eq(project_issues_url(project, opened_url_params)) end - - context 'when release_mr_issue_urls feature flag is disabled' do - before do - stub_feature_flags(release_mr_issue_urls: false) - end - - it { is_expected.to be_nil } - end end describe '#closed_issues_url' do @@ -141,14 +109,6 @@ RSpec.describe ReleasePresenter do it 'returns issues url with state=closed' do is_expected.to eq(project_issues_url(project, closed_url_params)) end - - context 'when release_mr_issue_urls feature flag is disabled' do - before do - stub_feature_flags(release_mr_issue_urls: false) - end - - it { is_expected.to be_nil } - end end describe '#edit_url' do diff --git a/spec/presenters/service_hook_presenter_spec.rb b/spec/presenters/service_hook_presenter_spec.rb index bc6e505d9e1..7d7b71f324a 100644 --- a/spec/presenters/service_hook_presenter_spec.rb +++ b/spec/presenters/service_hook_presenter_spec.rb @@ -4,15 +4,15 @@ require 'spec_helper' RSpec.describe ServiceHookPresenter do let(:web_hook_log) { create(:web_hook_log, web_hook: service_hook) } - let(:service_hook) { create(:service_hook, integration: service) } - let(:service) { create(:drone_ci_service, project: project) } + let(:service_hook) { create(:service_hook, integration: integration) } + let(:integration) { create(:drone_ci_integration, project: project) } let(:project) { create(:project) } describe '#logs_details_path' do subject { service_hook.present.logs_details_path(web_hook_log) } let(:expected_path) do - "/#{project.namespace.path}/#{project.name}/-/services/#{service.to_param}/hook_logs/#{web_hook_log.id}" + "/#{project.namespace.path}/#{project.name}/-/services/#{integration.to_param}/hook_logs/#{web_hook_log.id}" end it { is_expected.to eq(expected_path) } @@ -22,7 +22,7 @@ RSpec.describe ServiceHookPresenter do subject { service_hook.present.logs_retry_path(web_hook_log) } let(:expected_path) do - "/#{project.namespace.path}/#{project.name}/-/services/#{service.to_param}/hook_logs/#{web_hook_log.id}/retry" + "/#{project.namespace.path}/#{project.name}/-/services/#{integration.to_param}/hook_logs/#{web_hook_log.id}/retry" end it { is_expected.to eq(expected_path) } diff --git a/spec/presenters/web_hook_log_presenter_spec.rb b/spec/presenters/web_hook_log_presenter_spec.rb index ec930be266d..aa9d1d8f545 100644 --- a/spec/presenters/web_hook_log_presenter_spec.rb +++ b/spec/presenters/web_hook_log_presenter_spec.rb @@ -18,10 +18,10 @@ RSpec.describe WebHookLogPresenter do end context 'service hook' do - let(:web_hook) { create(:service_hook, integration: service) } - let(:service) { create(:drone_ci_service, project: project) } + let(:web_hook) { create(:service_hook, integration: integration) } + let(:integration) { create(:drone_ci_integration, project: project) } - it { is_expected.to eq(project_service_hook_log_path(project, service, web_hook_log)) } + it { is_expected.to eq(project_service_hook_log_path(project, integration, web_hook_log)) } end end @@ -38,10 +38,10 @@ RSpec.describe WebHookLogPresenter do end context 'service hook' do - let(:web_hook) { create(:service_hook, integration: service) } - let(:service) { create(:drone_ci_service, project: project) } + let(:web_hook) { create(:service_hook, integration: integration) } + let(:integration) { create(:drone_ci_integration, project: project) } - it { is_expected.to eq(retry_project_service_hook_log_path(project, service, web_hook_log)) } + it { is_expected.to eq(retry_project_service_hook_log_path(project, integration, web_hook_log)) } end end end |