diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-18 09:08:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-18 09:08:14 +0300 |
commit | 7e5f8d08817c5672a0fe2f36609897f20d7e120e (patch) | |
tree | c09839c3ea64f6ec1035fdc4942c9022ca5a101a /spec/serializers/environment_entity_spec.rb | |
parent | 25861ffdce4061974732c8403992a0532433e012 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/serializers/environment_entity_spec.rb')
-rw-r--r-- | spec/serializers/environment_entity_spec.rb | 50 |
1 files changed, 38 insertions, 12 deletions
diff --git a/spec/serializers/environment_entity_spec.rb b/spec/serializers/environment_entity_spec.rb index b4ea90d2141..36e971c467a 100644 --- a/spec/serializers/environment_entity_spec.rb +++ b/spec/serializers/environment_entity_spec.rb @@ -10,7 +10,13 @@ describe EnvironmentEntity do described_class.new(environment, request: spy('request')) end - let(:environment) { create(:environment) } + let_it_be(:user) { create(:user) } + let_it_be(:project) { create(:project) } + let_it_be(:environment) { create(:environment, project: project) } + + before do + allow(entity).to receive(:current_user).and_return(user) + end subject { entity.as_json } @@ -67,28 +73,48 @@ describe EnvironmentEntity do end context 'with auto_stop_in' do - let(:environment) { create(:environment, :will_auto_stop) } + let(:environment) { create(:environment, :will_auto_stop, project: project) } it 'exposes auto stop related information' do + project.add_maintainer(user) + expect(subject).to include(:cancel_auto_stop_path, :auto_stop_at) end end context 'pod_logs' do - it 'exposes logs keys' do - expect(subject).to include(:logs_path) - expect(subject).to include(:logs_api_path) - expect(subject).to include(:enable_advanced_logs_querying) - end + context 'with developer access' do + before do + project.add_developer(user) + end - it 'uses k8s api when ES is not available' do - expect(subject[:logs_api_path]).to eq(k8s_project_logs_path(environment.project, environment_name: environment.name, format: :json)) + it 'does not expose logs keys' do + expect(subject).not_to include(:logs_path) + expect(subject).not_to include(:logs_api_path) + expect(subject).not_to include(:enable_advanced_logs_querying) + end end - it 'uses ES api when ES is available' do - allow(environment).to receive(:elastic_stack_available?).and_return(true) + context 'with maintainer access' do + before do + project.add_maintainer(user) + end + + it 'exposes logs keys' do + expect(subject).to include(:logs_path) + expect(subject).to include(:logs_api_path) + expect(subject).to include(:enable_advanced_logs_querying) + end - expect(subject[:logs_api_path]).to eq(elasticsearch_project_logs_path(environment.project, environment_name: environment.name, format: :json)) + it 'uses k8s api when ES is not available' do + expect(subject[:logs_api_path]).to eq(k8s_project_logs_path(project, environment_name: environment.name, format: :json)) + end + + it 'uses ES api when ES is available' do + allow(environment).to receive(:elastic_stack_available?).and_return(true) + + expect(subject[:logs_api_path]).to eq(elasticsearch_project_logs_path(project, environment_name: environment.name, format: :json)) + end end end end |