Mercurial > hg > soundsoftware-site
comparison test/unit/.svn/text-base/issue_test.rb.svn-base @ 37:94944d00e43c
* Update to SVN trunk rev 4411
author | Chris Cannam <chris.cannam@soundsoftware.ac.uk> |
---|---|
date | Fri, 19 Nov 2010 13:24:41 +0000 |
parents | 40f7cfd4df19 |
children | af80e5618e9b |
comparison
equal
deleted
inserted
replaced
22:40f7cfd4df19 | 37:94944d00e43c |
---|---|
501 assert !allowed_statuses.empty? | 501 assert !allowed_statuses.empty? |
502 closed_statuses = allowed_statuses.select {|st| st.is_closed?} | 502 closed_statuses = allowed_statuses.select {|st| st.is_closed?} |
503 assert !closed_statuses.empty? | 503 assert !closed_statuses.empty? |
504 end | 504 end |
505 | 505 |
506 def test_rescheduling_an_issue_should_reschedule_following_issue | |
507 issue1 = Issue.create!(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :subject => '-', :start_date => Date.today, :due_date => Date.today + 2) | |
508 issue2 = Issue.create!(:project_id => 1, :tracker_id => 1, :author_id => 1, :status_id => 1, :subject => '-', :start_date => Date.today, :due_date => Date.today + 2) | |
509 IssueRelation.create!(:issue_from => issue1, :issue_to => issue2, :relation_type => IssueRelation::TYPE_PRECEDES) | |
510 assert_equal issue1.due_date + 1, issue2.reload.start_date | |
511 | |
512 issue1.due_date = Date.today + 5 | |
513 issue1.save! | |
514 assert_equal issue1.due_date + 1, issue2.reload.start_date | |
515 end | |
516 | |
506 def test_overdue | 517 def test_overdue |
507 assert Issue.new(:due_date => 1.day.ago.to_date).overdue? | 518 assert Issue.new(:due_date => 1.day.ago.to_date).overdue? |
508 assert !Issue.new(:due_date => Date.today).overdue? | 519 assert !Issue.new(:due_date => Date.today).overdue? |
509 assert !Issue.new(:due_date => 1.day.from_now.to_date).overdue? | 520 assert !Issue.new(:due_date => 1.day.from_now.to_date).overdue? |
510 assert !Issue.new(:due_date => nil).overdue? | 521 assert !Issue.new(:due_date => nil).overdue? |
530 | 541 |
531 should "be true if the issue has used more calendar time than it's done ratio" do | 542 should "be true if the issue has used more calendar time than it's done ratio" do |
532 assert Issue.new(:start_date => 100.days.ago.to_date, :due_date => Date.today, :done_ratio => 90).behind_schedule? | 543 assert Issue.new(:start_date => 100.days.ago.to_date, :due_date => Date.today, :done_ratio => 90).behind_schedule? |
533 end | 544 end |
534 end | 545 end |
535 | 546 |
536 def test_assignable_users | 547 context "#assignable_users" do |
537 assert_kind_of User, Issue.find(1).assignable_users.first | 548 should "be Users" do |
549 assert_kind_of User, Issue.find(1).assignable_users.first | |
550 end | |
551 | |
552 should "include the issue author" do | |
553 project = Project.find(1) | |
554 non_project_member = User.generate! | |
555 issue = Issue.generate_for_project!(project, :author => non_project_member) | |
556 | |
557 assert issue.assignable_users.include?(non_project_member) | |
558 end | |
559 | |
560 should "not show the issue author twice" do | |
561 assignable_user_ids = Issue.find(1).assignable_users.collect(&:id) | |
562 assert_equal 2, assignable_user_ids.length | |
563 | |
564 assignable_user_ids.each do |user_id| | |
565 assert_equal 1, assignable_user_ids.select {|i| i == user_id}.length, "User #{user_id} appears more or less than once" | |
566 end | |
567 end | |
538 end | 568 end |
539 | 569 |
540 def test_create_should_send_email_notification | 570 def test_create_should_send_email_notification |
541 ActionMailer::Base.deliveries.clear | 571 ActionMailer::Base.deliveries.clear |
542 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3, :status_id => 1, :priority => IssuePriority.all.first, :subject => 'test_create', :estimated_hours => '1:30') | 572 issue = Issue.new(:project_id => 1, :tracker_id => 1, :author_id => 3, :status_id => 1, :priority => IssuePriority.all.first, :subject => 'test_create', :estimated_hours => '1:30') |
543 | 573 |
544 assert issue.save | 574 assert issue.save |
545 assert_equal 1, ActionMailer::Base.deliveries.size | 575 assert_equal 1, ActionMailer::Base.deliveries.size |
546 end | 576 end |
547 | 577 |
548 def test_stale_issue_should_not_send_email_notification | 578 def test_stale_issue_should_not_send_email_notification |
549 ActionMailer::Base.deliveries.clear | 579 ActionMailer::Base.deliveries.clear |
550 issue = Issue.find(1) | 580 issue = Issue.find(1) |
551 stale = Issue.find(1) | 581 stale = Issue.find(1) |
552 | 582 |
591 context "#done_ratio" do | 621 context "#done_ratio" do |
592 setup do | 622 setup do |
593 @issue = Issue.find(1) | 623 @issue = Issue.find(1) |
594 @issue_status = IssueStatus.find(1) | 624 @issue_status = IssueStatus.find(1) |
595 @issue_status.update_attribute(:default_done_ratio, 50) | 625 @issue_status.update_attribute(:default_done_ratio, 50) |
626 @issue2 = Issue.find(2) | |
627 @issue_status2 = IssueStatus.find(2) | |
628 @issue_status2.update_attribute(:default_done_ratio, 0) | |
596 end | 629 end |
597 | 630 |
598 context "with Setting.issue_done_ratio using the issue_field" do | 631 context "with Setting.issue_done_ratio using the issue_field" do |
599 setup do | 632 setup do |
600 Setting.issue_done_ratio = 'issue_field' | 633 Setting.issue_done_ratio = 'issue_field' |
601 end | 634 end |
602 | 635 |
603 should "read the issue's field" do | 636 should "read the issue's field" do |
604 assert_equal 0, @issue.done_ratio | 637 assert_equal 0, @issue.done_ratio |
638 assert_equal 30, @issue2.done_ratio | |
605 end | 639 end |
606 end | 640 end |
607 | 641 |
608 context "with Setting.issue_done_ratio using the issue_status" do | 642 context "with Setting.issue_done_ratio using the issue_status" do |
609 setup do | 643 setup do |
610 Setting.issue_done_ratio = 'issue_status' | 644 Setting.issue_done_ratio = 'issue_status' |
611 end | 645 end |
612 | 646 |
613 should "read the Issue Status's default done ratio" do | 647 should "read the Issue Status's default done ratio" do |
614 assert_equal 50, @issue.done_ratio | 648 assert_equal 50, @issue.done_ratio |
649 assert_equal 0, @issue2.done_ratio | |
615 end | 650 end |
616 end | 651 end |
617 end | 652 end |
618 | 653 |
619 context "#update_done_ratio_from_issue_status" do | 654 context "#update_done_ratio_from_issue_status" do |
620 setup do | 655 setup do |
621 @issue = Issue.find(1) | 656 @issue = Issue.find(1) |
622 @issue_status = IssueStatus.find(1) | 657 @issue_status = IssueStatus.find(1) |
623 @issue_status.update_attribute(:default_done_ratio, 50) | 658 @issue_status.update_attribute(:default_done_ratio, 50) |
659 @issue2 = Issue.find(2) | |
660 @issue_status2 = IssueStatus.find(2) | |
661 @issue_status2.update_attribute(:default_done_ratio, 0) | |
624 end | 662 end |
625 | 663 |
626 context "with Setting.issue_done_ratio using the issue_field" do | 664 context "with Setting.issue_done_ratio using the issue_field" do |
627 setup do | 665 setup do |
628 Setting.issue_done_ratio = 'issue_field' | 666 Setting.issue_done_ratio = 'issue_field' |
629 end | 667 end |
630 | 668 |
631 should "not change the issue" do | 669 should "not change the issue" do |
632 @issue.update_done_ratio_from_issue_status | 670 @issue.update_done_ratio_from_issue_status |
633 | 671 @issue2.update_done_ratio_from_issue_status |
634 assert_equal 0, @issue.done_ratio | 672 |
673 assert_equal 0, @issue.read_attribute(:done_ratio) | |
674 assert_equal 30, @issue2.read_attribute(:done_ratio) | |
635 end | 675 end |
636 end | 676 end |
637 | 677 |
638 context "with Setting.issue_done_ratio using the issue_status" do | 678 context "with Setting.issue_done_ratio using the issue_status" do |
639 setup do | 679 setup do |
640 Setting.issue_done_ratio = 'issue_status' | 680 Setting.issue_done_ratio = 'issue_status' |
641 end | 681 end |
642 | 682 |
643 should "not change the issue's done ratio" do | 683 should "change the issue's done ratio" do |
644 @issue.update_done_ratio_from_issue_status | 684 @issue.update_done_ratio_from_issue_status |
645 | 685 @issue2.update_done_ratio_from_issue_status |
646 assert_equal 50, @issue.done_ratio | 686 |
687 assert_equal 50, @issue.read_attribute(:done_ratio) | |
688 assert_equal 0, @issue2.read_attribute(:done_ratio) | |
647 end | 689 end |
648 end | 690 end |
649 end | 691 end |
650 | 692 |
651 test "#by_tracker" do | 693 test "#by_tracker" do |
724 # Move to an archived project | 766 # Move to an archived project |
725 issue.project = Project.find(2) | 767 issue.project = Project.find(2) |
726 assert issue.save | 768 assert issue.save |
727 assert_equal before, Issue.on_active_project.length | 769 assert_equal before, Issue.on_active_project.length |
728 end | 770 end |
771 | |
772 context "Issue#recipients" do | |
773 setup do | |
774 @project = Project.find(1) | |
775 @author = User.generate_with_protected! | |
776 @assignee = User.generate_with_protected! | |
777 @issue = Issue.generate_for_project!(@project, :assigned_to => @assignee, :author => @author) | |
778 end | |
779 | |
780 should "include project recipients" do | |
781 assert @project.recipients.present? | |
782 @project.recipients.each do |project_recipient| | |
783 assert @issue.recipients.include?(project_recipient) | |
784 end | |
785 end | |
786 | |
787 should "include the author if the author is active" do | |
788 assert @issue.author, "No author set for Issue" | |
789 assert @issue.recipients.include?(@issue.author.mail) | |
790 end | |
791 | |
792 should "include the assigned to user if the assigned to user is active" do | |
793 assert @issue.assigned_to, "No assigned_to set for Issue" | |
794 assert @issue.recipients.include?(@issue.assigned_to.mail) | |
795 end | |
796 | |
797 should "not include users who opt out of all email" do | |
798 @author.update_attribute(:mail_notification, :none) | |
799 | |
800 assert !@issue.recipients.include?(@issue.author.mail) | |
801 end | |
802 | |
803 should "not include the issue author if they are only notified of assigned issues" do | |
804 @author.update_attribute(:mail_notification, :only_assigned) | |
805 | |
806 assert !@issue.recipients.include?(@issue.author.mail) | |
807 end | |
808 | |
809 should "not include the assigned user if they are only notified of owned issues" do | |
810 @assignee.update_attribute(:mail_notification, :only_owner) | |
811 | |
812 assert !@issue.recipients.include?(@issue.assigned_to.mail) | |
813 end | |
814 | |
815 end | |
729 end | 816 end |