dolly 3.1.2 → 3.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dolly/collection.rb +3 -1
- data/lib/dolly/connection.rb +11 -4
- data/lib/dolly/depracated_database.rb +6 -6
- data/lib/dolly/document.rb +10 -12
- data/lib/dolly/document_creation.rb +10 -2
- data/lib/dolly/document_type.rb +27 -3
- data/lib/dolly/exceptions.rb +11 -0
- data/lib/dolly/mango.rb +2 -2
- data/lib/dolly/mango_index.rb +0 -1
- data/lib/dolly/properties.rb +20 -4
- data/lib/dolly/property.rb +2 -1
- data/lib/dolly/property_manager.rb +10 -6
- data/lib/dolly/property_set.rb +5 -2
- data/lib/dolly/query.rb +4 -5
- data/lib/dolly/request_header.rb +1 -1
- data/lib/dolly/slugable.rb +56 -0
- data/lib/dolly/version.rb +1 -1
- data/lib/dolly.rb +1 -0
- data/lib/tasks/db.rake +71 -0
- data/test/document_type_test.rb +4 -0
- data/test/inheritance_test.rb +2 -2
- data/test/mango_test.rb +3 -33
- data/test/partitioned_document_test.rb +38 -0
- data/test/property_manager_test.rb +3 -1
- data/test/slugable_document_test.rb +51 -0
- metadata +21 -6
- data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/test/dummy/log/test.log +0 -111345
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class PartitionedDocumentTest < Test::Unit::TestCase
|
4
|
+
PARTITIONED_DB_PATH = 'http://localhost:5984/partitioned/'
|
5
|
+
|
6
|
+
test 'unpartitioned DB will raise exception' do
|
7
|
+
stub_request(:get, PARTITIONED_DB_PATH).
|
8
|
+
with(headers: { 'Content-Type'=>'application/json' }).
|
9
|
+
to_return(status: 200, body: { db_name: 'partitioned' }.to_json)
|
10
|
+
|
11
|
+
assert_raise(Dolly::PartitionedDataBaseExpectedError) do
|
12
|
+
class Partitioned < Dolly::Document
|
13
|
+
partitioned!
|
14
|
+
property :foo, class_name: String
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
test 'document id is partitioned' do
|
20
|
+
stub_request(:get, PARTITIONED_DB_PATH).
|
21
|
+
with(headers: { 'Content-Type'=>'application/json' }).
|
22
|
+
to_return(status: 200, body: { db_name: 'partitioned', props: { partitioned: true } }.to_json)
|
23
|
+
|
24
|
+
class Partitioned < Dolly::Document
|
25
|
+
set_namespace 'partitioned'
|
26
|
+
partitioned!
|
27
|
+
|
28
|
+
property :foo, class_name: String
|
29
|
+
end
|
30
|
+
|
31
|
+
assert_equal Partitioned.absolute_id("partitioned:abc"), "abc"
|
32
|
+
|
33
|
+
doc = Partitioned.new(foo: "something")
|
34
|
+
assert doc.id =~ /^partitioned:.+/
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
|
@@ -4,15 +4,17 @@ class TestDoc < Dolly::Document
|
|
4
4
|
property :name, class_name: String
|
5
5
|
property :email, class_name: String
|
6
6
|
property :last_name, class_name: String
|
7
|
+
property :active, class_name: TrueClass
|
7
8
|
end
|
8
9
|
|
9
10
|
class PropertyManagerTest < Test::Unit::TestCase
|
10
11
|
test 'write_attribute with nil value' do
|
11
|
-
doc = TestDoc.new(name: 'name', last_name: nil, email: 'does not change')
|
12
|
+
doc = TestDoc.new(name: 'name', last_name: nil, email: 'does not change', active: 'true')
|
12
13
|
assert_equal(doc.name, 'name')
|
13
14
|
doc.update_properties(name: nil)
|
14
15
|
assert_equal(doc.name, nil)
|
15
16
|
assert_equal(doc.last_name, nil)
|
16
17
|
assert_equal(doc.email, 'does not change')
|
18
|
+
assert_equal(doc.active, true)
|
17
19
|
end
|
18
20
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class SlugedDocument < Dolly::Document
|
4
|
+
include Dolly::Slugable
|
5
|
+
property :name, class_name: String
|
6
|
+
set_slug :name
|
7
|
+
end
|
8
|
+
|
9
|
+
class MultiSlugedDocument < Dolly::Document
|
10
|
+
include Dolly::Slugable
|
11
|
+
property :foo, class_name: String
|
12
|
+
property :bar, class_name: Integer
|
13
|
+
|
14
|
+
set_slug :foo, :bar
|
15
|
+
end
|
16
|
+
|
17
|
+
class CustomSeparatorSlug < Dolly::Document
|
18
|
+
include Dolly::Slugable
|
19
|
+
property :a, class_name: Integer
|
20
|
+
property :b, class_name: String
|
21
|
+
property :c, class_name: String
|
22
|
+
|
23
|
+
set_slug :a, :b, :c, separator: '*'
|
24
|
+
end
|
25
|
+
|
26
|
+
class SlugableDocumentTest < Test::Unit::TestCase
|
27
|
+
test 'default id of slugable document is name' do
|
28
|
+
assert_equal SlugedDocument.new(name: "a").id, "sluged_document/a"
|
29
|
+
end
|
30
|
+
|
31
|
+
test 'bundled slug id' do
|
32
|
+
assert_equal MultiSlugedDocument.new(foo: "a", bar: 1).id, "multi_sluged_document/a_1"
|
33
|
+
end
|
34
|
+
|
35
|
+
test 'bundled slug id cant be empty' do
|
36
|
+
assert_equal MultiSlugedDocument.new(foo: "a").id, "multi_sluged_document/a_"
|
37
|
+
end
|
38
|
+
|
39
|
+
test 'custom seperator slug' do
|
40
|
+
assert_equal CustomSeparatorSlug.new(a: 1, b: 'x', c: 'c').id, "custom_separator_slug/1*x*c"
|
41
|
+
end
|
42
|
+
|
43
|
+
test 'raise missing slug exception' do
|
44
|
+
assert_raise(Dolly::MissingSlugableProperties) do
|
45
|
+
class MissingSlugDocument < Dolly::Document
|
46
|
+
include Dolly::Slugable
|
47
|
+
set_slug :foo
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dolly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- javierg
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '13.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rexml
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: test-unit-full
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -141,6 +155,7 @@ files:
|
|
141
155
|
- lib/dolly/query_arguments.rb
|
142
156
|
- lib/dolly/request.rb
|
143
157
|
- lib/dolly/request_header.rb
|
158
|
+
- lib/dolly/slugable.rb
|
144
159
|
- lib/dolly/timestamp.rb
|
145
160
|
- lib/dolly/version.rb
|
146
161
|
- lib/dolly/view_query.rb
|
@@ -151,12 +166,12 @@ files:
|
|
151
166
|
- test/bulk_document_test.rb
|
152
167
|
- test/document_test.rb
|
153
168
|
- test/document_type_test.rb
|
154
|
-
- test/dummy/config/initializers/filter_parameter_logging.rb
|
155
|
-
- test/dummy/log/test.log
|
156
169
|
- test/inheritance_test.rb
|
157
170
|
- test/mango_index_test.rb
|
158
171
|
- test/mango_test.rb
|
172
|
+
- test/partitioned_document_test.rb
|
159
173
|
- test/property_manager_test.rb
|
174
|
+
- test/slugable_document_test.rb
|
160
175
|
- test/support/test.txt
|
161
176
|
- test/test_helper.rb
|
162
177
|
- test/view_query_test.rb
|
@@ -183,8 +198,8 @@ signing_key:
|
|
183
198
|
specification_version: 4
|
184
199
|
summary: will write something
|
185
200
|
test_files:
|
186
|
-
- test/
|
187
|
-
- test/
|
201
|
+
- test/partitioned_document_test.rb
|
202
|
+
- test/slugable_document_test.rb
|
188
203
|
- test/inheritance_test.rb
|
189
204
|
- test/document_type_test.rb
|
190
205
|
- test/mango_index_test.rb
|