Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fixed bug where modified fields were cached wrong
  • Loading branch information
joshmh committed Jan 24, 2009
1 parent 97bb03a commit 0e5e8e7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/globalize/model/active_record/adapter.rb
Expand Up @@ -31,6 +31,7 @@ def fetch(locale, attr_name)


def stash(locale, attr_name, value) def stash(locale, attr_name, value)
@stash.write locale, attr_name, value @stash.write locale, attr_name, value
@cache.write locale, attr_name, value
end end


def update_translations! def update_translations!
Expand Down
19 changes: 19 additions & 0 deletions test/model/active_record/translated_test.rb
Expand Up @@ -15,6 +15,25 @@ def setup
reset_db! reset_db!
end 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 test "has post_translations" do
post = Post.create post = Post.create
assert_nothing_raised { post.globalize_translations } assert_nothing_raised { post.globalize_translations }
Expand Down

0 comments on commit 0e5e8e7

Please sign in to comment.