friendly_id 4.0.0.beta13 → 4.0.0.beta14

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -43,7 +43,7 @@ The current docs can always be found
43
43
 
44
44
  cd my_app
45
45
 
46
- gem "friendly_id", "~> 4.0.0.beta12"
46
+ gem "friendly_id", "~> 4.0.0.beta14"
47
47
 
48
48
  rails generate scaffold user name:string slug:string
49
49
 
@@ -81,7 +81,7 @@ In general, use slugs by default unless you know for sure you don't need them.
81
81
  module FriendlyId
82
82
 
83
83
  # The current version.
84
- VERSION = "4.0.0.beta13"
84
+ VERSION = "4.0.0.beta14"
85
85
 
86
86
  @mutex = Mutex.new
87
87
 
@@ -27,7 +27,7 @@ module FriendlyId
27
27
  # person = Person.exists?(['name = ?', 'joe'])
28
28
  #
29
29
  # @see FriendlyId::ObjectUtils
30
- def exists?(id = nil)
30
+ def exists?(id = false)
31
31
  return super if id.unfriendly_id?
32
32
  super @klass.friendly_id_config.query_field => id
33
33
  end
@@ -87,8 +87,8 @@ method.
87
87
  end
88
88
 
89
89
  # Search for a record in the slugs table using the specified slug.
90
- def exists?(id = nil)
91
- return super(id) if id.unfriendly_id?
90
+ def exists?(id = false)
91
+ return super if id.unfriendly_id?
92
92
  exists_without_friendly_id?(@klass.friendly_id_config.query_field => id) or
93
93
  with_old_friendly_id(id) {|x| exists_without_friendly_id?(x)} or
94
94
  exists_without_friendly_id?(id)
@@ -27,9 +27,11 @@ module FriendlyId
27
27
  # "123".friendly_id? #=> nil
28
28
  # "abc123".friendly_id? #=> true
29
29
  def friendly_id?
30
- unfriendly_classes = [ActiveRecord::Base, Array, Hash, NilClass, Numeric, Symbol]
31
30
  # Considered unfriendly if this is an instance of an unfriendly class or
32
31
  # one of its descendants.
32
+ unfriendly_classes = [ActiveRecord::Base, Array, Hash, NilClass, Numeric,
33
+ Symbol, TrueClass, FalseClass]
34
+
33
35
  if unfriendly_classes.detect {|klass| self.class <= klass}
34
36
  false
35
37
  elsif respond_to?(:to_i) && to_i.to_s != to_s
@@ -44,18 +44,20 @@ class SluggedTest < MiniTest::Unit::TestCase
44
44
 
45
45
  test "should not break validates_uniqueness_of" do
46
46
  model_class = Class.new(ActiveRecord::Base) do
47
- self.table_name = "articles"
47
+ self.table_name = "journalists"
48
48
  extend FriendlyId
49
49
  friendly_id :name, :use => :slugged
50
- validates_uniqueness_of :name
50
+ validates_uniqueness_of :slug_en
51
51
  def self.name
52
- "Article"
52
+ "Journalist"
53
53
  end
54
54
  end
55
- instance = model_class.create :name => "hello"
56
- instance2 = model_class.create :name => "hello"
57
- assert instance.valid?
58
- refute instance2.valid?
55
+ transaction do
56
+ instance = model_class.create! :name => "hello", :slug_en => "hello"
57
+ instance2 = model_class.create :name => "hello", :slug_en => "hello"
58
+ assert instance.valid?
59
+ refute instance2.valid?
60
+ end
59
61
  end
60
62
 
61
63
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: friendly_id
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.beta13
4
+ version: 4.0.0.beta14
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2011-10-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
16
- requirement: &70219708818280 !ruby/object:Gem::Requirement
16
+ requirement: &70302852816780 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 3.1.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70219708818280
24
+ version_requirements: *70302852816780
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: activerecord
27
- requirement: &70219708817420 !ruby/object:Gem::Requirement
27
+ requirement: &70302852816240 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 3.1.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70219708817420
35
+ version_requirements: *70302852816240
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: sqlite3
38
- requirement: &70219708816820 !ruby/object:Gem::Requirement
38
+ requirement: &70302852815740 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.3.4
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70219708816820
46
+ version_requirements: *70302852815740
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: minitest
49
- requirement: &70219708815960 !ruby/object:Gem::Requirement
49
+ requirement: &70302852815220 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 2.4.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70219708815960
57
+ version_requirements: *70302852815220
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: mocha
60
- requirement: &70219708804840 !ruby/object:Gem::Requirement
60
+ requirement: &70302852814740 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 0.9.12
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70219708804840
68
+ version_requirements: *70302852814740
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: ffaker
71
- requirement: &70219708804320 !ruby/object:Gem::Requirement
71
+ requirement: &70302852814280 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 1.8.0
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70219708804320
79
+ version_requirements: *70302852814280
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: maruku
82
- requirement: &70219708803840 !ruby/object:Gem::Requirement
82
+ requirement: &70302852813800 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 0.6.0
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70219708803840
90
+ version_requirements: *70302852813800
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: yard
93
- requirement: &70219708803380 !ruby/object:Gem::Requirement
93
+ requirement: &70302852813340 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ~>
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: 0.7.2
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70219708803380
101
+ version_requirements: *70302852813340
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: i18n
104
- requirement: &70219708802920 !ruby/object:Gem::Requirement
104
+ requirement: &70302852812880 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ~>
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: 0.6.0
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *70219708802920
112
+ version_requirements: *70302852812880
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: simplecov
115
- requirement: &70219708802520 !ruby/object:Gem::Requirement
115
+ requirement: &70302852812460 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,7 +120,7 @@ dependencies:
120
120
  version: '0'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *70219708802520
123
+ version_requirements: *70302852812460
124
124
  description: ! 'FriendlyId is the "Swiss Army bulldozer" of slugging and permalink
125
125
  plugins for
126
126