mongoid-permalinks 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +18 -0
- data/Gemfile +1 -1
- data/README.md +3 -4
- data/Rakefile +2 -3
- data/lib/mongoid/permalinks/version.rb +1 -1
- data/{spec/support → test}/mongoid.yml +0 -0
- data/test/permalinks_test.rb +61 -0
- data/{spec/spec_helper.rb → test/test_helper.rb} +1 -2
- metadata +22 -29
- data/spec/permalinks_spec.rb +0 -69
- data/spec/support/connection.rb +0 -1
- data/spec/support/document.rb +0 -18
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1f4c76d8d0fa60c0252e205222c02455b4cc9af3
|
4
|
+
data.tar.gz: 11275c45290f146ccf133f06a8e02cefd5478334
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 16860f9e5499b0872903c670be110f8addd06847e087ca80b6966390f0fad1b5c6d3e4f0f63ed86288b9fc3ac3a1bed52297da1fcaee8b64afa970448c5cb929
|
7
|
+
data.tar.gz: 5825e52f9f3edfd0cdd750d1f4f060920c3e2dbca4547531b0be4723b2663c66424babd1de918dc4cc53a71dbfb27d8ce2d8c6673bf44f2f620bd1399f524d61
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# 0.4.0 (March 3, 2014)
|
2
|
+
|
3
|
+
* Use Rake::FileList.
|
4
|
+
* Removes Gemfile warning.
|
5
|
+
* Simplifies tests a lot.
|
6
|
+
|
7
|
+
# 0.3.0 (December 31, 2012)
|
8
|
+
|
9
|
+
* Use require_relative.
|
10
|
+
|
11
|
+
# 0.2.0 (December 27, 2012)
|
12
|
+
|
13
|
+
* Added installation information.
|
14
|
+
* Renamed to mongoid-permalinks.
|
15
|
+
|
16
|
+
# 0.1.0 (December 22, 2012)
|
17
|
+
|
18
|
+
* First version.
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -16,9 +16,8 @@ gem 'mongoid-permalinks'
|
|
16
16
|
class Document
|
17
17
|
include Mongoid::Document
|
18
18
|
include Mongoid::Permalinks
|
19
|
-
|
19
|
+
|
20
20
|
field :name, type: String
|
21
|
-
|
22
21
|
alias_method :to_s, :name
|
23
22
|
end
|
24
23
|
```
|
@@ -40,7 +39,7 @@ document.permalink # => 'mongoid-permalinks-is-awesome'
|
|
40
39
|
|
41
40
|
(The MIT license)
|
42
41
|
|
43
|
-
Copyright (c) 2012 Mario Uher
|
42
|
+
Copyright (c) 2012-2014 Mario Uher
|
44
43
|
|
45
44
|
Permission is hereby granted, free of charge, to any person obtaining
|
46
45
|
a copy of this software and associated documentation files (the
|
@@ -59,4 +58,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
59
58
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
60
59
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
61
60
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
62
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
61
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
CHANGED
File without changes
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require_relative 'test_helper'
|
2
|
+
|
3
|
+
class Document
|
4
|
+
include Mongoid::Document
|
5
|
+
include Mongoid::Permalinks
|
6
|
+
|
7
|
+
field :name, type: String
|
8
|
+
|
9
|
+
alias_method :to_s, :name
|
10
|
+
end
|
11
|
+
|
12
|
+
class Localized < Document
|
13
|
+
field :name, type: String, localize: true
|
14
|
+
field :permalink, type: String, localize: true
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
class PermalinksTest < Minitest::Unit::TestCase
|
19
|
+
def test_it_responds_to_permalink_field
|
20
|
+
assert_equal String, Document.fields['permalink'].type
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
def test_providing_an_permalink
|
25
|
+
assert_equal 'custom-permalink', Document.create(permalink: 'Custom Permalink', name: 'Name').permalink
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
def test_providing_an_empty_permalink_uses_name_instead
|
30
|
+
assert_equal 'name', Document.create(permalink: '', name: 'Name').permalink
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
def test_providing_an_permalink_with_trailing_spaces
|
35
|
+
assert_equal 'custom-permalink', Document.create(permalink: ' Custom Permalink ', name: 'Name').permalink
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
def test_providing_an_permalink_with_special_characters
|
40
|
+
assert_equal 'mario-u', Document.create(permalink: 'Mario U.', name: 'Name').permalink
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
def test_localized_permalink
|
45
|
+
document = Localized.new
|
46
|
+
|
47
|
+
I18n.locale = :en
|
48
|
+
document.update_attributes permalink: 'English'
|
49
|
+
|
50
|
+
assert_equal 'english', document.permalink
|
51
|
+
|
52
|
+
I18n.locale = :de
|
53
|
+
document.update_attributes permalink: 'Deutsch'
|
54
|
+
|
55
|
+
assert_equal 'deutsch', document.permalink
|
56
|
+
|
57
|
+
I18n.locale = :en
|
58
|
+
|
59
|
+
assert_equal 'english', document.permalink
|
60
|
+
end
|
61
|
+
end
|
@@ -2,9 +2,8 @@ $: << File.expand_path('../../lib', __FILE__)
|
|
2
2
|
|
3
3
|
require 'minitest/autorun'
|
4
4
|
require 'minitest/pride'
|
5
|
-
require 'minitest/spec'
|
6
5
|
|
7
6
|
require 'mongoid/permalinks'
|
8
7
|
|
9
8
|
# Load support *.rb files in ./support
|
10
|
-
|
9
|
+
Mongoid.load!(File.expand_path('../mongoid.yml', __FILE__), 'test')
|
metadata
CHANGED
@@ -1,88 +1,81 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid-permalinks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 0.3.0
|
4
|
+
version: 0.4.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Mario Uher
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-03-03 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
|
-
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
|
-
none: false
|
21
|
-
name: activesupport
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
23
|
requirements:
|
26
|
-
- -
|
24
|
+
- - ">="
|
27
25
|
- !ruby/object:Gem::Version
|
28
26
|
version: '0'
|
29
|
-
none: false
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
|
-
|
28
|
+
name: mongoid
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
32
30
|
requirements:
|
33
|
-
- -
|
31
|
+
- - ">="
|
34
32
|
- !ruby/object:Gem::Version
|
35
33
|
version: '0'
|
36
|
-
none: false
|
37
|
-
name: mongoid
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
|
-
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
37
|
requirements:
|
42
|
-
- -
|
38
|
+
- - ">="
|
43
39
|
- !ruby/object:Gem::Version
|
44
40
|
version: '0'
|
45
|
-
none: false
|
46
41
|
description: Mongoid::Permalink adds a permalink based on your document to_s method.
|
47
42
|
email: uher.mario@gmail.com
|
48
43
|
executables: []
|
49
44
|
extensions: []
|
50
45
|
extra_rdoc_files: []
|
51
46
|
files:
|
52
|
-
- .gitignore
|
47
|
+
- ".gitignore"
|
48
|
+
- CHANGELOG.md
|
53
49
|
- Gemfile
|
54
50
|
- README.md
|
55
51
|
- Rakefile
|
56
52
|
- lib/mongoid/permalinks.rb
|
57
53
|
- lib/mongoid/permalinks/version.rb
|
58
54
|
- mongoid-permalinks.gemspec
|
59
|
-
-
|
60
|
-
-
|
61
|
-
-
|
62
|
-
- spec/support/document.rb
|
63
|
-
- spec/support/mongoid.yml
|
55
|
+
- test/mongoid.yml
|
56
|
+
- test/permalinks_test.rb
|
57
|
+
- test/test_helper.rb
|
64
58
|
homepage: https://github.com/haihappen/mongoid-permalinks
|
65
59
|
licenses: []
|
60
|
+
metadata: {}
|
66
61
|
post_install_message:
|
67
62
|
rdoc_options: []
|
68
63
|
require_paths:
|
69
64
|
- lib
|
70
65
|
required_ruby_version: !ruby/object:Gem::Requirement
|
71
66
|
requirements:
|
72
|
-
- -
|
67
|
+
- - ">="
|
73
68
|
- !ruby/object:Gem::Version
|
74
69
|
version: '0'
|
75
|
-
none: false
|
76
70
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
71
|
requirements:
|
78
|
-
- -
|
72
|
+
- - ">="
|
79
73
|
- !ruby/object:Gem::Version
|
80
74
|
version: '0'
|
81
|
-
none: false
|
82
75
|
requirements: []
|
83
76
|
rubyforge_project:
|
84
|
-
rubygems_version:
|
77
|
+
rubygems_version: 2.2.0
|
85
78
|
signing_key:
|
86
|
-
specification_version:
|
79
|
+
specification_version: 4
|
87
80
|
summary: Permalinks for your Mongoid documents.
|
88
81
|
test_files: []
|
data/spec/permalinks_spec.rb
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
require_relative 'spec_helper'
|
2
|
-
|
3
|
-
describe Mongoid::Permalinks do
|
4
|
-
it 'adds permalink field' do
|
5
|
-
Document.fields['permalink'].type.must_equal String
|
6
|
-
end
|
7
|
-
|
8
|
-
|
9
|
-
describe 'setting permalink' do
|
10
|
-
subject { Document.create(permalink: permalink, name: 'Name') }
|
11
|
-
let(:value) { subject.permalink }
|
12
|
-
|
13
|
-
|
14
|
-
describe 'providing an empty permalink' do
|
15
|
-
let(:permalink) { '' }
|
16
|
-
|
17
|
-
|
18
|
-
it 'parameterizes name instead' do
|
19
|
-
value.must_equal 'name'
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
|
24
|
-
describe 'providing an permalink' do
|
25
|
-
let(:permalink) { 'custom permalink' }
|
26
|
-
|
27
|
-
|
28
|
-
it 'parameterizes it' do
|
29
|
-
value.must_equal 'custom-permalink'
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
describe 'providing an permalink with trailing spaces' do
|
35
|
-
let(:permalink) { ' custom permalink ' }
|
36
|
-
|
37
|
-
|
38
|
-
it 'parameterizes it and removes the spaces' do
|
39
|
-
value.must_equal 'custom-permalink'
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
|
44
|
-
describe 'providing an permalink with special characters' do
|
45
|
-
let(:permalink) { 'Donald E. Knuth' }
|
46
|
-
|
47
|
-
|
48
|
-
it 'parameterizes it and makes it pretty' do
|
49
|
-
value.must_equal 'donald-e-knuth'
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
|
55
|
-
describe 'having localized permalink fields' do
|
56
|
-
subject { Localized.new }
|
57
|
-
|
58
|
-
|
59
|
-
it 'works too' do
|
60
|
-
{ en: 'English', de: 'Deutsch' }.each do |locale, permalink|
|
61
|
-
I18n.locale = locale
|
62
|
-
subject.permalink = permalink
|
63
|
-
subject.save
|
64
|
-
|
65
|
-
subject.permalink.must_equal permalink.parameterize
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
data/spec/support/connection.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
Mongoid.load!(File.expand_path('../mongoid.yml', __FILE__), 'test')
|
data/spec/support/document.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
class Document
|
2
|
-
include Mongoid::Document
|
3
|
-
include Mongoid::Permalinks
|
4
|
-
|
5
|
-
field :name, type: String
|
6
|
-
|
7
|
-
alias_method :to_s, :name
|
8
|
-
end
|
9
|
-
|
10
|
-
class Localized
|
11
|
-
include Mongoid::Document
|
12
|
-
include Mongoid::Permalinks
|
13
|
-
|
14
|
-
field :name, type: String, localize: true
|
15
|
-
field :permalink, type: String, localize: true
|
16
|
-
|
17
|
-
alias_method :to_s, :name
|
18
|
-
end
|