diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 12:26:25 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 12:26:25 +0000 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /spec/serializers/cluster_entity_spec.rb | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) | |
download | gitlab-ce-a09983ae35713f5a2bbb100981116d31ce99826e.tar.gz |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'spec/serializers/cluster_entity_spec.rb')
-rw-r--r-- | spec/serializers/cluster_entity_spec.rb | 34 |
1 files changed, 31 insertions, 3 deletions
diff --git a/spec/serializers/cluster_entity_spec.rb b/spec/serializers/cluster_entity_spec.rb index 16247eef655..223d37b6acd 100644 --- a/spec/serializers/cluster_entity_spec.rb +++ b/spec/serializers/cluster_entity_spec.rb @@ -2,9 +2,14 @@ require 'spec_helper' -describe ClusterEntity do +RSpec.describe ClusterEntity do + include Gitlab::Routing.url_helpers + describe '#as_json' do - subject { described_class.new(cluster).as_json } + let(:user) { nil } + let(:request) { EntityRequest.new({ current_user: user }) } + + subject { described_class.new(cluster, request: request).as_json } context 'when provider type is gcp' do let(:cluster) { create(:cluster, :instance, provider_type: :gcp, provider_gcp: provider) } @@ -40,7 +45,7 @@ describe ClusterEntity do context 'when no application has been installed' do let(:cluster) { create(:cluster, :instance) } - subject { described_class.new(cluster).as_json[:applications]} + subject { described_class.new(cluster, request: request).as_json[:applications]} it 'contains helm as not_installable' do expect(subject).not_to be_empty @@ -50,5 +55,28 @@ describe ClusterEntity do expect(helm[:status]).to eq(:not_installable) end end + + context 'gitlab_managed_apps_logs_path' do + let(:cluster) { create(:cluster, :project) } + let(:user) { create(:user) } + + subject { described_class.new(cluster, request: request).as_json } + + before do + allow_next_instance_of(Clusters::ClusterPresenter) do |presenter| + allow(presenter).to receive(:show_path).and_return(nil) + end + end + + it 'return projects log explorer path' do + log_explorer_path = project_logs_path(cluster.project, cluster_id: cluster.id) + + expect_next_instance_of(Clusters::ClusterPresenter, cluster, current_user: user) do |presenter| + expect(presenter).to receive(:gitlab_managed_apps_logs_path).and_return(log_explorer_path) + end + + expect(subject[:gitlab_managed_apps_logs_path]).to eq(log_explorer_path) + end + end end end |