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