validates-belongs-to 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Build Status](https://secure.travis-ci.org/spraints/validates-belongs-to.png)](http://travis-ci.org/spraints/validates-belongs-to)
2
+
1
3
  Rails 3 validation to ensure that two ActiveModel associations are related to each other.
2
4
 
3
5
  class JobApplication
@@ -6,6 +8,8 @@ Rails 3 validation to ensure that two ActiveModel associations are related to ea
6
8
  validates :resume, :belongs_to => :user
7
9
  end
8
10
 
11
+ The validation checks that `job_application.resume.user` is the same as `job_application.user`.
12
+
9
13
  Installation:
10
14
 
11
15
  gem 'validates-belongs-to'
data/Rakefile CHANGED
@@ -2,4 +2,8 @@ require 'bundler'
2
2
  Bundler::GemHelper.install_tasks
3
3
 
4
4
  require 'rake/testtask'
5
- Rake::TestTask.new
5
+ Rake::TestTask.new do |t|
6
+ t.test_files = FileList['test/*_test.rb']
7
+ end
8
+
9
+ task :default => :test
@@ -23,3 +23,6 @@ class BelongsToValidator < ActiveModel::EachValidator
23
23
  end
24
24
  end
25
25
  end
26
+
27
+ require 'active_support/i18n'
28
+ I18n.load_path << File.dirname(__FILE__) + '/validates-belongs-to/locale/en.yml'
@@ -0,0 +1,4 @@
1
+ en:
2
+ errors:
3
+ messages:
4
+ belongs_to: 'must have the same %{with} as this record'
@@ -1,7 +1,7 @@
1
1
  module Validates
2
2
  module Belongs
3
3
  module To
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  end
6
6
  end
7
7
  end
@@ -50,5 +50,6 @@ class ValidatesBelongsToTest < Test::Unit::TestCase
50
50
  obj.thing1.thing2 = :thing2
51
51
  obj.thing2 = :other_thing
52
52
  assert !obj.valid?, 'not valid with non-matching related objects'
53
+ assert_equal ['Thing1 must have the same thing2 as this record'], obj.errors.full_messages, 'error message'
53
54
  end
54
55
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validates-belongs-to
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matt Burke
@@ -49,6 +49,7 @@ files:
49
49
  - README.md
50
50
  - Rakefile
51
51
  - lib/validates-belongs-to.rb
52
+ - lib/validates-belongs-to/locale/en.yml
52
53
  - lib/validates-belongs-to/version.rb
53
54
  - test/validates-belongs-to_test.rb
54
55
  - validates-belongs-to.gemspec