Use ActiveRecord::RecordNotFound instead of ActionController::RoutingError for 404s (#2118)

This commit is contained in:
rhymes 2019-03-20 01:54:25 +01:00 committed by Ben Halpern
parent c851953d83
commit 27213bf6da
9 changed files with 10 additions and 10 deletions

View file

@ -11,7 +11,7 @@ class ApplicationController < ActionController::Base
end
def not_found
raise ActionController::RoutingError, "Not Found"
raise ActiveRecord::RecordNotFound, "Not Found"
end
def efficient_current_user_id

View file

@ -141,7 +141,7 @@ RSpec.describe "ArticlesApi", type: :request do
}
end
expect(invalid_update_request).to raise_error(ActionController::RoutingError)
expect(invalid_update_request).to raise_error(ActiveRecord::RecordNotFound)
end
it "does allow super user to update a different article" do

View file

@ -14,7 +14,7 @@ RSpec.describe "Badges", type: :request do
context "when badge does not exist" do
it "renders 404" do
expect { get "/badge/that-does-not-exists" }.to raise_error(ActionController::RoutingError)
expect { get "/badge/that-does-not-exists" }.to raise_error(ActiveRecord::RecordNotFound)
end
end
end

View file

@ -87,7 +87,7 @@ RSpec.describe "ChatChannels", type: :request do
context "when request is invalid" do
it "returns proper error message" do
expect { get "/chat_channels/1200" }.to raise_error(ActionController::RoutingError)
expect { get "/chat_channels/1200" }.to raise_error(ActiveRecord::RecordNotFound)
end
end
end

View file

@ -10,7 +10,7 @@ RSpec.describe "Delayed Job web interface", type: :request do
it "raises 404" do
expect do
get "/delayed_job"
end.to raise_error(ActionController::RoutingError)
end.to raise_error(ActiveRecord::RecordNotFound)
end
end
@ -19,7 +19,7 @@ RSpec.describe "Delayed Job web interface", type: :request do
login_as user
expect do
get "/delayed_job"
end.to raise_error(ActionController::RoutingError)
end.to raise_error(ActiveRecord::RecordNotFound)
end
end

View file

@ -29,7 +29,7 @@ RSpec.describe "EmailSubscriptions", type: :request do
it "handles error properly" do
expect { get email_subscriptions_unsubscribe_url }.
to raise_error(ActionController::RoutingError)
to raise_error(ActiveRecord::RecordNotFound)
end
it "won't work if it's past expiration date" do

View file

@ -30,7 +30,7 @@ RSpec.describe "ArticlesApi", type: :request, vcr: vcr_option do
it "returns nothing is passed invalid podcast slug" do
expect { get "/api/podcast_episodes?username=nothing_#{rand(1_000_000_000_000_000)}" }.
to raise_error(ActionController::RoutingError)
to raise_error(ActiveRecord::RecordNotFound)
end
end
end

View file

@ -22,7 +22,7 @@ RSpec.describe "UserOrganization", type: :request do
it "returns 404 if secret is wrong" do
expect { post "/users/join_org", params: { org_secret: "NOT SECRET" } }.
to raise_error ActionController::RoutingError
to raise_error ActiveRecord::RecordNotFound
end
it "leaves org" do

View file

@ -23,7 +23,7 @@ RSpec.describe "UserSettings", type: :request do
it "handles unknown settings tab properly" do
expect { get "/settings/does-not-exist" }.
to raise_error(ActionController::RoutingError)
to raise_error(ActiveRecord::RecordNotFound)
end
it "doesn't let user access membership if user has no monthly_dues" do