Commit 81ee2ff8 authored by Eric Davis's avatar Eric Davis

Updated object_daddy to a newer version (bugfixes)

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3398 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 94828313
...@@ -25,5 +25,5 @@ config.action_controller.session = { ...@@ -25,5 +25,5 @@ config.action_controller.session = {
config.action_controller.allow_forgery_protection = false config.action_controller.allow_forgery_protection = false
config.gem "thoughtbot-shoulda", :lib => "shoulda", :source => "http://gems.github.com" config.gem "thoughtbot-shoulda", :lib => "shoulda", :source => "http://gems.github.com"
config.gem "nofxx-object_daddy", :lib => "object_daddy", :source => "http://gems.github.com" config.gem "edavis10-object_daddy", :lib => "object_daddy"
config.gem "mocha" config.gem "mocha"
class Issue < ActiveRecord::Base class Issue < ActiveRecord::Base
generator_for :subject, :method => :next_subject generator_for :subject, :method => :next_subject
generator_for :author, :method => :next_author generator_for :author, :method => :next_author
generator_for :priority, :method => :fetch_priority
def self.next_subject def self.next_subject
@last_subject ||= 'Subject 0' @last_subject ||= 'Subject 0'
...@@ -12,4 +13,8 @@ class Issue < ActiveRecord::Base ...@@ -12,4 +13,8 @@ class Issue < ActiveRecord::Base
User.generate_with_protected! User.generate_with_protected!
end end
def self.fetch_priority
IssuePriority.first || IssuePriority.generate!
end
end end
module ObjectDaddyHelpers module ObjectDaddyHelpers
# TODO: The gem or official version of ObjectDaddy doesn't set # TODO: Remove these three once everyone has ported their code to use the
# protected attributes so they need to be wrapped. # new object_daddy version with protected attribute support
def User.generate_with_protected(attributes={}) def User.generate_with_protected(attributes={})
user = User.spawn_with_protected(attributes) User.generate(attributes)
user.save
user
end end
# TODO: The gem or official version of ObjectDaddy doesn't set
# protected attributes so they need to be wrapped.
def User.generate_with_protected!(attributes={}) def User.generate_with_protected!(attributes={})
user = User.spawn_with_protected(attributes) User.generate!(attributes)
user.save!
user
end end
# TODO: The gem or official version of ObjectDaddy doesn't set
# protected attributes so they need to be wrapped.
def User.spawn_with_protected(attributes={}) def User.spawn_with_protected(attributes={})
user = User.spawn(attributes) do |user| User.spawn(attributes)
user.login = User.next_login
attributes.each do |attr,v|
user.send("#{attr}=", v)
end
end
user
end end
# Generate the default Query # Generate the default Query
......
...@@ -555,7 +555,7 @@ class ProjectTest < ActiveSupport::TestCase ...@@ -555,7 +555,7 @@ class ProjectTest < ActiveSupport::TestCase
end end
should "copy issues" do should "copy issues" do
@source_project.issues << Issue.generate!(:status_id => 5, @source_project.issues << Issue.generate!(:status => IssueStatus.find_by_name('Closed'),
:subject => "copy issue status", :subject => "copy issue status",
:tracker_id => 1, :tracker_id => 1,
:assigned_to_id => 2, :assigned_to_id => 2,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment