Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed bug where modified fields were cached wrong

  • Loading branch information...
commit 0e5e8e70e231b7029e59d13a2fbb0c4d3b4a4d97 1 parent 97bb03a
@joshmh joshmh authored
View
1  lib/globalize/model/active_record/adapter.rb
@@ -31,6 +31,7 @@ def fetch(locale, attr_name)
def stash(locale, attr_name, value)
@stash.write locale, attr_name, value
+ @cache.write locale, attr_name, value
end
def update_translations!
View
19 test/model/active_record/translated_test.rb
@@ -15,6 +15,25 @@ def setup
reset_db!
end
+ test "modifiying translated fields" do
+ post = Post.create :subject => 'foo'
+ assert_equal 'foo', post.subject
+ post.subject = 'bar'
+ assert_equal 'bar', post.subject
+ end
+
+ test "modifiying translated fields while switching locales" do
+ post = Post.create :subject => 'foo'
+ assert_equal 'foo', post.subject
+ I18n.locale = :'de-DE'
+ post.subject = 'bar'
+ assert_equal 'bar', post.subject
+ I18n.locale = :'en-US'
+ assert_equal 'foo', post.subject
+ I18n.locale = :'de-DE'
+ post.subject = 'bar'
+ end
+
test "has post_translations" do
post = Post.create
assert_nothing_raised { post.globalize_translations }
Please sign in to comment.
Something went wrong with that request. Please try again.