2

I'm using Mongoid and Mongoid-Enum.

Here's my User model snippet:

enum :role, [:admin, :artist, :customer], :validate => true, :default => :admin

For my Voice model I wrote a test (using an example in Mongoid-rspec website) such as:

it { is_expected.to belong_to(:artist).of_type(User) }

And in my Voice model:

belongs_to :users

However I can't get the test to pass. How do I to enforce that the user is of specific type (artist, through enum)?

shilovk
  • 11,718
  • 17
  • 75
  • 74
WagnerMatosUK
  • 4,309
  • 7
  • 56
  • 95

0 Answers0