svenfuchs/globalize3 — pull request #255 by shioyama (2013-07-18 12:05:12+00:00)
Title: add failing test for case when creating record in other locale.

Changing `Globalize.locale` in the `CreateRowTest` makes the test fail. In other words, this operation:

````ruby
Globalize.with_locale(:de) { account = Page.create!(:title => 'title v1') }
````

performs an `UPDATE` operation, when there is no logical reason it should.

The source of the problem is this block of code, which has been updated for rails4:

````ruby
def translated_attributes
translated_attribute_names.inject({}) do |attributes, name|
if self.respond_to?(name) && Globalize.locale == I18n.default_locale
attributes.merge(name.to_s => self.send(name))
else
attributes.merge(name.to_s => translation.send(name))
end
end
end
````

If the `Globalize.locale == I18n.default_locale` condition is removed from the if/else block, then this test passes but another (versioning) test fails.

I'm actually not entirely clear of the logic for why this locale check is here in the first place, and in particular why we're checking against `I18n.default_locale`.

But in any case, from what I can tell, the problem is not the return value of this function, but the fact that calling `translation.send(name)` here actually *changes* state: it caches the translated attribute value in `translation_caches` and this subsequently changes how rails saves the record.

Still investigating how to fix this problem, but at least for now this is one concrete case to tackle.