aboutsummaryrefslogtreecommitdiffstats
path: root/spec/factories/user.rb
blob: 94fe1d0aad50b3f887c0f7f9f64faef57aa769ec (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
require 'refinerycms/all'
require 'refinery/role'

Factory.define :user, :class => ::Refinery::User do |u|
  u.sequence(:username) { |n| "person#{n}" }
  u.sequence(:email) { |n| "person#{n}@cucumber.com" }
  u.password  "greenandjuicy"
  u.password_confirmation "greenandjuicy"
end

Factory.define :refinery_user, :parent => :user do |u|
  u.roles { [ ::Refinery::Role[:refinery] ] }

  u.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.define :refinery_translator, :parent => :user do |u|
  u.roles { [ ::Refinery::Role[:refinery], ::Refinery::Role[:translator] ] }

  u.after_create do |user|
    user.plugins.create(:name => 'refinery_pages', :position => 0)
  end
end