mongoid 5.1.2 → 5.1.3
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/mongoid/attributes.rb +1 -1
- data/lib/mongoid/criteria/modifiable.rb +1 -1
- data/lib/mongoid/shardable.rb +3 -1
- data/lib/mongoid/version.rb +1 -1
- data/spec/mongoid/attributes_spec.rb +11 -1
- data/spec/mongoid/criteria/modifiable_spec.rb +0 -22
- data/spec/mongoid/relations/auto_save_spec.rb +1 -1
- data/spec/mongoid/serializable_spec.rb +3 -1
- data/spec/mongoid/shardable_spec.rb +18 -8
- metadata +3 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4fed172bb6af11ba2b149b79f186088e927654b
|
4
|
+
data.tar.gz: 5a773064e7b4e5b53b299763cc224376e1c2b982
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c0acac4c15262c18ada59b3297588f8ad173f9a3729ecb8b2bbffdb43276549c7e9f7ea94856141c7dde36c028964373d3a27e7bba21990fb8958f6051931b0a
|
7
|
+
data.tar.gz: 70a79115a1c45102070577281ad7664b89a34a284c14bb08a6b79af4bd385d544c4f9bce177b9babedfb13734dcfd480e1c2ca7e9676b5b405a77ed21e588788
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/mongoid/attributes.rb
CHANGED
@@ -173,7 +173,7 @@ module Mongoid
|
|
173
173
|
# @since 3.0.0
|
174
174
|
def create_document(method, attrs = nil, &block)
|
175
175
|
attributes = selector.reduce(attrs ? attrs.dup : {}) do |hash, (key, value)|
|
176
|
-
unless key.to_s =~ /\$/ ||
|
176
|
+
unless key.to_s =~ /\$/ || value.is_a?(Hash)
|
177
177
|
hash[key] = value
|
178
178
|
end
|
179
179
|
hash
|
data/lib/mongoid/shardable.rb
CHANGED
data/lib/mongoid/version.rb
CHANGED
@@ -1652,6 +1652,16 @@ describe Mongoid::Attributes do
|
|
1652
1652
|
|
1653
1653
|
context 'when calling the attribute check method' do
|
1654
1654
|
|
1655
|
+
context 'when the attribute is blank' do
|
1656
|
+
let(:person) do
|
1657
|
+
Person.create(title: '')
|
1658
|
+
end
|
1659
|
+
|
1660
|
+
it 'returns false' do
|
1661
|
+
expect(person.title?).to be(false)
|
1662
|
+
end
|
1663
|
+
end
|
1664
|
+
|
1655
1665
|
context 'when the attribute is localized' do
|
1656
1666
|
let(:person) do
|
1657
1667
|
Person.create(desc: 'localized')
|
@@ -1687,7 +1697,7 @@ describe Mongoid::Attributes do
|
|
1687
1697
|
end
|
1688
1698
|
|
1689
1699
|
it 'does not apply localization when checking the attribute' do
|
1690
|
-
expect(person.
|
1700
|
+
expect(person.username?).to be(false)
|
1691
1701
|
end
|
1692
1702
|
end
|
1693
1703
|
end
|
@@ -612,17 +612,6 @@ describe Mongoid::Criteria::Modifiable do
|
|
612
612
|
end
|
613
613
|
end
|
614
614
|
end
|
615
|
-
|
616
|
-
context 'when the criteria selector includes a hash field' do
|
617
|
-
|
618
|
-
let(:document) do
|
619
|
-
Person.where(map: { foo: :bar }).first_or_create
|
620
|
-
end
|
621
|
-
|
622
|
-
it 'sets the hash field' do
|
623
|
-
expect(document.map).to eq({ foo: :bar })
|
624
|
-
end
|
625
|
-
end
|
626
615
|
end
|
627
616
|
end
|
628
617
|
|
@@ -747,17 +736,6 @@ describe Mongoid::Criteria::Modifiable do
|
|
747
736
|
end
|
748
737
|
end
|
749
738
|
end
|
750
|
-
|
751
|
-
context 'when the criteria selector includes a hash field' do
|
752
|
-
|
753
|
-
let(:document) do
|
754
|
-
Person.where(map: { foo: :bar }).first_or_create
|
755
|
-
end
|
756
|
-
|
757
|
-
it 'sets the hash field' do
|
758
|
-
expect(document.map).to eq({ foo: :bar })
|
759
|
-
end
|
760
|
-
end
|
761
739
|
end
|
762
740
|
end
|
763
741
|
|
@@ -394,7 +394,7 @@ describe Mongoid::Serializable do
|
|
394
394
|
hash["addresses"]
|
395
395
|
end
|
396
396
|
|
397
|
-
|
397
|
+
context "when the ids were not loaded" do
|
398
398
|
|
399
399
|
before do
|
400
400
|
person.save
|
@@ -409,6 +409,8 @@ describe Mongoid::Serializable do
|
|
409
409
|
end
|
410
410
|
|
411
411
|
it "does not generate new ids" do
|
412
|
+
pending
|
413
|
+
fail
|
412
414
|
expect(hash["addresses"].first["_id"]).to be_nil
|
413
415
|
end
|
414
416
|
end
|
@@ -22,27 +22,37 @@ describe Mongoid::Shardable do
|
|
22
22
|
describe ".shard_key" do
|
23
23
|
|
24
24
|
let(:klass) do
|
25
|
-
|
26
|
-
include Mongoid::Shardable
|
27
|
-
end
|
25
|
+
Band
|
28
26
|
end
|
29
27
|
|
30
28
|
before do
|
31
|
-
|
29
|
+
Band.shard_key(:name)
|
32
30
|
end
|
33
31
|
|
34
32
|
it "specifies a shard key on the collection" do
|
35
33
|
expect(klass.shard_key_fields).to eq([:name])
|
36
34
|
end
|
35
|
+
|
36
|
+
context 'when a relation is used as the shard key' do
|
37
|
+
|
38
|
+
let(:klass) do
|
39
|
+
Game
|
40
|
+
end
|
41
|
+
|
42
|
+
before do
|
43
|
+
Game.shard_key(:person)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "converts the shard key to the foreign key field" do
|
47
|
+
expect(klass.shard_key_fields).to eq([:person_id])
|
48
|
+
end
|
49
|
+
end
|
37
50
|
end
|
38
51
|
|
39
52
|
describe "#shard_key_selector" do
|
40
53
|
|
41
54
|
let(:klass) do
|
42
|
-
|
43
|
-
include Mongoid::Shardable
|
44
|
-
attr_accessor :name
|
45
|
-
end
|
55
|
+
Band
|
46
56
|
end
|
47
57
|
|
48
58
|
let(:object) do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.1.
|
4
|
+
version: 5.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Durran Jordan
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
ZIvvwAhgCjVW5QCi2I1noxXLmtZ3XDawWu8kaGtu8giHXcwL3941m8hvFZ/Wr9Yi
|
31
31
|
JvcXJt2a4/JvwnIs2hmKuyfhZmB9HEE5wQQaCMnnC14=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2016-
|
33
|
+
date: 2016-04-21 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: activemodel
|
@@ -811,7 +811,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
811
811
|
version: 1.3.6
|
812
812
|
requirements: []
|
813
813
|
rubyforge_project: mongoid
|
814
|
-
rubygems_version: 2.4.
|
814
|
+
rubygems_version: 2.4.5.1
|
815
815
|
signing_key:
|
816
816
|
specification_version: 4
|
817
817
|
summary: Elegant Persistence in Ruby for MongoDB.
|
metadata.gz.sig
CHANGED
Binary file
|