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

validates uniqueness fails while cloning in 2.4.3

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

      class ContentElement
        include Mongoid::Document
        field :title, :type => String
      
        validates :title, :uniqueness => true
      end
      

      If it test that with this spec

      describe ContentElement do
          it "is only valid with a unique name" do
          contentElement1 = ContentElement.create :title => "ups"
          contentElement2 = ContentElement.new :title => "ups"
          contentElement2.save.should_not be_true
        end
        describe "#clone" do
          it "is only valid with a unique name" do
            contentElement1 = ContentElement.create :title => "ups"
            contentElement2 = contentElement1.clone
            contentElement2.save.should_not be_true
          end
        end
      end
      

      First spec is green, but second is red, it says that the clone is valid - but should not be valid.
      With 2.3.4 everything was fine, but after updating to 2.4.3 it was broken.

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

              Created:
              Updated:
              Resolved: