Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only include errors mixin in production mode #12

Merged
merged 1 commit into from
Nov 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion app/controllers/alchemy/json_api/base_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 8 additions & 6 deletions spec/requests/alchemy/json_api/layout_pages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
7 changes: 4 additions & 3 deletions spec/requests/alchemy/json_api/pages_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down