From 0fa73e3b02d8a757ce95fe29dd76fad49f628e96 Mon Sep 17 00:00:00 2001 From: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com> Date: Thu, 27 Feb 2020 11:23:48 +0100 Subject: [PATCH] Fix headers in api/base_controller spec The headers in the request were not being populated correctly in the test, so the #api_key method was not functioning as intended. Fixes: 48) Api::BaseController cannot make a request to the API with an invalid API key Failure/Error: expect(json_response).to eq( "error" => "Invalid API key (fake_key) specified." ) expected: {"error"=>"Invalid API key (fake_key) specified."} got: {"products"=>[]} (compared using ==) Diff: @@ -1,2 +1,2 @@ -"error" => "Invalid API key (fake_key) specified.", +"products" => [], # ./spec/controllers/api/base_controller_spec.rb:40:in `block (3 levels) in ' --- spec/controllers/api/base_controller_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/controllers/api/base_controller_spec.rb b/spec/controllers/api/base_controller_spec.rb index 9e31fc138e..3742fcab2c 100644 --- a/spec/controllers/api/base_controller_spec.rb +++ b/spec/controllers/api/base_controller_spec.rb @@ -35,7 +35,7 @@ describe Api::BaseController do context "cannot make a request to the API" do it "with an invalid API key" do - request.env["X-Spree-Token"] = "fake_key" + request.headers["X-Spree-Token"] = "fake_key" get :index, {} expect(json_response).to eq( "error" => "Invalid API key (fake_key) specified." ) expect(response.status).to eq(401)