From: Andy Allan Date: Thu, 2 Feb 2017 12:35:29 +0000 (+0000) Subject: Add a user_role factory X-Git-Tag: live~3604^2~8 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/c55169659ccab3fdb4aea11b5bea6ad62b6d297d Add a user_role factory Naming the association in the model makes the relationship easier to express in the factory. --- 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