diff options
Diffstat (limited to 'test/unit/page_test.rb')
| -rw-r--r-- | test/unit/page_test.rb | 24 |
1 files changed, 24 insertions, 0 deletions
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 | |||
| 105 | 105 | ||
| 106 | assert_equal after, d.body | 106 | assert_equal after, d.body |
| 107 | end | 107 | end |
| 108 | |||
| 109 | def test_find_with_outdated_translations | ||
| 110 | Node.delete_all | ||
| 111 | Page.delete_all | ||
| 112 | I18n.locale = :de | ||
| 113 | |||
| 114 | assert_not_nil page = Page.create!( :title => "Hallo" ) | ||
| 115 | page.reload | ||
| 116 | assert_equal 2, page.globalize_translations.size | ||
| 117 | assert_equal [], Page.find_with_outdated_translations | ||
| 118 | |||
| 119 | I18n.locale = :en | ||
| 120 | page.title = "Hello" | ||
| 121 | page.save | ||
| 122 | |||
| 123 | assert_equal 3, page.globalize_translations.size | ||
| 124 | assert_equal 0, Page.find_with_outdated_translations.count | ||
| 125 | |||
| 126 | english = *page.globalize_translations.select {|x| x.locale == :en} | ||
| 127 | PageTranslation.record_timestamps = false | ||
| 128 | english.update_attributes(:updated_at => (Time.now+25.hours)) | ||
| 129 | PageTranslation.record_timestamps = true | ||
| 130 | assert_equal 1, Page.find_with_outdated_translations.count | ||
| 131 | end | ||
| 108 | end | 132 | end |
