diff options
| author | hukl <contact@smyck.org> | 2009-03-29 00:00:47 +0100 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-03-29 00:00:47 +0100 |
| commit | fb25bab7dd0ac761702d23ff60decbca9d03dd56 (patch) | |
| tree | 956517f36ebc20874109cf286c6a3930b652b64a /test/unit/page_test.rb | |
| parent | b03132fb4c6fa7a2f37005440ac42497d189a6eb (diff) | |
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
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 |
