uniqueable 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +5 -0
- data/README.md +2 -0
- data/lib/uniqueable/validates_uniqueable.rb +2 -1
- data/lib/uniqueable/version.rb +1 -1
- data/spec/uniqueable/validates_uniqueable_spec.rb +5 -0
- metadata +4 -3
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Uniqueable
|
2
2
|
|
3
|
+
[![Build Status](https://secure.travis-ci.org/Gazler/githug.png?branch=master)](http://travis-ci.org/Gazler/githug)
|
4
|
+
|
3
5
|
Uniqueable allows the checking of cross-model and cross-attribute uniqueness check. For example, if you have users and organisations, both of which have a name that is used in the url, then you will want to check uniqueness across both of the models.
|
4
6
|
|
5
7
|
## Installation
|
@@ -14,7 +14,8 @@ module Uniqueable
|
|
14
14
|
if options[:case_sensitive]
|
15
15
|
result = klass.where(key => value)
|
16
16
|
else
|
17
|
-
|
17
|
+
value = value.downcase if value.kind_of?(String)
|
18
|
+
result = klass.find(:all, :conditions => ["lower(#{key}) = ?", value])
|
18
19
|
end
|
19
20
|
|
20
21
|
unless result.empty?
|
data/lib/uniqueable/version.rb
CHANGED
@@ -72,6 +72,11 @@ describe Uniqueable::UniqueableValidator do
|
|
72
72
|
user2.should_not be_valid
|
73
73
|
end
|
74
74
|
|
75
|
+
it "should not raise an exception when a value is nil" do
|
76
|
+
lambda { User.create(:name => nil, :username => nil) }.should_not raise_error
|
77
|
+
|
78
|
+
end
|
79
|
+
|
75
80
|
it "should not affect an organisation with a unique alias" do
|
76
81
|
organisation = Organisation.create(:name => "Organisation", :alias => "org")
|
77
82
|
organisation.should be_valid
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uniqueable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -100,6 +100,7 @@ extra_rdoc_files: []
|
|
100
100
|
files:
|
101
101
|
- .gitignore
|
102
102
|
- .rspec
|
103
|
+
- .travis.yml
|
103
104
|
- Gemfile
|
104
105
|
- LICENSE
|
105
106
|
- README.md
|
@@ -126,7 +127,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
126
127
|
version: '0'
|
127
128
|
segments:
|
128
129
|
- 0
|
129
|
-
hash:
|
130
|
+
hash: -753480171143598750
|
130
131
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
132
|
none: false
|
132
133
|
requirements:
|
@@ -135,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
136
|
version: '0'
|
136
137
|
segments:
|
137
138
|
- 0
|
138
|
-
hash:
|
139
|
+
hash: -753480171143598750
|
139
140
|
requirements: []
|
140
141
|
rubyforge_project:
|
141
142
|
rubygems_version: 1.8.24
|