seofy 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/seofy/adapters/base36.rb +10 -1
- data/lib/seofy/version.rb +1 -1
- data/spec/lib/seofy/adapters/base36_spec.rb +1 -0
- metadata +3 -3
@@ -12,7 +12,16 @@ module Seofy
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def set_seofy_slug(inst)
|
15
|
-
|
15
|
+
slug_exist = true
|
16
|
+
while slug_exist
|
17
|
+
random = ::Seofy::Encoders::Base36.random(self.length)
|
18
|
+
if inst.class.exists?(["#{column} = ?", random])
|
19
|
+
slug_exist = true
|
20
|
+
else
|
21
|
+
inst.send("#{column}=", random)
|
22
|
+
slug_exist = false
|
23
|
+
end
|
24
|
+
end
|
16
25
|
end
|
17
26
|
end
|
18
27
|
end
|
data/lib/seofy/version.rb
CHANGED
@@ -12,6 +12,7 @@ describe Seofy::Adapters::Base36 do
|
|
12
12
|
stub = Object.new
|
13
13
|
::Seofy::Encoders::Base36.should_receive(:random).with(3).and_return("abc")
|
14
14
|
stub.should_receive("slug=").with("abc")
|
15
|
+
stub.class.should_receive(:exists?).with(['slug = ?', "abc"]).and_return(false)
|
15
16
|
adapter.set_seofy_slug(stub)
|
16
17
|
end
|
17
18
|
end
|
metadata
CHANGED