summaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/issue_test.rb26
-rw-r--r--test/unit/lib/redmine/helpers/gantt_test.rb6
-rw-r--r--test/unit/project_test.rb42
-rw-r--r--test/unit/query_test.rb10
-rw-r--r--test/unit/user_test.rb2
5 files changed, 38 insertions, 48 deletions
diff --git a/test/unit/issue_test.rb b/test/unit/issue_test.rb
index 4bd718de1..329d64361 100644
--- a/test/unit/issue_test.rb
+++ b/test/unit/issue_test.rb
@@ -115,14 +115,14 @@ class IssueTest < ActiveSupport::TestCase
def test_anonymous_should_not_see_private_issues_with_issues_visibility_set_to_default
assert Role.anonymous.update_attribute(:issues_visibility, 'default')
- issue = Issue.generate_for_project!(Project.find(1), :author => User.anonymous, :assigned_to => User.anonymous, :is_private => true)
+ issue = Issue.generate!(:author => User.anonymous, :assigned_to => User.anonymous, :is_private => true)
assert_nil Issue.where(:id => issue.id).visible(User.anonymous).first
assert !issue.visible?(User.anonymous)
end
def test_anonymous_should_not_see_private_issues_with_issues_visibility_set_to_own
assert Role.anonymous.update_attribute(:issues_visibility, 'own')
- issue = Issue.generate_for_project!(Project.find(1), :author => User.anonymous, :assigned_to => User.anonymous, :is_private => true)
+ issue = Issue.generate!(:author => User.anonymous, :assigned_to => User.anonymous, :is_private => true)
assert_nil Issue.where(:id => issue.id).visible(User.anonymous).first
assert !issue.visible?(User.anonymous)
end
@@ -720,10 +720,9 @@ class IssueTest < ActiveSupport::TestCase
def test_should_close_duplicates
# Create 3 issues
- project = Project.find(1)
- issue1 = Issue.generate_for_project!(project)
- issue2 = Issue.generate_for_project!(project)
- issue3 = Issue.generate_for_project!(project)
+ issue1 = Issue.generate!
+ issue2 = Issue.generate!
+ issue3 = Issue.generate!
# 2 is a dupe of 1
IssueRelation.create!(:issue_from => issue2, :issue_to => issue1, :relation_type => IssueRelation::TYPE_DUPLICATES)
@@ -744,9 +743,8 @@ class IssueTest < ActiveSupport::TestCase
end
def test_should_not_close_duplicated_issue
- project = Project.find(1)
- issue1 = Issue.generate_for_project!(project)
- issue2 = Issue.generate_for_project!(project)
+ issue1 = Issue.generate!
+ issue2 = Issue.generate!
# 2 is a dupe of 1
IssueRelation.create(:issue_from => issue2, :issue_to => issue1, :relation_type => IssueRelation::TYPE_DUPLICATES)
@@ -1211,17 +1209,15 @@ class IssueTest < ActiveSupport::TestCase
end
should "include the issue author" do
- project = Project.find(1)
non_project_member = User.generate!
- issue = Issue.generate_for_project!(project, :author => non_project_member)
+ issue = Issue.generate!(:author => non_project_member)
assert issue.assignable_users.include?(non_project_member)
end
should "include the current assignee" do
- project = Project.find(1)
user = User.generate!
- issue = Issue.generate_for_project!(project, :assigned_to => user)
+ issue = Issue.generate!(:assigned_to => user)
user.lock!
assert Issue.find(issue.id).assignable_users.include?(user)
@@ -1580,7 +1576,7 @@ class IssueTest < ActiveSupport::TestCase
before = Issue.on_active_project.length
# test inclusion to results
- issue = Issue.generate_for_project!(Project.find(1), :tracker => Project.find(2).trackers.first)
+ issue = Issue.generate!(:tracker => Project.find(2).trackers.first)
assert_equal before + 1, Issue.on_active_project.length
# Move to an archived project
@@ -1594,7 +1590,7 @@ class IssueTest < ActiveSupport::TestCase
@project = Project.find(1)
@author = User.generate!
@assignee = User.generate!
- @issue = Issue.generate_for_project!(@project, :assigned_to => @assignee, :author => @author)
+ @issue = Issue.generate!(:project => @project, :assigned_to => @assignee, :author => @author)
end
should "include project recipients" do
diff --git a/test/unit/lib/redmine/helpers/gantt_test.rb b/test/unit/lib/redmine/helpers/gantt_test.rb
index 54b004bde..819b506e3 100644
--- a/test/unit/lib/redmine/helpers/gantt_test.rb
+++ b/test/unit/lib/redmine/helpers/gantt_test.rb
@@ -67,7 +67,7 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
should "not exceed max_rows option" do
p = Project.generate!
5.times do
- Issue.generate_for_project!(p)
+ Issue.generate!(:project => p)
end
create_gantt(p)
@gantt.render
@@ -90,14 +90,14 @@ class Redmine::Helpers::GanttHelperTest < ActionView::TestCase
end
should "count the number of issues without a version" do
- @project.issues << Issue.generate_for_project!(@project, :fixed_version => nil)
+ @project.issues << Issue.generate!(:project => @project, :fixed_version => nil)
assert_equal 2, @gantt.number_of_rows_on_project(@project)
end
should "count the number of issues on versions, including cross-project" do
version = Version.generate!
@project.versions << version
- @project.issues << Issue.generate_for_project!(@project, :fixed_version => version)
+ @project.issues << Issue.generate!(:project => @project, :fixed_version => version)
assert_equal 3, @gantt.number_of_rows_on_project(@project)
end
end
diff --git a/test/unit/project_test.rb b/test/unit/project_test.rb
index cb374e177..8338a1f53 100644
--- a/test/unit/project_test.rb
+++ b/test/unit/project_test.rb
@@ -828,11 +828,9 @@ class ProjectTest < ActiveSupport::TestCase
User.current = User.find(1)
assigned_version = Version.generate!(:name => "Assigned Issues")
@source_project.versions << assigned_version
- Issue.generate_for_project!(@source_project,
- :fixed_version_id => assigned_version.id,
- :subject => "copy issues assigned to a locked version",
- :tracker_id => 1,
- :project_id => @source_project.id)
+ Issue.generate!(:project => @source_project,
+ :fixed_version_id => assigned_version.id,
+ :subject => "copy issues assigned to a locked version")
assigned_version.update_attribute :status, 'locked'
assert @project.copy(@source_project)
@@ -850,11 +848,9 @@ class ProjectTest < ActiveSupport::TestCase
assigned_version = Version.generate!(:name => "Assigned Issues", :status => 'open')
@source_project.versions << assigned_version
assert_equal 3, @source_project.versions.size
- Issue.generate_for_project!(@source_project,
- :fixed_version_id => assigned_version.id,
- :subject => "change the new issues to use the copied version",
- :tracker_id => 1,
- :project_id => @source_project.id)
+ Issue.generate!(:project => @source_project,
+ :fixed_version_id => assigned_version.id,
+ :subject => "change the new issues to use the copied version")
assert @project.copy(@source_project)
@project.reload
@@ -868,11 +864,9 @@ class ProjectTest < ActiveSupport::TestCase
should "keep target shared versions from other project" do
assigned_version = Version.generate!(:name => "Assigned Issues", :status => 'open', :project_id => 1, :sharing => 'system')
- issue = Issue.generate_for_project!(@source_project,
- :fixed_version => assigned_version,
- :subject => "keep target shared versions",
- :tracker_id => 1,
- :project_id => @source_project.id)
+ issue = Issue.generate!(:project => @source_project,
+ :fixed_version => assigned_version,
+ :subject => "keep target shared versions")
assert @project.copy(@source_project)
@project.reload
@@ -1090,8 +1084,8 @@ class ProjectTest < ActiveSupport::TestCase
should "be the earliest start date of it's issues" do
early = 7.days.ago.to_date
- Issue.generate_for_project!(@project, :start_date => Date.today)
- Issue.generate_for_project!(@project, :start_date => early)
+ Issue.generate!(:project => @project, :start_date => Date.today)
+ Issue.generate!(:project => @project, :start_date => early)
assert_equal early, @project.start_date
end
@@ -1113,8 +1107,8 @@ class ProjectTest < ActiveSupport::TestCase
should "be the latest due date of it's issues" do
future = 7.days.from_now.to_date
- Issue.generate_for_project!(@project, :due_date => future)
- Issue.generate_for_project!(@project, :due_date => Date.today)
+ Issue.generate!(:project => @project, :due_date => future)
+ Issue.generate!(:project => @project, :due_date => Date.today)
assert_equal future, @project.due_date
end
@@ -1132,7 +1126,7 @@ class ProjectTest < ActiveSupport::TestCase
should "pick the latest date from it's issues and versions" do
future = 7.days.from_now.to_date
far_future = 14.days.from_now.to_date
- Issue.generate_for_project!(@project, :due_date => far_future)
+ Issue.generate!(:project => @project, :due_date => far_future)
@project.versions << Version.generate!(:effective_date => future)
assert_equal far_future, @project.due_date
@@ -1163,18 +1157,18 @@ class ProjectTest < ActiveSupport::TestCase
should "return 100 if the version has only closed issues" do
v1 = Version.generate!(:project => @project)
- Issue.generate_for_project!(@project, :status => IssueStatus.find_by_name('Closed'), :fixed_version => v1)
+ Issue.generate!(:project => @project, :status => IssueStatus.find_by_name('Closed'), :fixed_version => v1)
v2 = Version.generate!(:project => @project)
- Issue.generate_for_project!(@project, :status => IssueStatus.find_by_name('Closed'), :fixed_version => v2)
+ Issue.generate!(:project => @project, :status => IssueStatus.find_by_name('Closed'), :fixed_version => v2)
assert_equal 100, @project.completed_percent
end
should "return the averaged completed percent of the versions (not weighted)" do
v1 = Version.generate!(:project => @project)
- Issue.generate_for_project!(@project, :status => IssueStatus.find_by_name('New'), :estimated_hours => 10, :done_ratio => 50, :fixed_version => v1)
+ Issue.generate!(:project => @project, :status => IssueStatus.find_by_name('New'), :estimated_hours => 10, :done_ratio => 50, :fixed_version => v1)
v2 = Version.generate!(:project => @project)
- Issue.generate_for_project!(@project, :status => IssueStatus.find_by_name('New'), :estimated_hours => 10, :done_ratio => 50, :fixed_version => v2)
+ Issue.generate!(:project => @project, :status => IssueStatus.find_by_name('New'), :estimated_hours => 10, :done_ratio => 50, :fixed_version => v2)
assert_equal 50, @project.completed_percent
end
diff --git a/test/unit/query_test.rb b/test/unit/query_test.rb
index 3513e5a68..edf6e32ca 100644
--- a/test/unit/query_test.rb
+++ b/test/unit/query_test.rb
@@ -1149,11 +1149,11 @@ class QueryTest < ActiveSupport::TestCase
User.add_to_project(@developer, @project, @developer_role)
User.add_to_project(@boss, @project, [@manager_role, @developer_role])
- @issue1 = Issue.generate_for_project!(@project, :assigned_to_id => @manager.id)
- @issue2 = Issue.generate_for_project!(@project, :assigned_to_id => @developer.id)
- @issue3 = Issue.generate_for_project!(@project, :assigned_to_id => @boss.id)
- @issue4 = Issue.generate_for_project!(@project, :assigned_to_id => @guest.id)
- @issue5 = Issue.generate_for_project!(@project)
+ @issue1 = Issue.generate!(:project => @project, :assigned_to_id => @manager.id)
+ @issue2 = Issue.generate!(:project => @project, :assigned_to_id => @developer.id)
+ @issue3 = Issue.generate!(:project => @project, :assigned_to_id => @boss.id)
+ @issue4 = Issue.generate!(:project => @project, :assigned_to_id => @guest.id)
+ @issue5 = Issue.generate!(:project => @project)
end
should "search assigned to for users with the Role" do
diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb
index 20056406b..a1eaf31f6 100644
--- a/test/unit/user_test.rb
+++ b/test/unit/user_test.rb
@@ -948,7 +948,7 @@ class UserTest < ActiveSupport::TestCase
@project = Project.find(1)
@author = User.generate!
@assignee = User.generate!
- @issue = Issue.generate_for_project!(@project, :assigned_to => @assignee, :author => @author)
+ @issue = Issue.generate!(:project => @project, :assigned_to => @assignee, :author => @author)
end
should "be true for a user with :all" do