aboutsummaryrefslogtreecommitdiffstats
path: root/spec/factories/user.rb
blob: 0112b25f733827428c5765dc53b7408d439efe70 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
FactoryGirl.define do
  factory :authentication_devise_user, :class => Refinery::Authentication::Devise::User do
    sequence(:username) { |n| "refinery#{n}" }
    sequence(:email) { |n| "refinery#{n}@example.com" }
    password  "refinerycms"
    password_confirmation "refinerycms"
  end

  factory :authentication_devise_refinery_user, :parent => :authentication_devise_user do
    roles { [ ::Refinery::Authentication::Devise::Role[:refinery] ] }

    after(:create) do |user|
      ::Refinery::Plugins.registered.each_with_index do |plugin, index|
        user.plugins.create(:name => plugin.name, :position => index)
      end
    end
  end

  factory :authentication_devise_refinery_superuser, :parent => :authentication_devise_refinery_user do
    roles {
      [
        ::Refinery::Authentication::Devise::Role[:refinery],
        ::Refinery::Authentication::Devise::Role[:superuser]
      ]
    }
  end
end