uniqueable 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
@@ -17,10 +17,10 @@ module Uniqueable
|
|
17
17
|
key = key.keys.first
|
18
18
|
end
|
19
19
|
if options[:case_sensitive]
|
20
|
-
result = klass.where(["#{key} = ?", value]).where(conditions).all
|
20
|
+
result = klass.unscoped.where(["#{key} = ?", value]).where(conditions).all
|
21
21
|
else
|
22
22
|
value = value.downcase if value.kind_of?(String)
|
23
|
-
result = klass.where(["lower(#{key}) = ?", value]).where(conditions).all
|
23
|
+
result = klass.unscoped.where(["lower(#{key}) = ?", value]).where(conditions).all
|
24
24
|
end
|
25
25
|
|
26
26
|
unless result.empty?
|
data/lib/uniqueable/version.rb
CHANGED
@@ -194,5 +194,32 @@ describe Uniqueable::UniqueableValidator do
|
|
194
194
|
user.should_not be_valid
|
195
195
|
end
|
196
196
|
end
|
197
|
+
|
198
|
+
context "default_scope should not affect the outcome" do
|
199
|
+
before(:each) do
|
200
|
+
Uniqueable.instance_variable_set(:@uniqueable_checks, nil)
|
201
|
+
class User < ActiveRecord::Base
|
202
|
+
include Uniqueable
|
203
|
+
uniqueable :username
|
204
|
+
validates :username, :uniqueable => {:case_sensitive => false}
|
205
|
+
end
|
206
|
+
|
207
|
+
class Organisation < ActiveRecord::Base
|
208
|
+
default_scope where(:public => true)
|
209
|
+
include Uniqueable
|
210
|
+
uniqueable :alias
|
211
|
+
validates :alias, :uniqueable => {:case_sensitive => false}
|
212
|
+
end
|
213
|
+
User.delete_all
|
214
|
+
Organisation.delete_all
|
215
|
+
end
|
216
|
+
|
217
|
+
it "should validate even when an organisation is not public" do
|
218
|
+
organisation = Organisation.create(:name => "Gazler", :alias => "Gazler", :public => false)
|
219
|
+
organisation.should be_valid
|
220
|
+
user = User.create(:name => "Gazler", :username => "Gazler")
|
221
|
+
user.should_not be_valid
|
222
|
+
end
|
223
|
+
end
|
197
224
|
|
198
225
|
end
|
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.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -127,7 +127,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
127
127
|
version: '0'
|
128
128
|
segments:
|
129
129
|
- 0
|
130
|
-
hash: -
|
130
|
+
hash: -2704558754954571647
|
131
131
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
132
|
none: false
|
133
133
|
requirements:
|
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
136
|
version: '0'
|
137
137
|
segments:
|
138
138
|
- 0
|
139
|
-
hash: -
|
139
|
+
hash: -2704558754954571647
|
140
140
|
requirements: []
|
141
141
|
rubyforge_project:
|
142
142
|
rubygems_version: 1.8.24
|