I can't get my any test to run because every user I try to fabricate generates validation errors.
I have the following test.
class BillTest < ActiveSupport::TestCase def setup load_all_sponsors @the_bill = Bill.new(:govtrack_name => "h1") @user1 = Fabricate(:user1) @user2 = Fabricate(:user2)
My fabrications are defined by:
Fabricator(:user) do email '[email protected]' name 'anew user' roles_mask 1 password "secret" password_confirmation "secret" polco_groups {[Fabricate(:polco_group, :name => 'foreign', :type => :custom)]} end Fabricator(:admin, :class_name => :user) do email '[email protected]' name 'Administrator' roles_mask 5 password "secret" password_confirmation "secret" end Fabricator(:registered, :class_name => :user) do email '[email protected]' name 'Tim TheRegistered' roles_mask 2 password "the_secret" password_confirmation "the_secret" polco_groups {[Fabricate(:polco_group, {:name => 'AL', :type => :state}), Fabricate(:polco_group, {:name => 'AL01', :type => :district}), Fabricate(:polco_group, {:name => "Kirk\'s Kids" , :type => :custom})]} end Fabricator(:user1, :class_name => :user) do email '[email protected]' name 'User1' roles_mask 2 password "the_big_secret" password_confirmation "the_big_secret" polco_groups {[Fabricate(:polco_group, {:name => 'AL', :type => :state}), Fabricate(:polco_group, {:name => 'AL01', :type => :district}), Fabricate(:polco_group, {:name => "Kirk\'s Kids" , :type => :custom})]} end Fabricator(:user2, :class_name => :user) do email '[email protected]' name 'User2' roles_mask 2 password "the_big_secret" password_confirmation "the_big_secret" polco_groups {[Fabricate(:polco_group, {:name => 'AL', :type => :state}), Fabricate(:polco_group, {:name => 'FL01', :type => :district}), Fabricate(:polco_group, {:name => "Ft. Sam Washington 1st Grade" , :type => :custom})]} end
No matter which test runs, I get the same error
9) Error: test_update_from_directory(BillTest): Mongoid::Errors::Validations: Validation failed - Email is already taken, Email is already taken, Name is already taken. test/unit/bill_test.rb:8:in `setup'
I have tried a number of different fabricators, inheriting in all kinds of different ways and nothing gets past this error. I'm pretty desperate for help on this one.