From fb25bab7dd0ac761702d23ff60decbca9d03dd56 Mon Sep 17 00:00:00 2001 From: hukl Date: Sun, 29 Mar 2009 00:00:47 +0100 Subject: Added unit test to verify the basic functionality of the find_with_outdated_translations method. Found and fixed some issued on the way. [ x ] Testing rocks --- test/unit/page_test.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'test') diff --git a/test/unit/page_test.rb b/test/unit/page_test.rb index 77c6243..04a7ba5 100644 --- a/test/unit/page_test.rb +++ b/test/unit/page_test.rb @@ -105,4 +105,28 @@ class PageTest < ActiveSupport::TestCase assert_equal after, d.body end + + def test_find_with_outdated_translations + Node.delete_all + Page.delete_all + I18n.locale = :de + + assert_not_nil page = Page.create!( :title => "Hallo" ) + page.reload + assert_equal 2, page.globalize_translations.size + assert_equal [], Page.find_with_outdated_translations + + I18n.locale = :en + page.title = "Hello" + page.save + + assert_equal 3, page.globalize_translations.size + assert_equal 0, Page.find_with_outdated_translations.count + + english = *page.globalize_translations.select {|x| x.locale == :en} + PageTranslation.record_timestamps = false + english.update_attributes(:updated_at => (Time.now+25.hours)) + PageTranslation.record_timestamps = true + assert_equal 1, Page.find_with_outdated_translations.count + end end -- cgit v1.3