mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-04 16:28:50 +01:00
Prevent redefinition of factories
This commit catches Factory::DuplicateDefinitionErrors raised by factory_girl 2.1.0. See the following thread for some background. http://groups.google.com/group/factory_girl/browse_thread/thread/4df21d9240c20198
This commit is contained in:
parent
e221264e74
commit
a11937788e
1 changed files with 21 additions and 17 deletions
|
|
@ -1,21 +1,25 @@
|
|||
Factory.define :user do |u|
|
||||
u.sequence(:login) { |n| "testuser#{n}" }
|
||||
u.password "secret"
|
||||
u.password_confirmation { |user| user.password }
|
||||
u.is_admin false
|
||||
end
|
||||
begin
|
||||
Factory.define :user do |u|
|
||||
u.sequence(:login) { |n| "testuser#{n}" }
|
||||
u.password "secret"
|
||||
u.password_confirmation { |user| user.password }
|
||||
u.is_admin false
|
||||
end
|
||||
|
||||
Factory.define :context do |c|
|
||||
c.sequence(:name) { |n| "testcontext#{n}" }
|
||||
c.hide false
|
||||
c.created_at Time.now.utc
|
||||
end
|
||||
Factory.define :context do |c|
|
||||
c.sequence(:name) { |n| "testcontext#{n}" }
|
||||
c.hide false
|
||||
c.created_at Time.now.utc
|
||||
end
|
||||
|
||||
Factory.define :project do |p|
|
||||
p.sequence(:name) { |n| "testproject#{n}" }
|
||||
end
|
||||
Factory.define :project do |p|
|
||||
p.sequence(:name) { |n| "testproject#{n}" }
|
||||
end
|
||||
|
||||
Factory.define :todo do |t|
|
||||
t.sequence(:description) { |n| "testtodo#{n}" }
|
||||
t.association :context
|
||||
Factory.define :todo do |t|
|
||||
t.sequence(:description) { |n| "testtodo#{n}" }
|
||||
t.association :context
|
||||
end
|
||||
rescue FactoryGirl::DuplicateDefinitionError
|
||||
# No problem, apparently this file was included already.
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue