Skip to content

Commit

Permalink
Remove Page#published_at overwrite
Browse files Browse the repository at this point in the history
We need the value from the database in all cases in order to be able
to use it as the last_modified header. The overwrite is not necessary
for the cache_key (ETag header) since it already takes the use case
for admins into account.
  • Loading branch information
tvdeyen committed Aug 19, 2021
1 parent f2d7534 commit fa841c1
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 12 deletions.
9 changes: 0 additions & 9 deletions app/models/alchemy/page/page_natures.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,6 @@ def cache_key
end
end

# We use the published_at value for the cache_key.
#
# If no published_at value is set yet, i.e. because it was never published,
# we return the updated_at value.
#
def published_at
read_attribute(:published_at) || updated_at
end

# Returns true if the page cache control headers should be set.
#
# == Disable Alchemy's page caching globally
Expand Down
4 changes: 1 addition & 3 deletions spec/models/alchemy/page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1871,9 +1871,7 @@ class AnotherUrlPathClass; end
let(:updated_at) { 3.days.ago }
let(:page) { build_stubbed(:alchemy_page, published_at: nil, updated_at: updated_at) }

it "returns the updated_at value" do
expect(page.published_at).to be_within(1.second).of(updated_at)
end
it { expect(page.published_at).to be_nil }
end
end

Expand Down

0 comments on commit fa841c1

Please sign in to comment.