mongoid_slug 3.2.0 → 3.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mongoid/slug.rb +2 -2
- data/lib/mongoid/slug/unique_slug.rb +7 -3
- data/lib/mongoid/slug/version.rb +1 -1
- data/spec/mongoid/slug_spec.rb +13 -1
- data/spec/spec_helper.rb +2 -0
- metadata +24 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a920281ade5b1dd639583fb26fe03d73889ee1f6
|
4
|
+
data.tar.gz: b614389ac8cf8725170892ccbd91b385e2ff7e4e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b58513044d6d147813315bfd44c1d8de70bb908cf54e3e4c1072e3090bce3bd8a0d6cd0333de181ed3d964eed674d5af0eb4e8c5263509bb799757159a39ff7
|
7
|
+
data.tar.gz: d362fec6a047cc6adb0c843fa943c476528719d8febf78381fb97a830546d43b3540cd5035d01f9032444772a7660611af757407b689adb749491f1014294721
|
data/lib/mongoid/slug.rb
CHANGED
@@ -66,7 +66,7 @@ module Mongoid
|
|
66
66
|
# Add _type to the index to fix polymorphism
|
67
67
|
index({ _type: 1, scope_key => 1, _slugs: 1})
|
68
68
|
else
|
69
|
-
index({scope_key => 1, _slugs: 1}, {unique: true})
|
69
|
+
index({scope_key => 1, _slugs: 1}, {unique: true, sparse: true})
|
70
70
|
end
|
71
71
|
|
72
72
|
else
|
@@ -74,7 +74,7 @@ module Mongoid
|
|
74
74
|
if options[:by_model_type] == true
|
75
75
|
index({_type: 1, _slugs: 1})
|
76
76
|
else
|
77
|
-
index({_slugs: 1}, {unique: true})
|
77
|
+
index({_slugs: 1}, {unique: true, sparse: true})
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
@@ -62,8 +62,8 @@ module Mongoid
|
|
62
62
|
attr_reader :model, :_slug
|
63
63
|
|
64
64
|
def_delegators :@model, :slug_scope, :reflect_on_association, :read_attribute,
|
65
|
-
:check_against_id, :reserved_words, :url_builder, :
|
66
|
-
:
|
65
|
+
:check_against_id, :reserved_words, :url_builder, :collection_name,
|
66
|
+
:embedded?, :reflect_on_all_associations, :by_model_type
|
67
67
|
|
68
68
|
def initialize model
|
69
69
|
@model = model
|
@@ -71,6 +71,10 @@ module Mongoid
|
|
71
71
|
@state = nil
|
72
72
|
end
|
73
73
|
|
74
|
+
def metadata
|
75
|
+
@model.respond_to?(:relation_metadata) ? @model.relation_metadata : @model.metadata
|
76
|
+
end
|
77
|
+
|
74
78
|
def find_unique attempt = nil
|
75
79
|
@_slug = if attempt
|
76
80
|
attempt.to_url
|
@@ -132,7 +136,7 @@ module Mongoid
|
|
132
136
|
|
133
137
|
if embedded?
|
134
138
|
parent_metadata = reflect_on_all_associations(:embedded_in)[0]
|
135
|
-
return model._parent.send(parent_metadata.inverse_of ||
|
139
|
+
return model._parent.send(parent_metadata.inverse_of || self.metadata.name)
|
136
140
|
end
|
137
141
|
|
138
142
|
#unless embedded or slug scope, return the deepest document superclass
|
data/lib/mongoid/slug/version.rb
CHANGED
data/spec/mongoid/slug_spec.rb
CHANGED
@@ -809,6 +809,18 @@ module Mongoid
|
|
809
809
|
page["_slugs"].should == {"en" => ["title-on-english"], "nl" => ["title-on-netherlands"]}
|
810
810
|
end
|
811
811
|
|
812
|
+
it "exact same title multiple langauges" do
|
813
|
+
page = PageSlugLocalized.new
|
814
|
+
page.title_translations = {"en" => "Title on English", "nl" => "Title on English"}
|
815
|
+
page.save
|
816
|
+
page["_slugs"].should == {"en" => ["title-on-english"], "nl" => ["title-on-english"]}
|
817
|
+
|
818
|
+
page = PageSlugLocalized.create(title_translations: {"en" => "Title on English2", "nl" => "Title on English2"})
|
819
|
+
page["_slugs"].should == {"en" => ["title-on-english2"], "nl" => ["title-on-english2"]}
|
820
|
+
end
|
821
|
+
|
822
|
+
|
823
|
+
|
812
824
|
it "does not produce duplicate slugs" do
|
813
825
|
old_locale = I18n.locale
|
814
826
|
|
@@ -872,7 +884,7 @@ module Mongoid
|
|
872
884
|
page = PageSlugLocalizedCustom.new
|
873
885
|
page.title = "a title for the slug"
|
874
886
|
page.save
|
875
|
-
page["_slugs"].should == {"en" => ["a-title-for-the-slug"]}
|
887
|
+
page["_slugs"].should == {"en" => ["a-title-for-the-slug"], "nl"=>["a-title-for-the-slug"]}
|
876
888
|
end
|
877
889
|
end
|
878
890
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,125 +1,125 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid_slug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.2.
|
4
|
+
version: 3.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andreas Saebjoernsen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: stringex
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '2.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: guard-rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- -
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: awesome_print
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- -
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: uuid
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- -
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: pry
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
description: Mongoid URL slug or permalink generator
|
@@ -129,14 +129,14 @@ executables: []
|
|
129
129
|
extensions: []
|
130
130
|
extra_rdoc_files: []
|
131
131
|
files:
|
132
|
+
- LICENSE
|
133
|
+
- README.md
|
134
|
+
- lib/mongoid/slug.rb
|
132
135
|
- lib/mongoid/slug/criteria.rb
|
133
136
|
- lib/mongoid/slug/slug_id_strategy.rb
|
134
137
|
- lib/mongoid/slug/unique_slug.rb
|
135
138
|
- lib/mongoid/slug/version.rb
|
136
|
-
- lib/mongoid/slug.rb
|
137
139
|
- lib/mongoid_slug.rb
|
138
|
-
- LICENSE
|
139
|
-
- README.md
|
140
140
|
- spec/models/alias.rb
|
141
141
|
- spec/models/article.rb
|
142
142
|
- spec/models/author.rb
|
@@ -176,17 +176,17 @@ require_paths:
|
|
176
176
|
- lib
|
177
177
|
required_ruby_version: !ruby/object:Gem::Requirement
|
178
178
|
requirements:
|
179
|
-
- -
|
179
|
+
- - ">="
|
180
180
|
- !ruby/object:Gem::Version
|
181
181
|
version: '0'
|
182
182
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
183
183
|
requirements:
|
184
|
-
- -
|
184
|
+
- - ">="
|
185
185
|
- !ruby/object:Gem::Version
|
186
186
|
version: '0'
|
187
187
|
requirements: []
|
188
188
|
rubyforge_project: mongoid_slug
|
189
|
-
rubygems_version: 2.
|
189
|
+
rubygems_version: 2.2.2
|
190
190
|
signing_key:
|
191
191
|
specification_version: 4
|
192
192
|
summary: Mongoid URL slugs
|