From 8420f251099ad855bd347e3f687471f18ee40df4 Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Thu, 28 Jan 2010 19:05:21 +0000 Subject: [PATCH] Added and updated some more object daddy exemplars. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3342 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- test/exemplars/attachment_exemplar.rb | 21 +++++++++++++++++++ ...ce_exemplar.rb => auth_source_exemplar.rb} | 0 test/exemplars/comment_exemplar.rb | 13 ++++++++++++ test/exemplars/custom_value_exemplar.rb | 5 +++++ test/exemplars/group_exemplar.rb | 10 +++++++++ test/exemplars/journal_exemplar.rb | 13 ++++++++++++ test/exemplars/member_exemplar.rb | 10 +++++++++ 7 files changed, 72 insertions(+) create mode 100644 test/exemplars/attachment_exemplar.rb rename test/exemplars/{auth_soruce_exemplar.rb => auth_source_exemplar.rb} (100%) create mode 100644 test/exemplars/comment_exemplar.rb create mode 100644 test/exemplars/group_exemplar.rb create mode 100644 test/exemplars/journal_exemplar.rb diff --git a/test/exemplars/attachment_exemplar.rb b/test/exemplars/attachment_exemplar.rb new file mode 100644 index 00000000..e86c4d32 --- /dev/null +++ b/test/exemplars/attachment_exemplar.rb @@ -0,0 +1,21 @@ +class Attachment < ActiveRecord::Base + generator_for :container, :method => :generate_project + generator_for :file, :method => :generate_file + generator_for :author, :method => :generate_author + + def self.generate_project + Project.generate! + end + + def self.generate_author + User.generate_with_protected! + end + + def self.generate_file + @file = 'a_file.png' + @file.stubs(:original_filename).returns('a_file.png') + @file.stubs(:content_type).returns('image/png') + @file.stubs(:read).returns(false) + @file + end +end diff --git a/test/exemplars/auth_soruce_exemplar.rb b/test/exemplars/auth_source_exemplar.rb similarity index 100% rename from test/exemplars/auth_soruce_exemplar.rb rename to test/exemplars/auth_source_exemplar.rb diff --git a/test/exemplars/comment_exemplar.rb b/test/exemplars/comment_exemplar.rb new file mode 100644 index 00000000..036e8275 --- /dev/null +++ b/test/exemplars/comment_exemplar.rb @@ -0,0 +1,13 @@ +class Comment < ActiveRecord::Base + generator_for :commented, :method => :generate_news + generator_for :author, :method => :generate_author + generator_for :comments => 'What great news this is.' + + def self.generate_news + News.generate! + end + + def self.generate_author + User.generate_with_protected! + end +end diff --git a/test/exemplars/custom_value_exemplar.rb b/test/exemplars/custom_value_exemplar.rb index 4e982614..aeb5412e 100644 --- a/test/exemplars/custom_value_exemplar.rb +++ b/test/exemplars/custom_value_exemplar.rb @@ -1,2 +1,7 @@ class CustomValue < ActiveRecord::Base + generator_for :custom_field, :method => :generate_custom_field + + def self.generate_custom_field + CustomField.generate! + end end diff --git a/test/exemplars/group_exemplar.rb b/test/exemplars/group_exemplar.rb new file mode 100644 index 00000000..5d2cd747 --- /dev/null +++ b/test/exemplars/group_exemplar.rb @@ -0,0 +1,10 @@ +class Group < Principal + generator_for :lastname, :method => :next_lastname + + def self.next_lastname + @last_lastname ||= 'Group' + @last_lastname.succ! + @last_lastname + end + +end diff --git a/test/exemplars/journal_exemplar.rb b/test/exemplars/journal_exemplar.rb new file mode 100644 index 00000000..dbb66f20 --- /dev/null +++ b/test/exemplars/journal_exemplar.rb @@ -0,0 +1,13 @@ +class Journal < ActiveRecord::Base + generator_for :journalized, :method => :generate_issue + generator_for :user, :method => :generate_user + + def self.generate_issue + project = Project.generate! + Issue.generate_for_project!(project) + end + + def self.generate_user + User.generate_with_protected! + end +end diff --git a/test/exemplars/member_exemplar.rb b/test/exemplars/member_exemplar.rb index 999bd448..ecb09bb9 100644 --- a/test/exemplars/member_exemplar.rb +++ b/test/exemplars/member_exemplar.rb @@ -1,2 +1,12 @@ class Member < ActiveRecord::Base + generator_for :roles, :method => :generate_roles + generator_for :principal, :method => :generate_user + + def self.generate_roles + [Role.generate!] + end + + def self.generate_user + User.generate_with_protected! + end end