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:
Akshay Mahajan 2020-10-13 23:34:07 +05:30 committed by GitHub
parent 73cb7f0d42
commit f6c1fe0ade
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View file

@ -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

View file

@ -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 }