summaryrefslogtreecommitdiff
path: root/test/models
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-08-09 15:45:56 +0200
committererdgeist <erdgeist@erdgeist.org>2026-08-09 15:45:56 +0200
commit9d32458491d79f8e06a706375030c78282f4427b (patch)
tree5eee208b844df39dfd66d9f0d1618fb5fa437fdb /test/models
parented3905b5409190c1e11c2c49c2163ac967c6d8b9 (diff)
Report every editorial attribute in the revision diff
diff_against gained external_url, published_at and user. The view renders each metadata section only when that attribute changed, and says so once when none did. Metadata now precedes the locale pointer, which speaks only of translations: above the metadata it read as "nothing changed" on a revision that had moved the page.
Diffstat (limited to 'test/models')
-rw-r--r--test/models/page_test.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/models/page_test.rb b/test/models/page_test.rb
index b737e8b0..f095a7e1 100644
--- a/test/models/page_test.rb
+++ b/test/models/page_test.rb
@@ -302,6 +302,34 @@ class PageTest < ActiveSupport::TestCase
302 assert_equal "title_only", diff[:template_name][:to] 302 assert_equal "title_only", diff[:template_name][:to]
303 end 303 end
304 304
305 test "diff_against reports external URL, publication date and author changes" do
306 n = Node.root.children.create! :slug => "meta_diff_test"
307 d = find_or_create_draft(n, @user1)
308 d.external_url = "https://old.example.org/"
309 d.published_at = Time.utc(2026, 1, 1, 12, 0, 0)
310 d.save!
311 n.publish_draft!
312
313 new_author = User.where.not(:id => n.head.user_id).first
314 d2 = find_or_create_draft(n, @user1)
315 d2.external_url = "https://new.example.org/"
316 d2.published_at = Time.utc(2026, 3, 1, 12, 0, 0)
317 d2.user = new_author
318 d2.save!
319
320 diff = d2.diff_against(n.head)
321
322 assert diff[:external_url][:changed]
323 assert_equal "https://old.example.org/", diff[:external_url][:from]
324 assert_equal "https://new.example.org/", diff[:external_url][:to]
325
326 assert diff[:published_at][:changed]
327 assert_equal Time.utc(2026, 3, 1, 12, 0, 0).to_i, diff[:published_at][:to].to_i
328
329 assert diff[:user][:changed]
330 assert_equal new_author.login, diff[:user][:to].login
331 end
332
305 test "diff_against reports added and removed assets by filename" do 333 test "diff_against reports added and removed assets by filename" do
306 n = Node.root.children.create! :slug => "asset_diff_test" 334 n = Node.root.children.create! :slug => "asset_diff_test"
307 d = find_or_create_draft(n, @user1) 335 d = find_or_create_draft(n, @user1)