puret 1.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -9,6 +9,7 @@ Puret is quiet like model_translations http://github.com/janne/model_translation
9
9
 
10
10
  You need configure the puret gem inside your gemfile:
11
11
 
12
+ source 'http://gemcutter.org'
12
13
  gem 'puret'
13
14
 
14
15
  You can also use the latest edge version by specifying the git repository:
@@ -82,6 +83,11 @@ This will create the appropriate migration and configure your Post model to tran
82
83
  Keep it simple! Relax.
83
84
 
84
85
 
86
+ == Diggin deeper
87
+
88
+ Read the Rdoc documentation at http://rdoc.info/projects/jo/puret.
89
+
90
+
85
91
  == Bugs and Feedback
86
92
 
87
93
  If you discover any bugs or want to drop a line, feel free to create an issue on
@@ -1,10 +1,22 @@
1
1
  module Puret
2
2
  module ActiveRecordExtensions
3
3
  module ClassMethods
4
+ # Configure translation model dependency.
5
+ # Eg:
6
+ # class PostTranslation < ActiveRecord::Base
7
+ # puret_for :post
8
+ # end
4
9
  def puret_for(model)
5
10
  belongs_to model
11
+ validates_presence_of model, :locale
12
+ validates_uniqueness_of :locale, :scope => "#{model}_id"
6
13
  end
7
14
 
15
+ # Configure translated attributes.
16
+ # Eg:
17
+ # class Post < ActiveRecord::Base
18
+ # puret :title, description
19
+ # end
8
20
  def puret(*attributes)
9
21
  make_it_puret! unless included_modules.include?(InstanceMethods)
10
22
 
@@ -1,3 +1,3 @@
1
1
  module Puret
2
- VERSION = "1.0".freeze
2
+ VERSION = "1.0.1".freeze
3
3
  end
@@ -57,4 +57,24 @@ class PuretTest < ActiveSupport::TestCase
57
57
  post.title.blank?
58
58
  assert_equal 'Deutscher Text', post.text
59
59
  end
60
+
61
+ test 'translation model should validate presence of model' do
62
+ t = PostTranslation.new
63
+ t.valid?
64
+ assert_not_nil t.errors[:post]
65
+ end
66
+
67
+ test 'translation model should validate presence of locale' do
68
+ t = PostTranslation.new
69
+ t.valid?
70
+ assert_not_nil t.errors[:locale]
71
+ end
72
+
73
+ test 'translation model should validate uniqueness of locale in model scope' do
74
+ post = Post.first
75
+ t1 = PostTranslation.new :post => post, :locale => "de"
76
+ t1.save!
77
+ t2 = PostTranslation.new :post => post, :locale => "de"
78
+ assert_not_nil t2.errors[:locale]
79
+ end
60
80
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puret
3
3
  version: !ruby/object:Gem::Version
4
- version: "1.0"
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Johannes J\xC3\xB6rg Schmidt"
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-22 00:00:00 +01:00
12
+ date: 2010-02-23 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15