diff --git a/app/controllers/alchemy/json_api/base_controller.rb b/app/controllers/alchemy/json_api/base_controller.rb index fe63c3c..c89399a 100644 --- a/app/controllers/alchemy/json_api/base_controller.rb +++ b/app/controllers/alchemy/json_api/base_controller.rb @@ -4,9 +4,7 @@ module JsonApi class BaseController < ::ApplicationController include Alchemy::ControllerActions include JSONAPI::Fetching - if Rails.env.production? - include JSONAPI::Errors - end + include JSONAPI::Errors include JSONAPI::Filtering include JSONAPI::Pagination end diff --git a/spec/requests/alchemy/json_api/layout_pages_spec.rb b/spec/requests/alchemy/json_api/layout_pages_spec.rb index d83b333..7687493 100644 --- a/spec/requests/alchemy/json_api/layout_pages_spec.rb +++ b/spec/requests/alchemy/json_api/layout_pages_spec.rb @@ -27,10 +27,9 @@ let(:page) { FactoryBot.create(:alchemy_page, :public, elements: [element]) } let(:element) { FactoryBot.create(:alchemy_element, name: "article", autogenerate_contents: true) } - it "raises 404 error" do - expect { - get alchemy_json_api.layout_page_path(page) - }.to raise_error(ActiveRecord::RecordNotFound) + it "returns a 404" do + get alchemy_json_api.layout_page_path(page) + expect(response).to have_http_status(404) end end @@ -49,10 +48,9 @@ let!(:other_language) { FactoryBot.create(:alchemy_language, :german) } let(:page) { FactoryBot.create(:alchemy_page, :public, :layoutpage, language: other_language) } - it "raises 404 error" do - expect { - get alchemy_json_api.layout_page_path(page) - }.to raise_error(ActiveRecord::RecordNotFound) + it "returns a 404" do + get alchemy_json_api.layout_page_path(page.urlname) + expect(response).to have_http_status(404) end end end diff --git a/spec/requests/alchemy/json_api/pages_spec.rb b/spec/requests/alchemy/json_api/pages_spec.rb index 3a1fddb..dbbf301 100644 --- a/spec/requests/alchemy/json_api/pages_spec.rb +++ b/spec/requests/alchemy/json_api/pages_spec.rb @@ -66,10 +66,9 @@ let!(:other_language) { FactoryBot.create(:alchemy_language, :german) } let(:page) { FactoryBot.create(:alchemy_page, :public, language: other_language) } - it "raises 404 error" do - expect { - get alchemy_json_api.page_path(page) - }.to raise_error(ActiveRecord::RecordNotFound) + it "returns a 404" do + get alchemy_json_api.page_path(page.urlname) + expect(response).to have_http_status(404) end end end