From c55169659ccab3fdb4aea11b5bea6ad62b6d297d Mon Sep 17 00:00:00 2001 From: Andy Allan Date: Thu, 2 Feb 2017 12:35:29 +0000 Subject: [PATCH] Add a user_role factory Naming the association in the model makes the relationship easier to express in the factory. --- app/models/user_role.rb | 1 + test/factories/user_role.rb | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 test/factories/user_role.rb diff --git a/app/models/user_role.rb b/app/models/user_role.rb index 6bc7435ae..4f80f1952 100644 --- a/app/models/user_role.rb +++ b/app/models/user_role.rb @@ -1,5 +1,6 @@ class UserRole < ActiveRecord::Base belongs_to :user + belongs_to :granter, :class_name => "User" ALL_ROLES = %w(administrator moderator).freeze diff --git a/test/factories/user_role.rb b/test/factories/user_role.rb new file mode 100644 index 000000000..0eea25cee --- /dev/null +++ b/test/factories/user_role.rb @@ -0,0 +1,6 @@ +FactoryGirl.define do + factory :user_role do + user + association :granter, :factory => :user + end +end -- 2.39.5