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

Atomic Paths error in 2.3.4

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

      Spec:

      1. spec/models/view_spec.rb
        require "spec_helper"

      class Account
      include Mongoid::Document

      #this is correct, account has many users, not has many views
      has_many :users, as: :account
      end

      class User
      include Mongoid::Document

      embeds_many :views
      end

      class View
      include Mongoid::Document

      embedded_in :user

      #this is correct, view belongs to account, not user belongs to account
      belongs_to :account , polymorphic: true
      attr_accessible :account, :account_id, :account_type
      validates :account, :presence => true
      end

      describe View do

      let!(:account)

      { Account.create! }

      let!(:user)

      { User.create! }

      let!(:view) do
      user.views.build(
      :account_id => account.id,
      :account_type => account.class.name
      )
      end

      it "works" do
      user.save!
      end

      it "works" do
      view.save!(:validate => false)
      end

      it "doesn't work" do
      view.save!
      end

      end

      Failure:

      $ rspec spec -f d -b

      View
      works
      works
      doesn't work (FAILED - 1)

      Failures:

      1) View doesn't work
      Failure/Error: view.save!
      NoMethodError:
      undefined method `insert_modifier' for #<Mongoid::Atomic::Paths::Root:0x00000003aa9058>

      1. mongoid-2.3.4/lib/mongoid/atomic.rb:71:in `atomic_insert_modifier'
      2. mongoid-2.3.4/lib/mongoid/persistence/operations.rb:65:in `inserts'
      3. mongoid-2.3.4/lib/mongoid/persistence/operations/embedded/insert.rb:34:in `block in persist'
      4. mongoid-2.3.4/lib/mongoid/persistence/insertion.rb:26:in `block (3 levels) in prepare'
      5. activesupport-3.1.3/lib/active_support/callbacks.rb:390:in `_run_create_callbacks'
      6. activesupport-3.1.3/lib/active_support/callbacks.rb:81:in `run_callbacks'
      7. mongoid-2.3.4/lib/mongoid/callbacks.rb:42:in `block in run_callbacks'
      8. mongoid-2.3.4/lib/mongoid/callbacks.rb:67:in `call'
      9. mongoid-2.3.4/lib/mongoid/callbacks.rb:67:in `run_cascading_callbacks'
      10. mongoid-2.3.4/lib/mongoid/callbacks.rb:41:in `run_callbacks'
      11. mongoid-2.3.4/lib/mongoid/persistence/insertion.rb:25:in `block (2 levels) in prepare'
      12. activesupport-3.1.3/lib/active_support/callbacks.rb:390:in `_run_save_callbacks'
      13. activesupport-3.1.3/lib/active_support/callbacks.rb:81:in `run_callbacks'
      14. mongoid-2.3.4/lib/mongoid/callbacks.rb:42:in `block in run_callbacks'
      15. mongoid-2.3.4/lib/mongoid/callbacks.rb:67:in `call'
      16. mongoid-2.3.4/lib/mongoid/callbacks.rb:67:in `run_cascading_callbacks'
      17. mongoid-2.3.4/lib/mongoid/callbacks.rb:41:in `run_callbacks'
      18. mongoid-2.3.4/lib/mongoid/persistence/insertion.rb:24:in `block in prepare'
      19. mongoid-2.3.4/lib/mongoid/persistence/insertion.rb:22:in `tap'
      20. mongoid-2.3.4/lib/mongoid/persistence/insertion.rb:22:in `prepare'
      21. mongoid-2.3.4/lib/mongoid/persistence/operations/embedded/insert.rb:30:in `persist'
      22. mongoid-2.3.4/lib/mongoid/persistence.rb:44:in `insert'
      23. mongoid-2.3.4/lib/mongoid/persistence.rb:149:in `upsert'
      24. mongoid-2.3.4/lib/mongoid/persistence.rb:70:in `save!'
      25. ./spec/models/view_spec.rb:47:in `block (2 levels) in <top (required)>'
      26. ... rspec cli/runner methods ...

      Finished in 2.68 seconds
      3 examples, 1 failure

      Failed examples:

      rspec ./spec/models/view_spec.rb:46 # View doesn't work

            Assignee:
            Unassigned Unassigned
            Reporter:
            yfeldblum yfeldblum
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: