mongoid 5.0.0.beta → 5.0.0.rc0

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: da1ad4f848fcad2ee5ad4eee51d2d31eb444d900
4
- data.tar.gz: a373cbfa6a5541b9bbc3dd37b119458c91bb16fc
3
+ metadata.gz: 54ef20325b3cd2e53ac0f9f3ab587fdef250af88
4
+ data.tar.gz: 3a2230b51c21767e0d0255f83b0d26cfd016585c
5
5
  SHA512:
6
- metadata.gz: 1ff95e684aca5bc7a4b1d3293a3f1dd6feb5ad24e1d711f86db32a6d7b5cd86159846ee23524376ecfccf8638d837928a10f8514ed015e65d38be5b8bf466f9a
7
- data.tar.gz: fba913e1cdb0a81796016bb266d8fbd14173f044e53ad94de35576f017b2373009302d57f9ab736458e7fdda5587391a505e1ba6de47a880ac0a6d3f2942e01a
6
+ metadata.gz: d5922a0735e4a5245b095e28abd81ebed7513169a0586dfc8b137cb645adce577d202f2928746f2d87c0cf4f384928dfbd2e3f93402e21cafc88f0a9bfb4c178
7
+ data.tar.gz: 6b8aef5ac85b8715ee9106bc018ca2abda954766b8277e98d6e9a7134e6986d5645c83291b4ee520cf294687816d0c52cd0ddebae7a51e1ee31341b6f13d175b
data/README.md CHANGED
@@ -1,23 +1,15 @@
1
1
  # Mongoid
2
- [![Build Status](https://travis-ci.org/mongoid/mongoid.svg?branch=master)](https://travis-ci.org/mongoid/mongoid)
3
- [![Code Climate](https://codeclimate.com/github/mongoid/mongoid.svg)](https://codeclimate.com/github/mongoid/mongoid)
4
- [![Coverage Status](https://img.shields.io/coveralls/mongoid/mongoid/master.svg)](https://coveralls.io/r/mongoid/mongoid?branch=master)
2
+ [![Build Status](https://travis-ci.org/mongodb/mongoid.svg?branch=master)](https://travis-ci.org/mongodb/mongoid)
3
+ [![Code Climate](https://codeclimate.com/github/mongodb/mongoid.svg)](https://codeclimate.com/github/mongodb/mongoid)
4
+ [![Coverage Status](https://img.shields.io/coveralls/mongodb/mongoid/master.svg)](https://coveralls.io/r/mongodb/mongoid?branch=master)
5
5
  [![Dependency Status](https://www.versioneye.com/ruby/mongoid/4.0.0/badge.svg)](https://www.versioneye.com/ruby/mongoid/4.0.0)
6
6
 
7
-
8
7
  Mongoid is an ODM (Object-Document-Mapper) framework for MongoDB in Ruby.
9
8
 
10
- Project Move and Support
11
- ------------------------
12
-
13
- For the upcoming 5.0.0 release, the repository will be getting moved to the MongoDB
14
- organization. Please pay special attention to the following information with regards
15
- to this move:
9
+ Issues
10
+ ------
16
11
 
17
- * 5.0.0 and higher releases of Mongoid will be officially supported by MongoDB with a dedicated team.
18
- * Issues tagged 5.0.0 and higher in Github will be migrated to the [Mongoid Jira project](https://jira.mongodb.org/browse/MONGOID/) upon the release. There will be no more Github issues.
19
- * 4.x and 3.x releases will no longer be supported. Fixes to these branches will need to be maintained in community forks, although not recommended.
20
- * 5.0.0 release will still be supporting Rails 4.x, although there will be some backwards incompatible changes with respect to the configuration options. The Mongoid public API itself will not be changed.
12
+ Issues are now in the [Mongoid Jira project](https://jira.mongodb.org/browse/MONGOID/).
21
13
 
22
14
  Project Tracking
23
15
  ----------------
@@ -35,8 +27,7 @@ Mongoid is tested against MRI 1.9.3, 2.0.0, 2.1.0. 2.2.0 and JRuby (1.9).
35
27
  Documentation
36
28
  -------------
37
29
 
38
- Please see the new Mongoid website for up-to-date documentation:
39
- [mongoid.org](http://mongoid.org)
30
+ Please see the [MongoDB website](http://docs.mongodb.org/ecosystem/tutorial/ruby-mongoid-tutorial/#ruby-mongoid-tutorial) for up-to-date documentation on 5.0.0:
40
31
 
41
32
  License
42
33
  -------
@@ -4,6 +4,9 @@ en:
4
4
  messages:
5
5
  blank_in_locale:
6
6
  "can't be blank in %{location}"
7
+ message_title: "message"
8
+ summary_title: "summary"
9
+ resolution_title: "resolution"
7
10
  ambiguous_relationship:
8
11
  message: "Ambiguous relations %{candidates} defined on %{klass}."
9
12
  summary:
@@ -442,8 +445,8 @@ en:
442
445
  unsaved_document:
443
446
  message: "Attempted to save %{document} before the parent %{base}."
444
447
  summary: "You cannot call create or create! through the
445
- relation (%{document}) who's parent (%{base}) is
446
- not already saved. This would case the database to be out of sync
448
+ relation (%{document}) whose parent (%{base}) is
449
+ not already saved. This would cause the database to be out of sync
447
450
  since the child could potentially reference a nonexistant parent."
448
451
  resolution: "Make sure to only use create or create! when the parent
449
452
  document %{base} is persisted."
@@ -118,8 +118,7 @@ module Mongoid
118
118
  name = client_name
119
119
  client = Clients.with_name(name)
120
120
  client = client.use(database_name)
121
- client = client.with(self.persistence_options)
122
- Clients.set(name, client)
121
+ client.with(self.persistence_options)
123
122
  end
124
123
  alias :mongo_session :mongo_client
125
124
  deprecate :mongo_session, :mongo_client, 2015, 12
@@ -9,7 +9,7 @@ module Mongoid
9
9
 
10
10
  # Validate a configuration option.
11
11
  #
12
- # @example Validate a configuraiton option.
12
+ # @example Validate a configuration option.
13
13
  #
14
14
  # @param [ String ] option The name of the option.
15
15
  #
@@ -195,7 +195,7 @@ module Mongoid
195
195
  end
196
196
 
197
197
  # Eager loads all the provided relations. Will load all the documents
198
- # into the identity map who's ids match based on the extra query for the
198
+ # into the identity map whose ids match based on the extra query for the
199
199
  # ids.
200
200
  #
201
201
  # @note This will work for embedded relations that reference another
@@ -21,10 +21,14 @@ module Mongoid
21
21
  @problem = problem(key, attributes)
22
22
  @summary = summary(key, attributes)
23
23
  @resolution = resolution(key, attributes)
24
+ @problem_title = translate("message_title", {})
25
+ @summary_title = translate("summary_title", {})
26
+ @resolution_title = translate("resolution_title", {})
24
27
 
25
- "\nProblem:\n #{@problem}"+
26
- "\nSummary:\n #{@summary}"+
27
- "\nResolution:\n #{@resolution}"
28
+
29
+ "\n#{@problem_title}:\n #{@problem}"+
30
+ "\n#{@summary_title}:\n #{@summary}"+
31
+ "\n#{@resolution_title}:\n #{@resolution}"
28
32
  end
29
33
 
30
34
  private
@@ -60,11 +60,11 @@ module Rails
60
60
  ::Mongoid.load!(config_file)
61
61
  rescue ::Mongoid::Errors::NoClientsConfig => e
62
62
  handle_configuration_error(e)
63
- rescue ::Mongoid::Errors::NoDefaultSession => e
63
+ rescue ::Mongoid::Errors::NoDefaultClient => e
64
64
  handle_configuration_error(e)
65
- rescue ::Mongoid::Errors::NoSessionDatabase => e
65
+ rescue ::Mongoid::Errors::NoClientDatabase => e
66
66
  handle_configuration_error(e)
67
- rescue ::Mongoid::Errors::NoSessionHosts => e
67
+ rescue ::Mongoid::Errors::NoClientHosts => e
68
68
  handle_configuration_error(e)
69
69
  end
70
70
  end
@@ -20,6 +20,7 @@ module Mongoid
20
20
  characterize_one(target)
21
21
  bind_one
22
22
  characterize_one(target)
23
+ base._reset_memoized_children!
23
24
  target.save if persistable?
24
25
  end
25
26
  end
@@ -107,7 +107,7 @@ module Mongoid
107
107
 
108
108
  private
109
109
  def logger
110
- @logger ||= Logger.new($stdout)
110
+ Mongoid.logger
111
111
  end
112
112
  end
113
113
  end
@@ -139,6 +139,7 @@ module Mongoid
139
139
  #
140
140
  # @since 5.0.0
141
141
  def _reset_memoized_children!
142
+ _parent._reset_memoized_children! if _parent
142
143
  @__children = nil
143
144
  end
144
145
 
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module Mongoid
3
- VERSION = "5.0.0.beta"
3
+ VERSION = "5.0.0.rc0"
4
4
  end
@@ -2,4 +2,10 @@ class Code
2
2
  include Mongoid::Document
3
3
  field :name, type: String
4
4
  embedded_in :address
5
+ embeds_one :deepest
6
+ end
7
+
8
+ class Deepest
9
+ include Mongoid::Document
10
+ embedded_in :code
5
11
  end
@@ -1625,4 +1625,90 @@ describe Mongoid::Changeable do
1625
1625
  expect(person.setters).to_not eq({ "addresses" => nil })
1626
1626
  end
1627
1627
  end
1628
+
1629
+ context 'when nesting deeply embedded documents' do
1630
+
1631
+ context 'when persisting the root document' do
1632
+
1633
+ let!(:person) do
1634
+ Person.create
1635
+ end
1636
+
1637
+ it 'is not marked as changed' do
1638
+ expect(person).to_not be_changed
1639
+ end
1640
+
1641
+ context 'when creating a new first level embedded document' do
1642
+
1643
+ let!(:address) do
1644
+ person.addresses.new(street: 'goltzstr.')
1645
+ end
1646
+
1647
+ it 'flags the root document as changed' do
1648
+ expect(person).to be_changed
1649
+ end
1650
+
1651
+ it 'flags the first level child as changed' do
1652
+ expect(address).to be_changed
1653
+ end
1654
+
1655
+ context 'when building the lowest level document' do
1656
+
1657
+ before do
1658
+ person.save
1659
+ end
1660
+
1661
+ let!(:code) do
1662
+ address.build_code
1663
+ end
1664
+
1665
+ it 'flags the root document as changed' do
1666
+ expect(person).to be_changed
1667
+ end
1668
+
1669
+ it 'flags the first level embedded document as changed' do
1670
+ expect(address).to be_changed
1671
+ end
1672
+
1673
+ it 'flags the lowest level embedded document as changed' do
1674
+ expect(code).to be_changed
1675
+ end
1676
+
1677
+ context 'when saving the hierarchy' do
1678
+
1679
+ before do
1680
+ person.save
1681
+ end
1682
+
1683
+ let(:reloaded) do
1684
+ Person.find(person.id)
1685
+ end
1686
+
1687
+ it 'saves the first embedded document' do
1688
+ expect(reloaded.addresses.first).to eq(address)
1689
+ end
1690
+
1691
+ it 'saves the lowest level embedded document' do
1692
+ expect(reloaded.addresses.first.code).to eq(code)
1693
+ end
1694
+
1695
+ context 'when embedding further' do
1696
+
1697
+ let!(:deepest) do
1698
+ reloaded.addresses.first.code.build_deepest
1699
+ end
1700
+
1701
+ before do
1702
+ reloaded.save
1703
+ end
1704
+
1705
+ it 'saves the deepest embedded document' do
1706
+ expect(reloaded.reload.addresses.first.code.deepest).to eq(deepest)
1707
+ end
1708
+ end
1709
+ end
1710
+ end
1711
+ end
1712
+ end
1713
+ end
1628
1714
  end
@@ -519,6 +519,21 @@ describe Mongoid::Clients do
519
519
 
520
520
  describe ".with", if: non_legacy_server? do
521
521
 
522
+ context "when changing write concern options" do
523
+
524
+ let(:client_one) do
525
+ Band.with(write: { w: 2 }).mongo_client
526
+ end
527
+
528
+ let(:client_two) do
529
+ Band.mongo_client
530
+ end
531
+
532
+ it "does not carry over the options" do
533
+ expect(client_one.write_concern).to_not eq(client_two.write_concern)
534
+ end
535
+ end
536
+
522
537
  context "when sending operations to a different database" do
523
538
 
524
539
  after do
@@ -7,6 +7,10 @@ describe Mongoid::Errors::MongoidError do
7
7
  let(:options) { {} }
8
8
 
9
9
  before do
10
+ {"message_title" => "message", "summary_title" => "summary", "resolution_title" => "resolution"}.each do |key, name|
11
+ expect(::I18n).to receive(:translate).with("mongoid.errors.messages.#{key}", {}).and_return(name)
12
+ end
13
+
10
14
  ["message", "summary", "resolution"].each do |name|
11
15
  expect(::I18n).to receive(:translate).
12
16
  with("mongoid.errors.messages.#{key}.#{name}", {}).
@@ -29,6 +33,18 @@ describe Mongoid::Errors::MongoidError do
29
33
  it "sets ivar resolution" do
30
34
  expect(error.instance_variable_get(:@resolution)).to be
31
35
  end
36
+
37
+ it "sets ivar problem_title" do
38
+ expect(error.instance_variable_get(:@problem_title)).to be
39
+ end
40
+
41
+ it "sets ivar summary_title" do
42
+ expect(error.instance_variable_get(:@summary_title)).to be
43
+ end
44
+
45
+ it "sets ivar resolution_title" do
46
+ expect(error.instance_variable_get(:@resolution_title)).to be
47
+ end
32
48
  end
33
49
 
34
50
  describe "#to_json" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0.beta
4
+ version: 5.0.0.rc0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Durran Jordan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-06 00:00:00.000000000 Z
11
+ date: 2015-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 2.1.0.beta
47
+ version: 2.1.0.rc0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 2.1.0.beta
54
+ version: 2.1.0.rc0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: origin
57
57
  requirement: !ruby/object:Gem::Requirement