dolly 3.1.2 → 3.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -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.2
4
+ version: 3.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - javierg
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-10-08 00:00:00.000000000 Z
11
+ date: 2022-10-12 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/dummy/config/initializers/filter_parameter_logging.rb
187
- - test/dummy/log/test.log
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
@@ -1,4 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Configure sensitive parameters which will be filtered from the log file.
4
- Rails.application.config.filter_parameters += [:password]