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

Remove render_404 from frontend #2329

Merged
merged 2 commits into from
Oct 27, 2017
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
7 changes: 0 additions & 7 deletions core/lib/spree/core/controller_helpers/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,6 @@ def accurate_title
current_store.seo_title
end

def render_404(_exception = nil)
respond_to do |type|
type.html { render status: :not_found, file: "#{::Rails.root}/public/404", formats: [:html], layout: nil }
type.all { render status: :not_found, nothing: true }
end
end

private

def set_user_language
Expand Down
1 change: 0 additions & 1 deletion frontend/app/controllers/spree/orders_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module Spree
class OrdersController < Spree::StoreController
before_action :check_authorization
rescue_from ActiveRecord::RecordNotFound, with: :render_404
helper 'spree/products', 'spree/orders'

respond_to :html
Expand Down
1 change: 0 additions & 1 deletion frontend/app/controllers/spree/products_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ class ProductsController < Spree::StoreController
before_action :load_product, only: :show
before_action :load_taxon, only: :index

rescue_from ActiveRecord::RecordNotFound, with: :render_404
helper 'spree/taxons'

respond_to :html
Expand Down
1 change: 0 additions & 1 deletion frontend/app/controllers/spree/taxons_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module Spree
class TaxonsController < Spree::StoreController
rescue_from ActiveRecord::RecordNotFound, with: :render_404
helper 'spree/products'

respond_to :html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module Spree
let(:user) { create(:user) }
let(:guest_user) { create(:user) }
let(:order) { Spree::Order.create }
let(:variant) { create(:variant) }

it 'should understand order routes with token' do
expect(spree.token_order_path('R123456', 'ABCDEF')).to eq('/orders/R123456/token/ABCDEF')
Expand All @@ -25,11 +26,11 @@ module Spree
context '#populate' do
it 'should check if user is authorized for :edit' do
expect(controller).to receive(:authorize!).with(:edit, order, token)
post :populate, params: { token: token }
post :populate, params: { variant_id: variant.id, token: token }
end
it "should check against the specified order" do
expect(controller).to receive(:authorize!).with(:edit, specified_order, token)
post :populate, params: { id: specified_order.number, token: token }
post :populate, params: { id: specified_order.number, variant_id: variant.id, token: token }
end
end

Expand Down Expand Up @@ -95,8 +96,9 @@ module Spree

context 'when no token present' do
it 'should respond with 404' do
get :show, params: { id: 'R123' }
expect(response.code).to eq('404')
expect {
get :show, params: { id: 'R123' }
}.to raise_error(ActiveRecord::RecordNotFound)
end
end
end
Expand Down
3 changes: 2 additions & 1 deletion frontend/spec/controllers/spree/orders_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

context "#populate" do
it "should create a new order when none specified" do
post :populate
post :populate, params: { variant_id: variant.id }
expect(response).to be_redirect
expect(cookies.signed[:guest_token]).not_to be_blank

order_by_token = Spree::Order.find_by(guest_token: cookies.signed[:guest_token])
Expand Down
5 changes: 3 additions & 2 deletions frontend/spec/controllers/spree/products_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
end

it "cannot view non-active products" do
get :show, params: { id: product.to_param }
expect(response.status).to eq(404)
expect {
get :show, params: { id: product.to_param }
}.to raise_error(ActiveRecord::RecordNotFound)
end

it "should provide the current user to the searcher class" do
Expand Down