Skip to content

Commit

Permalink
User's factory
Browse files Browse the repository at this point in the history
  • Loading branch information
arzumy committed Apr 10, 2010
1 parent e65ae1d commit 885ef15
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@

config.gem 'turn', :version => '~> 0.7.0'
config.gem 'shoulda', :version => '~> 2.10.2'
config.gem 'factory_girl', :version => '~> 1.2.3', :lib => false
config.gem 'factory_girl', :version => '~> 1.2.3'
config.gem 'rr', :version => '~> 0.10.11'
15 changes: 15 additions & 0 deletions test/factories/user.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Factory.define :user do |user|
user.username "username"
user.password 'password'
user.first_name 'first name'
user.last_name 'last name'
user.email '[email protected]'
user.role 'Admin'
end

Factory.define :admin_user, :parent => :user do |user|
user.username "admin"
user.password 'admin123'
user.first_name 'Fedena'
user.last_name 'Administrator'
end
8 changes: 8 additions & 0 deletions test/unit/user_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require File.expand_path(File.dirname(__FILE__) + './../test_helper')

class UserTest < ActiveSupport::TestCase
should "be valid with factory" do
assert_valid Factory.build(:user)
assert_valid Factory.build(:admin_user)
end
end

0 comments on commit 885ef15

Please sign in to comment.