simple_model_translations 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
@@ -6,10 +6,11 @@ module SimpleModelTranslations
6
6
 
7
7
  def translation_class
8
8
  begin
9
- klass = Module.const_get(translation_class_name.to_sym)
9
+ klass = const_get(translation_class_name.to_sym)
10
10
  rescue NameError => e
11
- klass = Module.const_set(translation_class_name.to_sym, Class.new(ActiveRecord::Base))
11
+ klass = const_set(translation_class_name.to_sym, Class.new(ActiveRecord::Base))
12
12
  klass.translation_for(self.name.underscore.to_sym)
13
+ klass.set_table_name(translation_class_name.underscore.pluralize)
13
14
  end
14
15
  klass
15
16
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{simple_model_translations}
8
- s.version = "0.1.2"
8
+ s.version = "0.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Pavel Forkert"]
@@ -45,6 +45,7 @@ Gem::Specification.new do |s|
45
45
  s.summary = %q{Simple ActiveRecord translations for Rails 3}
46
46
  s.test_files = [
47
47
  "spec/attributes_spec.rb",
48
+ "spec/auto_generated_translation_classes_spec.rb",
48
49
  "spec/class_methods_spec.rb",
49
50
  "spec/data/models.rb",
50
51
  "spec/data/schema.rb",
@@ -0,0 +1,15 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Tag do
4
+ it "should create translation class automatically if it doesn't exists" do
5
+ Tag.translation_class.should_not be_nil
6
+ Tag.translation_class.table_name.should == 'tag_translations'
7
+ end
8
+
9
+ it "should be" do
10
+ tag = Tag.new(:locale => :en, :name => 'hello')
11
+ tag.name.should be_nil
12
+ I18n.locale = :en
13
+ tag.name.should == 'hello'
14
+ end
15
+ end
data/spec/data/schema.rb CHANGED
@@ -22,5 +22,14 @@ ActiveRecord::Schema.define do
22
22
  t.string :name
23
23
  t.text :content
24
24
  end
25
+
26
+ create_table :tags, :force => true do |t|
27
+ end
28
+
29
+ create_table :tag_translations, :force => true do |t|
30
+ t.string :locale
31
+ t.references :tag
32
+ t.string :name
33
+ end
25
34
  end
26
35
 
@@ -24,11 +24,6 @@ describe Article do
24
24
  I18n.locale = :de
25
25
  article.name.should == 'Hello'
26
26
  end
27
-
28
- it "should create translation class automatically if it doesn't exists" do
29
- Tag.translation_class.should_not be_nil
30
- Tag.translation_class.table_name.should == 'tag_translations'
31
- end
32
27
  end
33
28
 
34
29
  describe ArticleTranslation do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple_model_translations
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Pavel Forkert
@@ -146,6 +146,7 @@ files:
146
146
  - spec/simple_model_translations_spec.rb
147
147
  - spec/spec_helper.rb
148
148
  - spec/validations_spec.rb
149
+ - spec/auto_generated_translation_classes_spec.rb
149
150
  has_rdoc: true
150
151
  homepage: http://github.com/fxposter/simple_model_translations
151
152
  licenses: []
@@ -182,6 +183,7 @@ specification_version: 3
182
183
  summary: Simple ActiveRecord translations for Rails 3
183
184
  test_files:
184
185
  - spec/attributes_spec.rb
186
+ - spec/auto_generated_translation_classes_spec.rb
185
187
  - spec/class_methods_spec.rb
186
188
  - spec/data/models.rb
187
189
  - spec/data/schema.rb