Skip to content

Commit

Permalink
Update the updated_at field of the page itself when a page_part got u…
Browse files Browse the repository at this point in the history
…pdated
  • Loading branch information
veger committed Jan 9, 2017
1 parent 56e02c6 commit 243e2b7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pages/app/models/refinery/page_part.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Refinery
class PagePart < Refinery::Core::BaseModel

belongs_to :page, :foreign_key => :refinery_page_id
belongs_to :page, :foreign_key => :refinery_page_id, :touch => true

before_validation :set_default_slug

Expand Down
10 changes: 10 additions & 0 deletions pages/spec/models/refinery/page_part_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ module Refinery
expect(part_two.errors[:slug]).to be_empty
end

it 'updates the page updated_at field when changed' do
page.save
original_updated_at = page.updated_at

page.parts.first.content = 'Modified'
page.parts.first.save

expect(original_updated_at).to be < page.updated_at
end

context 'when using content_for?' do

it 'return true when page part has content' do
Expand Down

0 comments on commit 243e2b7

Please sign in to comment.