has_slug 0.2.6 → 0.2.7

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.
@@ -42,27 +42,27 @@ module HasSlug
42
42
  options = DEFAULT_HAS_SLUG_OPTIONS.merge(options).merge(:attribute => attribute)
43
43
 
44
44
  if defined?(has_slug_options)
45
- raise Exception, "has_slug_options is already defined, you can only call has_slug once"
46
- end
47
-
48
- write_inheritable_attribute(:has_slug_options, options)
49
- class_inheritable_reader(:has_slug_options)
50
-
51
- if columns.any? { |column| column.name.to_s == options[:slug_column].to_s }
52
- require 'has_slug/sluggable_class_methods'
53
- require 'has_slug/sluggable_instance_methods'
54
-
55
- extend SluggableClassMethods
56
- include SluggableInstanceMethods
57
-
58
- before_save :set_slug,
59
- :if => :new_slug_needed?
45
+ Rails.logger.error "has_slug_options is already defined, you can only call has_slug once. This call has been ignored."
60
46
  else
61
- require 'has_slug/not_sluggable_class_methods'
62
- require 'has_slug/not_sluggable_instance_methods'
63
-
64
- extend NotSluggableClassMethods
65
- include NotSluggableInstanceMethods
47
+ write_inheritable_attribute(:has_slug_options, options)
48
+ class_inheritable_reader(:has_slug_options)
49
+
50
+ if columns.any? { |column| column.name.to_s == options[:slug_column].to_s }
51
+ require 'has_slug/sluggable_class_methods'
52
+ require 'has_slug/sluggable_instance_methods'
53
+
54
+ extend SluggableClassMethods
55
+ include SluggableInstanceMethods
56
+
57
+ before_save :set_slug,
58
+ :if => :new_slug_needed?
59
+ else
60
+ require 'has_slug/not_sluggable_class_methods'
61
+ require 'has_slug/not_sluggable_instance_methods'
62
+
63
+ extend NotSluggableClassMethods
64
+ include NotSluggableInstanceMethods
65
+ end
66
66
  end
67
67
  end
68
68
  end
@@ -0,0 +1,16 @@
1
+ begin
2
+ Factory.define :city do |f|
3
+ f.name 'New York'
4
+ end
5
+
6
+ Factory.define :kitchen do |f|
7
+ f.name 'Italian'
8
+ end
9
+
10
+ Factory.define :restaurant do |f|
11
+ f.name 'Da Marco'
12
+ f.city { |city| city.association(:city) }
13
+ f.kitchen { |kitchen| kitchen.association(:kitchen) }
14
+ end
15
+ rescue Factory::DuplicateDefinitionError
16
+ end
@@ -0,0 +1,24 @@
1
+ class City < ActiveRecord::Base
2
+ has_slug :name
3
+
4
+ has_many :restaurants
5
+
6
+ has_many :kitchens,
7
+ :through => :restaurants
8
+ end
9
+
10
+ class Kitchen < ActiveRecord::Base
11
+ has_slug :name
12
+
13
+ belongs_to :restaurant
14
+ end
15
+
16
+ class Restaurant < ActiveRecord::Base
17
+ has_slug :name,
18
+ :scope => :city,
19
+ :preserve => '.'
20
+
21
+ belongs_to :city
22
+
23
+ belongs_to :kitchen
24
+ end
@@ -6,15 +6,16 @@ require 'shoulda'
6
6
  require 'factory_girl'
7
7
 
8
8
  HAS_SLUG_ROOT = File.dirname(__FILE__) + "/.."
9
- $:.unshift("#{HAS_SLUG_ROOT}/lib")
10
9
 
11
- ActiveRecord::Base.establish_connection(:adapter => "sqlite3",
12
- :dbfile => "#{HAS_SLUG_ROOT}/test/test.db")
10
+ ActiveRecord::Base.establish_connection(:adapter => "sqlite3",
11
+ :database => "#{HAS_SLUG_ROOT}/test/test.db")
12
+
13
+ $:.unshift("#{HAS_SLUG_ROOT}/lib")
13
14
  require 'has_slug'
14
- require "#{HAS_SLUG_ROOT}/test/schema.rb"
15
15
 
16
- Dir["#{HAS_SLUG_ROOT}/test/models/*"].each { |f| require f }
17
- Dir["#{HAS_SLUG_ROOT}/test/factories/*"].each { |f| require f }
16
+ require "#{HAS_SLUG_ROOT}/test/schema"
17
+ require "#{HAS_SLUG_ROOT}/test/factories"
18
+ require "#{HAS_SLUG_ROOT}/test/models"
18
19
 
19
20
  [City, Restaurant, Kitchen].each { |c| c.reset_column_information }
20
21
 
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- require "#{File.dirname(__FILE__)}/../test_helper"
2
+ require File.join(File.dirname(__FILE__), '..', 'test_helper')
3
3
 
4
4
  class HasSlugTest < Test::Unit::TestCase
5
5
  context 'A model' do
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- require "#{File.dirname(__FILE__)}/../test_helper"
2
+ require File.join(File.dirname(__FILE__), '..', 'test_helper')
3
3
 
4
4
  class SlugTest < Test::Unit::TestCase
5
5
  context 'A Slug' do
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_slug
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 2
8
+ - 7
9
+ version: 0.2.7
5
10
  platform: ruby
6
11
  authors:
7
12
  - Tom-Eric Gerritsen
@@ -9,7 +14,7 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-02-12 00:00:00 +01:00
17
+ date: 2010-04-14 00:00:00 +02:00
13
18
  default_executable:
14
19
  dependencies: []
15
20
 
@@ -48,30 +53,28 @@ required_ruby_version: !ruby/object:Gem::Requirement
48
53
  requirements:
49
54
  - - ">="
50
55
  - !ruby/object:Gem::Version
56
+ segments:
57
+ - 0
51
58
  version: "0"
52
- version:
53
59
  required_rubygems_version: !ruby/object:Gem::Requirement
54
60
  requirements:
55
61
  - - ">="
56
62
  - !ruby/object:Gem::Version
63
+ segments:
64
+ - 0
57
65
  version: "0"
58
- version:
59
66
  requirements:
60
67
  - unicode_utils or unicode gem install
61
68
  rubyforge_project:
62
- rubygems_version: 1.3.5
69
+ rubygems_version: 1.3.6
63
70
  signing_key:
64
71
  specification_version: 3
65
72
  summary: A slugging plugin for Ruby on Rails
66
73
  test_files:
67
74
  - test/schema.rb
68
75
  - test/test_helper.rb
69
- - test/factories/city_factory.rb
70
- - test/factories/kitchen_factory.rb
71
- - test/factories/restaurant_factory.rb
72
- - test/models/city.rb
73
- - test/models/kitchen.rb
74
- - test/models/restaurant.rb
76
+ - test/factories.rb
77
+ - test/models.rb
75
78
  - test/unit/has_slug_test.rb
76
79
  - rails/init.rb
77
80
  - test/unit/slug_test.rb
@@ -1,3 +0,0 @@
1
- Factory.define :city do |city|
2
- city.name 'New York'
3
- end
@@ -1,3 +0,0 @@
1
- Factory.define :kitchen do |kitchen|
2
- kitchen.name 'Italian'
3
- end
@@ -1,5 +0,0 @@
1
- Factory.define :restaurant do |restaurant|
2
- restaurant.name 'Da Marco'
3
- restaurant.city { |city| city.association(:city) }
4
- restaurant.kitchen { |kitchen| kitchen.association(:kitchen) }
5
- end
@@ -1,8 +0,0 @@
1
- class City < ActiveRecord::Base
2
- has_slug :name
3
-
4
- has_many :restaurants
5
-
6
- has_many :kitchens,
7
- :through => :restaurants
8
- end
@@ -1,5 +0,0 @@
1
- class Kitchen < ActiveRecord::Base
2
- has_slug :name
3
-
4
- belongs_to :restaurant
5
- end
@@ -1,9 +0,0 @@
1
- class Restaurant < ActiveRecord::Base
2
- has_slug :name,
3
- :scope => :city,
4
- :preserve => '.'
5
-
6
- belongs_to :city
7
-
8
- belongs_to :kitchen
9
- end