Skip to content
Snippets Groups Projects
Unverified Commit 58fa4095 authored by Jerry Seto's avatar Jerry Seto
Browse files

Merge branch '424371_fix_undefined_method_error' into 'master'

Fix NoMethodError for ActivityPub

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/131066



Merged-by: default avatarJerry Seto <jseto@gitlab.com>
Approved-by: default avatarJerry Seto <jseto@gitlab.com>
Co-authored-by: default avatarVasilii Iakliushin <viakliushin@gitlab.com>
parents 42a15ee9 d91226dd
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -3,7 +3,7 @@
module Constraints
class ActivityPubConstrainer
def matches?(request)
mime_types.any? { |m| request.headers['Accept'].include?(m) }
mime_types.any? { |m| request.headers.fetch('Accept', '').include?(m) }
end
 
private
Loading
Loading
# 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 mime is #{mime}" do
let(:headers) { { 'HTTP_ACCEPT' => mime } }
it 'matches the header' do
is_expected.to be_truthy
end
end
end
context 'when Accept header is missing' do
let(:headers) { {} }
it 'does not match' do
is_expected.to be_falsey
end
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment