Sha256: da2c8a127e13abdd6387d10dd23a9ea94a266a7f5890a77882aba87f31791176

Contents?: true

Size: 456 Bytes

Versions: 22

Compression:

Stored size: 456 Bytes

Contents

module UserFactory 
  def create_user role = :user
    # ||= here is important!
    @user ||= user_class(role).create(:name => "Kristian") 
  end

  def create_user_account user, role = :user
    user.active_account = account_class(role).create :role => role, :user => user
    user.active_account
  end

  def user_class role
    "#{role.to_s.camelize}".constantize
  end

  def account_class role
    "#{role.to_s.camelize}Account".constantize
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
cantango-0.9.4.7 spec/active_record/scenarios/user_accounts/helpers/user_factory.rb
cantango-0.9.4.6 spec/active_record/scenarios/user_accounts/helpers/user_factory.rb
cantango-0.9.4.5 spec/active_record/scenarios/user_accounts/helpers/user_factory.rb
cantango-0.9.4.3 spec/active_record/scenarios/user_accounts/helpers/user_factory.rb
cantango-0.9.4.2 spec/active_record/scenarios/user_accounts/helpers/user_factory.rb
cantango-0.9.4.1 spec/active_record/scenarios/user_accounts/helpers/user_factory.rb
cantango-0.9.4 spec/active_record/scenarios/user_accounts/helpers/user_factory.rb
cantango-0.9.3.2 spec/active_record/scenarios/user_accounts/helpers/user_factory.rb
cantango-0.8.9.5 spec/active_record/scenarios/user_accounts/helpers/user_factory.rb
cantango-0.8.9.4 spec/active_record/scenarios/user_accounts/helpers/user_factory.rb
cantango-0.8.9.3 spec/active_record/scenarios/user_accounts/helpers/user_factory.rb
cantango-0.8.9.2 spec/active_record/scenarios/user_accounts/helpers/user_factory.rb
cantango-0.8.9.1 spec/active_record/scenarios/user_accounts/helpers/user_factory.rb
cantango-0.8.9 spec/active_record/scenarios/user_accounts/helpers/user_factory.rb
cantango-0.8.8.1 spec/active_record/scenarios/user_accounts/helpers/user_factory.rb
cantango-0.8.8 spec/active_record/scenarios/user_accounts/helpers/user_factory.rb
cantango-0.8.7 spec/active_record/scenarios/user_accounts/helpers/user_factory.rb
cantango-0.8.6.2 spec/active_record/scenarios/user_accounts/helpers/user_factory.rb
cantango-0.8.6.1 spec/active_record/scenarios/user_accounts/helpers/user_factory.rb
cantango-0.8.6 spec/active_record/scenarios/user_accounts/helpers/user_factory.rb