Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change set_cache_headers to before_action #302

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
class PagesController < ApplicationController
before_action :require_website, only: :show
before_action :require_page, only: :show

after_action :set_cache_headers, only: :show
before_action :set_cache_headers, only: :show

def current_styleguide
end
Expand Down
3 changes: 1 addition & 2 deletions app/controllers/programs_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
class ProgramsController < ApplicationController
before_action :require_website

after_action :set_cache_headers, only: :show
before_action :set_cache_headers, only: :show

def show
@program_sessions = current_website.event.program_sessions.live
Expand Down
5 changes: 2 additions & 3 deletions app/controllers/schedule_controller.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
class ScheduleController < ApplicationController
include WebsiteScheduleHelper
before_action :require_event

after_action :set_cache_headers, only: :show
before_action :set_cache_headers, only: :show

decorates_assigned :schedule, with: Staff::TimeSlotDecorator

def show
@schedule = current_event.time_slots.grid_order.includes(:room, program_session: { proposal: {speakers: :user}})
render layout: "themes/#{current_website.theme}"
end
end
end
3 changes: 1 addition & 2 deletions app/controllers/sponsors_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
class SponsorsController < ApplicationController
before_action :require_website

after_action :set_cache_headers, only: :show
before_action :set_cache_headers, only: :show

def show
@sponsors_by_tier = Sponsor.published.order_by_tier.group_by(&:tier)
Expand Down
9 changes: 9 additions & 0 deletions spec/features/website/page_viewing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,13 @@
visit landing_path(slug: website.event.slug)
expect(page).to have_content("Page Not Found")
end

scenario 'Public views a cached page twice and gets 304 without rendering', :caching, :js do
website.update(caching: :automatic)
create(:page, published_body: 'Home Content', landing: true)

expect_any_instance_of(PagesController).to receive(:show).once.and_call_original
visit landing_path(slug: website.event.slug)
visit landing_path(slug: website.event.slug)
end
end