efficient_translations 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- efficient_translations (0.0.4)
4
+ efficient_translations (0.0.5)
5
5
  activerecord (~> 2.3)
6
6
  activesupport (~> 2.3)
7
7
 
@@ -114,7 +114,7 @@ module EfficientTranslations
114
114
  end
115
115
 
116
116
  def default_locale_required
117
- unless translations.detect { |t| t.locale.to_sym == I18n.default_locale }
117
+ if efficient_translations_attributes[I18n.default_locale.to_sym].blank? && translations.detect { |t| t.locale.to_sym == I18n.default_locale.to_sym }.nil?
118
118
  # people may expect this message to be localized too ;-)
119
119
  errors.add :translations, "for #{I18n.default_locale} is missing"
120
120
  end
@@ -9,9 +9,9 @@ module EfficientTranslations
9
9
  table_name = "#{base_model.table_name.singularize}_translations"
10
10
  cattr_accessor :translatable_model, :translatable_relation_field
11
11
  self.translatable_model = base_model
12
- self.translatable_relation_field = base_model.name.underscore.gsub '/', '_'
12
+ self.translatable_relation_field = base_model.model_name.underscore.gsub '/', '_'
13
13
 
14
- belongs_to translatable_relation_field
14
+ belongs_to translatable_relation_field, :class_name => self.translatable_model.name
15
15
  before_save :stringify_locale!
16
16
 
17
17
  named_scope :for_locale, lambda { |locale|
@@ -1,3 +1,3 @@
1
1
  module EfficientTranslations
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -4,7 +4,7 @@ require 'active_record'
4
4
  describe EfficientTranslations do
5
5
  def my_model_class
6
6
  Kernel.silence_warnings do
7
- Kernel.const_set :MyModel, Class.new(ActiveRecord::Base)
7
+ Object.const_set :MyModel, Class.new(ActiveRecord::Base)
8
8
  end
9
9
  end
10
10
 
@@ -47,8 +47,9 @@ describe EfficientTranslations do
47
47
  model = my_model_class
48
48
  model.translates :name
49
49
  model.validates_presence_of_default_locale
50
- lambda { model.new.save! }.should raise_error ActiveRecord::RecordInvalid
51
- inst = model.new :translations_attributes => [{ :locale => :en, :name => 'pippo' }]
50
+ inst = model.new
51
+ lambda { inst.save! }.should raise_error ActiveRecord::RecordInvalid
52
+ inst.set_name_translation I18n.default_locale, 'pippo'
52
53
  lambda { inst.save! }.should_not raise_error
53
54
  end
54
55
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe EfficientTranslations::TranslationFactory do
4
4
  before :each do
5
5
  Kernel.silence_warnings do
6
- @model_class = Kernel.const_set :MyModel, Class.new(ActiveRecord::Base)
6
+ @model_class = Object.const_set :MyModel, Class.new(ActiveRecord::Base)
7
7
  end
8
8
  end
9
9
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: efficient_translations
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
9
+ - 5
10
+ version: 0.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Nicola Racco