Skip to content

Commit

Permalink
Merge pull request #12 from AlchemyCMS/error-mixin-production-only
Browse files Browse the repository at this point in the history
Only include errors mixin in production mode
  • Loading branch information
tvdeyen authored Nov 2, 2020
2 parents c71d880 + e2d71b1 commit 7c6afb9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
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

0 comments on commit 7c6afb9

Please sign in to comment.