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