mongoid-slug 5.2.0 → 5.3.0

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.
@@ -1,27 +1,41 @@
1
+ shared_context 'with an index' do |key|
2
+ if Mongoid::Compatibility::Version.mongoid3?
3
+ let(:index) { subject.index_options[key] }
4
+ let(:index_keys) { key }
5
+ let(:index_options) { index }
6
+ else
7
+ let(:index) { subject.index_specifications.detect { |spec| spec.key == key } }
8
+ let(:index_keys) { index.key }
9
+ let(:index_options) { index.options }
10
+ end
11
+ end
12
+
1
13
  shared_examples 'has an index' do |key, options|
2
- it "has a #{key} index" do
3
- index = if Mongoid::Compatibility::Version.mongoid3?
4
- subject.index_options[key]
5
- else
6
- subject.index_specifications.detect { |spec| spec.key == key }
7
- end
14
+ include_context 'with an index', key
15
+
16
+ it "has a #{[key, options].compact.join(', ')} index" do
8
17
  expect(index).not_to be_nil
18
+ end
19
+
20
+ it 'has the correct order of keys' do
21
+ expect(index_keys.keys).to eq key.keys
22
+ end
23
+
24
+ it 'has the correct order of key values' do
25
+ expect(index_keys.values).to eq key.values
26
+ end
27
+
28
+ it 'matches option values' do
9
29
  options.each_pair do |name, value|
10
- if Mongoid::Compatibility::Version.mongoid3?
11
- expect(index[name]).to eq(value)
12
- else
13
- expect(index.options[name]).to eq(value)
14
- end
15
- end if options
30
+ expect(index_options[name]).to eq(value)
31
+ end
16
32
  end
17
33
  end
18
34
 
19
- shared_examples 'does not have an index' do |key, _option|
35
+ shared_examples 'does not have an index' do |key|
36
+ include_context 'with an index', key
37
+
20
38
  it "does not have the #{key} index" do
21
- if Mongoid::Compatibility::Version.mongoid3?
22
- expect(subject.index_options[key]).to be_nil
23
- else
24
- expect(subject.index_specifications.detect { |spec| spec.key == key }).to be_nil
25
- end
39
+ expect(index).to be nil
26
40
  end
27
41
  end
@@ -43,11 +43,25 @@ RSpec.configure do |c|
43
43
 
44
44
  c.before :all do
45
45
  Mongoid.logger.level = Logger::INFO
46
- Mongo::Logger.logger.level = Logger::INFO if Mongoid::Compatibility::Version.mongoid5?
46
+ if Mongoid::Compatibility::Version.mongoid5? || Mongoid::Compatibility::Version.mongoid6?
47
+ Mongo::Logger.logger.level = Logger::INFO
48
+ end
47
49
  end
48
50
 
49
51
  c.before(:each) do
50
52
  Mongoid.purge!
53
+ Author.create_indexes
54
+ Book.create_indexes
55
+ AuthorPolymorphic.create_indexes
56
+ BookPolymorphic.create_indexes
51
57
  Mongoid::IdentityMap.clear if defined?(Mongoid::IdentityMap)
52
58
  end
59
+
60
+ c.after(:all) do
61
+ if Mongoid::Compatibility::Version.mongoid3? || Mongoid::Compatibility::Version.mongoid4?
62
+ Mongoid.default_session.drop
63
+ else
64
+ Mongoid::Clients.default.database.drop
65
+ end
66
+ end
53
67
  end
@@ -41,7 +41,7 @@ describe 'mongoid_slug:set' do
41
41
  Rake::Task['mongoid_slug:set'].invoke('UninitalizedSlugFirst')
42
42
 
43
43
  expect(uninitalized_slug1.reload.slugs).to eq(['uninitalized-slug1'])
44
- expect(uninitalized_slug2.reload.slugs).to eq []
44
+ expect(uninitalized_slug2.reload.slugs).to be nil
45
45
  end
46
46
  end
47
47
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-slug
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.2.0
4
+ version: 5.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andreas Saebjoernsen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-03 00:00:00.000000000 Z
11
+ date: 2016-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid
@@ -136,34 +136,6 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
- - !ruby/object:Gem::Dependency
140
- name: pry
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: '0'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- version: '0'
153
- - !ruby/object:Gem::Dependency
154
- name: rubocop
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - '='
158
- - !ruby/object:Gem::Version
159
- version: 0.34.2
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - '='
165
- - !ruby/object:Gem::Version
166
- version: 0.34.2
167
139
  description: Mongoid URL slug or permalink generator
168
140
  email:
169
141
  - andy@cosemble.com
@@ -218,7 +190,7 @@ files:
218
190
  - spec/shared/indexes.rb
219
191
  - spec/spec_helper.rb
220
192
  - spec/tasks/mongoid_slug_rake_spec.rb
221
- homepage: https://github.com/digitalplaywright/mongoid-slug
193
+ homepage: https://github.com/mongoid/mongoid-slug
222
194
  licenses:
223
195
  - MIT
224
196
  metadata: {}
@@ -238,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
238
210
  version: '0'
239
211
  requirements: []
240
212
  rubyforge_project: mongoid-slug
241
- rubygems_version: 2.4.8
213
+ rubygems_version: 2.5.1
242
214
  signing_key:
243
215
  specification_version: 4
244
216
  summary: Mongoid URL slugs