summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/models/page.rb5
-rw-r--r--test/unit/page_test.rb10
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
134 end 134 end
135 135
136 # Returns true if a page has translations where one of them is significantly 136 # Returns true if a page has translations where one of them is significantly
137 # older than the other 137 # older than the other.
138 # Takes the I18n.default locale and a second :locale to test if the 138 # Takes the I18n.default locale and a second :locale to test if the
139 # translations for the given locales exist and if their updated_at attributes 139 # translations for the given locales exist and if their updated_at attributes
140 # have a delta time that is greater than the specified :delta_time 140 # have a delta time that is greater than the specified :delta_time
@@ -156,8 +156,7 @@ class Page < ActiveRecord::Base
156 if translations.size > 1 && default && custom 156 if translations.size > 1 && default && custom
157 time = default.updated_at - custom.updated_at 157 time = default.updated_at - custom.updated_at
158 difference = time.to_i.abs 158 difference = time.to_i.abs
159 159 return (options[:delta_time].to_i.abs < difference)
160 return (options[:delta_time].abs < difference)
161 else 160 else
162 return false 161 return false
163 end 162 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
128 english.update_attributes(:updated_at => (Time.now+25.hours)) 128 english.update_attributes(:updated_at => (Time.now+25.hours))
129 PageTranslation.record_timestamps = true 129 PageTranslation.record_timestamps = true
130 assert_equal 1, Page.find_with_outdated_translations.count 130 assert_equal 1, Page.find_with_outdated_translations.count
131
132 I18n.locale = :de
133 page2 = Page.create!( :title => "Hallo2" )
134 I18n.locale = :en
135 page2.title = "Hello2"
136 page2.save!
137
138 assert_equal 0, Page.find_with_outdated_translations(:delta_time => 23.days).count
139 assert_equal 1, Page.find_with_outdated_translations(:delta_time => 23.minutes).count
140 assert_equal 2, Page.count
131 end 141 end
132end 142end