Skip to content

Commit

Permalink
Touch page if page version gets updated
Browse files Browse the repository at this point in the history
Crucial for page caching
  • Loading branch information
tvdeyen committed Aug 19, 2021
1 parent 6f02825 commit 329d257
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/alchemy/page_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Alchemy
class PageVersion < BaseRecord
belongs_to :page, class_name: "Alchemy::Page", inverse_of: :versions
belongs_to :page, class_name: "Alchemy::Page", inverse_of: :versions, touch: true

has_many :elements, -> { order(:position) },
class_name: "Alchemy::Element",
Expand Down
10 changes: 10 additions & 0 deletions spec/models/alchemy/page_version_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@
end
end

describe "when saved" do
let(:page_version) { build(:alchemy_page_version) }
let(:page) { page_version.page }

it "touches the page" do
expect(page).to receive(:touch)
page_version.save
end
end

describe "#public?" do
subject { page_version.public? }

Expand Down

0 comments on commit 329d257

Please sign in to comment.