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

ActiveModel::Validations not working

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 12_01_17
    • Affects Version/s: 6.0.0
    • Component/s: None
    • None
    • Environment:
      Rails 5.0.0.1

      I'm trying to create a simple model and spec for the validations and it seems the ActiveModel::Validations are not working. A simple case is this:

      Model:
      class Account
      include Mongoid::Document
      include ActiveModel::Validations

      field :email, type: String

      validates :email, presence: true

      end

      Spec:
      require 'rails_helper'

      RSpec.describe Account, type: :model do
      it "errors when with no id" do
      expect

      {Account.create!(email: 'test@gmail.com')}

      .to raise_error(Mongoid::Errors::Validations, /Validation of Account failed./)
      end
      end

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            toymachiner62 Tom Caflisch
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: