Fixing date in listing modal (#11260)
* Fixing date in listing modal * Adding test * Fixing test message
This commit is contained in:
parent
8564c52d9d
commit
01725d9344
2 changed files with 20 additions and 1 deletions
|
|
@ -3,7 +3,8 @@ class ListingsController < ApplicationController
|
|||
|
||||
INDEX_JSON_OPTIONS = {
|
||||
only: %i[
|
||||
title processed_html tag_list category id user_id slug contact_via_connect location
|
||||
title processed_html tag_list category id user_id slug contact_via_connect location bumped_at
|
||||
originally_published_at
|
||||
],
|
||||
include: {
|
||||
author: { only: %i[username name], methods: %i[username profile_image_90] },
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
require "rails_helper"
|
||||
require "nokogiri"
|
||||
|
||||
RSpec.describe "/listings", type: :request do
|
||||
let(:user) { create(:user) }
|
||||
|
|
@ -35,6 +36,8 @@ RSpec.describe "/listings", type: :request do
|
|||
before do
|
||||
sign_in user
|
||||
create_list(:credit, 25, user: user)
|
||||
listing_params[:listing][:post_as_organization] = "1"
|
||||
post "/listings", params: listing_params
|
||||
end
|
||||
|
||||
it "returns text/html and has status 200" do
|
||||
|
|
@ -43,6 +46,21 @@ RSpec.describe "/listings", type: :request do
|
|||
expect(response).to have_http_status(:ok)
|
||||
end
|
||||
|
||||
it "listings have correct keys" do
|
||||
get "/listings"
|
||||
|
||||
parsed_response = Nokogiri.HTML(response.body)
|
||||
|
||||
listings = JSON.parse(parsed_response.xpath("//*[@id='listings-index-container']")[0]["data-listings"])
|
||||
|
||||
index_keys = %w[
|
||||
title processed_html tag_list id user_id slug contact_via_connect location bumped_at
|
||||
originally_published_at author user
|
||||
]
|
||||
|
||||
expect(listings.first.keys).to match_array index_keys
|
||||
end
|
||||
|
||||
context "when the user has no params" do
|
||||
it "shows all active listings" do
|
||||
get "/listings"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue