Removing shoulda context.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11315 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2013-02-03 09:20:05 +00:00
parent de8033d183
commit 14b50dfbab
7 changed files with 412 additions and 524 deletions
+165 -217
View File
@@ -1129,57 +1129,51 @@ class IssueTest < ActiveSupport::TestCase
assert_nil copy.custom_value_for(2)
end
context "#copy" do
setup do
@issue = Issue.find(1)
end
test "#copy should not create a journal" do
copy = Issue.find(1).copy(:project_id => 3, :tracker_id => 2, :assigned_to_id => 3)
copy.save!
assert_equal 0, copy.reload.journals.size
end
should "not create a journal" do
copy = @issue.copy(:project_id => 3, :tracker_id => 2, :assigned_to_id => 3)
copy.save!
assert_equal 0, copy.reload.journals.size
end
test "#copy should allow assigned_to changes" do
copy = Issue.find(1).copy(:project_id => 3, :tracker_id => 2, :assigned_to_id => 3)
assert_equal 3, copy.assigned_to_id
end
should "allow assigned_to changes" do
copy = @issue.copy(:project_id => 3, :tracker_id => 2, :assigned_to_id => 3)
assert_equal 3, copy.assigned_to_id
end
test "#copy should allow status changes" do
copy = Issue.find(1).copy(:project_id => 3, :tracker_id => 2, :status_id => 2)
assert_equal 2, copy.status_id
end
should "allow status changes" do
copy = @issue.copy(:project_id => 3, :tracker_id => 2, :status_id => 2)
assert_equal 2, copy.status_id
end
test "#copy should allow start date changes" do
date = Date.today
copy = Issue.find(1).copy(:project_id => 3, :tracker_id => 2, :start_date => date)
assert_equal date, copy.start_date
end
should "allow start date changes" do
date = Date.today
copy = @issue.copy(:project_id => 3, :tracker_id => 2, :start_date => date)
assert_equal date, copy.start_date
end
test "#copy should allow due date changes" do
date = Date.today
copy = Issue.find(1).copy(:project_id => 3, :tracker_id => 2, :due_date => date)
assert_equal date, copy.due_date
end
should "allow due date changes" do
date = Date.today
copy = @issue.copy(:project_id => 3, :tracker_id => 2, :due_date => date)
assert_equal date, copy.due_date
end
test "#copy should set current user as author" do
User.current = User.find(9)
copy = Issue.find(1).copy(:project_id => 3, :tracker_id => 2)
assert_equal User.current, copy.author
end
should "set current user as author" do
User.current = User.find(9)
copy = @issue.copy(:project_id => 3, :tracker_id => 2)
assert_equal User.current, copy.author
end
test "#copy should create a journal with notes" do
date = Date.today
notes = "Notes added when copying"
copy = Issue.find(1).copy(:project_id => 3, :tracker_id => 2, :start_date => date)
copy.init_journal(User.current, notes)
copy.save!
should "create a journal with notes" do
date = Date.today
notes = "Notes added when copying"
copy = @issue.copy(:project_id => 3, :tracker_id => 2, :start_date => date)
copy.init_journal(User.current, notes)
copy.save!
assert_equal 1, copy.journals.size
journal = copy.journals.first
assert_equal 0, journal.details.size
assert_equal notes, journal.notes
end
assert_equal 1, copy.journals.size
journal = copy.journals.first
assert_equal 0, journal.details.size
assert_equal notes, journal.notes
end
def test_valid_parent_project
@@ -1454,88 +1448,80 @@ class IssueTest < ActiveSupport::TestCase
).overdue?
end
context "#behind_schedule?" do
should "be false if the issue has no start_date" do
assert !Issue.new(:start_date => nil,
:due_date => 1.day.from_now.to_date,
:done_ratio => 0).behind_schedule?
end
test "#behind_schedule? should be false if the issue has no start_date" do
assert !Issue.new(:start_date => nil,
:due_date => 1.day.from_now.to_date,
:done_ratio => 0).behind_schedule?
end
should "be false if the issue has no end_date" do
assert !Issue.new(:start_date => 1.day.from_now.to_date,
:due_date => nil,
:done_ratio => 0).behind_schedule?
end
test "#behind_schedule? should be false if the issue has no end_date" do
assert !Issue.new(:start_date => 1.day.from_now.to_date,
:due_date => nil,
:done_ratio => 0).behind_schedule?
end
should "be false if the issue has more done than it's calendar time" do
assert !Issue.new(:start_date => 50.days.ago.to_date,
:due_date => 50.days.from_now.to_date,
:done_ratio => 90).behind_schedule?
end
test "#behind_schedule? should be false if the issue has more done than it's calendar time" do
assert !Issue.new(:start_date => 50.days.ago.to_date,
:due_date => 50.days.from_now.to_date,
:done_ratio => 90).behind_schedule?
end
should "be true if the issue hasn't been started at all" do
assert Issue.new(:start_date => 1.day.ago.to_date,
:due_date => 1.day.from_now.to_date,
:done_ratio => 0).behind_schedule?
end
test "#behind_schedule? should be true if the issue hasn't been started at all" do
assert Issue.new(:start_date => 1.day.ago.to_date,
:due_date => 1.day.from_now.to_date,
:done_ratio => 0).behind_schedule?
end
should "be true if the issue has used more calendar time than it's done ratio" do
assert Issue.new(:start_date => 100.days.ago.to_date,
:due_date => Date.today,
:done_ratio => 90).behind_schedule?
test "#behind_schedule? should be true if the issue has used more calendar time than it's done ratio" do
assert Issue.new(:start_date => 100.days.ago.to_date,
:due_date => Date.today,
:done_ratio => 90).behind_schedule?
end
test "#assignable_users should be Users" do
assert_kind_of User, Issue.find(1).assignable_users.first
end
test "#assignable_users should include the issue author" do
non_project_member = User.generate!
issue = Issue.generate!(:author => non_project_member)
assert issue.assignable_users.include?(non_project_member)
end
test "#assignable_users should include the current assignee" do
user = User.generate!
issue = Issue.generate!(:assigned_to => user)
user.lock!
assert Issue.find(issue.id).assignable_users.include?(user)
end
test "#assignable_users should not show the issue author twice" do
assignable_user_ids = Issue.find(1).assignable_users.collect(&:id)
assert_equal 2, assignable_user_ids.length
assignable_user_ids.each do |user_id|
assert_equal 1, assignable_user_ids.select {|i| i == user_id}.length,
"User #{user_id} appears more or less than once"
end
end
context "#assignable_users" do
should "be Users" do
assert_kind_of User, Issue.find(1).assignable_users.first
test "#assignable_users with issue_group_assignment should include groups" do
issue = Issue.new(:project => Project.find(2))
with_settings :issue_group_assignment => '1' do
assert_equal %w(Group User), issue.assignable_users.map {|a| a.class.name}.uniq.sort
assert issue.assignable_users.include?(Group.find(11))
end
end
should "include the issue author" do
non_project_member = User.generate!
issue = Issue.generate!(:author => non_project_member)
test "#assignable_users without issue_group_assignment should not include groups" do
issue = Issue.new(:project => Project.find(2))
assert issue.assignable_users.include?(non_project_member)
end
should "include the current assignee" do
user = User.generate!
issue = Issue.generate!(:assigned_to => user)
user.lock!
assert Issue.find(issue.id).assignable_users.include?(user)
end
should "not show the issue author twice" do
assignable_user_ids = Issue.find(1).assignable_users.collect(&:id)
assert_equal 2, assignable_user_ids.length
assignable_user_ids.each do |user_id|
assert_equal 1, assignable_user_ids.select {|i| i == user_id}.length,
"User #{user_id} appears more or less than once"
end
end
context "with issue_group_assignment" do
should "include groups" do
issue = Issue.new(:project => Project.find(2))
with_settings :issue_group_assignment => '1' do
assert_equal %w(Group User), issue.assignable_users.map {|a| a.class.name}.uniq.sort
assert issue.assignable_users.include?(Group.find(11))
end
end
end
context "without issue_group_assignment" do
should "not include groups" do
issue = Issue.new(:project => Project.find(2))
with_settings :issue_group_assignment => '0' do
assert_equal %w(User), issue.assignable_users.map {|a| a.class.name}.uniq.sort
assert !issue.assignable_users.include?(Group.find(11))
end
end
with_settings :issue_group_assignment => '0' do
assert_equal %w(User), issue.assignable_users.map {|a| a.class.name}.uniq.sort
assert !issue.assignable_users.include?(Group.find(11))
end
end
@@ -1728,79 +1714,47 @@ class IssueTest < ActiveSupport::TestCase
assert_equal [2, 3, 8], Issue.find(1).all_dependent_issues.collect(&:id).sort
end
context "#done_ratio" do
setup do
@issue = Issue.find(1)
@issue_status = IssueStatus.find(1)
@issue_status.update_attribute(:default_done_ratio, 50)
@issue2 = Issue.find(2)
@issue_status2 = IssueStatus.find(2)
@issue_status2.update_attribute(:default_done_ratio, 0)
test "#done_ratio should use the issue_status according to Setting.issue_done_ratio" do
@issue = Issue.find(1)
@issue_status = IssueStatus.find(1)
@issue_status.update_attribute(:default_done_ratio, 50)
@issue2 = Issue.find(2)
@issue_status2 = IssueStatus.find(2)
@issue_status2.update_attribute(:default_done_ratio, 0)
with_settings :issue_done_ratio => 'issue_field' do
assert_equal 0, @issue.done_ratio
assert_equal 30, @issue2.done_ratio
end
teardown do
Setting.issue_done_ratio = 'issue_field'
end
context "with Setting.issue_done_ratio using the issue_field" do
setup do
Setting.issue_done_ratio = 'issue_field'
end
should "read the issue's field" do
assert_equal 0, @issue.done_ratio
assert_equal 30, @issue2.done_ratio
end
end
context "with Setting.issue_done_ratio using the issue_status" do
setup do
Setting.issue_done_ratio = 'issue_status'
end
should "read the Issue Status's default done ratio" do
assert_equal 50, @issue.done_ratio
assert_equal 0, @issue2.done_ratio
end
with_settings :issue_done_ratio => 'issue_status' do
assert_equal 50, @issue.done_ratio
assert_equal 0, @issue2.done_ratio
end
end
context "#update_done_ratio_from_issue_status" do
setup do
@issue = Issue.find(1)
@issue_status = IssueStatus.find(1)
@issue_status.update_attribute(:default_done_ratio, 50)
@issue2 = Issue.find(2)
@issue_status2 = IssueStatus.find(2)
@issue_status2.update_attribute(:default_done_ratio, 0)
test "#update_done_ratio_from_issue_status should update done_ratio according to Setting.issue_done_ratio" do
@issue = Issue.find(1)
@issue_status = IssueStatus.find(1)
@issue_status.update_attribute(:default_done_ratio, 50)
@issue2 = Issue.find(2)
@issue_status2 = IssueStatus.find(2)
@issue_status2.update_attribute(:default_done_ratio, 0)
with_settings :issue_done_ratio => 'issue_field' do
@issue.update_done_ratio_from_issue_status
@issue2.update_done_ratio_from_issue_status
assert_equal 0, @issue.read_attribute(:done_ratio)
assert_equal 30, @issue2.read_attribute(:done_ratio)
end
context "with Setting.issue_done_ratio using the issue_field" do
setup do
Setting.issue_done_ratio = 'issue_field'
end
with_settings :issue_done_ratio => 'issue_status' do
@issue.update_done_ratio_from_issue_status
@issue2.update_done_ratio_from_issue_status
should "not change the issue" do
@issue.update_done_ratio_from_issue_status
@issue2.update_done_ratio_from_issue_status
assert_equal 0, @issue.read_attribute(:done_ratio)
assert_equal 30, @issue2.read_attribute(:done_ratio)
end
end
context "with Setting.issue_done_ratio using the issue_status" do
setup do
Setting.issue_done_ratio = 'issue_status'
end
should "change the issue's done ratio" do
@issue.update_done_ratio_from_issue_status
@issue2.update_done_ratio_from_issue_status
assert_equal 50, @issue.read_attribute(:done_ratio)
assert_equal 0, @issue2.read_attribute(:done_ratio)
end
assert_equal 50, @issue.read_attribute(:done_ratio)
assert_equal 0, @issue2.read_attribute(:done_ratio)
end
end
@@ -1873,48 +1827,42 @@ class IssueTest < ActiveSupport::TestCase
assert_equal before, Issue.on_active_project.length
end
context "Issue#recipients" do
setup do
@project = Project.find(1)
@author = User.generate!
@assignee = User.generate!
@issue = Issue.generate!(:project => @project, :assigned_to => @assignee, :author => @author)
test "Issue#recipients should include project recipients" do
issue = Issue.generate!
assert issue.project.recipients.present?
issue.project.recipients.each do |project_recipient|
assert issue.recipients.include?(project_recipient)
end
end
should "include project recipients" do
assert @project.recipients.present?
@project.recipients.each do |project_recipient|
assert @issue.recipients.include?(project_recipient)
end
end
test "Issue#recipients should include the author if the author is active" do
issue = Issue.generate!(:author => User.generate!)
assert issue.author, "No author set for Issue"
assert issue.recipients.include?(issue.author.mail)
end
should "include the author if the author is active" do
assert @issue.author, "No author set for Issue"
assert @issue.recipients.include?(@issue.author.mail)
end
test "Issue#recipients should include the assigned to user if the assigned to user is active" do
issue = Issue.generate!(:assigned_to => User.generate!)
assert issue.assigned_to, "No assigned_to set for Issue"
assert issue.recipients.include?(issue.assigned_to.mail)
end
should "include the assigned to user if the assigned to user is active" do
assert @issue.assigned_to, "No assigned_to set for Issue"
assert @issue.recipients.include?(@issue.assigned_to.mail)
end
test "Issue#recipients should not include users who opt out of all email" do
issue = Issue.generate!(:author => User.generate!)
issue.author.update_attribute(:mail_notification, :none)
assert !issue.recipients.include?(issue.author.mail)
end
should "not include users who opt out of all email" do
@author.update_attribute(:mail_notification, :none)
test "Issue#recipients should not include the issue author if they are only notified of assigned issues" do
issue = Issue.generate!(:author => User.generate!)
issue.author.update_attribute(:mail_notification, :only_assigned)
assert !issue.recipients.include?(issue.author.mail)
end
assert !@issue.recipients.include?(@issue.author.mail)
end
should "not include the issue author if they are only notified of assigned issues" do
@author.update_attribute(:mail_notification, :only_assigned)
assert !@issue.recipients.include?(@issue.author.mail)
end
should "not include the assigned user if they are only notified of owned issues" do
@assignee.update_attribute(:mail_notification, :only_owner)
assert !@issue.recipients.include?(@issue.assigned_to.mail)
end
test "Issue#recipients should not include the assigned user if they are only notified of owned issues" do
issue = Issue.generate!(:assigned_to => User.generate!)
issue.assigned_to.update_attribute(:mail_notification, :only_owner)
assert !issue.recipients.include?(issue.assigned_to.mail)
end
def test_last_journal_id_with_journals_should_return_the_journal_id