Forum: Ruby on Rails Globalize not with Rails 1.1.2

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Doug D. (Guest)
on 2006-04-14 02:48
Does anybody have the latest Globalize (r184) working with Rails 1.1.2?

I can't seem to get a very simple example to work:
-----
ruby test/unit/news_item_test.rb
Loaded suite test/unit/news_item_test
Started
F.
Finished in 0.10109 seconds.

  1) Failure:
test_add_content_translations(NewsItemTest)
[test/unit/news_item_test.rb:49]:
<"US Title"> expected but was
<"NL Titel">.

2 tests, 8 assertions, 1 failures, 0 errors
-----

news_item_test.rb based on
http://wiki.globalize-rails.org/wiki/pages/example
-----
require File.dirname(__FILE__) + '/../test_helper'

class NewsItemTest < Test::Unit::TestCase
  # Uncomment the following line if the test/fixtures are used
  # fixtures :globalize_countries, :globalize_languages,
:globalize_translations

  def test_add_content_translations
    NewsItem.delete_all

    Globalize::Locale.set_base_language('en-US')

    # create a row in the base language
    Globalize::Locale.set('en-US')
    assert_nothing_raised() do
      assert_kind_of NewsItem, NewsItem.create!(:title => 'US Title',
                                                :excerpt => 'US
excerpt',
                                                :body => 'US body copy')
    end
    assert_equal 1, NewsItem.find(:all).size

    # retrieve row
    news_item = NewsItem.find(:first)
    assert_kind_of NewsItem, news_item
    assert_equal 'US Title', news_item.title

    # create a translation by switching the locale and updating
attributes
    Globalize::Locale.set('nl-NL')
    # news_item.title = 'NL Titel'
    # news_item.excerpt = 'NL samenvatting.'
    # news_item.body = 'NL Broodtekst.'
    # assert_nothing_raised() {news_item.save!}

    # either use the commented out code above or the line below

    #As you cannot load in one language and save in another...
    news_item = NewsItem.find(:first)
    news_item.update_attributes(:title => 'NL Titel',
                               :excerpt => 'NL samenvatting.',
                               :body => 'NL broodtekst')

    # check if the translated row has been saved
    assert_equal 'NL Titel', news_item.title

    # check if the base language row still exists
    Globalize::Locale.set('en-US')

    # now see if the example from the wiki gives the expected result
    news_item = NewsItem.find(:first)
    assert_equal 'US Title', news_item.title

    Globalize::Locale.set('nl-NL')
    news_item = NewsItem.find(news_item.id)
    assert_equal 'NL Titel', news_item.title
  end

  def test_add_string_translations
    Globalize::Locale.set_base_language('en-US')
    Globalize::Locale.set('en-US')

    language = Globalize::Language.pick 'nl-NL'
    Globalize::Locale.set_translation(
      "This is written in English",
      language,
      "Dit is geschreven in het Nederlands"
    )

    assert_equal 'This is written in English', "This is written in
English".t

    Globalize::Locale.set('nl-NL')
    assert_equal 'Dit is geschreven in het Nederlands', "This is written
in English".t
  end
end
-----
This topic is locked and can not be replied to.