handle missing displayed_classified_listing for moderate views (#6881) [deploy]
This commit is contained in:
parent
1be91d131f
commit
84a14aed0a
2 changed files with 14 additions and 0 deletions
|
|
@ -12,6 +12,7 @@ class ClassifiedListingsController < ApplicationController
|
|||
@displayed_classified_listing = published_listings.find_by(slug: params[:slug]) if params[:slug]
|
||||
|
||||
if params[:view] == "moderate"
|
||||
not_found unless @displayed_classified_listing
|
||||
return redirect_to "/internal/listings/#{@displayed_classified_listing.id}/edit"
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -63,6 +63,19 @@ RSpec.describe "ClassifiedListings", type: :request do
|
|||
expect(response.body).not_to include(CGI.escapeHTML(expired_listing.title))
|
||||
end
|
||||
end
|
||||
|
||||
context "when view is moderate" do
|
||||
it "redirects to internal/listings/:id/edit" do
|
||||
get "/listings", params: { view: "moderate", slug: listing.slug }
|
||||
expect(response.redirect_url).to include("/internal/listings/#{listing.id}/edit")
|
||||
end
|
||||
|
||||
it "without a slug raises an ActiveRecord::RecordNotFound error" do
|
||||
expect do
|
||||
get "/listings", params: { view: "moderate" }
|
||||
end.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /listings/new" do
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue