summaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-04-22 11:56:47 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-04-22 11:56:47 +0000
commitb960470d7817843906d42628d8bb4228ee49b2d9 (patch)
tree9c16e3fe4ae68e36e4d3c6c0dfebb267eab9a774 /test/unit
parent4a3f038595922dc5fef9f3541363a16078a5ace9 (diff)
downloadredmine-b960470d7817843906d42628d8bb4228ee49b2d9.tar.gz
redmine-b960470d7817843906d42628d8bb4228ee49b2d9.zip
Removed object_daddy dependency.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9469 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/issue_test.rb4
-rw-r--r--test/unit/lib/redmine/ciphering_test.rb20
-rw-r--r--test/unit/lib/redmine/helpers/gantt_test.rb1
-rw-r--r--test/unit/project_test.rb18
-rw-r--r--test/unit/query_test.rb4
-rw-r--r--test/unit/testing_test.rb46
-rw-r--r--test/unit/user_test.rb22
7 files changed, 37 insertions, 78 deletions
diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb
index b55b3d065..77c2b2b73 100644
--- a/test/unit/issue_test.rb
+++ b/test/unit/issue_test.rb
@@ -373,13 +373,13 @@ class IssueTest < ActiveSupport::TestCase
tracker = Tracker.find(1)
user = User.find(2)
- issue = Issue.generate!(:tracker => tracker, :status => status, :project_id => 1)
+ issue = Issue.generate!(:tracker => tracker, :status => status, :project_id => 1, :author_id => 1)
assert_equal [1, 2], issue.new_statuses_allowed_to(user).map(&:id)
issue = Issue.generate!(:tracker => tracker, :status => status, :project_id => 1, :author => user)
assert_equal [1, 2, 3, 5], issue.new_statuses_allowed_to(user).map(&:id)
- issue = Issue.generate!(:tracker => tracker, :status => status, :project_id => 1, :assigned_to => user)
+ issue = Issue.generate!(:tracker => tracker, :status => status, :project_id => 1, :author_id => 1, :assigned_to => user)
assert_equal [1, 2, 4, 5], issue.new_statuses_allowed_to(user).map(&:id)
issue = Issue.generate!(:tracker => tracker, :status => status, :project_id => 1, :author => user, :assigned_to => user)
diff --git a/test/unit/lib/redmine/ciphering_test.rb b/test/unit/lib/redmine/ciphering_test.rb
index 94d40116e..6d10f6abf 100644
--- a/test/unit/lib/redmine/ciphering_test.rb
+++ b/test/unit/lib/redmine/ciphering_test.rb
@@ -21,7 +21,7 @@ class Redmine::CipheringTest < ActiveSupport::TestCase
def test_password_should_be_encrypted
Redmine::Configuration.with 'database_cipher_key' => 'secret' do
- r = Repository::Subversion.generate!(:password => 'foo')
+ r = Repository::Subversion.create!(:password => 'foo', :url => 'file:///tmp', :identifier => 'svn')
assert_equal 'foo', r.password
assert r.read_attribute(:password).match(/\Aaes-256-cbc:.+\Z/)
end
@@ -29,7 +29,7 @@ class Redmine::CipheringTest < ActiveSupport::TestCase
def test_password_should_be_clear_with_blank_key
Redmine::Configuration.with 'database_cipher_key' => '' do
- r = Repository::Subversion.generate!(:password => 'foo')
+ r = Repository::Subversion.create!(:password => 'foo', :url => 'file:///tmp', :identifier => 'svn')
assert_equal 'foo', r.password
assert_equal 'foo', r.read_attribute(:password)
end
@@ -37,7 +37,7 @@ class Redmine::CipheringTest < ActiveSupport::TestCase
def test_password_should_be_clear_with_nil_key
Redmine::Configuration.with 'database_cipher_key' => nil do
- r = Repository::Subversion.generate!(:password => 'foo')
+ r = Repository::Subversion.create!(:password => 'foo', :url => 'file:///tmp', :identifier => 'svn')
assert_equal 'foo', r.password
assert_equal 'foo', r.read_attribute(:password)
end
@@ -45,7 +45,7 @@ class Redmine::CipheringTest < ActiveSupport::TestCase
def test_blank_password_should_be_clear
Redmine::Configuration.with 'database_cipher_key' => 'secret' do
- r = Repository::Subversion.generate!(:password => '')
+ r = Repository::Subversion.create!(:password => '', :url => 'file:///tmp', :identifier => 'svn')
assert_equal '', r.password
assert_equal '', r.read_attribute(:password)
end
@@ -53,7 +53,7 @@ class Redmine::CipheringTest < ActiveSupport::TestCase
def test_unciphered_password_should_be_readable
Redmine::Configuration.with 'database_cipher_key' => nil do
- r = Repository::Subversion.generate!(:password => 'clear')
+ r = Repository::Subversion.create!(:password => 'clear', :url => 'file:///tmp', :identifier => 'svn')
end
Redmine::Configuration.with 'database_cipher_key' => 'secret' do
@@ -64,7 +64,7 @@ class Redmine::CipheringTest < ActiveSupport::TestCase
def test_ciphered_password_with_no_cipher_key_configured_should_be_returned_ciphered
Redmine::Configuration.with 'database_cipher_key' => 'secret' do
- r = Repository::Subversion.generate!(:password => 'clear')
+ r = Repository::Subversion.create!(:password => 'clear', :url => 'file:///tmp', :identifier => 'svn')
end
Redmine::Configuration.with 'database_cipher_key' => '' do
@@ -79,8 +79,8 @@ class Redmine::CipheringTest < ActiveSupport::TestCase
def test_encrypt_all
Repository.delete_all
Redmine::Configuration.with 'database_cipher_key' => nil do
- Repository::Subversion.generate!(:password => 'foo')
- Repository::Subversion.generate!(:password => 'bar')
+ Repository::Subversion.create!(:password => 'foo', :url => 'file:///tmp', :identifier => 'foo')
+ Repository::Subversion.create!(:password => 'bar', :url => 'file:///tmp', :identifier => 'bar')
end
Redmine::Configuration.with 'database_cipher_key' => 'secret' do
@@ -94,8 +94,8 @@ class Redmine::CipheringTest < ActiveSupport::TestCase
def test_decrypt_all
Repository.delete_all
Redmine::Configuration.with 'database_cipher_key' => 'secret' do
- Repository::Subversion.generate!(:password => 'foo')
- Repository::Subversion.generate!(:password => 'bar')
+ Repository::Subversion.create!(:password => 'foo', :url => 'file:///tmp', :identifier => 'foo')
+ Repository::Subversion.create!(:password => 'bar', :url => 'file:///tmp', :identifier => 'bar')
assert Repository.decrypt_all(:password)
r = Repository.first(:order => 'id DESC')
diff --git a/test/unit/lib/redmine/helpers/gantt_test.rb b/test/unit/lib/redmine/helpers/gantt_test.rb
index 614bcfac7..b4f201a2b 100644
--- a/test/unit/lib/redmine/helpers/gantt_test.rb
+++ b/test/unit/lib/redmine/helpers/gantt_test.rb
@@ -160,7 +160,6 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
context "assigned to a shared version of another project" do
setup do
p = Project.generate!
- p.trackers << @tracker
p.enabled_module_names = [:issue_tracking]
@shared_version = Version.generate!(:sharing => 'system')
p.versions << @shared_version
diff --git a/test/unit/project_test.rb b/test/unit/project_test.rb
index 6613ef0b2..fa0b908c1 100644
--- a/test/unit/project_test.rb
+++ b/test/unit/project_test.rb
@@ -742,7 +742,7 @@ class ProjectTest < ActiveSupport::TestCase
project = Project.find(1)
system_activity = TimeEntryActivity.find_by_name('Design')
assert system_activity.active?
- overridden_activity = TimeEntryActivity.generate!(:project => project, :parent => system_activity, :active => false)
+ overridden_activity = TimeEntryActivity.create!(:name => "Project", :project => project, :parent => system_activity, :active => false)
assert overridden_activity.save!
assert !project.activities.include?(overridden_activity), "Inactive Project specific Activity not found"
@@ -822,10 +822,10 @@ class ProjectTest < ActiveSupport::TestCase
:tracker_id => 1,
:assigned_to_id => 2,
:project_id => @source_project.id)
- source_relation = IssueRelation.generate!(:issue_from => Issue.find(4),
+ source_relation = IssueRelation.create!(:issue_from => Issue.find(4),
:issue_to => second_issue,
:relation_type => "relates")
- source_relation_cross_project = IssueRelation.generate!(:issue_from => Issue.find(1),
+ source_relation_cross_project = IssueRelation.create!(:issue_from => Issue.find(1),
:issue_to => second_issue,
:relation_type => "duplicates")
@@ -1104,22 +1104,22 @@ class ProjectTest < ActiveSupport::TestCase
@role = Role.generate!
@user_with_membership_notification = User.generate!(:mail_notification => 'selected')
- Member.generate!(:project => @project, :roles => [@role], :principal => @user_with_membership_notification, :mail_notification => true)
+ Member.create!(:project => @project, :roles => [@role], :principal => @user_with_membership_notification, :mail_notification => true)
@all_events_user = User.generate!(:mail_notification => 'all')
- Member.generate!(:project => @project, :roles => [@role], :principal => @all_events_user)
+ Member.create!(:project => @project, :roles => [@role], :principal => @all_events_user)
@no_events_user = User.generate!(:mail_notification => 'none')
- Member.generate!(:project => @project, :roles => [@role], :principal => @no_events_user)
+ Member.create!(:project => @project, :roles => [@role], :principal => @no_events_user)
@only_my_events_user = User.generate!(:mail_notification => 'only_my_events')
- Member.generate!(:project => @project, :roles => [@role], :principal => @only_my_events_user)
+ Member.create!(:project => @project, :roles => [@role], :principal => @only_my_events_user)
@only_assigned_user = User.generate!(:mail_notification => 'only_assigned')
- Member.generate!(:project => @project, :roles => [@role], :principal => @only_assigned_user)
+ Member.create!(:project => @project, :roles => [@role], :principal => @only_assigned_user)
@only_owned_user = User.generate!(:mail_notification => 'only_owner')
- Member.generate!(:project => @project, :roles => [@role], :principal => @only_owned_user)
+ Member.create!(:project => @project, :roles => [@role], :principal => @only_owned_user)
end
should "include members with a mail notification" do
diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb
index 52e29de7e..a516c7a98 100644
--- a/test/unit/query_test.rb
+++ b/test/unit/query_test.rb
@@ -670,7 +670,9 @@ class QueryTest < ActiveSupport::TestCase
end
def test_issue_count_with_archived_issues
- p = Project.generate!( :status => Project::STATUS_ARCHIVED )
+ p = Project.generate! do |project|
+ project.status = Project::STATUS_ARCHIVED
+ end
i = Issue.generate!( :project => p, :tracker => p.trackers.first )
assert !i.visible?
diff --git a/test/unit/testing_test.rb b/test/unit/testing_test.rb
deleted file mode 100644
index 011162743..000000000
--- a/test/unit/testing_test.rb
+++ /dev/null
@@ -1,46 +0,0 @@
-# Redmine - project management software
-# Copyright (C) 2006-2011 Jean-Philippe Lang
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
-require File.expand_path('../../test_helper', __FILE__)
-
-# Test case that checks that the testing infrastructure is setup correctly.
-class TestingTest < ActiveSupport::TestCase
- def test_working
- assert true
- end
-
- test "Rails 'test' case syntax" do
- 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
-
- context "works with a context" do
- should "work" do
- assert true
- end
- end
-
-end
diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb
index cf21298f0..cbd3de5e9 100644
--- a/test/unit/user_test.rb
+++ b/test/unit/user_test.rb
@@ -337,8 +337,10 @@ class UserTest < ActiveSupport::TestCase
def test_destroy_should_nullify_changesets
changeset = Changeset.create!(
- :repository => Repository::Subversion.generate!(
- :project_id => 1
+ :repository => Repository::Subversion.create!(
+ :project_id => 1,
+ :url => 'file:///tmp',
+ :identifier => 'tmp'
),
:revision => '12',
:committed_on => Time.now,
@@ -378,9 +380,9 @@ class UserTest < ActiveSupport::TestCase
end
should "select the exact matching user first" do
- case_sensitive_user = User.generate_with_protected!(
- :login => 'changed', :password => 'admin',
- :password_confirmation => 'admin')
+ case_sensitive_user = User.generate! do |user|
+ user.password = "admin"
+ end
# bypass validations to make it appear like existing data
case_sensitive_user.update_attribute(:login, 'ADMIN')
@@ -628,7 +630,7 @@ class UserTest < ActiveSupport::TestCase
should "return the existing api token value" do
user = User.generate_with_protected!
- token = Token.generate!(:action => 'api')
+ token = Token.create!(:action => 'api')
user.api_token = token
assert user.save
@@ -643,7 +645,7 @@ class UserTest < ActiveSupport::TestCase
should "return nil if the key is found for an inactive user" do
user = User.generate_with_protected!(:status => User::STATUS_LOCKED)
- token = Token.generate!(:action => 'api')
+ token = Token.create!(:action => 'api')
user.api_token = token
user.save
@@ -652,7 +654,7 @@ class UserTest < ActiveSupport::TestCase
should "return the user if the key is found for an active user" do
user = User.generate_with_protected!(:status => User::STATUS_ACTIVE)
- token = Token.generate!(:action => 'api')
+ token = Token.create!(:action => 'api')
user.api_token = token
user.save
@@ -823,7 +825,9 @@ class UserTest < ActiveSupport::TestCase
end
def test_own_account_deletable_should_be_true_for_an_admin_if_other_admin_exists
- User.generate_with_protected(:admin => true)
+ User.generate! do |user|
+ user.admin = true
+ end
with_settings :unsubscribe => '1' do
assert_equal true, User.find(1).own_account_deletable?