Add ability to view specific billboard via params in any context if it is live (#20599)
* Fix AudienceSegmentRefreshAllWorker args issue * Add ability to view specific billboard via params if it is live * Fix lingering * Refactor to clean up
This commit is contained in:
parent
b43cb38d40
commit
2d9c87d9d3
2 changed files with 19 additions and 1 deletions
|
|
@ -68,7 +68,10 @@ class BillboardsController < ApplicationController
|
|||
end
|
||||
|
||||
def return_test_billboard?
|
||||
params[:bb_test_placement_area] == placement_area && params[:bb_test_id].present? && current_user&.any_admin?
|
||||
param_present = params[:bb_test_placement_area] == placement_area && params[:bb_test_id].present?
|
||||
present_and_admin = param_present && current_user&.any_admin?
|
||||
present_and_live = param_present && Billboard.approved_and_published.where(id: params[:bb_test_id]).any?
|
||||
present_and_admin || present_and_live
|
||||
end
|
||||
|
||||
def cookies_allowed?
|
||||
|
|
|
|||
|
|
@ -205,6 +205,21 @@ RSpec.describe "Billboards" do
|
|||
expect(response.body).not_to include(test_billboard.processed_html)
|
||||
end
|
||||
|
||||
it "does return live billboards for non-admin contexts" do
|
||||
# Create a few live billboards which should not be returned
|
||||
create_list(:billboard, 8, placement_area: "post_sidebar", approved: true, published: true)
|
||||
get article_billboard_path(
|
||||
username: article.username,
|
||||
slug: article.slug,
|
||||
placement_area: "post_sidebar",
|
||||
bb_test_placement_area: "post_sidebar",
|
||||
bb_test_id: billboard.id,
|
||||
)
|
||||
|
||||
expect(response).to have_http_status(:ok)
|
||||
expect(response.body).to include(billboard.processed_html)
|
||||
end
|
||||
|
||||
it "does not return the test billboard for non-admin users" do
|
||||
sign_out admin
|
||||
sign_in create(:user)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue