mongoid_permalink_extension 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f13fb1ed216c60973b45afab89fa6ec65a0552ac
|
4
|
+
data.tar.gz: d8449c8b1d4751d6ea1b9d5431c2640e9eaf973b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15fd20bdbdf234afe35eb838ce97070e664b8e2d7ea87cefbea0c593e72f54ac3ae4741e1c0c7f8922d90e7436be4a5def47fc4c2f8279751821fa1c8b121024
|
7
|
+
data.tar.gz: efcebe2e00315277a00663433737effe21a29975f899c926a78cbac05ab3ab42b661c44802f15839156f71e735c32db590184dd2c448dc8599f62b88bdaaf060
|
@@ -2,62 +2,63 @@
|
|
2
2
|
|
3
3
|
require 'test_helper'
|
4
4
|
|
5
|
-
# ---------------------------------------------------------------------
|
6
|
-
|
7
5
|
class MongoidPermalinkExtensionTest
|
8
6
|
include Mongoid::Document
|
9
7
|
field :permalink, type: MongoidPermalinkExtension::Permalink
|
10
8
|
end
|
11
9
|
|
12
10
|
# ---------------------------------------------------------------------
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
11
|
+
|
12
|
+
describe MongoidPermalinkExtension::Permalink do
|
13
|
+
subject { MongoidPermalinkExtensionTest.new }
|
14
|
+
|
15
|
+
# ---------------------------------------------------------------------
|
16
|
+
|
17
|
+
describe '.demongoize' do
|
18
|
+
let(:permalink_value) { 'something stored in the database' }
|
19
|
+
it 'does not change the value' do
|
20
|
+
MongoidPermalinkExtension::Permalink.demongoize(permalink_value).must_equal permalink_value
|
24
21
|
end
|
22
|
+
end
|
25
23
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
it 'produces nice slugs' do
|
56
|
-
MongoidPermalinkExtension::Permalink.mongoize('Future Vocabularies?').must_equal 'Future-Vocabularies'
|
57
|
-
MongoidPermalinkExtension::Permalink.mongoize('2011 space odyssey').must_equal '2011-Space-Odyssey'
|
58
|
-
MongoidPermalinkExtension::Permalink.mongoize('A permalink with & in it').must_equal 'A-Permalink-With-In-It'
|
24
|
+
# ---------------------------------------------------------------------
|
25
|
+
|
26
|
+
describe '.mongoize' do
|
27
|
+
it 'converts anything to string' do
|
28
|
+
MongoidPermalinkExtension::Permalink.mongoize(12).must_equal '12'
|
29
|
+
end
|
30
|
+
it 'stores transformed string' do
|
31
|
+
MongoidPermalinkExtension::Permalink.mongoize("some some").must_be :present?
|
32
|
+
end
|
33
|
+
it 'stores nil if nil passed' do
|
34
|
+
MongoidPermalinkExtension::Permalink.mongoize(nil).must_be_nil
|
35
|
+
end
|
36
|
+
it 'converts spaces to hyphens' do
|
37
|
+
MongoidPermalinkExtension::Permalink.mongoize(" ").must_equal '-'
|
38
|
+
MongoidPermalinkExtension::Permalink.mongoize(" ").must_equal '-'
|
39
|
+
end
|
40
|
+
it 'converts slashes to hyphens' do
|
41
|
+
MongoidPermalinkExtension::Permalink.mongoize("/").must_equal '-'
|
42
|
+
end
|
43
|
+
it 'converts to camel case' do
|
44
|
+
MongoidPermalinkExtension::Permalink.mongoize("hello hello").wont_include 'h'
|
45
|
+
end
|
46
|
+
it 'converts all dashes to hyphens' do
|
47
|
+
MongoidPermalinkExtension::Permalink.mongoize("–").must_equal '-'
|
48
|
+
MongoidPermalinkExtension::Permalink.mongoize("—").must_equal '-'
|
49
|
+
end
|
50
|
+
it 'remove non-alphanumeric characters' do
|
51
|
+
%w(?!@#$%^&*()+=.,;<>[]).shuffle.each do |i|
|
52
|
+
MongoidPermalinkExtension::Permalink.mongoize(i).wont_include i
|
59
53
|
end
|
60
54
|
end
|
61
|
-
|
55
|
+
it 'preserves accented characters' do
|
56
|
+
MongoidPermalinkExtension::Permalink.mongoize('Bienále Brno Česká republika').must_equal 'Bienale-Brno-Ceska-Republika'
|
57
|
+
end
|
58
|
+
it 'produces nice slugs' do
|
59
|
+
MongoidPermalinkExtension::Permalink.mongoize('Future Vocabularies?').must_equal 'Future-Vocabularies'
|
60
|
+
MongoidPermalinkExtension::Permalink.mongoize('2011 space odyssey').must_equal '2011-Space-Odyssey'
|
61
|
+
MongoidPermalinkExtension::Permalink.mongoize('A permalink with & in it').must_equal 'A-Permalink-With-In-It'
|
62
|
+
end
|
62
63
|
end
|
63
|
-
end
|
64
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid_permalink_extension
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Celizna
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mongoid
|
@@ -165,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
165
|
version: '0'
|
166
166
|
requirements: []
|
167
167
|
rubyforge_project:
|
168
|
-
rubygems_version: 2.
|
168
|
+
rubygems_version: 2.4.8
|
169
169
|
signing_key:
|
170
170
|
specification_version: 4
|
171
171
|
summary: Custom field type for Mongoid that automatically converts strings to URL
|