Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-1969

Default scoping in embedded documents

    • Type: Icon: Task Task
    • Resolution: Done
    • 2.4.10
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      Hi,

      I create an embedded document and change the attributes, so that the default scope doesn't match any more. Then the test without reloading fails. The same works the other way round, too.
      I found this issue while looking through the sample code from apneadiving for MONGOID-1918.

       
      require 'spec_helper'
      
      describe "default scoping on embedded documents" do
      
        let(:person) do
          Person.create 
        end
      
        before do
          person.appointments.create
        end
      
        context "when changing the default scope attribute" do
        
          before do
            a = person.appointments.first
            a.active = false
            a.save
          end
      
          context "when reloading" do
            
            it "hides the document" do
              person.reload.appointments.should eq([])
              # PASS
            end
          end
      
          context "when not reloading" do
            
            it "hides the document" do
              person.appointments.should eq([])
              # FAIL
            end
          end
        end
      end
      

      I already looked at the code, but couldn't find the place to fix this issue.

            Assignee:
            Unassigned Unassigned
            Reporter:
            i0rek Hans Hasselberg
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: