Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-06-27 03:09:00 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-06-27 03:09:00 +0300
commit661be4dd35d8258dee746c26e919e6f552afbec9 (patch)
tree786fa64a5df921c3fccb10990e55c617dd23f33b /spec
parent2ff7b07dbc1f16c5cb70f8484d061b0a00005985 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/finders/users_finder_spec.rb13
-rw-r--r--spec/helpers/application_helper_spec.rb16
-rw-r--r--spec/helpers/search_helper_spec.rb10
-rw-r--r--spec/lib/gitlab/search_results_spec.rb12
-rw-r--r--spec/requests/api/environments_spec.rb68
5 files changed, 66 insertions, 53 deletions
diff --git a/spec/finders/users_finder_spec.rb b/spec/finders/users_finder_spec.rb
index e0a9237a79b..c931de92d1c 100644
--- a/spec/finders/users_finder_spec.rb
+++ b/spec/finders/users_finder_spec.rb
@@ -70,19 +70,6 @@ RSpec.describe UsersFinder do
expect(users).to be_empty
end
-
- context 'when autocomplete_users_use_search_service feature flag is disabled' do
- before do
- stub_feature_flags(autocomplete_users_use_search_service: false)
- end
-
- it 'does not pass use_minimum_char_limit from params' do
- search_term = normal_user.username[..1]
- expect(User).to receive(:search).with(search_term, with_private_emails: anything).once.and_call_original
-
- described_class.new(user, { search: search_term, use_minimum_char_limit: false }).execute
- end
- end
end
it 'filters by external users' do
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
index 8ff36280dbc..f82b4146643 100644
--- a/spec/helpers/application_helper_spec.rb
+++ b/spec/helpers/application_helper_spec.rb
@@ -720,21 +720,7 @@ RSpec.describe ApplicationHelper do
end
describe 'stylesheet_link_tag_defer' do
- it 'uses print stylesheet when feature flag disabled' do
- stub_feature_flags(remove_startup_css: false)
-
- expect(helper.stylesheet_link_tag_defer('test')).to eq( '<link rel="stylesheet" href="/stylesheets/test.css" media="print" />')
- end
-
- it 'uses regular stylesheet when feature flag enabled' do
- stub_feature_flags(remove_startup_css: true)
-
- expect(helper.stylesheet_link_tag_defer('test')).to eq( '<link rel="stylesheet" href="/stylesheets/test.css" media="all" />')
- end
-
- it 'uses regular stylesheet when no_startup_css param present' do
- allow(helper.controller).to receive(:params).and_return({ no_startup_css: '' })
-
+ it 'uses media="all" in stylesheet' do
expect(helper.stylesheet_link_tag_defer('test')).to eq( '<link rel="stylesheet" href="/stylesheets/test.css" media="all" />')
end
end
diff --git a/spec/helpers/search_helper_spec.rb b/spec/helpers/search_helper_spec.rb
index b2606fcfae1..5c55c1d604a 100644
--- a/spec/helpers/search_helper_spec.rb
+++ b/spec/helpers/search_helper_spec.rb
@@ -153,15 +153,7 @@ RSpec.describe SearchHelper, feature_category: :global_search do
end
end
- [true, false].each do |enabled|
- context "with feature flag autcomplete_users_use_search_service #{enabled}" do
- before do
- stub_feature_flags(autocomplete_users_use_search_service: enabled)
- end
-
- include_examples 'for users'
- end
- end
+ include_examples 'for users'
it "includes the required project attrs" do
project = create(:project, namespace: create(:namespace, owner: user))
diff --git a/spec/lib/gitlab/search_results_spec.rb b/spec/lib/gitlab/search_results_spec.rb
index ce54f853e1b..662eab11cc0 100644
--- a/spec/lib/gitlab/search_results_spec.rb
+++ b/spec/lib/gitlab/search_results_spec.rb
@@ -302,18 +302,6 @@ RSpec.describe Gitlab::SearchResults, feature_category: :global_search do
results.objects('users')
end
-
- context 'when autocomplete_users_use_search_service feature flag is disabled' do
- before do
- stub_feature_flags(autocomplete_users_use_search_service: false)
- end
-
- it 'calls the UsersFinder without use_minimum_char_limit' do
- expect(UsersFinder).to receive(:new).with(user, search: 'foo').and_call_original
-
- results.objects('users')
- end
- end
end
end
diff --git a/spec/requests/api/environments_spec.rb b/spec/requests/api/environments_spec.rb
index 9a435b3bce9..498e030da0b 100644
--- a/spec/requests/api/environments_spec.rb
+++ b/spec/requests/api/environments_spec.rb
@@ -31,6 +31,14 @@ RSpec.describe API::Environments, feature_category: :continuous_delivery do
expect(json_response.first).not_to have_key('last_deployment')
end
+ it 'returns 200 HTTP status when using JOB-TOKEN auth' do
+ job = create(:ci_build, :running, project: project, user: user)
+
+ get api("/projects/#{project.id}/environments"), params: { job_token: job.token }
+
+ expect(response).to have_gitlab_http_status(:ok)
+ end
+
context 'when filtering' do
let_it_be(:stopped_environment) { create(:environment, :stopped, project: project) }
@@ -132,6 +140,14 @@ RSpec.describe API::Environments, feature_category: :continuous_delivery do
expect(json_response['external']).to be nil
end
+ it 'returns 200 HTTP status when using JOB-TOKEN auth' do
+ job = create(:ci_build, :running, project: project, user: user)
+
+ post api("/projects/#{project.id}/environments"), params: { name: "mepmep", job_token: job.token }
+
+ expect(response).to have_gitlab_http_status(:created)
+ end
+
it 'requires name to be passed' do
post api("/projects/#{project.id}/environments", user), params: { external_url: 'test.gitlab.com' }
@@ -173,6 +189,15 @@ RSpec.describe API::Environments, feature_category: :continuous_delivery do
expect(response).to have_gitlab_http_status(:ok)
end
+ it 'returns 200 HTTP status when using JOB-TOKEN auth' do
+ job = create(:ci_build, :running, project: project, user: user)
+
+ post api("/projects/#{project.id}/environments/stop_stale"),
+ params: { before: 1.week.ago.to_date.to_s, job_token: job.token }
+
+ expect(response).to have_gitlab_http_status(:ok)
+ end
+
it 'returns a 400 for bad input date' do
post api("/projects/#{project.id}/environments/stop_stale", user), params: { before: 1.day.ago.to_date.to_s }
@@ -229,6 +254,15 @@ RSpec.describe API::Environments, feature_category: :continuous_delivery do
expect(json_response['tier']).to eq('production')
end
+ it 'returns 200 HTTP status when using JOB-TOKEN auth' do
+ job = create(:ci_build, :running, project: project, user: user)
+
+ put api("/projects/#{project.id}/environments/#{environment.id}"),
+ params: { tier: 'production', job_token: job.token }
+
+ expect(response).to have_gitlab_http_status(:ok)
+ end
+
it "won't allow slug to be changed" do
slug = environment.slug
api_url = api("/projects/#{project.id}/environments/#{environment.id}", user)
@@ -261,6 +295,17 @@ RSpec.describe API::Environments, feature_category: :continuous_delivery do
expect(response).to have_gitlab_http_status(:no_content)
end
+ it 'returns 204 HTTP status when using JOB-TOKEN auth' do
+ environment.stop
+
+ job = create(:ci_build, :running, project: project, user: user)
+
+ delete api("/projects/#{project.id}/environments/#{environment.id}"),
+ params: { job_token: job.token }
+
+ expect(response).to have_gitlab_http_status(:no_content)
+ end
+
it 'returns a 404 for non existing id' do
delete api("/projects/#{project.id}/environments/#{non_existing_record_id}", user)
@@ -291,17 +336,23 @@ RSpec.describe API::Environments, feature_category: :continuous_delivery do
context 'with a stoppable environment' do
before do
environment.update!(state: :available)
-
- post api("/projects/#{project.id}/environments/#{environment.id}/stop", user)
end
it 'returns a 200' do
+ post api("/projects/#{project.id}/environments/#{environment.id}/stop", user)
+
expect(response).to have_gitlab_http_status(:ok)
expect(response).to match_response_schema('public_api/v4/environment')
+ expect(environment.reload).to be_stopped
end
- it 'actually stops the environment' do
- expect(environment.reload).to be_stopped
+ it 'returns 200 HTTP status when using JOB-TOKEN auth' do
+ job = create(:ci_build, :running, project: project, user: user)
+
+ post api("/projects/#{project.id}/environments/#{environment.id}/stop"),
+ params: { job_token: job.token }
+
+ expect(response).to have_gitlab_http_status(:ok)
end
end
@@ -333,6 +384,15 @@ RSpec.describe API::Environments, feature_category: :continuous_delivery do
expect(response).to match_response_schema('public_api/v4/environment')
expect(json_response['last_deployment']).to be_present
end
+
+ it 'returns 200 HTTP status when using JOB-TOKEN auth' do
+ job = create(:ci_build, :running, project: project, user: user)
+
+ get api("/projects/#{project.id}/environments/#{environment.id}"),
+ params: { job_token: job.token }
+
+ expect(response).to have_gitlab_http_status(:ok)
+ end
end
context 'as non member' do