diff --git a/config/environments/test.rb b/config/environments/test.rb index 2d2f7671..efaf9a9f 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -22,3 +22,4 @@ config.action_controller.session = { } config.gem "thoughtbot-shoulda", :lib => "shoulda", :source => "http://gems.github.com" +config.gem "nofxx-object_daddy", :lib => "object_daddy", :source => "http://gems.github.com" diff --git a/test/exemplars/custom_field_exemplar.rb b/test/exemplars/custom_field_exemplar.rb new file mode 100644 index 00000000..b9577bb9 --- /dev/null +++ b/test/exemplars/custom_field_exemplar.rb @@ -0,0 +1,10 @@ +class CustomField < ActiveRecord::Base + generator_for :name, :method => :next_name + generator_for :field_format => 'string' + + def self.next_name + @last_name ||= 'CustomField0' + @last_name.succ! + @last_name + end +end diff --git a/test/exemplars/custom_value_exemplar.rb b/test/exemplars/custom_value_exemplar.rb new file mode 100644 index 00000000..4e982614 --- /dev/null +++ b/test/exemplars/custom_value_exemplar.rb @@ -0,0 +1,2 @@ +class CustomValue < ActiveRecord::Base +end diff --git a/test/exemplars/enumeration_exemplar.rb b/test/exemplars/enumeration_exemplar.rb new file mode 100644 index 00000000..6665a6d5 --- /dev/null +++ b/test/exemplars/enumeration_exemplar.rb @@ -0,0 +1,10 @@ +class Enumeration < ActiveRecord::Base + generator_for :name, :method => :next_name + generator_for :type => 'TimeEntryActivity' + + def self.next_name + @last_name ||= 'Enumeration0' + @last_name.succ! + @last_name + end +end diff --git a/test/exemplars/issue_exemplar.rb b/test/exemplars/issue_exemplar.rb new file mode 100644 index 00000000..48a92ee4 --- /dev/null +++ b/test/exemplars/issue_exemplar.rb @@ -0,0 +1,15 @@ +class Issue < ActiveRecord::Base + generator_for :subject, :method => :next_subject + generator_for :author, :method => :next_author + + def self.next_subject + @last_subject ||= 'Subject 0' + @last_subject.succ! + @last_subject + end + + def self.next_author + User.generate_with_protected! + end + +end diff --git a/test/exemplars/issue_status_exemplar.rb b/test/exemplars/issue_status_exemplar.rb new file mode 100644 index 00000000..9d3ccdc1 --- /dev/null +++ b/test/exemplars/issue_status_exemplar.rb @@ -0,0 +1,9 @@ +class IssueStatus < ActiveRecord::Base + generator_for :name, :method => :next_name + + def self.next_name + @last_name ||= 'Status 0' + @last_name.succ! + @last_name + end +end diff --git a/test/exemplars/member_exemplar.rb b/test/exemplars/member_exemplar.rb new file mode 100644 index 00000000..999bd448 --- /dev/null +++ b/test/exemplars/member_exemplar.rb @@ -0,0 +1,2 @@ +class Member < ActiveRecord::Base +end diff --git a/test/exemplars/project_exemplar.rb b/test/exemplars/project_exemplar.rb new file mode 100644 index 00000000..a0edd1fd --- /dev/null +++ b/test/exemplars/project_exemplar.rb @@ -0,0 +1,17 @@ +class Project < ActiveRecord::Base + generator_for :name, :method => :next_name + generator_for :identifier, :method => :next_identifier_from_object_daddy + + def self.next_name + @last_name ||= 'Project 0' + @last_name.succ! + @last_name + end + + # Project#next_identifier is defined on Redmine + def self.next_identifier_from_object_daddy + @last_identifier ||= 'project0' + @last_identifier.succ! + @last_identifier + end +end diff --git a/test/exemplars/role_exemplar.rb b/test/exemplars/role_exemplar.rb new file mode 100644 index 00000000..9f17e138 --- /dev/null +++ b/test/exemplars/role_exemplar.rb @@ -0,0 +1,8 @@ +class Role < ActiveRecord::Base + generator_for :name, :method => :next_name + + def self.next_name + @last_name ||= 'Role0' + @last_name.succ! + end +end diff --git a/test/exemplars/time_entry_activity.rb b/test/exemplars/time_entry_activity.rb new file mode 100644 index 00000000..8473c2f8 --- /dev/null +++ b/test/exemplars/time_entry_activity.rb @@ -0,0 +1,10 @@ +class TimeEntryActivity < Enumeration + generator_for :name, :method => :next_name + generator_for :type => 'TimeEntryActivity' + + def self.next_name + @last_name ||= 'TimeEntryActivity0' + @last_name.succ! + @last_name + end +end diff --git a/test/exemplars/time_entry_exemplar.rb b/test/exemplars/time_entry_exemplar.rb new file mode 100644 index 00000000..5aa4179f --- /dev/null +++ b/test/exemplars/time_entry_exemplar.rb @@ -0,0 +1,5 @@ +class TimeEntry < ActiveRecord::Base + generator_for(:spent_on) { Date.today } + generator_for(:hours) { (rand * 10).round(2) } # 0.01 to 9.99 + +end diff --git a/test/exemplars/tracker_exemplar.rb b/test/exemplars/tracker_exemplar.rb new file mode 100644 index 00000000..94523f79 --- /dev/null +++ b/test/exemplars/tracker_exemplar.rb @@ -0,0 +1,9 @@ +class Tracker < ActiveRecord::Base + generator_for :name, :method => :next_name + + def self.next_name + @last_name ||= 'Tracker 0' + @last_name.succ! + @last_name + end +end diff --git a/test/exemplars/user_exemplar.rb b/test/exemplars/user_exemplar.rb new file mode 100644 index 00000000..d88f5fe7 --- /dev/null +++ b/test/exemplars/user_exemplar.rb @@ -0,0 +1,30 @@ +class User < ActiveRecord::Base + generator_for :login, :method => :next_email + generator_for :mail, :method => :next_email + generator_for :firstname, :method => :next_firstname + generator_for :lastname, :method => :next_lastname + + def self.next_login + @gen_login ||= 'user1' + @gen_login.succ! + @gen_login + end + + def self.next_email + @last_email ||= 'user1' + @last_email.succ! + "#{@last_email}@example.com" + end + + def self.next_firstname + @last_firstname ||= 'Bob' + @last_firstname.succ! + @last_firstname + end + + def self.next_lastname + @last_lastname ||= 'Doe' + @last_lastname.succ! + @last_lastname + end +end diff --git a/test/unit/testing_test.rb b/test/unit/testing_test.rb index 82eb9ed5..7c78288e 100644 --- a/test/unit/testing_test.rb +++ b/test/unit/testing_test.rb @@ -27,6 +27,12 @@ class TestingTest < ActiveSupport::TestCase assert true end + test "Generating with object_daddy" do + assert_difference "IssueStatus.count" do + IssueStatus.generate! + end + end + should "work with shoulda" do assert true end