]> git.openstreetmap.org Git - rails.git/commitdiff
Add a user_role factory
authorAndy Allan <git@gravitystorm.co.uk>
Thu, 2 Feb 2017 12:35:29 +0000 (12:35 +0000)
committerAndy Allan <git@gravitystorm.co.uk>
Thu, 2 Feb 2017 12:35:29 +0000 (12:35 +0000)
Naming the association in the model makes the relationship easier
to express in the factory.

app/models/user_role.rb
test/factories/user_role.rb [new file with mode: 0644]

index 6bc7435aeaa6590e6421386ce7ac2c6c007488c3..4f80f195279916daac70c8225386c47da0e73d80 100644 (file)
@@ -1,5 +1,6 @@
 class UserRole < ActiveRecord::Base
   belongs_to :user
 class UserRole < ActiveRecord::Base
   belongs_to :user
+  belongs_to :granter, :class_name => "User"
 
   ALL_ROLES = %w(administrator moderator).freeze
 
 
   ALL_ROLES = %w(administrator moderator).freeze
 
diff --git a/test/factories/user_role.rb b/test/factories/user_role.rb
new file mode 100644 (file)
index 0000000..0eea25c
--- /dev/null
@@ -0,0 +1,6 @@
+FactoryGirl.define do
+  factory :user_role do
+    user
+    association :granter, :factory => :user
+  end
+end