mongoid 5.1.2 → 5.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 922955f679b61344863a31c45286a9e6a98fef4c
4
- data.tar.gz: 70619f1566afa0b012a1125fd19532cb8e7ab7b1
3
+ metadata.gz: b4fed172bb6af11ba2b149b79f186088e927654b
4
+ data.tar.gz: 5a773064e7b4e5b53b299763cc224376e1c2b982
5
5
  SHA512:
6
- metadata.gz: 200a3e9686b108018cc53c8278333f71ad8aff307a730d7e5ab5c09d1849b56a34dfd3e59f48af397314d2b936261ed4d482a26ca5d83e8f0b1bc7ebb9b962eb
7
- data.tar.gz: c4daaaa77a96197384841ba4849621a63b9ea8add033cd691ff3323285d0221ffec05dce0024e8b59f012f1e0a56548da40158b5c76184b1baa1d9333a853cfa
6
+ metadata.gz: c0acac4c15262c18ada59b3297588f8ad173f9a3729ecb8b2bbffdb43276549c7e9f7ea94856141c7dde36c028964373d3a27e7bba21990fb8958f6051931b0a
7
+ data.tar.gz: 70a79115a1c45102070577281ad7664b89a34a284c14bb08a6b79af4bd385d544c4f9bce177b9babedfb13734dcfd480e1c2ca7e9676b5b405a77ed21e588788
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -350,7 +350,7 @@ module Mongoid
350
350
  if localized_fields.has_key?(name)
351
351
  value = localized_fields[name].send(:lookup, value)
352
352
  end
353
- !!value
353
+ value.present?
354
354
  end
355
355
  end
356
356
  end
@@ -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 =~ /\$/ || (value.is_a?(Hash) && !attribute_names.include?(key))
176
+ unless key.to_s =~ /\$/ || value.is_a?(Hash)
177
177
  hash[key] = value
178
178
  end
179
179
  hash
@@ -58,7 +58,9 @@ module Mongoid
58
58
  #
59
59
  # @since 2.0.0
60
60
  def shard_key(*names)
61
- self.shard_key_fields = names
61
+ names.each do |name|
62
+ self.shard_key_fields << self.database_field_name(name).to_sym
63
+ end
62
64
  end
63
65
  end
64
66
  end
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module Mongoid
3
- VERSION = "5.1.2"
3
+ VERSION = "5.1.3"
4
4
  end
@@ -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.name?).to be(false)
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
 
@@ -150,7 +150,7 @@ describe Mongoid::Relations::AutoSave do
150
150
  end
151
151
  end
152
152
 
153
- pending "when updating the child" do
153
+ context "when updating the child" do
154
154
 
155
155
  before do
156
156
  person.account = account
@@ -394,7 +394,7 @@ describe Mongoid::Serializable do
394
394
  hash["addresses"]
395
395
  end
396
396
 
397
- pending "when the ids were not loaded" do
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
- Class.new do
26
- include Mongoid::Shardable
27
- end
25
+ Band
28
26
  end
29
27
 
30
28
  before do
31
- klass.shard_key(:name)
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
- Class.new do
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.2
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-03-31 00:00:00.000000000 Z
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.6
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