Ok, so I want to check the functions that need admin user, and I'm trying to log in as administrator, but for this I need to have admin user
here is my code
let(:user) { FactoryGirl.create(:user) }
let(:admin_role) { FactoryGirl.create(:role) }
FactoryGirl.define do
factory :user do
first_name "John"
last_name "Doe"
email "john@doe.com"
end
factory :role do
name "Admin"
end
end
how i connected them i tried user.roles << user_rolebut got this error
/Users/matt/Sites/application/spec/controllers/directory_controller_spec.rb:16:in `block (3 levels) in <top (required)>': undefined local variable or method `user' for
Here are my models
class User < ActiveRecord::Base
has_many :roles, :through => :role_users
has_many :role_users
...
class Role < ActiveRecord::Base
has_many :users, :through => :role_users
has_many :role_users
...
class RoleUser < ActiveRecord::Base
belongs_to :role
belongs_to :user
end
source
share