* wip * Removed reference to cached_tag_list as the feed enpoint only returns tag_list now. * Removed reference to cached_properties. * Updated <CommentsCount /> and <TagList /> to support additinal className * wip * wip * Undid init scrolling for Algolia articles * Converted homePageFeed.jsx to an ERB template to access Sprockets. * Now the homePageFeed.jsx files is an ERB so it can load Sprockets assets. * wip * Removed accidental commit of debugger statement in ERB. * Now different feed time frames are loaded based on the homepage feed tab clicked. * Prevent default Algolia paging when on the homepage. * Added a tiny comment about feed time frame. * Now feed loads properly for each time frame on home page. * prop name refactor. * Reneabled default Algolia scrolling. * On the homepage, we no longer overwrite article HTML with Algolia data for initial articles. * Assumption is the proper URL for main_image of featured article will be sent in the feed. * Fixed Google Analytics for featured article. * No longer need the new-feed ID for checking if we're on the homepage. * Trying to make codeclimate happy. * wip * Removed reference to cached_tag_list as the feed enpoint only returns tag_list now. * Removed reference to cached_properties. * Updated <CommentsCount /> and <TagList /> to support additinal className * wip * wip * Undid init scrolling for Algolia articles * Converted homePageFeed.jsx to an ERB template to access Sprockets. * Now the homePageFeed.jsx files is an ERB so it can load Sprockets assets. * wip * Removed accidental commit of debugger statement in ERB. * Now different feed time frames are loaded based on the homepage feed tab clicked. * Prevent default Algolia paging when on the homepage. * Added a tiny comment about feed time frame. * Now feed loads properly for each time frame on home page. * prop name refactor. * Reneabled default Algolia scrolling. * On the homepage, we no longer overwrite article HTML with Algolia data for initial articles. * Assumption is the proper URL for main_image of featured article will be sent in the feed. * Fixed Google Analytics for featured article. * No longer need the new-feed ID for checking if we're on the homepage. * Added postcst episodes to <Feed /> state. * Breaking up Article.jsx to make codeclimate happy. * wip * Created the <TodaysPodcastEpisodes /> and <PodcastEpisode /> components. * Fixed issues with some components that were updated for the <FeaturedArticle /> * Added tests for <FeaturedArticle /> * Barreled up <FeaturedArticle /> * Added Storybook stories for <FeaturedArticle /> * Featured articles don't display org, so removed that test. * Added proper today's podcasts components to feed. * Converted some leftover ERB + removed pro checkmark as it doesn't exist yet. * Now logic is same as master for feed timeframe. * Updated <FeaturedArticle /> snapshots. * On frontpage, bookmark button state is managed by Preact components now. * bookmarkedFeedItems is now a prop on <Feed />. * Fixed logic check for initializing reading list icons. * Now <Article /> and <FeaturedArticle /> receive a bookmarkClick prop. * Removed beginnings of scroll handler in <Feed /> as we're using what's there already for now. * Removed logic to not show main image on other time frame feeds as it was not correct. * Fixed issue with 0 rendering when no podcast episodes in feed. * Converted <SaveButton /> to a stateful component. * wip - <Feed /> render prop now passes bookmarked feed item ID set and a click event. * Moved FEED_ICONS to an export so it's easier to use JSX/JS in <Feed /> * Moved <Feed /> into article components. * Now reading list save buttons work properly in Preact components. * Fixed issue with Save buttons in Algolia paging/<Feed /> * Updated snapshots. * Took <Feed /> out of articles barrel file as jest was trying to import FEED_ICONs which is an ERB template. * Now the Preact feed is dynamically imported. * Now the Preact <Feed /> only loads for a logged on user. * Fixed <FeaturedArticle /> so that the save button behaves properly now. * Updated article stories for Storybook. * Putting this back to the order it was because I've removed my code changes for this block. * Fixed when renderFeed is imported for a logged on user. * Add podcasts to feed and render home from server * Add padding to feature laoding div * Update tests * Add more loading articles * Fix conflicts * Add readinglist javascript to initscrolling * Ensure first article is one with image * Organize feed items outside of feed instead of in it Co-authored-by: Ben Halpern <bendhalpern@gmail.com> Co-authored-by: Josh Puetz <josh@grorichpuetz.com>
214 lines
6.9 KiB
Ruby
214 lines
6.9 KiB
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe "StoriesIndex", type: :request do
|
|
let!(:article) { create(:article, featured: true) }
|
|
|
|
describe "GET stories index" do
|
|
it "renders page with article list" do
|
|
get "/"
|
|
expect(response.body).to include(CGI.escapeHTML(article.title))
|
|
end
|
|
|
|
it "renders page with min read" do
|
|
get "/"
|
|
expect(response.body).to include("min read")
|
|
end
|
|
|
|
it "renders page with proper sidebar" do
|
|
get "/"
|
|
expect(response.body).to include("<h4>Key links</h4>")
|
|
end
|
|
|
|
it "renders left display_ads when published and approved" do
|
|
org = create(:organization)
|
|
ad = create(:display_ad, published: true, approved: true, organization: org)
|
|
get "/"
|
|
expect(response.body).to include(ad.processed_html)
|
|
end
|
|
|
|
it "renders right display_ads when published and approved" do
|
|
org = create(:organization)
|
|
ad = create(:display_ad, published: true, approved: true, placement_area: "sidebar_right", organization: org)
|
|
get "/"
|
|
expect(response.body).to include(ad.processed_html)
|
|
end
|
|
|
|
it "does not render left display_ads when not approved" do
|
|
org = create(:organization)
|
|
ad = create(:display_ad, published: true, approved: false, organization: org)
|
|
get "/"
|
|
expect(response.body).not_to include(ad.processed_html)
|
|
end
|
|
|
|
it "does not render right display_ads when not approved" do
|
|
org = create(:organization)
|
|
ad = create(:display_ad, published: true, approved: false, placement_area: "sidebar_right", organization: org)
|
|
get "/"
|
|
expect(response.body).not_to include(ad.processed_html)
|
|
end
|
|
|
|
it "has gold sponsors displayed" do
|
|
org = create(:organization)
|
|
sponsorship = create(:sponsorship, level: "gold", tagline: "Oh Yeah!!!", status: "live", organization: org)
|
|
get "/"
|
|
expect(response.body).to include(sponsorship.tagline)
|
|
end
|
|
|
|
it "does not display silver sponsors" do
|
|
org = create(:organization)
|
|
sponsorship = create(:sponsorship, level: "silver", tagline: "Oh Yeah!!!", status: "live", organization: org)
|
|
get "/"
|
|
expect(response.body).not_to include(sponsorship.tagline)
|
|
end
|
|
|
|
it "does not display non live gold sponsorships" do
|
|
org = create(:organization)
|
|
sponsorship = create(:sponsorship, level: "gold", tagline: "Oh Yeah!!!", status: "pending", organization: org)
|
|
get "/"
|
|
expect(response.body).not_to include(sponsorship.tagline)
|
|
end
|
|
|
|
it "shows listings" do
|
|
user = create(:user)
|
|
listing = create(:classified_listing, user_id: user.id)
|
|
get "/"
|
|
expect(response.body).to include(CGI.escapeHTML(listing.title))
|
|
end
|
|
|
|
context "with campaign hero" do
|
|
let_it_be_readonly(:hero_html) do
|
|
create(
|
|
:html_variant,
|
|
group: "campaign",
|
|
name: "hero",
|
|
html: "<em>#{Faker::Book.title}'s</em>",
|
|
published: true,
|
|
approved: true,
|
|
)
|
|
end
|
|
|
|
it "displays hero html when it exists and is set in config" do
|
|
SiteConfig.campaign_hero_html_variant_name = "hero"
|
|
|
|
get root_path
|
|
expect(response.body).to include(hero_html.html)
|
|
end
|
|
|
|
it "doesn't display when campaign_hero_html_variant_name is not set" do
|
|
SiteConfig.campaign_hero_html_variant_name = ""
|
|
|
|
get root_path
|
|
expect(response.body).not_to include(hero_html.html)
|
|
end
|
|
|
|
it "doesn't display when hero html is not approved" do
|
|
SiteConfig.campaign_hero_html_variant_name = "hero"
|
|
hero_html.update_column(:approved, false)
|
|
|
|
get root_path
|
|
expect(response.body).not_to include(hero_html.html)
|
|
end
|
|
end
|
|
|
|
context "with campaign_sidebar" do
|
|
before do
|
|
SiteConfig.campaign_featured_tags = "shecoded,theycoded"
|
|
|
|
a_body = "---\ntitle: Super-sheep#{rand(1000)}\npublished: true\ntags: heyheyhey,shecoded\n---\n\nHello"
|
|
create(:article, approved: true, body_markdown: a_body)
|
|
u_body = "---\ntitle: Unapproved-post#{rand(1000)}\npublished: true\ntags: heyheyhey,shecoded\n---\n\nHello"
|
|
create(:article, approved: false, body_markdown: u_body)
|
|
end
|
|
|
|
it "doesn't display posts with the campaign tags when sidebar is disabled" do
|
|
SiteConfig.campaign_sidebar_enabled = false
|
|
get "/"
|
|
expect(response.body).not_to include(CGI.escapeHTML("Super-sheep"))
|
|
end
|
|
|
|
it "displays posts with the campaign tags when sidebar is enabled" do
|
|
SiteConfig.campaign_sidebar_enabled = true
|
|
get "/"
|
|
expect(response.body).not_to include(CGI.escapeHTML("Unapproved-post"))
|
|
end
|
|
|
|
it "displays only approved posts with the campaign tags" do
|
|
SiteConfig.campaign_sidebar_enabled = false
|
|
get "/"
|
|
expect(response.body).not_to include(CGI.escapeHTML("Super-puper"))
|
|
end
|
|
end
|
|
end
|
|
|
|
describe "GET query page" do
|
|
it "renders page with proper header" do
|
|
get "/search?q=hello"
|
|
expect(response.body).to include("query-header-text")
|
|
end
|
|
end
|
|
|
|
describe "GET podcast index" do
|
|
it "renders page with proper header" do
|
|
podcast = create(:podcast)
|
|
create(:podcast_episode, podcast: podcast)
|
|
get "/" + podcast.slug
|
|
expect(response.body).to include(podcast.title)
|
|
end
|
|
end
|
|
|
|
describe "GET tag index" do
|
|
let(:tag) { create(:tag) }
|
|
let(:org) { create(:organization) }
|
|
|
|
def create_live_sponsor(org, tag)
|
|
create(
|
|
:sponsorship,
|
|
level: :tag,
|
|
blurb_html: "<p>Oh Yeah!!!</p>",
|
|
status: "live",
|
|
organization: org,
|
|
sponsorable: tag,
|
|
expires_at: 30.days.from_now,
|
|
)
|
|
end
|
|
|
|
it "renders page with proper header" do
|
|
get "/t/#{tag.name}"
|
|
expect(response.body).to include(tag.name)
|
|
end
|
|
|
|
it "renders page with top/week etc." do
|
|
get "/t/#{tag.name}/top/week"
|
|
expect(response.body).to include(tag.name)
|
|
get "/t/#{tag.name}/top/month"
|
|
expect(response.body).to include(tag.name)
|
|
get "/t/#{tag.name}/top/year"
|
|
expect(response.body).to include(tag.name)
|
|
get "/t/#{tag.name}/top/infinity"
|
|
expect(response.body).to include(tag.name)
|
|
end
|
|
|
|
it "renders tag after alias change" do
|
|
tag2 = create(:tag, alias_for: tag.name)
|
|
get "/t/#{tag2.name}"
|
|
expect(response.body).to redirect_to "/t/#{tag.name}"
|
|
end
|
|
|
|
it "does not render sponsor if not live" do
|
|
sponsorship = create(
|
|
:sponsorship, level: :tag, tagline: "Oh Yeah!!!", status: "pending", organization: org, sponsorable: tag
|
|
)
|
|
|
|
get "/t/#{tag.name}"
|
|
expect(response.body).not_to include("is sponsored by")
|
|
expect(response.body).not_to include(sponsorship.tagline)
|
|
end
|
|
|
|
it "renders live sponsor" do
|
|
sponsorship = create_live_sponsor(org, tag)
|
|
get "/t/#{tag.name}"
|
|
expect(response.body).to include("is sponsored by")
|
|
expect(response.body).to include(sponsorship.blurb_html)
|
|
end
|
|
end
|
|
end
|