glebtv-mongoid_nested_set 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/glebtv-mongoid_nested_set.gemspec +1 -2
- data/lib/mongoid_nested_set/update.rb +1 -2
- data/lib/mongoid_nested_set/version.rb +1 -1
- data/spec/matchers/nestedset_pos.rb +20 -0
- data/spec/mongoid_nested_set_spec.rb +17 -21
- data/spec/spec_helper.rb +2 -1
- metadata +24 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d3ae4fb0473cf7cef052ee941ef62e4d0f642ef
|
4
|
+
data.tar.gz: ed8aef4a4d36c0936bbd8e0397fba3c84fb2907c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9f0a5179fb255f08f64f78be3dc517e80acc04200e61b63b01372a9efd488817df9c8bfa1b458b18f12a2308e3d603fa4074328a98ff1595f5ed811ce079be9
|
7
|
+
data.tar.gz: 20079c928fae0fbf0633c73f8d4d7ddff0b81b92125658be59fee61627fbaf68ebd279d7a4ab96cc45a35570904039be3cbc3815701f01137348049ead99c631
|
@@ -26,8 +26,7 @@ Gem::Specification.new do |s|
|
|
26
26
|
s.add_development_dependency 'bundler'
|
27
27
|
s.add_development_dependency 'simplecov'
|
28
28
|
s.add_development_dependency 'simplecov-rcov'
|
29
|
-
s.add_development_dependency 'mongoid-rspec'
|
30
|
-
|
31
29
|
s.add_development_dependency 'database_cleaner'
|
32
30
|
s.add_development_dependency 'rspec-expectations'
|
31
|
+
s.add_development_dependency 'mongoid-rspec', '3.0.0'
|
33
32
|
end
|
@@ -125,8 +125,7 @@ module Mongoid::Acts::NestedSet
|
|
125
125
|
left += width
|
126
126
|
end
|
127
127
|
|
128
|
-
|
129
|
-
collection = client[scope_class.collection_name]
|
128
|
+
collection = scope_class.collection
|
130
129
|
scope = nested_set_scope.remove_order_by
|
131
130
|
|
132
131
|
# allocate space for new move
|
@@ -36,6 +36,26 @@ module Mongoid::Acts::NestedSet
|
|
36
36
|
)
|
37
37
|
end
|
38
38
|
|
39
|
+
def failure_message
|
40
|
+
sprintf("expected nested set position: {left: %2s, right: %2s}\n" +
|
41
|
+
" got: {left: %2s, right: %2s}",
|
42
|
+
@lft,
|
43
|
+
@rgt,
|
44
|
+
@node.respond_to?('left') ? @node.left : '?',
|
45
|
+
@node.respond_to?('right') ? @node.right : '?'
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
def failure_message_when_negated
|
50
|
+
sprintf("expected nested set to not have position: {left: %2s, right: %2s}\n" +
|
51
|
+
" got: {left: %2s, right: %2s}",
|
52
|
+
@lft,
|
53
|
+
@rgt,
|
54
|
+
@node.respond_to?('left') ? @node.left : '?',
|
55
|
+
@node.respond_to?('right') ? @node.right : '?'
|
56
|
+
)
|
57
|
+
end
|
58
|
+
|
39
59
|
def failure_message_for_should_not
|
40
60
|
sprintf("expected nested set to not have position: {left: %2s, right: %2s}", @lft, @rgt)
|
41
61
|
end
|
@@ -66,11 +66,11 @@ describe "A Mongoid::Document" do
|
|
66
66
|
|
67
67
|
context "that does not act as a nested set" do
|
68
68
|
it "does not have a left field" do
|
69
|
-
NodeWithoutNestedSet.should_not have_field('lft'
|
69
|
+
NodeWithoutNestedSet.should_not have_field('lft').of_type(Integer)
|
70
70
|
end
|
71
71
|
|
72
72
|
it "does not have a right field" do
|
73
|
-
NodeWithoutNestedSet.should_not have_field('rgt'
|
73
|
+
NodeWithoutNestedSet.should_not have_field('rgt').of_type(Integer)
|
74
74
|
end
|
75
75
|
|
76
76
|
it "does not include NestedSet methods" do
|
@@ -135,26 +135,26 @@ describe "A Mongoid::Document" do
|
|
135
135
|
# Adds fields
|
136
136
|
|
137
137
|
it "has a left field" do
|
138
|
-
Node.should have_field('lft'
|
139
|
-
RenamedFields.should have_field('red'
|
140
|
-
RenamedFields.should_not have_field('lft'
|
138
|
+
Node.should have_field('lft').of_type(Integer)
|
139
|
+
RenamedFields.should have_field('red').of_type(Integer)
|
140
|
+
RenamedFields.should_not have_field('lft').of_type(Integer)
|
141
141
|
end
|
142
142
|
|
143
143
|
it "has a right field" do
|
144
|
-
Node.should have_field('rgt'
|
145
|
-
RenamedFields.should have_field('red'
|
146
|
-
RenamedFields.should_not have_field('rgt'
|
144
|
+
Node.should have_field('rgt').of_type(Integer)
|
145
|
+
RenamedFields.should have_field('red').of_type(Integer)
|
146
|
+
RenamedFields.should_not have_field('rgt').of_type(Integer)
|
147
147
|
end
|
148
148
|
|
149
149
|
it "has a parent field" do
|
150
150
|
# Starting in Mongoid 2.0.rc1, all foreign keys are Objects
|
151
|
-
Node.should have_field('parent_id'
|
152
|
-
RenamedFields.should have_field('mother_id'
|
153
|
-
RenamedFields.should_not have_field('parent_id'
|
151
|
+
Node.should have_field('parent_id').of_type(Object)
|
152
|
+
RenamedFields.should have_field('mother_id').of_type(Object)
|
153
|
+
RenamedFields.should_not have_field('parent_id').of_type(Object)
|
154
154
|
end
|
155
155
|
|
156
156
|
it "does not have a number field" do
|
157
|
-
Node.should_not have_field('number'
|
157
|
+
Node.should_not have_field('number').of_type(String)
|
158
158
|
end
|
159
159
|
|
160
160
|
it "has a default left field name" do
|
@@ -191,17 +191,13 @@ describe "A Mongoid::Document" do
|
|
191
191
|
end
|
192
192
|
|
193
193
|
it "does not allow assigning the left field" do
|
194
|
-
|
195
|
-
|
196
|
-
expect { Node.new.lft = 1 }.to raise_error
|
197
|
-
expect { RenamedFields.new.red = 1 }.to raise_error
|
194
|
+
expect { Node.new.lft = 1 }.to raise_error(NameError)
|
195
|
+
expect { RenamedFields.new.red = 1 }.to raise_error(NameError)
|
198
196
|
end
|
199
197
|
|
200
198
|
it "does not allow assigning the right field" do
|
201
|
-
|
202
|
-
|
203
|
-
expect { Node.new.rgt = 1 }.to raise_error
|
204
|
-
expect { RenamedFields.new.black = 1 }.to raise_error
|
199
|
+
expect { Node.new.rgt = 1 }.to raise_error(NameError)
|
200
|
+
expect { RenamedFields.new.black = 1 }.to raise_error(NameError)
|
205
201
|
end
|
206
202
|
|
207
203
|
|
@@ -735,7 +731,7 @@ describe "A Mongoid::Document" do
|
|
735
731
|
end
|
736
732
|
|
737
733
|
it "has a number field" do
|
738
|
-
NumberingNode.should have_field('number'
|
734
|
+
NumberingNode.should have_field('number').of_type(String)
|
739
735
|
end
|
740
736
|
|
741
737
|
context "in a tree" do
|
data/spec/spec_helper.rb
CHANGED
@@ -32,7 +32,8 @@ Dir["#{File.dirname(__FILE__)}/matchers/*.rb"].each {|file| require file }
|
|
32
32
|
Mongoid.load!("#{File.dirname(__FILE__)}/mongoid.yml", :test)
|
33
33
|
|
34
34
|
RSpec.configure do |config|
|
35
|
-
config.include Mongoid::Matchers
|
35
|
+
config.include Mongoid::Matchers
|
36
|
+
#config.expect_with(:rspec) { |c| c.syntax = :should }
|
36
37
|
|
37
38
|
config.before(:suite) do
|
38
39
|
DatabaseCleaner[:mongoid, {client: :default }]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glebtv-mongoid_nested_set
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GlebTV
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-07-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mongoid
|
@@ -102,7 +102,7 @@ dependencies:
|
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: '0'
|
104
104
|
- !ruby/object:Gem::Dependency
|
105
|
-
name:
|
105
|
+
name: database_cleaner
|
106
106
|
requirement: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - ">="
|
@@ -116,7 +116,7 @@ dependencies:
|
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
- !ruby/object:Gem::Dependency
|
119
|
-
name:
|
119
|
+
name: rspec-expectations
|
120
120
|
requirement: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - ">="
|
@@ -130,19 +130,19 @@ dependencies:
|
|
130
130
|
- !ruby/object:Gem::Version
|
131
131
|
version: '0'
|
132
132
|
- !ruby/object:Gem::Dependency
|
133
|
-
name: rspec
|
133
|
+
name: mongoid-rspec
|
134
134
|
requirement: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
|
-
- -
|
136
|
+
- - '='
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version:
|
138
|
+
version: 3.0.0
|
139
139
|
type: :development
|
140
140
|
prerelease: false
|
141
141
|
version_requirements: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
|
-
- -
|
143
|
+
- - '='
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version:
|
145
|
+
version: 3.0.0
|
146
146
|
description: Fully featured tree implementation for Mongoid using the nested set model
|
147
147
|
email:
|
148
148
|
- bt@brandonturner.net
|
@@ -209,8 +209,21 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
209
209
|
version: '0'
|
210
210
|
requirements: []
|
211
211
|
rubyforge_project: mongoid_nested_set
|
212
|
-
rubygems_version: 2.
|
212
|
+
rubygems_version: 2.5.1
|
213
213
|
signing_key:
|
214
214
|
specification_version: 4
|
215
215
|
summary: Nested set based tree implementation for Mongoid
|
216
|
-
test_files:
|
216
|
+
test_files:
|
217
|
+
- spec/matchers/nestedset_pos.rb
|
218
|
+
- spec/models/circle_node.rb
|
219
|
+
- spec/models/node.rb
|
220
|
+
- spec/models/node_without_nested_set.rb
|
221
|
+
- spec/models/numbering_node.rb
|
222
|
+
- spec/models/renamed_fields.rb
|
223
|
+
- spec/models/shape_node.rb
|
224
|
+
- spec/models/square_node.rb
|
225
|
+
- spec/models/test_document.rb
|
226
|
+
- spec/models/unscoped_node.rb
|
227
|
+
- spec/mongoid.yml
|
228
|
+
- spec/mongoid_nested_set_spec.rb
|
229
|
+
- spec/spec_helper.rb
|