acts_more_seo 0.2.5 → 0.2.6
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/CHANGELOG.rdoc +3 -1
- data/Rakefile +1 -1
- data/acts_more_seo.gemspec +2 -2
- data/lib/acts_more_seo.rb +10 -4
- data/spec/acts_more_seo_spec.rb +6 -5
- metadata +6 -6
data/CHANGELOG.rdoc
CHANGED
|
@@ -11,4 +11,6 @@
|
|
|
11
11
|
= Version 0.2.4
|
|
12
12
|
Backward compatibility improvements
|
|
13
13
|
= Version 0.2.5
|
|
14
|
-
* Using ID when to_url returns same string as existing (conflicts)
|
|
14
|
+
* Using ID when to_url returns same string as existing (conflicts)
|
|
15
|
+
= Version 0.2.6
|
|
16
|
+
* find_by_seo and find_by_seo! (with raising not found exception)
|
data/Rakefile
CHANGED
|
@@ -3,7 +3,7 @@ require 'rubygems'
|
|
|
3
3
|
require 'rake'
|
|
4
4
|
require 'echoe'
|
|
5
5
|
|
|
6
|
-
Echoe.new('acts_more_seo', '0.2.
|
|
6
|
+
Echoe.new('acts_more_seo', '0.2.6') do |p|
|
|
7
7
|
p.description = "Gem makes your ActiveRecord models more SEO friendly. Changes URL to look way better"
|
|
8
8
|
p.url = "https://github.com/mensfeld/Css-Image-Embedder"
|
|
9
9
|
p.author = "Maciej Mensfeld"
|
data/acts_more_seo.gemspec
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |s|
|
|
4
4
|
s.name = %q{acts_more_seo}
|
|
5
|
-
s.version = "0.2.
|
|
5
|
+
s.version = "0.2.6"
|
|
6
6
|
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
|
8
8
|
s.authors = [%q{Maciej Mensfeld}]
|
|
9
|
-
s.date = %q{2011-11-
|
|
9
|
+
s.date = %q{2011-11-15}
|
|
10
10
|
s.description = %q{Gem makes your ActiveRecord models more SEO friendly. Changes URL to look way better}
|
|
11
11
|
s.email = %q{maciej@mensfeld.pl}
|
|
12
12
|
s.extra_rdoc_files = [%q{CHANGELOG.rdoc}, %q{README.md}, %q{lib/acts_more_seo.rb}, %q{lib/string_ext.rb}]
|
data/lib/acts_more_seo.rb
CHANGED
|
@@ -91,13 +91,19 @@ module Acts
|
|
|
91
91
|
self.column_names.include?("#{:seo_url}")
|
|
92
92
|
end
|
|
93
93
|
|
|
94
|
-
def find_by_seo(id)
|
|
94
|
+
def find_by_seo!(id)
|
|
95
95
|
if self.seo_use_id
|
|
96
96
|
find(id)
|
|
97
97
|
else
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
find_by_seo_url! id, :first
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def find_by_seo(id)
|
|
103
|
+
if self.seo_use_id
|
|
104
|
+
find_by_id(id)
|
|
105
|
+
else
|
|
106
|
+
find_by_seo_url id, :first
|
|
101
107
|
end
|
|
102
108
|
end
|
|
103
109
|
|
data/spec/acts_more_seo_spec.rb
CHANGED
|
@@ -29,7 +29,8 @@ describe CoolElement do
|
|
|
29
29
|
subject.find_by_seo(a.id).should eql(a)
|
|
30
30
|
subject.find_by_seo(a.to_param).should eql(a)
|
|
31
31
|
subject.find_by_seo("#{a.to_param}aaa").should eql(a)
|
|
32
|
-
|
|
32
|
+
subject.find_by_seo("134534dass").should eql(nil)
|
|
33
|
+
lambda { subject.find_by_seo!("134534dass") }.should raise_error(ActiveRecord::RecordNotFound)
|
|
33
34
|
end
|
|
34
35
|
end
|
|
35
36
|
|
|
@@ -72,7 +73,7 @@ describe CoolerElement do
|
|
|
72
73
|
|
|
73
74
|
it "should raise error when there is no element" do
|
|
74
75
|
a = subject.create
|
|
75
|
-
lambda { subject.find_by_seo(a.id+1) }.should raise_error(ActiveRecord::RecordNotFound)
|
|
76
|
+
lambda { subject.find_by_seo!(a.id+1) }.should raise_error(ActiveRecord::RecordNotFound)
|
|
76
77
|
end
|
|
77
78
|
end
|
|
78
79
|
|
|
@@ -80,7 +81,7 @@ describe CoolerElement do
|
|
|
80
81
|
it "should return nice url" do
|
|
81
82
|
a = subject.create(:title => 'bla bla bla')
|
|
82
83
|
a.to_param.should eql("#{a.id}-bla-bla-bla")
|
|
83
|
-
subject.find_by_seo(a.to_param).should eql(a)
|
|
84
|
+
subject.find_by_seo!(a.to_param).should eql(a)
|
|
84
85
|
end
|
|
85
86
|
|
|
86
87
|
context "and there are some url-not-friendly letters" do
|
|
@@ -167,8 +168,8 @@ describe BestElement do
|
|
|
167
168
|
context "when we have a class which has use_id => false" do
|
|
168
169
|
it "should find element only when seo_url is same (or by id)" do
|
|
169
170
|
a = subject.create(:name => 'bla bla bla')
|
|
170
|
-
subject.find_by_seo(a.seo_url).should eql(a)
|
|
171
|
-
lambda { subject.find_by_seo("#{a.to_param}aaa") }.should raise_error(ActiveRecord::RecordNotFound)
|
|
171
|
+
subject.find_by_seo!(a.seo_url).should eql(a)
|
|
172
|
+
lambda { subject.find_by_seo!("#{a.to_param}aaa") }.should raise_error(ActiveRecord::RecordNotFound)
|
|
172
173
|
end
|
|
173
174
|
end
|
|
174
175
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: acts_more_seo
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.6
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,11 +9,11 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2011-11-
|
|
12
|
+
date: 2011-11-15 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rspec
|
|
16
|
-
requirement: &
|
|
16
|
+
requirement: &15894980 !ruby/object:Gem::Requirement
|
|
17
17
|
none: false
|
|
18
18
|
requirements:
|
|
19
19
|
- - ! '>='
|
|
@@ -21,10 +21,10 @@ dependencies:
|
|
|
21
21
|
version: 2.0.0
|
|
22
22
|
type: :development
|
|
23
23
|
prerelease: false
|
|
24
|
-
version_requirements: *
|
|
24
|
+
version_requirements: *15894980
|
|
25
25
|
- !ruby/object:Gem::Dependency
|
|
26
26
|
name: active_record
|
|
27
|
-
requirement: &
|
|
27
|
+
requirement: &15868480 !ruby/object:Gem::Requirement
|
|
28
28
|
none: false
|
|
29
29
|
requirements:
|
|
30
30
|
- - ! '>='
|
|
@@ -32,7 +32,7 @@ dependencies:
|
|
|
32
32
|
version: '0'
|
|
33
33
|
type: :development
|
|
34
34
|
prerelease: false
|
|
35
|
-
version_requirements: *
|
|
35
|
+
version_requirements: *15868480
|
|
36
36
|
description: Gem makes your ActiveRecord models more SEO friendly. Changes URL to
|
|
37
37
|
look way better
|
|
38
38
|
email: maciej@mensfeld.pl
|