summaryrefslogtreecommitdiff
path: root/spec/presenters
diff options
context:
space:
mode:
Diffstat (limited to 'spec/presenters')
-rw-r--r--spec/presenters/ci/bridge_presenter_spec.rb2
-rw-r--r--spec/presenters/ci/build_presenter_spec.rb4
-rw-r--r--spec/presenters/ci/build_runner_presenter_spec.rb2
-rw-r--r--spec/presenters/ci/group_variable_presenter_spec.rb2
-rw-r--r--spec/presenters/ci/pipeline_presenter_spec.rb2
-rw-r--r--spec/presenters/ci/trigger_presenter_spec.rb2
-rw-r--r--spec/presenters/ci/variable_presenter_spec.rb2
-rw-r--r--spec/presenters/clusters/cluster_presenter_spec.rb2
-rw-r--r--spec/presenters/commit_status_presenter_spec.rb2
-rw-r--r--spec/presenters/conversational_development_index/metric_presenter_spec.rb2
-rw-r--r--spec/presenters/group_clusterable_presenter_spec.rb6
-rw-r--r--spec/presenters/group_member_presenter_spec.rb2
-rw-r--r--spec/presenters/instance_clusterable_presenter_spec.rb37
-rw-r--r--spec/presenters/merge_request_presenter_spec.rb2
-rw-r--r--spec/presenters/project_clusterable_presenter_spec.rb6
-rw-r--r--spec/presenters/project_member_presenter_spec.rb2
-rw-r--r--spec/presenters/project_presenter_spec.rb62
-rw-r--r--spec/presenters/projects/settings/deploy_keys_presenter_spec.rb2
-rw-r--r--spec/presenters/release_presenter_spec.rb101
19 files changed, 226 insertions, 16 deletions
diff --git a/spec/presenters/ci/bridge_presenter_spec.rb b/spec/presenters/ci/bridge_presenter_spec.rb
index 986818a7b9e..1c2eeced20c 100644
--- a/spec/presenters/ci/bridge_presenter_spec.rb
+++ b/spec/presenters/ci/bridge_presenter_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
describe Ci::BridgePresenter do
diff --git a/spec/presenters/ci/build_presenter_spec.rb b/spec/presenters/ci/build_presenter_spec.rb
index e202f7a9b5f..b6c47f40ceb 100644
--- a/spec/presenters/ci/build_presenter_spec.rb
+++ b/spec/presenters/ci/build_presenter_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
describe Ci::BuildPresenter do
@@ -267,7 +269,7 @@ describe Ci::BuildPresenter do
let(:build) { create(:ci_build, :failed, :script_failure) }
context 'when is a script or missing dependency failure' do
- let(:failure_reasons) { %w(script_failure missing_dependency_failure archived_failure) }
+ let(:failure_reasons) { %w(script_failure missing_dependency_failure archived_failure scheduler_failure data_integrity_failure) }
it 'returns false' do
failure_reasons.each do |failure_reason|
diff --git a/spec/presenters/ci/build_runner_presenter_spec.rb b/spec/presenters/ci/build_runner_presenter_spec.rb
index fa8791f2257..017e94d04f1 100644
--- a/spec/presenters/ci/build_runner_presenter_spec.rb
+++ b/spec/presenters/ci/build_runner_presenter_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
describe Ci::BuildRunnerPresenter do
diff --git a/spec/presenters/ci/group_variable_presenter_spec.rb b/spec/presenters/ci/group_variable_presenter_spec.rb
index cb58a757564..3b81a425f5b 100644
--- a/spec/presenters/ci/group_variable_presenter_spec.rb
+++ b/spec/presenters/ci/group_variable_presenter_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
describe Ci::GroupVariablePresenter do
diff --git a/spec/presenters/ci/pipeline_presenter_spec.rb b/spec/presenters/ci/pipeline_presenter_spec.rb
index 8cfcd9befb3..eca5d3e05fe 100644
--- a/spec/presenters/ci/pipeline_presenter_spec.rb
+++ b/spec/presenters/ci/pipeline_presenter_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
describe Ci::PipelinePresenter do
diff --git a/spec/presenters/ci/trigger_presenter_spec.rb b/spec/presenters/ci/trigger_presenter_spec.rb
index 231b539c188..ac3967f4f77 100644
--- a/spec/presenters/ci/trigger_presenter_spec.rb
+++ b/spec/presenters/ci/trigger_presenter_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
describe Ci::TriggerPresenter do
diff --git a/spec/presenters/ci/variable_presenter_spec.rb b/spec/presenters/ci/variable_presenter_spec.rb
index e3ce88372ea..70cf2f539b6 100644
--- a/spec/presenters/ci/variable_presenter_spec.rb
+++ b/spec/presenters/ci/variable_presenter_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
describe Ci::VariablePresenter do
diff --git a/spec/presenters/clusters/cluster_presenter_spec.rb b/spec/presenters/clusters/cluster_presenter_spec.rb
index 6b988e2645b..8bc5374f2db 100644
--- a/spec/presenters/clusters/cluster_presenter_spec.rb
+++ b/spec/presenters/clusters/cluster_presenter_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
describe Clusters::ClusterPresenter do
diff --git a/spec/presenters/commit_status_presenter_spec.rb b/spec/presenters/commit_status_presenter_spec.rb
index 2b7742ddbb8..b02497d4c11 100644
--- a/spec/presenters/commit_status_presenter_spec.rb
+++ b/spec/presenters/commit_status_presenter_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
describe CommitStatusPresenter do
diff --git a/spec/presenters/conversational_development_index/metric_presenter_spec.rb b/spec/presenters/conversational_development_index/metric_presenter_spec.rb
index b8b68a676e6..ac18d5203e5 100644
--- a/spec/presenters/conversational_development_index/metric_presenter_spec.rb
+++ b/spec/presenters/conversational_development_index/metric_presenter_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
describe ConversationalDevelopmentIndex::MetricPresenter do
diff --git a/spec/presenters/group_clusterable_presenter_spec.rb b/spec/presenters/group_clusterable_presenter_spec.rb
index fa77273f6aa..11a8decc9cc 100644
--- a/spec/presenters/group_clusterable_presenter_spec.rb
+++ b/spec/presenters/group_clusterable_presenter_spec.rb
@@ -43,6 +43,12 @@ describe GroupClusterablePresenter do
it { is_expected.to eq(new_group_cluster_path(group)) }
end
+ describe '#authorize_aws_role_path' do
+ subject { presenter.authorize_aws_role_path }
+
+ it { is_expected.to eq(authorize_aws_role_group_clusters_path(group)) }
+ end
+
describe '#create_user_clusters_path' do
subject { presenter.create_user_clusters_path }
diff --git a/spec/presenters/group_member_presenter_spec.rb b/spec/presenters/group_member_presenter_spec.rb
index bb66523a83d..382b1881ab7 100644
--- a/spec/presenters/group_member_presenter_spec.rb
+++ b/spec/presenters/group_member_presenter_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
describe GroupMemberPresenter do
diff --git a/spec/presenters/instance_clusterable_presenter_spec.rb b/spec/presenters/instance_clusterable_presenter_spec.rb
new file mode 100644
index 00000000000..9f1268379f5
--- /dev/null
+++ b/spec/presenters/instance_clusterable_presenter_spec.rb
@@ -0,0 +1,37 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe InstanceClusterablePresenter do
+ include Gitlab::Routing.url_helpers
+
+ let(:presenter) { described_class.new(instance) }
+ let(:cluster) { create(:cluster, :provided_by_gcp, :instance) }
+ let(:instance) { cluster.instance }
+
+ describe '#create_aws_clusters_path' do
+ subject { described_class.new(instance).create_aws_clusters_path }
+
+ it { is_expected.to eq(create_aws_admin_clusters_path) }
+ end
+
+ describe '#authorize_aws_role_path' do
+ subject { described_class.new(instance).authorize_aws_role_path }
+
+ it { is_expected.to eq(authorize_aws_role_admin_clusters_path) }
+ end
+
+ describe '#revoke_aws_role_path' do
+ subject { described_class.new(instance).revoke_aws_role_path }
+
+ it { is_expected.to eq(revoke_aws_role_admin_clusters_path) }
+ end
+
+ describe '#aws_api_proxy_path' do
+ let(:resource) { 'resource' }
+
+ subject { described_class.new(instance).aws_api_proxy_path(resource) }
+
+ it { is_expected.to eq(aws_proxy_admin_clusters_path(resource: resource)) }
+ end
+end
diff --git a/spec/presenters/merge_request_presenter_spec.rb b/spec/presenters/merge_request_presenter_spec.rb
index 6408b0bd748..ce437090d43 100644
--- a/spec/presenters/merge_request_presenter_spec.rb
+++ b/spec/presenters/merge_request_presenter_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
describe MergeRequestPresenter do
diff --git a/spec/presenters/project_clusterable_presenter_spec.rb b/spec/presenters/project_clusterable_presenter_spec.rb
index 6786a84243f..441c2a50fea 100644
--- a/spec/presenters/project_clusterable_presenter_spec.rb
+++ b/spec/presenters/project_clusterable_presenter_spec.rb
@@ -43,6 +43,12 @@ describe ProjectClusterablePresenter do
it { is_expected.to eq(new_project_cluster_path(project)) }
end
+ describe '#authorize_aws_role_path' do
+ subject { presenter.authorize_aws_role_path }
+
+ it { is_expected.to eq(authorize_aws_role_project_clusters_path(project)) }
+ end
+
describe '#create_user_clusters_path' do
subject { presenter.create_user_clusters_path }
diff --git a/spec/presenters/project_member_presenter_spec.rb b/spec/presenters/project_member_presenter_spec.rb
index 73ef113a1c5..743c89fc7c2 100644
--- a/spec/presenters/project_member_presenter_spec.rb
+++ b/spec/presenters/project_member_presenter_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
describe ProjectMemberPresenter do
diff --git a/spec/presenters/project_presenter_spec.rb b/spec/presenters/project_presenter_spec.rb
index 2a00548c2c3..ce095d2225f 100644
--- a/spec/presenters/project_presenter_spec.rb
+++ b/spec/presenters/project_presenter_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
describe ProjectPresenter do
@@ -310,8 +312,8 @@ describe ProjectPresenter do
project.add_developer(user)
allow(project.repository).to receive(:license_blob).and_return(nil)
- expect(presenter.license_anchor_data).to have_attributes(is_link: true,
- label: a_string_including('Add license'),
+ expect(presenter.license_anchor_data).to have_attributes(is_link: false,
+ label: a_string_including('Add LICENSE'),
link: presenter.add_license_path)
end
end
@@ -320,7 +322,7 @@ describe ProjectPresenter do
it 'returns anchor data' do
allow(project.repository).to receive(:license_blob).and_return(double(name: 'foo'))
- expect(presenter.license_anchor_data).to have_attributes(is_link: true,
+ expect(presenter.license_anchor_data).to have_attributes(is_link: false,
label: a_string_including(presenter.license_short_name),
link: presenter.license_path)
end
@@ -418,6 +420,7 @@ describe ProjectPresenter do
it 'orders the items correctly' do
allow(project.repository).to receive(:readme).and_return(double(name: 'readme'))
+ allow(project.repository).to receive(:license_blob).and_return(nil)
allow(project.repository).to receive(:changelog).and_return(nil)
allow(project.repository).to receive(:contribution_guide).and_return(double(name: 'foo'))
allow(presenter).to receive(:filename_path).and_return('fake/path')
@@ -431,25 +434,54 @@ describe ProjectPresenter do
end
end
- describe '#empty_repo_statistics_buttons' do
- let(:project) { create(:project, :repository) }
+ describe '#repo_statistics_buttons' do
let(:presenter) { described_class.new(project, current_user: user) }
-
subject(:empty_repo_statistics_buttons) { presenter.empty_repo_statistics_buttons }
before do
- project.add_developer(user)
allow(project).to receive(:auto_devops_enabled?).and_return(false)
end
- it 'orders the items correctly in an empty project' do
- expect(empty_repo_statistics_buttons.map(&:label)).to start_with(
- a_string_including('New'),
- a_string_including('README'),
- a_string_including('CHANGELOG'),
- a_string_including('CONTRIBUTING'),
- a_string_including('CI/CD')
- )
+ context 'empty repo' do
+ let(:project) { create(:project, :stubbed_repository)}
+
+ context 'for a guest user' do
+ it 'orders the items correctly' do
+ expect(empty_repo_statistics_buttons.map(&:label)).to start_with(
+ a_string_including('No license')
+ )
+ end
+ end
+
+ context 'for a developer' do
+ before do
+ project.add_developer(user)
+ end
+
+ it 'orders the items correctly' do
+ expect(empty_repo_statistics_buttons.map(&:label)).to start_with(
+ a_string_including('New'),
+ a_string_including('README'),
+ a_string_including('LICENSE'),
+ a_string_including('CHANGELOG'),
+ a_string_including('CONTRIBUTING'),
+ a_string_including('CI/CD')
+ )
+ end
+ end
+ end
+
+ context 'initialized repo' do
+ let(:project) { create(:project, :repository) }
+
+ it 'orders the items correctly' do
+ expect(empty_repo_statistics_buttons.map(&:label)).to start_with(
+ a_string_including('README'),
+ a_string_including('License'),
+ a_string_including('CHANGELOG'),
+ a_string_including('CONTRIBUTING')
+ )
+ end
end
end
end
diff --git a/spec/presenters/projects/settings/deploy_keys_presenter_spec.rb b/spec/presenters/projects/settings/deploy_keys_presenter_spec.rb
index b4bf39f3cdb..de58733c8ea 100644
--- a/spec/presenters/projects/settings/deploy_keys_presenter_spec.rb
+++ b/spec/presenters/projects/settings/deploy_keys_presenter_spec.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
require 'spec_helper'
describe Projects::Settings::DeployKeysPresenter do
diff --git a/spec/presenters/release_presenter_spec.rb b/spec/presenters/release_presenter_spec.rb
new file mode 100644
index 00000000000..4d9fa7a4d75
--- /dev/null
+++ b/spec/presenters/release_presenter_spec.rb
@@ -0,0 +1,101 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+describe ReleasePresenter do
+ include Gitlab::Routing.url_helpers
+
+ let_it_be(:project) { create(:project, :repository) }
+ let(:developer) { create(:user) }
+ let(:guest) { create(:user) }
+ let(:user) { developer }
+ let(:release) { create(:release, project: project) }
+ let(:presenter) { described_class.new(release, current_user: user) }
+
+ before do
+ project.add_developer(developer)
+ project.add_guest(guest)
+ end
+
+ describe '#commit_path' do
+ subject { presenter.commit_path }
+
+ it 'returns commit path' do
+ is_expected.to eq(project_commit_path(project, release.commit.id))
+ end
+
+ context 'when commit is not found' do
+ let(:release) { create(:release, project: project, sha: 'not-found') }
+
+ it { is_expected.to be_nil }
+ end
+
+ context 'when user is guest' do
+ let(:user) { guest }
+
+ it { is_expected.to be_nil }
+ end
+ end
+
+ describe '#tag_path' do
+ subject { presenter.tag_path }
+
+ it 'returns tag path' do
+ is_expected.to eq(project_tag_path(project, release.tag))
+ end
+
+ context 'when user is guest' do
+ let(:user) { guest }
+
+ it { is_expected.to be_nil }
+ end
+ end
+
+ describe '#merge_requests_url' do
+ subject { presenter.merge_requests_url }
+
+ it 'returns merge requests url' do
+ is_expected.to match /#{project_merge_requests_url(project)}/
+ 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 '#issues_url' do
+ subject { presenter.issues_url }
+
+ it 'returns merge requests url' do
+ is_expected.to match /#{project_issues_url(project)}/
+ 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
+ subject { presenter.edit_url }
+
+ it 'returns release edit url' do
+ is_expected.to match /#{edit_project_release_url(project, release)}/
+ end
+
+ context 'when release_edit_page feature flag is disabled' do
+ before do
+ stub_feature_flags(release_edit_page: false)
+ end
+
+ it { is_expected.to be_nil }
+ end
+ end
+end