diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-10-27 18:09:34 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-10-27 18:09:34 +0300 |
commit | f459f810d53dd453d3fc39df2dd62f01629d99e4 (patch) | |
tree | 1ecd155b532808014da10d0c04357292f06700a9 /spec/requests | |
parent | 71329edee6b7c2af838e07189dfeef8a41cd66ec (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/requests')
-rw-r--r-- | spec/requests/api/graphql/mutations/container_repository/destroy_tags_spec.rb | 2 | ||||
-rw-r--r-- | spec/requests/api/vs_code/settings/vs_code_settings_sync_spec.rb | 65 |
2 files changed, 66 insertions, 1 deletions
diff --git a/spec/requests/api/graphql/mutations/container_repository/destroy_tags_spec.rb b/spec/requests/api/graphql/mutations/container_repository/destroy_tags_spec.rb index 0cb607e13ec..7ced22890df 100644 --- a/spec/requests/api/graphql/mutations/container_repository/destroy_tags_spec.rb +++ b/spec/requests/api/graphql/mutations/container_repository/destroy_tags_spec.rb @@ -27,7 +27,7 @@ RSpec.describe 'Destroying a container repository tags', feature_category: :cont shared_examples 'destroying the container repository tags' do before do stub_delete_reference_requests(tags) - expect_delete_tag_by_names(tags) + expect_delete_tags(tags) allow_next_instance_of(ContainerRegistry::Client) do |client| allow(client).to receive(:supports_tag_delete?).and_return(true) end diff --git a/spec/requests/api/vs_code/settings/vs_code_settings_sync_spec.rb b/spec/requests/api/vs_code/settings/vs_code_settings_sync_spec.rb index 1055a8efded..c2c75619f36 100644 --- a/spec/requests/api/vs_code/settings/vs_code_settings_sync_spec.rb +++ b/spec/requests/api/vs_code/settings/vs_code_settings_sync_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' RSpec.describe API::VsCode::Settings::VsCodeSettingsSync, :aggregate_failures, factory_default: :keep, feature_category: :web_ide do + include GrapePathHelpers::NamedRouteMatcher + let_it_be(:user) { create_default(:user) } let_it_be(:user_token) { create(:personal_access_token) } @@ -21,6 +23,14 @@ RSpec.describe API::VsCode::Settings::VsCodeSettingsSync, :aggregate_failures, f end end + shared_examples "returns 400" do + it 'returns 400' do + get api(path, personal_access_token: user_token) + + expect(response).to have_gitlab_http_status(:bad_request) + end + end + describe 'GET /vscode/settings_sync/v1/manifest' do let(:path) { "/vscode/settings_sync/v1/manifest" } @@ -80,6 +90,12 @@ RSpec.describe API::VsCode::Settings::VsCodeSettingsSync, :aggregate_failures, f it_behaves_like "returns 20x when authenticated", :no_content it_behaves_like "returns unauthorized when not authenticated" + context "when resource type is invalid" do + let(:path) { "/vscode/settings_sync/v1/resource/foo/1" } + + it_behaves_like "returns 400" + end + context 'when settings with that type are not present' do it 'returns 204 no content and no content ETag header' do get api(path, personal_access_token: user_token) @@ -102,6 +118,55 @@ RSpec.describe API::VsCode::Settings::VsCodeSettingsSync, :aggregate_failures, f end end + describe 'GET /vscode/settings_sync/v1/resource/:resource_name/' do + let(:path) { "/vscode/settings_sync/v1/resource/settings/" } + + context "when resource type is invalid" do + let(:path) { "/vscode/settings_sync/v1/resource/foo" } + + it_behaves_like "returns 400" + end + + it_behaves_like "returns unauthorized when not authenticated" + it_behaves_like "returns 20x when authenticated", :ok + + context 'when settings with that type are not present' do + it "returns empty array response" do + get api(path, personal_access_token: user_token) + + expect(json_response.length).to eq(0) + end + end + + context 'when settings with that type are present' do + let_it_be(:settings) { create(:vscode_setting, content: '{ "key": "value" }') } + + it 'returns settings with the correct json content' do + get api(path, personal_access_token: user_token) + + setting_type = settings[:setting_type] + uuid = settings[:uuid] + + resource_ref = "/api/v4/vscode/settings_sync/v1/resource/#{setting_type}/#{uuid}" + + expect(json_response.length).to eq(1) + expect(json_response.first['url']).to eq(resource_ref) + expect(json_response.first['created']).to eq(settings.updated_at.to_i) + end + end + + context 'when setting type is machine' do + let(:path) { "/vscode/settings_sync/v1/resource/machines/" } + + it 'created field is nil' do + get api(path, personal_access_token: user_token) + + expect(json_response.length).to eq(1) + expect(json_response.first['created']).to be_nil + end + end + end + describe 'POST /vscode/settings_sync/v1/resource/:resource_name' do let(:path) { "/vscode/settings_sync/v1/resource/settings" } |