Skip to content

Commit

Permalink
Fix uses of ActionController::TestResponse in specs
Browse files Browse the repository at this point in the history
This class has moved / changed slightly.
  • Loading branch information
Matt-Yorkley committed Jan 9, 2021
1 parent 8309b97 commit c725d4e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

# Context which will be passed to the renderer. The response object is not automatically prepared,
# so this has to be assigned explicitly.
let!(:response) { ActionController::TestResponse.new }
let!(:response) { ActionDispatch::TestResponse.new }
let!(:controller) do
ActionController::Base.new.tap do |controller_mock|
controller_mock.instance_variable_set(:@_response, response)
Expand Down
8 changes: 4 additions & 4 deletions spec/services/embedded_page_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
let(:enterprise_slug) { 'test-enterprise' }
let(:params) { { controller: 'enterprises', action: 'shop', id: enterprise_slug, embedded_shopfront: true } }
let(:session) { {} }
let(:request) { ActionController::TestRequest.new('HTTP_HOST' => 'ofn-instance.com', 'HTTP_REFERER' => 'https://embedding-enterprise.com') }
let(:response) { ActionController::TestResponse.new(200, 'X-Frame-Options' => 'DENY', 'Content-Security-Policy' => "frame-ancestors 'none'") }
let(:request) { ActionController::TestRequest.new({'HTTP_HOST' => 'ofn-instance.com', 'HTTP_REFERER' => 'https://embedding-enterprise.com'}, nil) }
let(:response) { ActionDispatch::TestResponse.new(200, 'X-Frame-Options' => 'DENY', 'Content-Security-Policy' => "frame-ancestors 'none'") }
let(:service) { EmbeddedPageService.new(params, session, request, response) }

before do
Expand All @@ -23,7 +23,7 @@

it "sets the response headers to enables embedding requests from the embedding site" do
expect(response.headers).to_not include 'X-Frame-Options' => 'DENY'
expect(response.headers).to include 'Content-Security-Policy' => "frame-ancestors 'self' embedding-enterprise.com"
expect(response.headers).to eq 'Content-Security-Policy' => "frame-ancestors 'self' embedding-enterprise.com"
end

it "sets session variables" do
Expand Down Expand Up @@ -63,7 +63,7 @@
end

context "when the request's referer is malformed" do
let(:request) { ActionController::TestRequest.new('HTTP_HOST' => 'ofn-instance.com', 'HTTP_REFERER' => 'hello') }
let(:request) { ActionController::TestRequest.new({'HTTP_HOST' => 'ofn-instance.com', 'HTTP_REFERER' => 'hello'}, nil) }
before do
service.embed!
end
Expand Down

0 comments on commit c725d4e

Please sign in to comment.