Add a user_role factory
Naming the association in the model makes the relationship easier to express in the factory.
This commit is contained in:
parent
9e591d8ccb
commit
c55169659c
2 changed files with 7 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
||||||
class UserRole < ActiveRecord::Base
|
class UserRole < ActiveRecord::Base
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
|
belongs_to :granter, :class_name => "User"
|
||||||
|
|
||||||
ALL_ROLES = %w(administrator moderator).freeze
|
ALL_ROLES = %w(administrator moderator).freeze
|
||||||
|
|
||||||
|
|
6
test/factories/user_role.rb
Normal file
6
test/factories/user_role.rb
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
FactoryGirl.define do
|
||||||
|
factory :user_role do
|
||||||
|
user
|
||||||
|
association :granter, :factory => :user
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue