3171: Add tests for desired behavior. Start using FactoryGirl.
[arvados.git] / services / api / test / factories / user.rb
1 include CurrentApiClient
2
3 FactoryGirl.define do
4   factory :user do
5     before :create do
6       Thread.current[:user_was] = Thread.current[:user]
7       Thread.current[:user] = system_user
8     end
9     after :create do
10       Thread.current[:user] = Thread.current[:user_was]
11     end
12     first_name "Factory"
13     last_name "Factory"
14     identity_url do
15       "https://example.com/#{rand(2**24).to_s(36)}"
16     end
17     factory :active_user do
18       is_active true
19       after :create do |user|
20         act_as_system_user do
21           Link.create!(tail_uuid: user.uuid,
22                        head_uuid: Group.where('uuid ~ ?', '-f+$').first.uuid,
23                        link_class: 'permission',
24                        name: 'can_read')
25         end
26       end
27     end
28   end
29 end