docbrown/spec/requests/sidebars_spec.rb
Ben Halpern 2f9769a89d
Add new sidebar billboard locations and remove legacy campaign area (#20562)
* Add new sidebar billboard locations

* Remove some specs

* Remove campaign tests

* Adjust tag-allowed billboards

* Fix up targeting functionality

* Fix sidebar third render
2024-02-08 16:55:48 +00:00

52 lines
1.7 KiB
Ruby

require "rails_helper"
RSpec.describe "Sidebars" do
describe "GET /sidebars/home" do
it "includes relevant parts" do
listing = create(:listing, published: true)
create(:tag, name: "rubymagoo")
allow(Settings::General).to receive(:sidebar_tags).and_return(["rubymagoo"])
get "/sidebars/home"
expect(response.body).to include("rubymagoo")
end
context "when active discussions exist" do
let(:tag) { create(:tag, name: "testmagoo") }
let(:user) { create(:user) }
let!(:article) do
create(:article, tag_list: tag.name, last_comment_at: 1.day.ago, language: "en",
score: 10, comments_count: 5, created_at: 3.days.ago)
end
before do
article.update_columns(language: "en")
user.follow(tag)
end
it "does not include active article if not signed in" do
get "/sidebars/home"
expect(response.body).not_to include("active-discussions")
end
it "does show active discussions if signed in and user follows tag" do
sign_in user
get "/sidebars/home"
expect(response.body).to include(CGI.escapeHTML(article.title))
end
it "includes an article without the proper tags if featured" do
second_article = create(:article, featured: true)
sign_in user
get "/sidebars/home"
expect(response.body).to include(CGI.escapeHTML(second_article.title))
end
it "does not include non-featured non-tagg-followed article" do
second_article = create(:article, language: "en")
sign_in user
get "/sidebars/home"
expect(response.body).not_to include(CGI.escapeHTML(second_article.title))
end
end
end
end