slugable 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/changelog.md CHANGED
@@ -1,4 +1,8 @@
1
- # 0.0.1
1
+ # 0.0.2
2
+ ## fixed
3
+ * fill in slug from name parameter if slug.parameterize is blank
4
+
5
+ # 0.0.1 (October 11, 2012)
2
6
  ## added
3
7
  * init version from real project
4
8
  * support for storing seo friendly url
@@ -23,11 +23,11 @@ module Slugable
23
23
  # generate this
24
24
  #
25
25
  # def fill_slug
26
- # self.slug = name unless slug.present?
26
+ # self.slug = name if slug.blank? || slug.parameterize.blank?
27
27
  # end
28
28
  code =<<-method
29
29
  def fill_slug_from_#{from}_to_#{to}
30
- self.#{to} = #{from} unless #{to}.present?
30
+ self.#{to} = #{from} if #{to}.blank? || #{to}.parameterize.blank?
31
31
  end
32
32
  method
33
33
  class_eval(code)
@@ -1,3 +1,3 @@
1
1
  module Slugable
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -41,6 +41,11 @@ describe Slugable::HasSlug do
41
41
  item.slug.should eq "my-name-is"
42
42
  end
43
43
 
44
+ it "should fill in slug from attribute name if parameterize version of slug is blank", :focus => true do
45
+ item = Item.create!(:name => "my name is", :slug => "/")
46
+ item.slug.should eq "my-name-is"
47
+ end
48
+
44
49
  it "should only parametrize slug attribute if slug is present" do
45
50
  item = Item.create!(:name => "my name is", :slug => "my url")
46
51
  item.slug.should eq "my-url"
@@ -56,11 +61,16 @@ describe Slugable::HasSlug do
56
61
  Page.new.should respond_to :format_slug_from_title_to_seo_url
57
62
  end
58
63
 
59
- it "should fill in slug parameter from attribute name and parametrize it" do
64
+ it "should fill in slug parameter from attribute title and parametrize it" do
60
65
  page = Page.create!(:title => "my name is")
61
66
  page.seo_url.should eq "my-name-is"
62
67
  end
63
68
 
69
+ it "should fill in slug parameter from attribute title if parameterize version of slug is blank" do
70
+ page = Page.create!(:title => "my name is", :seo_url => "/")
71
+ page.seo_url.should eq "my-name-is"
72
+ end
73
+
64
74
  it "should only parametrize slug attribute if slug is present" do
65
75
  page = Page.create!(:title => "my name is", :seo_url => "my url")
66
76
  page.seo_url.should eq "my-url"
@@ -69,7 +79,7 @@ describe Slugable::HasSlug do
69
79
 
70
80
  describe "to_slug" do
71
81
  context "default options" do
72
- it "should define mehtod to_seo_url" do
82
+ it "should define method to_seo_url" do
73
83
  Item.new.should respond_to :to_slug
74
84
  end
75
85
 
@@ -80,7 +90,7 @@ describe Slugable::HasSlug do
80
90
  end
81
91
 
82
92
  context "given options" do
83
- it "should define mehtod to_seo_url" do
93
+ it "should define method to_seo_url" do
84
94
  Page.new.should respond_to :to_seo_url
85
95
  end
86
96
 
data/spec/spec_helper.rb CHANGED
@@ -2,7 +2,7 @@ require "slugable"
2
2
  require "sqlite3"
3
3
  require "ancestry"
4
4
 
5
- ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
5
+ ActiveRecord::Base.establish_connection :adapter => "sqlite3", :database => ":memory:"
6
6
 
7
7
  load "db/schema.rb"
8
8
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slugable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-11 00:00:00.000000000 Z
12
+ date: 2012-12-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord