Merge branch '3627-selectable-projects' closes #3627
[arvados.git] / services / api / test / factories / user.rb
1 include CurrentApiClient
2
3 FactoryGirl.define do
4   factory :user do
5     ignore do
6       join_groups []
7     end
8     after :create do |user, evaluator|
9       act_as_system_user do
10         evaluator.join_groups.each do |g|
11           Link.create!(tail_uuid: user.uuid,
12                        head_uuid: g.uuid,
13                        link_class: 'permission',
14                        name: 'can_read')
15           Link.create!(tail_uuid: g.uuid,
16                        head_uuid: user.uuid,
17                        link_class: 'permission',
18                        name: 'can_read')
19         end
20       end
21     end
22     first_name "Factory"
23     last_name "Factory"
24     identity_url do
25       "https://example.com/#{rand(2**24).to_s(36)}"
26     end
27     factory :active_user do
28       is_active true
29       after :create do |user|
30         act_as_system_user do
31           Link.create!(tail_uuid: user.uuid,
32                        head_uuid: Group.where('uuid ~ ?', '-f+$').first.uuid,
33                        link_class: 'permission',
34                        name: 'can_read')
35         end
36       end
37     end
38     to_create do |instance|
39       act_as_system_user do
40         instance.save!
41       end
42     end
43   end
44 end