I have a model where I'm validating a field conditionally. It looks like this:
validates :case_id,
uniqueness: {
scope: :user_id,
message: 'Message'
},
unless: Proc.new { |c| c.user_id.nil? }
The test I have for it, thus far, looks like this:
it { should validate_uniqueness_of(:case_id)
.scoped_to(:user_id)
.with_message('Message.') }
The problems is I don't know how to incorporate the unless conditional into the test?
Any ideas?
Aucun commentaire:
Enregistrer un commentaire