* Change models and related files * Update controllers and specs * More renaming * Seek and destroy, I mean search and replace * Round up the stragglers * Ground control to Major Travis... * More fixes * PR feedback * Various fixes * Rename view * Fix list query builder * Unify request specs * Fix some API spec errors * Fix remaining API specs * Make spec conform to API * Fix leftover problems * Fix JS tests * Fix column name in select * Fix API specs * Fix search specs * Paging Mr. Travis
49 lines
1.4 KiB
Ruby
49 lines
1.4 KiB
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe "/internal/listings", type: :request do
|
|
let_it_be(:admin) { create(:user, :super_admin) }
|
|
let_it_be(:listing) { create(:listing, user_id: admin.id) }
|
|
|
|
before do
|
|
allow(CacheBuster).to receive(:bust_listings)
|
|
sign_in admin
|
|
end
|
|
|
|
describe "PUT /internal/listings/:id" do
|
|
it "clears listing cache" do
|
|
put internal_listing_path(id: listing.id), params: {
|
|
listing: { title: "updated" }
|
|
}
|
|
sidekiq_perform_enqueued_jobs
|
|
expect(CacheBuster).to have_received(:bust_listings)
|
|
end
|
|
|
|
describe "GET /internal/listings" do
|
|
let!(:unpublished_listing) { create(:listing, published: false) }
|
|
|
|
it "shows published listings" do
|
|
get internal_listings_path
|
|
|
|
expect(response.body).to include(CGI.escapeHTML(listing.title))
|
|
end
|
|
|
|
it "filters unpublished listings by default" do
|
|
get internal_listings_path
|
|
|
|
expect(response.body).not_to include(CGI.escapeHTML(unpublished_listing.title))
|
|
end
|
|
|
|
it "includes unpublished listings when asked to" do
|
|
get internal_listings_path, params: { include_unpublished: "1" }
|
|
|
|
expect(response.body).to include(CGI.escapeHTML(unpublished_listing.title))
|
|
end
|
|
|
|
it "filters by category" do
|
|
get internal_listings_path(filter: "misc")
|
|
|
|
expect(response.body).not_to include(CGI.escapeHTML(listing.title))
|
|
end
|
|
end
|
|
end
|
|
end
|