Skip to content

Commit

Permalink
Touch page version's updated at when updating
Browse files Browse the repository at this point in the history
Without this, the previous commit will not do what we expect. If we
don´t update the page version's updated at, it will not serve as a good
cache invalidator.
  • Loading branch information
mamhoff committed May 13, 2024
1 parent 62fa05b commit 3eb93f9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/models/alchemy/page/publisher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def publish!(public_on:)
end
end
end
version.update(updated_at: public_on)
page.update(published_at: public_on)
end
end
Expand Down
4 changes: 4 additions & 0 deletions spec/models/alchemy/page/publisher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@
expect { publish }.to_not change(page.public_version, :public_on)
end

it "updates public version's updated_at timestamp" do
expect { publish }.to change(page.public_version, :updated_at)
end

it "does not create another public version" do
expect { publish }.to_not change(page.versions, :count)
end
Expand Down
4 changes: 2 additions & 2 deletions spec/models/alchemy/page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -711,13 +711,13 @@ module Alchemy
end

around do |example|
travel_to(Time.parse("2019-01-01 12:00:00")) do
travel_to(Time.parse("2019-01-01 12:00:00 UTC")) do
example.run
end
end

it "returns a cache version string" do
expect(page.cache_version).to eq("2018-12-31 11:00:00 UTC")
expect(page.cache_version).to eq("2018-12-31 12:00:00 UTC")
end
end

Expand Down

0 comments on commit 3eb93f9

Please sign in to comment.