attr-translatable 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,6 +15,13 @@ module AttrTranslatable
15
15
  internal_translate(attr, lang)
16
16
  end
17
17
 
18
+ def translated_all?(lang)
19
+ lang = lang.to_s
20
+ self.class.translatable_attrs.all? do |attr|
21
+ AttrTranslation.exists? :attr => attr, :lang => lang, :model_id => self.id, :model_type => self.class.name
22
+ end
23
+ end
24
+
18
25
  private
19
26
 
20
27
  def new_translation(attr, lang, translation)
@@ -1,3 +1,3 @@
1
1
  module AttrTranslatable
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -80,5 +80,18 @@ describe ActiveRecord::Base do
80
80
  end
81
81
  end
82
82
  end
83
+
84
+ describe "#translated_all?" do
85
+ it "returns false if not all translatable attr is translated" do
86
+ @post.translated_all?(:ja).should be_false
87
+ @post.update_translation(:title, :ja, "ブログのタイトル")
88
+ @post.translated_all?(:ja).should be_false
89
+ end
90
+ it "returns true if all translatable attr is translated" do
91
+ @post.update_translation(:title, :ja, "ブログのタイトル")
92
+ @post.update_translation(:content, :ja, "ブログのコンテンツ")
93
+ @post.translated_all?(:ja).should be_true
94
+ end
95
+ end
83
96
  end
84
97
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attr-translatable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -140,7 +140,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
140
140
  version: '0'
141
141
  segments:
142
142
  - 0
143
- hash: -1987629538429590803
143
+ hash: -2579796850564710956
144
144
  required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  none: false
146
146
  requirements:
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
149
  version: '0'
150
150
  segments:
151
151
  - 0
152
- hash: -1987629538429590803
152
+ hash: -2579796850564710956
153
153
  requirements: []
154
154
  rubyforge_project:
155
155
  rubygems_version: 1.8.24