@@ -198,8 +198,7 class AttachmentTest < ActiveSupport::TestCase | |||
|
198 | 198 | assert a.readable? |
|
199 | 199 | end |
|
200 | 200 | |
|
201 |
|
|
|
202 | should "attach the file" do | |
|
201 | test "Attachmnet.attach_files should attach the file" do | |
|
203 | 202 |
|
|
204 | 203 |
|
|
205 | 204 |
|
@@ -219,7 +218,7 class AttachmentTest < ActiveSupport::TestCase | |||
|
219 | 218 |
|
|
220 | 219 |
|
|
221 | 220 | |
|
222 |
|
|
|
221 | test "Attachmnet.attach_files should add unsaved files to the object as unsaved attachments" do | |
|
223 | 222 |
|
|
224 | 223 |
|
|
225 | 224 |
|
@@ -235,7 +234,6 class AttachmentTest < ActiveSupport::TestCase | |||
|
235 | 234 |
|
|
236 | 235 |
|
|
237 | 236 |
|
|
238 | end | |
|
239 | 237 | |
|
240 | 238 | def test_latest_attach |
|
241 | 239 | set_fixtures_attachments_directory |
@@ -58,61 +58,48 class AuthSourceLdapTest < ActiveSupport::TestCase | |||
|
58 | 58 | end |
|
59 | 59 | |
|
60 | 60 | if ldap_configured? |
|
61 | context '#authenticate' do | |
|
62 | setup do | |
|
63 | @auth = AuthSourceLdap.find(1) | |
|
64 | @auth.update_attribute :onthefly_register, true | |
|
65 | end | |
|
61 | test '#authenticate with a valid LDAP user should return the user attributes' do | |
|
62 | auth = AuthSourceLdap.find(1) | |
|
63 | auth.update_attribute :onthefly_register, true | |
|
66 | 64 | |
|
67 | context 'with a valid LDAP user' do | |
|
68 | should 'return the user attributes' do | |
|
69 | attributes = @auth.authenticate('example1','123456') | |
|
65 | attributes = auth.authenticate('example1','123456') | |
|
70 | 66 |
|
|
71 | 67 |
|
|
72 | 68 |
|
|
73 | 69 |
|
|
74 |
|
|
|
70 | assert_equal auth.id, attributes[:auth_source_id] | |
|
75 | 71 |
|
|
76 | 72 |
|
|
77 | 73 |
|
|
78 | 74 |
|
|
79 | end | |
|
80 | 75 | |
|
81 |
|
|
|
82 | should 'return nil' do | |
|
83 |
|
|
|
84 | end | |
|
76 | test '#authenticate with an invalid LDAP user should return nil' do | |
|
77 | auth = AuthSourceLdap.find(1) | |
|
78 | assert_equal nil, auth.authenticate('nouser','123456') | |
|
85 | 79 |
|
|
86 | 80 | |
|
87 | context 'without a login' do | |
|
88 | should 'return nil' do | |
|
89 |
|
|
|
90 | end | |
|
81 | test '#authenticate without a login should return nil' do | |
|
82 | auth = AuthSourceLdap.find(1) | |
|
83 | assert_equal nil, auth.authenticate('','123456') | |
|
91 | 84 |
|
|
92 | 85 | |
|
93 |
|
|
|
94 | should 'return nil' do | |
|
95 |
|
|
|
96 | end | |
|
86 | test '#authenticate without a password should return nil' do | |
|
87 | auth = AuthSourceLdap.find(1) | |
|
88 | assert_equal nil, auth.authenticate('edavis','') | |
|
97 | 89 |
|
|
98 | 90 | |
|
99 | context 'without filter' do | |
|
100 | should 'return any user' do | |
|
101 |
|
|
|
102 |
|
|
|
103 | end | |
|
91 | test '#authenticate without filter should return any user' do | |
|
92 | auth = AuthSourceLdap.find(1) | |
|
93 | assert auth.authenticate('example1','123456') | |
|
94 | assert auth.authenticate('edavis', '123456') | |
|
104 | 95 |
|
|
105 | 96 | |
|
106 | context 'with filter' do | |
|
107 | setup do | |
|
108 |
|
|
|
109 | end | |
|
97 | test '#authenticate with filter should return user who matches the filter only' do | |
|
98 | auth = AuthSourceLdap.find(1) | |
|
99 | auth.filter = "(mail=*@redmine.org)" | |
|
110 | 100 | |
|
111 | should 'return user who matches the filter only' do | |
|
112 |
|
|
|
113 | assert_nil @auth.authenticate('edavis', '123456') | |
|
114 | end | |
|
115 | end | |
|
101 | assert auth.authenticate('example1','123456') | |
|
102 | assert_nil auth.authenticate('edavis', '123456') | |
|
116 | 103 | end |
|
117 | 104 | |
|
118 | 105 | def test_authenticate_should_timeout |
@@ -1129,49 +1129,44 class IssueTest < ActiveSupport::TestCase | |||
|
1129 | 1129 | assert_nil copy.custom_value_for(2) |
|
1130 | 1130 | end |
|
1131 | 1131 | |
|
1132 | context "#copy" do | |
|
1133 | setup do | |
|
1134 | @issue = Issue.find(1) | |
|
1135 | end | |
|
1136 | ||
|
1137 | should "not create a journal" do | |
|
1138 | copy = @issue.copy(:project_id => 3, :tracker_id => 2, :assigned_to_id => 3) | |
|
1132 | test "#copy should not create a journal" do | |
|
1133 | copy = Issue.find(1).copy(:project_id => 3, :tracker_id => 2, :assigned_to_id => 3) | |
|
1139 | 1134 |
|
|
1140 | 1135 |
|
|
1141 | 1136 |
|
|
1142 | 1137 | |
|
1143 |
|
|
|
1144 |
|
|
|
1138 | test "#copy should allow assigned_to changes" do | |
|
1139 | copy = Issue.find(1).copy(:project_id => 3, :tracker_id => 2, :assigned_to_id => 3) | |
|
1145 | 1140 |
|
|
1146 | 1141 |
|
|
1147 | 1142 | |
|
1148 |
|
|
|
1149 |
|
|
|
1143 | test "#copy should allow status changes" do | |
|
1144 | copy = Issue.find(1).copy(:project_id => 3, :tracker_id => 2, :status_id => 2) | |
|
1150 | 1145 |
|
|
1151 | 1146 |
|
|
1152 | 1147 | |
|
1153 |
|
|
|
1148 | test "#copy should allow start date changes" do | |
|
1154 | 1149 |
|
|
1155 |
|
|
|
1150 | copy = Issue.find(1).copy(:project_id => 3, :tracker_id => 2, :start_date => date) | |
|
1156 | 1151 |
|
|
1157 | 1152 |
|
|
1158 | 1153 | |
|
1159 |
|
|
|
1154 | test "#copy should allow due date changes" do | |
|
1160 | 1155 |
|
|
1161 |
|
|
|
1156 | copy = Issue.find(1).copy(:project_id => 3, :tracker_id => 2, :due_date => date) | |
|
1162 | 1157 |
|
|
1163 | 1158 |
|
|
1164 | 1159 | |
|
1165 |
|
|
|
1160 | test "#copy should set current user as author" do | |
|
1166 | 1161 |
|
|
1167 |
|
|
|
1162 | copy = Issue.find(1).copy(:project_id => 3, :tracker_id => 2) | |
|
1168 | 1163 |
|
|
1169 | 1164 |
|
|
1170 | 1165 | |
|
1171 |
|
|
|
1166 | test "#copy should create a journal with notes" do | |
|
1172 | 1167 |
|
|
1173 | 1168 |
|
|
1174 |
|
|
|
1169 | copy = Issue.find(1).copy(:project_id => 3, :tracker_id => 2, :start_date => date) | |
|
1175 | 1170 |
|
|
1176 | 1171 |
|
|
1177 | 1172 | |
@@ -1180,7 +1175,6 class IssueTest < ActiveSupport::TestCase | |||
|
1180 | 1175 |
|
|
1181 | 1176 |
|
|
1182 | 1177 |
|
|
1183 | end | |
|
1184 | 1178 | |
|
1185 | 1179 | def test_valid_parent_project |
|
1186 | 1180 | issue = Issue.find(1) |
@@ -1454,51 +1448,48 class IssueTest < ActiveSupport::TestCase | |||
|
1454 | 1448 | ).overdue? |
|
1455 | 1449 | end |
|
1456 | 1450 | |
|
1457 | context "#behind_schedule?" do | |
|
1458 | should "be false if the issue has no start_date" do | |
|
1451 | test "#behind_schedule? should be false if the issue has no start_date" do | |
|
1459 | 1452 |
|
|
1460 | 1453 |
|
|
1461 | 1454 |
|
|
1462 | 1455 |
|
|
1463 | 1456 | |
|
1464 |
|
|
|
1457 | test "#behind_schedule? should be false if the issue has no end_date" do | |
|
1465 | 1458 |
|
|
1466 | 1459 |
|
|
1467 | 1460 |
|
|
1468 | 1461 |
|
|
1469 | 1462 | |
|
1470 |
|
|
|
1463 | test "#behind_schedule? should be false if the issue has more done than it's calendar time" do | |
|
1471 | 1464 |
|
|
1472 | 1465 |
|
|
1473 | 1466 |
|
|
1474 | 1467 |
|
|
1475 | 1468 | |
|
1476 |
|
|
|
1469 | test "#behind_schedule? should be true if the issue hasn't been started at all" do | |
|
1477 | 1470 |
|
|
1478 | 1471 |
|
|
1479 | 1472 |
|
|
1480 | 1473 |
|
|
1481 | 1474 | |
|
1482 |
|
|
|
1475 | test "#behind_schedule? should be true if the issue has used more calendar time than it's done ratio" do | |
|
1483 | 1476 |
|
|
1484 | 1477 |
|
|
1485 | 1478 |
|
|
1486 | 1479 |
|
|
1487 | end | |
|
1488 | 1480 | |
|
1489 |
|
|
|
1490 | should "be Users" do | |
|
1481 | test "#assignable_users should be Users" do | |
|
1491 | 1482 |
|
|
1492 | 1483 |
|
|
1493 | 1484 | |
|
1494 |
|
|
|
1485 | test "#assignable_users should include the issue author" do | |
|
1495 | 1486 |
|
|
1496 | 1487 |
|
|
1497 | 1488 | |
|
1498 | 1489 |
|
|
1499 | 1490 |
|
|
1500 | 1491 | |
|
1501 |
|
|
|
1492 | test "#assignable_users should include the current assignee" do | |
|
1502 | 1493 |
|
|
1503 | 1494 |
|
|
1504 | 1495 |
|
@@ -1506,7 +1497,7 class IssueTest < ActiveSupport::TestCase | |||
|
1506 | 1497 |
|
|
1507 | 1498 |
|
|
1508 | 1499 | |
|
1509 |
|
|
|
1500 | test "#assignable_users should not show the issue author twice" do | |
|
1510 | 1501 |
|
|
1511 | 1502 |
|
|
1512 | 1503 | |
@@ -1516,8 +1507,7 class IssueTest < ActiveSupport::TestCase | |||
|
1516 | 1507 |
|
|
1517 | 1508 |
|
|
1518 | 1509 | |
|
1519 |
|
|
|
1520 | should "include groups" do | |
|
1510 | test "#assignable_users with issue_group_assignment should include groups" do | |
|
1521 | 1511 |
|
|
1522 | 1512 | |
|
1523 | 1513 |
|
@@ -1525,10 +1515,8 class IssueTest < ActiveSupport::TestCase | |||
|
1525 | 1515 |
|
|
1526 | 1516 |
|
|
1527 | 1517 |
|
|
1528 | end | |
|
1529 | 1518 | |
|
1530 |
|
|
|
1531 | should "not include groups" do | |
|
1519 | test "#assignable_users without issue_group_assignment should not include groups" do | |
|
1532 | 1520 |
|
|
1533 | 1521 | |
|
1534 | 1522 |
|
@@ -1536,8 +1524,6 class IssueTest < ActiveSupport::TestCase | |||
|
1536 | 1524 |
|
|
1537 | 1525 |
|
|
1538 | 1526 |
|
|
1539 | end | |
|
1540 | end | |
|
1541 | 1527 | |
|
1542 | 1528 | def test_create_should_send_email_notification |
|
1543 | 1529 | ActionMailer::Base.deliveries.clear |
@@ -1728,73 +1714,42 class IssueTest < ActiveSupport::TestCase | |||
|
1728 | 1714 | assert_equal [2, 3, 8], Issue.find(1).all_dependent_issues.collect(&:id).sort |
|
1729 | 1715 | end |
|
1730 | 1716 | |
|
1731 | context "#done_ratio" do | |
|
1732 | setup do | |
|
1717 | test "#done_ratio should use the issue_status according to Setting.issue_done_ratio" do | |
|
1733 | 1718 |
|
|
1734 | 1719 |
|
|
1735 | 1720 |
|
|
1736 | 1721 |
|
|
1737 | 1722 |
|
|
1738 | 1723 |
|
|
1739 | end | |
|
1740 | ||
|
1741 | teardown do | |
|
1742 | Setting.issue_done_ratio = 'issue_field' | |
|
1743 | end | |
|
1744 | ||
|
1745 | context "with Setting.issue_done_ratio using the issue_field" do | |
|
1746 | setup do | |
|
1747 | Setting.issue_done_ratio = 'issue_field' | |
|
1748 | end | |
|
1749 | 1724 | |
|
1750 | should "read the issue's field" do | |
|
1725 | with_settings :issue_done_ratio => 'issue_field' do | |
|
1751 | 1726 |
|
|
1752 | 1727 |
|
|
1753 | 1728 |
|
|
1754 | end | |
|
1755 | ||
|
1756 | context "with Setting.issue_done_ratio using the issue_status" do | |
|
1757 | setup do | |
|
1758 | Setting.issue_done_ratio = 'issue_status' | |
|
1759 | end | |
|
1760 | 1729 | |
|
1761 | should "read the Issue Status's default done ratio" do | |
|
1730 | with_settings :issue_done_ratio => 'issue_status' do | |
|
1762 | 1731 |
|
|
1763 | 1732 |
|
|
1764 | 1733 |
|
|
1765 | 1734 |
|
|
1766 | end | |
|
1767 | 1735 | |
|
1768 | context "#update_done_ratio_from_issue_status" do | |
|
1769 | setup do | |
|
1736 | test "#update_done_ratio_from_issue_status should update done_ratio according to Setting.issue_done_ratio" do | |
|
1770 | 1737 |
|
|
1771 | 1738 |
|
|
1772 | 1739 |
|
|
1773 | 1740 |
|
|
1774 | 1741 |
|
|
1775 | 1742 |
|
|
1776 | end | |
|
1777 | ||
|
1778 | context "with Setting.issue_done_ratio using the issue_field" do | |
|
1779 | setup do | |
|
1780 | Setting.issue_done_ratio = 'issue_field' | |
|
1781 | end | |
|
1782 | 1743 | |
|
1783 | should "not change the issue" do | |
|
1744 | with_settings :issue_done_ratio => 'issue_field' do | |
|
1784 | 1745 |
|
|
1785 | 1746 |
|
|
1786 | 1747 | |
|
1787 | 1748 |
|
|
1788 | 1749 |
|
|
1789 | 1750 |
|
|
1790 | end | |
|
1791 | ||
|
1792 | context "with Setting.issue_done_ratio using the issue_status" do | |
|
1793 | setup do | |
|
1794 | Setting.issue_done_ratio = 'issue_status' | |
|
1795 | end | |
|
1796 | 1751 | |
|
1797 | should "change the issue's done ratio" do | |
|
1752 | with_settings :issue_done_ratio => 'issue_status' do | |
|
1798 | 1753 |
|
|
1799 | 1754 |
|
|
1800 | 1755 | |
@@ -1802,7 +1757,6 class IssueTest < ActiveSupport::TestCase | |||
|
1802 | 1757 |
|
|
1803 | 1758 |
|
|
1804 | 1759 |
|
|
1805 | end | |
|
1806 | 1760 | |
|
1807 | 1761 | test "#by_tracker" do |
|
1808 | 1762 | User.current = User.anonymous |
@@ -1873,48 +1827,42 class IssueTest < ActiveSupport::TestCase | |||
|
1873 | 1827 | assert_equal before, Issue.on_active_project.length |
|
1874 | 1828 | end |
|
1875 | 1829 | |
|
1876 | context "Issue#recipients" do | |
|
1877 | setup do | |
|
1878 | @project = Project.find(1) | |
|
1879 | @author = User.generate! | |
|
1880 | @assignee = User.generate! | |
|
1881 | @issue = Issue.generate!(:project => @project, :assigned_to => @assignee, :author => @author) | |
|
1882 | end | |
|
1883 | ||
|
1884 | should "include project recipients" do | |
|
1885 | assert @project.recipients.present? | |
|
1886 | @project.recipients.each do |project_recipient| | |
|
1887 | assert @issue.recipients.include?(project_recipient) | |
|
1830 | test "Issue#recipients should include project recipients" do | |
|
1831 | issue = Issue.generate! | |
|
1832 | assert issue.project.recipients.present? | |
|
1833 | issue.project.recipients.each do |project_recipient| | |
|
1834 | assert issue.recipients.include?(project_recipient) | |
|
1888 | 1835 |
|
|
1889 | 1836 |
|
|
1890 | 1837 | |
|
1891 |
|
|
|
1892 | assert @issue.author, "No author set for Issue" | |
|
1893 | assert @issue.recipients.include?(@issue.author.mail) | |
|
1838 | test "Issue#recipients should include the author if the author is active" do | |
|
1839 | issue = Issue.generate!(:author => User.generate!) | |
|
1840 | assert issue.author, "No author set for Issue" | |
|
1841 | assert issue.recipients.include?(issue.author.mail) | |
|
1894 | 1842 |
|
|
1895 | 1843 | |
|
1896 |
|
|
|
1897 | assert @issue.assigned_to, "No assigned_to set for Issue" | |
|
1898 | assert @issue.recipients.include?(@issue.assigned_to.mail) | |
|
1844 | test "Issue#recipients should include the assigned to user if the assigned to user is active" do | |
|
1845 | issue = Issue.generate!(:assigned_to => User.generate!) | |
|
1846 | assert issue.assigned_to, "No assigned_to set for Issue" | |
|
1847 | assert issue.recipients.include?(issue.assigned_to.mail) | |
|
1899 | 1848 |
|
|
1900 | 1849 | |
|
1901 |
|
|
|
1902 | @author.update_attribute(:mail_notification, :none) | |
|
1903 | ||
|
1904 |
|
|
|
1850 | test "Issue#recipients should not include users who opt out of all email" do | |
|
1851 | issue = Issue.generate!(:author => User.generate!) | |
|
1852 | issue.author.update_attribute(:mail_notification, :none) | |
|
1853 | assert !issue.recipients.include?(issue.author.mail) | |
|
1905 | 1854 |
|
|
1906 | 1855 | |
|
1907 |
|
|
|
1908 | @author.update_attribute(:mail_notification, :only_assigned) | |
|
1909 | ||
|
1910 |
|
|
|
1856 | test "Issue#recipients should not include the issue author if they are only notified of assigned issues" do | |
|
1857 | issue = Issue.generate!(:author => User.generate!) | |
|
1858 | issue.author.update_attribute(:mail_notification, :only_assigned) | |
|
1859 | assert !issue.recipients.include?(issue.author.mail) | |
|
1911 | 1860 |
|
|
1912 | 1861 | |
|
1913 |
|
|
|
1914 | @assignee.update_attribute(:mail_notification, :only_owner) | |
|
1915 | ||
|
1916 |
|
|
|
1917 | end | |
|
1862 | test "Issue#recipients should not include the assigned user if they are only notified of owned issues" do | |
|
1863 | issue = Issue.generate!(:assigned_to => User.generate!) | |
|
1864 | issue.assigned_to.update_attribute(:mail_notification, :only_owner) | |
|
1865 | assert !issue.recipients.include?(issue.assigned_to.mail) | |
|
1918 | 1866 | end |
|
1919 | 1867 | |
|
1920 | 1868 | def test_last_journal_id_with_journals_should_return_the_journal_id |
@@ -646,13 +646,8 class MailHandlerTest < ActiveSupport::TestCase | |||
|
646 | 646 | assert_equal 'This is a html-only email.', issue.description |
|
647 | 647 | end |
|
648 | 648 | |
|
649 | context "truncate emails based on the Setting" do | |
|
650 | context "with no setting" do | |
|
651 | setup do | |
|
652 | Setting.mail_handler_body_delimiters = '' | |
|
653 | end | |
|
654 | ||
|
655 | should "add the entire email into the issue" do | |
|
649 | test "truncate emails with no setting should add the entire email into the issue" do | |
|
650 | with_settings :mail_handler_body_delimiters => '' do | |
|
656 | 651 |
|
|
657 | 652 |
|
|
658 | 653 |
|
@@ -660,11 +655,8 class MailHandlerTest < ActiveSupport::TestCase | |||
|
660 | 655 |
|
|
661 | 656 |
|
|
662 | 657 | |
|
663 | context "with a single string" do | |
|
664 | setup do | |
|
665 | Setting.mail_handler_body_delimiters = '---' | |
|
666 | end | |
|
667 | should "truncate the email at the delimiter for the issue" do | |
|
658 | test "truncate emails with a single string should truncate the email at the delimiter for the issue" do | |
|
659 | with_settings :mail_handler_body_delimiters => '---' do | |
|
668 | 660 |
|
|
669 | 661 |
|
|
670 | 662 |
|
@@ -674,11 +666,8 class MailHandlerTest < ActiveSupport::TestCase | |||
|
674 | 666 |
|
|
675 | 667 |
|
|
676 | 668 | |
|
677 | context "with a single quoted reply (e.g. reply to a Redmine email notification)" do | |
|
678 | setup do | |
|
679 | Setting.mail_handler_body_delimiters = '--- Reply above. Do not remove this line. ---' | |
|
680 | end | |
|
681 | should "truncate the email at the delimiter with the quoted reply symbols (>)" do | |
|
669 | test "truncate emails with a single quoted reply should truncate the email at the delimiter with the quoted reply symbols (>)" do | |
|
670 | with_settings :mail_handler_body_delimiters => '--- Reply above. Do not remove this line. ---' do | |
|
682 | 671 |
|
|
683 | 672 |
|
|
684 | 673 |
|
@@ -687,11 +676,8 class MailHandlerTest < ActiveSupport::TestCase | |||
|
687 | 676 |
|
|
688 | 677 |
|
|
689 | 678 | |
|
690 | context "with multiple quoted replies (e.g. reply to a reply of a Redmine email notification)" do | |
|
691 | setup do | |
|
692 | Setting.mail_handler_body_delimiters = '--- Reply above. Do not remove this line. ---' | |
|
693 | end | |
|
694 | should "truncate the email at the delimiter with the quoted reply symbols (>)" do | |
|
679 | test "truncate emails with multiple quoted replies should truncate the email at the delimiter with the quoted reply symbols (>)" do | |
|
680 | with_settings :mail_handler_body_delimiters => '--- Reply above. Do not remove this line. ---' do | |
|
695 | 681 |
|
|
696 | 682 |
|
|
697 | 683 |
|
@@ -700,11 +686,8 class MailHandlerTest < ActiveSupport::TestCase | |||
|
700 | 686 |
|
|
701 | 687 |
|
|
702 | 688 | |
|
703 | context "with multiple strings" do | |
|
704 | setup do | |
|
705 | Setting.mail_handler_body_delimiters = "---\nBREAK" | |
|
706 | end | |
|
707 | should "truncate the email at the first delimiter found (BREAK)" do | |
|
689 | test "truncate emails with multiple strings should truncate the email at the first delimiter found (BREAK)" do | |
|
690 | with_settings :mail_handler_body_delimiters => "---\nBREAK" do | |
|
708 | 691 |
|
|
709 | 692 |
|
|
710 | 693 |
|
@@ -714,7 +697,6 class MailHandlerTest < ActiveSupport::TestCase | |||
|
714 | 697 |
|
|
715 | 698 |
|
|
716 | 699 |
|
|
717 | end | |
|
718 | 700 | |
|
719 | 701 | def test_email_with_long_subject_line |
|
720 | 702 | issue = submit_email('ticket_with_long_subject.eml') |
@@ -279,25 +279,21 class MailerTest < ActiveSupport::TestCase | |||
|
279 | 279 | end |
|
280 | 280 | end |
|
281 | 281 | |
|
282 | context("#issue_add") do | |
|
283 | setup do | |
|
284 | ActionMailer::Base.deliveries.clear | |
|
285 | Setting.bcc_recipients = '1' | |
|
286 | @issue = Issue.find(1) | |
|
287 | end | |
|
288 | ||
|
289 | should "notify project members" do | |
|
290 | assert Mailer.issue_add(@issue).deliver | |
|
282 | test "#issue_add should notify project members" do | |
|
283 | issue = Issue.find(1) | |
|
284 | assert Mailer.issue_add(issue).deliver | |
|
291 | 285 |
|
|
292 | 286 |
|
|
293 | 287 | |
|
294 |
|
|
|
288 | test "#issue_add should not notify project members that are not allow to view the issue" do | |
|
289 | issue = Issue.find(1) | |
|
295 | 290 |
|
|
296 |
|
|
|
291 | assert Mailer.issue_add(issue).deliver | |
|
297 | 292 |
|
|
298 | 293 |
|
|
299 | 294 | |
|
300 |
|
|
|
295 | test "#issue_add should notify issue watchers" do | |
|
296 | issue = Issue.find(1) | |
|
301 | 297 |
|
|
302 | 298 |
|
|
303 | 299 |
|
@@ -305,19 +301,19 class MailerTest < ActiveSupport::TestCase | |||
|
305 | 301 |
|
|
306 | 302 |
|
|
307 | 303 | |
|
308 |
|
|
|
309 |
|
|
|
304 | Watcher.create!(:watchable => issue, :user => user) | |
|
305 | assert Mailer.issue_add(issue).deliver | |
|
310 | 306 |
|
|
311 | 307 |
|
|
312 | 308 | |
|
313 |
|
|
|
309 | test "#issue_add should not notify watchers not allowed to view the issue" do | |
|
310 | issue = Issue.find(1) | |
|
314 | 311 |
|
|
315 |
|
|
|
312 | Watcher.create!(:watchable => issue, :user => user) | |
|
316 | 313 |
|
|
317 |
|
|
|
314 | assert Mailer.issue_add(issue).deliver | |
|
318 | 315 |
|
|
319 | 316 |
|
|
320 | end | |
|
321 | 317 | |
|
322 | 318 | # test mailer methods for each language |
|
323 | 319 | def test_issue_add |
@@ -63,64 +63,46 class PrincipalTest < ActiveSupport::TestCase | |||
|
63 | 63 | assert_equal expected_order.map(&:name).map(&:downcase), scope.sorted.all.map(&:name).map(&:downcase) |
|
64 | 64 | end |
|
65 | 65 | |
|
66 | context "#like" do | |
|
67 | setup do | |
|
68 | Principal.create!(:login => 'login') | |
|
69 | Principal.create!(:login => 'login2') | |
|
66 | test "like scope should search login" do | |
|
67 | results = Principal.like('jsmi') | |
|
70 | 68 | |
|
71 | Principal.create!(:firstname => 'firstname') | |
|
72 | Principal.create!(:firstname => 'firstname2') | |
|
73 | ||
|
74 | Principal.create!(:lastname => 'lastname') | |
|
75 | Principal.create!(:lastname => 'lastname2') | |
|
76 | ||
|
77 | Principal.create!(:mail => 'mail@example.com') | |
|
78 | Principal.create!(:mail => 'mail2@example.com') | |
|
79 | ||
|
80 | @palmer = Principal.create!(:firstname => 'David', :lastname => 'Palmer') | |
|
69 | assert results.any? | |
|
70 | assert results.all? {|u| u.login.match(/jsmi/i) } | |
|
81 | 71 |
|
|
82 | 72 | |
|
83 |
|
|
|
84 |
|
|
|
73 | test "like scope should search firstname" do | |
|
74 | results = Principal.like('john') | |
|
85 | 75 | |
|
86 |
|
|
|
87 |
|
|
|
76 | assert results.any? | |
|
77 | assert results.all? {|u| u.firstname.match(/john/i) } | |
|
88 | 78 |
|
|
89 | 79 | |
|
90 |
|
|
|
91 |
|
|
|
80 | test "like scope should search lastname" do | |
|
81 | results = Principal.like('smi') | |
|
92 | 82 | |
|
93 |
|
|
|
94 |
|
|
|
83 | assert results.any? | |
|
84 | assert results.all? {|u| u.lastname.match(/smi/i) } | |
|
95 | 85 |
|
|
96 | 86 | |
|
97 |
|
|
|
98 |
|
|
|
87 | test "like scope should search mail" do | |
|
88 | results = Principal.like('somenet') | |
|
99 | 89 | |
|
100 |
|
|
|
101 |
|
|
|
90 | assert results.any? | |
|
91 | assert results.all? {|u| u.mail.match(/somenet/i) } | |
|
102 | 92 |
|
|
103 | 93 | |
|
104 | should "search mail" do | |
|
105 |
|
|
|
106 | ||
|
107 | assert_equal 2, results.count | |
|
108 | assert results.all? {|u| u.mail.match(/mail/) } | |
|
109 | end | |
|
110 | ||
|
111 | should "search firstname and lastname" do | |
|
112 | results = Principal.like('david palm') | |
|
94 | test "like scope should search firstname and lastname" do | |
|
95 | results = Principal.like('john smi') | |
|
113 | 96 | |
|
114 | 97 |
|
|
115 |
|
|
|
98 | assert_equal User.find(2), results.first | |
|
116 | 99 |
|
|
117 | 100 | |
|
118 |
|
|
|
119 |
|
|
|
101 | test "like scope should search lastname and firstname" do | |
|
102 | results = Principal.like('smith joh') | |
|
120 | 103 | |
|
121 | 104 |
|
|
122 |
|
|
|
123 | end | |
|
105 | assert_equal User.find(2), results.first | |
|
124 | 106 | end |
|
125 | 107 | |
|
126 | 108 | def test_like_scope_with_cyrillic_name |
@@ -435,56 +435,54 class ProjectTest < ActiveSupport::TestCase | |||
|
435 | 435 | assert_equal [1,2], parent.rolled_up_trackers.collect(&:id) |
|
436 | 436 | end |
|
437 | 437 | |
|
438 | context "#rolled_up_versions" do | |
|
439 | setup do | |
|
440 | @project = Project.generate! | |
|
441 |
|
|
|
442 | @parent_version_2 = Version.generate!(:project => @project) | |
|
443 | end | |
|
444 | ||
|
445 | should "include the versions for the current project" do | |
|
446 | assert_same_elements [@parent_version_1, @parent_version_2], @project.rolled_up_versions | |
|
438 | test "#rolled_up_versions should include the versions for the current project" do | |
|
439 | project = Project.generate! | |
|
440 | parent_version_1 = Version.generate!(:project => project) | |
|
441 | parent_version_2 = Version.generate!(:project => project) | |
|
442 | assert_same_elements [parent_version_1, parent_version_2], project.rolled_up_versions | |
|
447 | 443 |
|
|
448 | 444 | |
|
449 |
|
|
|
450 |
|
|
|
451 | @subproject.set_parent!(@project) | |
|
452 |
|
|
|
445 | test "#rolled_up_versions should include versions for a subproject" do | |
|
446 | project = Project.generate! | |
|
447 | parent_version_1 = Version.generate!(:project => project) | |
|
448 | parent_version_2 = Version.generate!(:project => project) | |
|
449 | subproject = Project.generate_with_parent!(project) | |
|
450 | subproject_version = Version.generate!(:project => subproject) | |
|
453 | 451 | |
|
454 | 452 |
|
|
455 |
|
|
|
456 |
|
|
|
457 |
|
|
|
458 |
|
|
|
459 |
|
|
|
460 | ||
|
461 |
|
|
|
462 |
|
|
|
463 | @subproject.set_parent!(@project) | |
|
464 | @sub_subproject = Project.generate! | |
|
465 |
|
|
|
466 |
|
|
|
467 | ||
|
468 |
|
|
|
453 | parent_version_1, | |
|
454 | parent_version_2, | |
|
455 | subproject_version | |
|
456 | ], project.rolled_up_versions | |
|
457 | end | |
|
458 | ||
|
459 | test "#rolled_up_versions should include versions for a sub-subproject" do | |
|
460 | project = Project.generate! | |
|
461 | parent_version_1 = Version.generate!(:project => project) | |
|
462 | parent_version_2 = Version.generate!(:project => project) | |
|
463 | subproject = Project.generate_with_parent!(project) | |
|
464 | sub_subproject = Project.generate_with_parent!(subproject) | |
|
465 | sub_subproject_version = Version.generate!(:project => sub_subproject) | |
|
466 | project.reload | |
|
469 | 467 | |
|
470 | 468 |
|
|
471 |
|
|
|
472 |
|
|
|
473 |
|
|
|
474 |
|
|
|
475 |
|
|
|
476 | ||
|
477 |
|
|
|
478 |
|
|
|
479 | @subproject.set_parent!(@project) | |
|
480 |
|
|
|
481 | assert @subproject.archive | |
|
482 | ||
|
483 |
|
|
|
469 | parent_version_1, | |
|
470 | parent_version_2, | |
|
471 | sub_subproject_version | |
|
472 | ], project.rolled_up_versions | |
|
473 | end | |
|
474 | ||
|
475 | test "#rolled_up_versions should only check active projects" do | |
|
476 | project = Project.generate! | |
|
477 | parent_version_1 = Version.generate!(:project => project) | |
|
478 | parent_version_2 = Version.generate!(:project => project) | |
|
479 | subproject = Project.generate_with_parent!(project) | |
|
480 | subproject_version = Version.generate!(:project => subproject) | |
|
481 | assert subproject.archive | |
|
482 | project.reload | |
|
484 | 483 | |
|
485 |
|
|
|
486 |
|
|
|
487 | end | |
|
484 | assert !subproject.active? | |
|
485 | assert_same_elements [parent_version_1, parent_version_2], project.rolled_up_versions | |
|
488 | 486 | end |
|
489 | 487 | |
|
490 | 488 | def test_shared_versions_none_sharing |
@@ -611,12 +609,8 class ProjectTest < ActiveSupport::TestCase | |||
|
611 | 609 | end |
|
612 | 610 | end |
|
613 | 611 | |
|
614 | context "enabled_modules" do | |
|
615 | setup do | |
|
612 | test "enabled_modules should define module by names and preserve ids" do | |
|
616 | 613 |
|
|
617 | end | |
|
618 | ||
|
619 | should "define module by names and preserve ids" do | |
|
620 | 614 |
|
|
621 | 615 |
|
|
622 | 616 |
|
@@ -628,7 +622,8 class ProjectTest < ActiveSupport::TestCase | |||
|
628 | 622 |
|
|
629 | 623 |
|
|
630 | 624 | |
|
631 |
|
|
|
625 | test "enabled_modules should enable a module" do | |
|
626 | @project = Project.find(1) | |
|
632 | 627 |
|
|
633 | 628 |
|
|
634 | 629 |
|
@@ -643,7 +638,8 class ProjectTest < ActiveSupport::TestCase | |||
|
643 | 638 |
|
|
644 | 639 |
|
|
645 | 640 | |
|
646 |
|
|
|
641 | test "enabled_modules should disable a module" do | |
|
642 | @project = Project.find(1) | |
|
647 | 643 |
|
|
648 | 644 |
|
|
649 | 645 |
|
@@ -657,7 +653,6 class ProjectTest < ActiveSupport::TestCase | |||
|
657 | 653 |
|
|
658 | 654 |
|
|
659 | 655 |
|
|
660 | end | |
|
661 | 656 | |
|
662 | 657 | def test_enabled_module_names_should_not_recreate_enabled_modules |
|
663 | 658 | project = Project.find(1) |
General Comments 0
You need to be logged in to leave comments.
Login now