Skip to content

Commit

Permalink
added translated_locales
Browse files Browse the repository at this point in the history
  • Loading branch information
joshmh committed Feb 24, 2009
1 parent 7e7fc29 commit bb4d1ad
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/globalize/model/active_record/translated.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ def globalize
def update_globalize_record
globalize.update_translations!
end

def translated_locales
globalize_translations.map {|gt| gt.locale.to_sym }
end
end
end
end
Expand Down
11 changes: 11 additions & 0 deletions test/model/active_record/translated_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,17 @@ def teardown
Globalize::Model::ActiveRecord::Translated::ActMethods.class_eval "remove_class_variable(:@@locale)"
assert_nothing_raised { ActiveRecord::Base.locale }
end

test "translated_locales" do
Post.locale = :de
post = Post.create :subject => 'foo'
Post.locale = :es
post.update_attribute :subject, 'bar'
Post.locale = :fr
post.update_attribute :subject, 'baz'
assert_equal [ :de, :es, :fr ], post.translated_locales
assert_equal [ :de, :es, :fr ], Post.first.translated_locales
end
end

# TODO should validate_presence_of take fallbacks into account? maybe we need
Expand Down

0 comments on commit bb4d1ad

Please sign in to comment.