Rename DisplayAdsController to BillboardsController (#19738)
This commit is contained in:
parent
290b9bd775
commit
7c1721675c
8 changed files with 18 additions and 15 deletions
|
|
@ -1,4 +1,4 @@
|
|||
class DisplayAdsController < ApplicationController
|
||||
class BillboardsController < ApplicationController
|
||||
before_action :set_cache_control_headers, only: %i[show], unless: -> { current_user }
|
||||
include DisplayAdHelper
|
||||
CACHE_EXPIRY_FOR_DISPLAY_ADS = 15.minutes.to_i.freeze
|
||||
|
|
@ -217,9 +217,9 @@ export const Feed = ({ timeFrame, renderFeed, afterRender }) => {
|
|||
},
|
||||
credentials: 'same-origin',
|
||||
}),
|
||||
fetch(`/display_ads/feed_first`),
|
||||
fetch(`/display_ads/feed_second`),
|
||||
fetch(`/display_ads/feed_third`),
|
||||
fetch(`/billboards/feed_first`),
|
||||
fetch(`/billboards/feed_second`),
|
||||
fetch(`/billboards/feed_third`),
|
||||
];
|
||||
|
||||
const results = await Promise.allSettled(promises);
|
||||
|
|
|
|||
|
|
@ -55,4 +55,4 @@
|
|||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="crayons-article-sticky grid gap-4 break-word js-display-ad-container" data-async-url="<%= article_display_ad_path(username: @article.username, slug: @article.slug, placement_area: :post_sidebar) %>"></div>
|
||||
<div class="crayons-article-sticky grid gap-4 break-word js-display-ad-container" data-async-url="<%= article_billboard_path(username: @article.username, slug: @article.slug, placement_area: :post_sidebar) %>"></div>
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@
|
|||
</article>
|
||||
|
||||
<div class="pb-4 crayons-layout__comments-display-ad">
|
||||
<div class="js-display-ad-container pb-4 crayons-layout__comments-display-ad" data-async-url="<%= article_display_ad_path(username: @article.username, slug: @article.slug, placement_area: :post_comments) %>"></div>
|
||||
<div class="js-display-ad-container pb-4 crayons-layout__comments-display-ad" data-async-url="<%= article_billboard_path(username: @article.username, slug: @article.slug, placement_area: :post_comments) %>"></div>
|
||||
</div>
|
||||
|
||||
<% cache("article-bottom-content-#{@article.id}-#{user_signed_in?}-#{(@organization || @user).latest_article_updated_at}", expires_in: 18.hours) do %>
|
||||
|
|
|
|||
|
|
@ -198,11 +198,15 @@ Rails.application.routes.draw do
|
|||
get "/async_info/base_data", to: "async_info#base_data", defaults: { format: :json }
|
||||
get "/async_info/navigation_links", to: "async_info#navigation_links"
|
||||
|
||||
# Display ads
|
||||
# Billboards
|
||||
scope "/:username/:slug" do
|
||||
get "/display_ads/:placement_area", to: "display_ads#show", as: :article_display_ad
|
||||
get "/billboards/:placement_area", to: "billboards#show", as: :article_billboard
|
||||
# temporary keeping both routes while transitioning (renaming) display_ads => billboards
|
||||
get "/display_ads/:placement_area", to: "billboards#show"
|
||||
end
|
||||
get "/display_ads/:placement_area", to: "display_ads#show"
|
||||
get "/billboards/:placement_area", to: "billboards#show"
|
||||
# temporary keeping both routes while transitioning (renaming) display_ads => billboards
|
||||
get "/display_ads/:placement_area", to: "billboards#show"
|
||||
|
||||
# Settings
|
||||
post "users/join_org", to: "users#join_org"
|
||||
|
|
|
|||
|
|
@ -102,7 +102,6 @@ namespace :admin do
|
|||
scope :customization do
|
||||
# We renamed the controller but don't want to change the route (yet)
|
||||
resource :config, controller: "settings"
|
||||
# resources :display_ads, only: %i[index edit update new create destroy]
|
||||
resources :billboards, only: %i[index edit update new create destroy]
|
||||
resources :html_variants, only: %i[index edit update new create show destroy]
|
||||
resources :navigation_links, only: %i[index update create destroy]
|
||||
|
|
|
|||
|
|
@ -1,19 +1,19 @@
|
|||
require "rails_helper"
|
||||
|
||||
RSpec.describe "DisplayAds" do
|
||||
RSpec.describe "Billboards" do
|
||||
let(:user) { create(:user) }
|
||||
let(:article) { create(:article, user: user) }
|
||||
|
||||
let(:max_age) { 15.minutes.to_i }
|
||||
let(:stale_if_error) { 26_400 }
|
||||
|
||||
describe "GET /:username/:slug/display_ads/:placement_area" do
|
||||
describe "GET /:username/:slug/billboards/:placement_area" do
|
||||
before do
|
||||
create(:display_ad, placement_area: "post_comments", published: true, approved: true)
|
||||
end
|
||||
|
||||
it "returns the correct response" do
|
||||
get article_display_ad_path(username: article.username, slug: article.slug, placement_area: "post_comments")
|
||||
get article_billboard_path(username: article.username, slug: article.slug, placement_area: "post_comments")
|
||||
display_ad = DisplayAd.find_by(placement_area: "post_comments")
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
|
|
@ -23,7 +23,7 @@ RSpec.describe "DisplayAds" do
|
|||
context "when signed in" do
|
||||
before do
|
||||
sign_in user
|
||||
get article_display_ad_path(username: article.username, slug: article.slug, placement_area: "post_comments")
|
||||
get article_billboard_path(username: article.username, slug: article.slug, placement_area: "post_comments")
|
||||
end
|
||||
|
||||
it "does not set surrogate key headers" do
|
||||
|
|
@ -44,7 +44,7 @@ RSpec.describe "DisplayAds" do
|
|||
|
||||
context "when signed out" do
|
||||
before do
|
||||
get article_display_ad_path(username: article.username, slug: article.slug, placement_area: "post_comments")
|
||||
get article_billboard_path(username: article.username, slug: article.slug, placement_area: "post_comments")
|
||||
end
|
||||
|
||||
it "sets the surrogate key header equal to params for article" do
|
||||
Loading…
Add table
Reference in a new issue