diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-21 12:09:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-21 12:09:11 +0300 |
commit | 49abdb108a4d3c3f2ef9b27c7c4dcde43da1016a (patch) | |
tree | 31dee66af9f14c3bd320c349810d877d96fd66cf /spec/support | |
parent | 760dc7721406a82bbea06f3512a4e270d0bb3f0a (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support')
3 files changed, 51 insertions, 5 deletions
diff --git a/spec/support/helpers/emails_helper_test_helper.rb b/spec/support/helpers/emails_helper_test_helper.rb index ea7dbc89ebd..572b2f6853d 100644 --- a/spec/support/helpers/emails_helper_test_helper.rb +++ b/spec/support/helpers/emails_helper_test_helper.rb @@ -2,7 +2,7 @@ module EmailsHelperTestHelper def default_header_logo - %r{<img alt="GitLab" src="/images/mailers/gitlab_logo\.(?:gif|png)" width="\d+" height="\d+" />} + %r{<img alt="GitLab" src="http://test.host/images/mailers/gitlab_logo\.(?:gif|png)" width="\d+" height="\d+" />} end end diff --git a/spec/support/shared_contexts/requests/api/npm_packages_metadata_shared_examples.rb b/spec/support/shared_contexts/requests/api/npm_packages_metadata_shared_examples.rb new file mode 100644 index 00000000000..7faf7cb32ba --- /dev/null +++ b/spec/support/shared_contexts/requests/api/npm_packages_metadata_shared_examples.rb @@ -0,0 +1,40 @@ +# frozen_string_literal: true + +RSpec.shared_examples 'generates metadata response "on-the-fly"' do + let(:metadata) do + { + 'dist-tags' => { + 'latest' => package.version + }, + 'name' => package.name, + 'versions' => { + package.version => { + 'dist' => { + 'shasum' => 'be93151dc23ac34a82752444556fe79b32c7a1ad', + 'tarball' => "http://localhost/api/v4/projects/#{project.id}/packages/npm/#{package.name}/-/foo-1.0.1.tgz" + }, + 'name' => package.name, + 'version' => package.version + } + } + } + end + + before do + Grape::Endpoint.before_each do |endpoint| + expect(endpoint).not_to receive(:present_carrierwave_file!) # rubocop:disable RSpec/ExpectInHook + end + end + + after do + Grape::Endpoint.before_each nil + end + + it 'generates metadata response "on-the-fly"', :aggregate_failures do + expect(Packages::Npm::GenerateMetadataService).to receive(:new).and_call_original + + subject + + expect(json_response).to eq(metadata) + end +end diff --git a/spec/support/shared_examples/features/rss_shared_examples.rb b/spec/support/shared_examples/features/rss_shared_examples.rb index f6566214e32..a6b9c98923a 100644 --- a/spec/support/shared_examples/features/rss_shared_examples.rb +++ b/spec/support/shared_examples/features/rss_shared_examples.rb @@ -2,20 +2,20 @@ RSpec.shared_examples "an autodiscoverable RSS feed with current_user's feed token" do it "has an RSS autodiscovery link tag with current_user's feed token" do - expect(page).to have_css("link[type*='atom+xml'][href*='feed_token=#{user.feed_token}']", visible: false) + expect(page).to have_css("link[type*='atom+xml'][href*='feed_token=glft-'][href*='-#{user.id}']", visible: false) end end RSpec.shared_examples "it has an RSS button with current_user's feed token" do it "shows the RSS button with current_user's feed token" do expect(page) - .to have_css("a:has([data-testid='rss-icon'])[href*='feed_token=#{user.feed_token}']") + .to have_css("a:has([data-testid='rss-icon'])[href*='feed_token=glft-'][href*='-#{user.id}']") end end RSpec.shared_examples "it has an RSS link with current_user's feed token" do it "shows the RSS link with current_user's feed token" do - expect(page).to have_link 'Subscribe to RSS feed', href: /feed_token=#{user.feed_token}/ + expect(page).to have_link 'Subscribe to RSS feed', href: /feed_token=glft-.*-#{user.id}/ end end @@ -51,11 +51,17 @@ RSpec.shared_examples "updates atom feed link" do |type| auto_discovery_params = CGI.parse(URI.parse(auto_discovery_link[:href]).query) expected = { - 'feed_token' => [user.feed_token], 'assignee_id' => [user.id.to_s] } expect(params).to include(expected) + feed_token_param = params['feed_token'] + expect(feed_token_param).to match([Gitlab::Auth::AuthFinders::PATH_DEPENDENT_FEED_TOKEN_REGEX]) + expect(feed_token_param.first).to end_with(user.id.to_s) + expect(auto_discovery_params).to include(expected) + feed_token_param = auto_discovery_params['feed_token'] + expect(feed_token_param).to match([Gitlab::Auth::AuthFinders::PATH_DEPENDENT_FEED_TOKEN_REGEX]) + expect(feed_token_param.first).to end_with(user.id.to_s) end end |