diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-20 14:18:08 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-09-20 14:18:08 +0300 |
commit | 5afcbe03ead9ada87621888a31a62652b10a7e4f (patch) | |
tree | 9918b67a0d0f0bafa6542e839a8be37adf73102d /spec/lib/constraints | |
parent | c97c0201564848c1f53226fe19d71fdcc472f7d0 (diff) |
Add latest changes from gitlab-org/gitlab@16-4-stable-eev16.4.0-rc42
Diffstat (limited to 'spec/lib/constraints')
-rw-r--r-- | spec/lib/constraints/activity_pub_constrainer_spec.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/lib/constraints/activity_pub_constrainer_spec.rb b/spec/lib/constraints/activity_pub_constrainer_spec.rb new file mode 100644 index 00000000000..2a3d23501a9 --- /dev/null +++ b/spec/lib/constraints/activity_pub_constrainer_spec.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Constraints::ActivityPubConstrainer, feature_category: :groups_and_projects do + subject(:constraint) { described_class.new } + + describe '#matches?' do + subject { constraint.matches?(request) } + + let(:request) { ActionDispatch::Request.new(headers) } + + ['application/ld+json; profile="https://www.w3.org/ns/activitystreams"', 'application/activity+json'].each do |mime| + context "when Accept header is #{mime}" do + let(:headers) { { 'HTTP_ACCEPT' => mime } } + + it 'matches the header' do + is_expected.to be_truthy + end + end + + context "when Content-Type header is #{mime}" do + let(:headers) { { 'CONTENT_TYPE' => mime } } + + it 'matches the header' do + is_expected.to be_truthy + end + end + end + + context 'when Accept and Content-Type headers are missing' do + let(:headers) { {} } + + it 'does not match' do + is_expected.to be_falsey + end + end + end +end |