@@ -125,29 +125,42 @@ module Alchemy
125125 let ( :content_pages ) { [ content_page_1 , content_page_2 ] }
126126 let ( :layout_pages ) { [ layout_page_1 , layout_page_2 ] }
127127
128- it "should update the updated_at field of content pages" do
129- content_pages
128+ it "should not update the updated_at field of pages" do
129+ pages = content_pages + layout_pages
130130
131131 travel_to ( Time . current ) do
132- post flush_admin_pages_path , xhr : true
133- # Reloading because updated_at was directly updated in the database.
134- content_pages . map ( & :reload )
135- content_pages . each do | page |
136- expect ( page . updated_at ) . to eq ( Time . current )
137- end
132+ expect {
133+ post flush_admin_pages_path , xhr : true
134+ } . to_not change {
135+ # Reloading because updated_at was directly updated in the database.
136+ pages . map { _1 . reload . updated_at }
137+ }
138138 end
139139 end
140140
141- it "should update the updated_at field of layout pages " do
142- layout_pages
141+ it "should update the updated_at field of public versions " do
142+ page_versions = content_pages . map ( & :public_version )
143143
144144 travel_to ( Time . current ) do
145- post flush_admin_pages_path , xhr : true
146- # Reloading because updated_at was directly updated in the database.
147- layout_pages . map ( &:reload )
148- layout_pages . each do |page |
149- expect ( page . updated_at ) . to eq ( Time . current )
150- end
145+ expect {
146+ post flush_admin_pages_path , xhr : true
147+ } . to change {
148+ # Reloading because updated_at was directly updated in the database.
149+ page_versions . map { _1 . reload . updated_at }
150+ }
151+ end
152+ end
153+
154+ it "should not update the updated_at field of draft versions" do
155+ page_versions = content_pages . map ( &:draft_version )
156+
157+ travel_to ( Time . current ) do
158+ expect {
159+ post flush_admin_pages_path , xhr : true
160+ } . to_not change {
161+ # Reloading because updated_at was directly updated in the database.
162+ page_versions . map { _1 . reload . updated_at }
163+ }
151164 end
152165 end
153166 end
0 commit comments