diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-14 15:09:05 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-14 15:09:05 +0000 |
commit | 66bd1f0fdcaf84fa3412c70d7962b49eb8a48fde (patch) | |
tree | 23f451b4e60a6e28bcc15043d7756bb27dcc2970 /spec/serializers/cluster_entity_spec.rb | |
parent | 49089d4fb1f5c17328ac61c955d95a68c6d4d545 (diff) | |
download | gitlab-ce-66bd1f0fdcaf84fa3412c70d7962b49eb8a48fde.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/serializers/cluster_entity_spec.rb')
-rw-r--r-- | spec/serializers/cluster_entity_spec.rb | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/spec/serializers/cluster_entity_spec.rb b/spec/serializers/cluster_entity_spec.rb index 6c692dbdbfc..223d37b6acd 100644 --- a/spec/serializers/cluster_entity_spec.rb +++ b/spec/serializers/cluster_entity_spec.rb @@ -3,8 +3,13 @@ require 'spec_helper' 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 @@ RSpec.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 @@ RSpec.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 |