Fix missing category in delete draft listing URL (#10809)
* added category in DASHBOARD_JSON_OPTIONS in listing_controller.rb * added test to make sure that draft listings contain category
This commit is contained in:
parent
73cb7f0d42
commit
f6c1fe0ade
2 changed files with 13 additions and 2 deletions
|
|
@ -13,9 +13,10 @@ class ListingsController < ApplicationController
|
|||
|
||||
DASHBOARD_JSON_OPTIONS = {
|
||||
only: %i[
|
||||
title tag_list created_at expires_at bumped_at updated_at category id
|
||||
title tag_list created_at expires_at bumped_at updated_at id
|
||||
user_id slug organization_id location published
|
||||
],
|
||||
methods: %i[category],
|
||||
include: {
|
||||
author: { only: %i[username name], methods: %i[username profile_image_90] }
|
||||
}
|
||||
|
|
@ -68,7 +69,7 @@ class ListingsController < ApplicationController
|
|||
|
||||
def dashboard
|
||||
listings = current_user.listings
|
||||
.includes(:organization, :taggings)
|
||||
.includes(:organization, :taggings, :listing_category)
|
||||
@listings_json = listings.to_json(DASHBOARD_JSON_OPTIONS)
|
||||
|
||||
organizations_ids = current_user.organization_memberships
|
||||
|
|
|
|||
|
|
@ -80,6 +80,16 @@ RSpec.describe "/listings", type: :request do
|
|||
end
|
||||
end
|
||||
|
||||
describe "GET /listings/dashboard" do
|
||||
before { sign_in user }
|
||||
|
||||
it "returns a category for draft listings" do
|
||||
post "/listings", params: draft_params
|
||||
get "/listings/dashboard"
|
||||
expect(response.body).to include(CGI.escapeHTML("\"category\":\"#{edu_category.slug}\""))
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /listings/new" do
|
||||
before { sign_in user }
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue