From c2fa7429dfb10a018731320a49e7ea061feef784 Mon Sep 17 00:00:00 2001 From: hukl Date: Sun, 29 Mar 2009 14:14:56 +0200 Subject: a few more assertions --- app/models/page.rb | 5 ++--- test/unit/page_test.rb | 10 ++++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/models/page.rb b/app/models/page.rb index ee1e70a..b11b43c 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -134,7 +134,7 @@ class Page < ActiveRecord::Base end # Returns true if a page has translations where one of them is significantly - # older than the other + # older than the other. # Takes the I18n.default locale and a second :locale to test if the # translations for the given locales exist and if their updated_at attributes # have a delta time that is greater than the specified :delta_time @@ -156,8 +156,7 @@ class Page < ActiveRecord::Base if translations.size > 1 && default && custom time = default.updated_at - custom.updated_at difference = time.to_i.abs - - return (options[:delta_time].abs < difference) + return (options[:delta_time].to_i.abs < difference) else return false end diff --git a/test/unit/page_test.rb b/test/unit/page_test.rb index 04a7ba5..2ada6de 100644 --- a/test/unit/page_test.rb +++ b/test/unit/page_test.rb @@ -128,5 +128,15 @@ class PageTest < ActiveSupport::TestCase english.update_attributes(:updated_at => (Time.now+25.hours)) PageTranslation.record_timestamps = true assert_equal 1, Page.find_with_outdated_translations.count + + I18n.locale = :de + page2 = Page.create!( :title => "Hallo2" ) + I18n.locale = :en + page2.title = "Hello2" + page2.save! + + assert_equal 0, Page.find_with_outdated_translations(:delta_time => 23.days).count + assert_equal 1, Page.find_with_outdated_translations(:delta_time => 23.minutes).count + assert_equal 2, Page.count end end -- cgit v1.3