@@ -227,29 +227,42 @@ module Alchemy
227227 let ( :content_pages ) { [ content_page_1 , content_page_2 ] }
228228 let ( :layout_pages ) { [ layout_page_1 , layout_page_2 ] }
229229
230- it "should update the updated_at field of content pages" do
231- content_pages
230+ it "should not update the updated_at field of pages" do
231+ pages = content_pages + layout_pages
232232
233233 travel_to ( Time . current ) do
234- post flush_admin_pages_path , xhr : true
235- # Reloading because updated_at was directly updated in the database.
236- content_pages . map ( & :reload )
237- content_pages . each do | page |
238- expect ( page . updated_at ) . to eq ( Time . current )
239- end
234+ expect {
235+ post flush_admin_pages_path , xhr : true
236+ } . to_not change {
237+ # Reloading because updated_at was directly updated in the database.
238+ pages . map { _1 . reload . updated_at }
239+ }
240240 end
241241 end
242242
243- it "should update the updated_at field of layout pages " do
244- layout_pages
243+ it "should update the updated_at field of public versions " do
244+ page_versions = content_pages . filter_map ( & :public_version )
245245
246246 travel_to ( Time . current ) do
247- post flush_admin_pages_path , xhr : true
248- # Reloading because updated_at was directly updated in the database.
249- layout_pages . map ( &:reload )
250- layout_pages . each do |page |
251- expect ( page . updated_at ) . to eq ( Time . current )
252- end
247+ expect {
248+ post flush_admin_pages_path , xhr : true
249+ } . to change {
250+ # Reloading because updated_at was directly updated in the database.
251+ page_versions . map { _1 . reload . updated_at }
252+ }
253+ end
254+ end
255+
256+ it "should not update the updated_at field of draft versions" do
257+ page_versions = content_pages . filter_map ( &:draft_version )
258+
259+ travel_to ( Time . current ) do
260+ expect {
261+ post flush_admin_pages_path , xhr : true
262+ } . to_not change {
263+ # Reloading because updated_at was directly updated in the database.
264+ page_versions . map { _1 . reload . updated_at }
265+ }
253266 end
254267 end
255268 end
0 commit comments