##// END OF EJS Templates
Code cleanup....
Jean-Philippe Lang -
r8159:914f9b603ef6
parent child
Show More
@@ -1,171 +1,170
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 require File.expand_path('../../../test_helper', __FILE__)
19 19
20 20 class IssuesHelperTest < ActionView::TestCase
21 21 include ApplicationHelper
22 22 include IssuesHelper
23 23
24 include ActionController::Assertions::SelectorAssertions
25 24 fixtures :projects, :trackers, :issue_statuses, :issues,
26 25 :enumerations, :users, :issue_categories,
27 26 :projects_trackers,
28 27 :roles,
29 28 :member_roles,
30 29 :members,
31 30 :enabled_modules,
32 31 :workflows
33 32
34 33 def setup
35 34 super
36 35 set_language_if_valid('en')
37 36 User.current = nil
38 37 end
39 38
40 39 def test_issue_heading
41 40 assert_equal "Bug #1", issue_heading(Issue.find(1))
42 41 end
43 42
44 43 def test_issues_destroy_confirmation_message_with_one_root_issue
45 44 assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find(1))
46 45 end
47 46
48 47 def test_issues_destroy_confirmation_message_with_an_arrayt_of_root_issues
49 48 assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find([1, 2]))
50 49 end
51 50
52 51 def test_issues_destroy_confirmation_message_with_one_parent_issue
53 52 Issue.find(2).update_attribute :parent_issue_id, 1
54 53 assert_equal l(:text_issues_destroy_confirmation) + "\n" + l(:text_issues_destroy_descendants_confirmation, :count => 1),
55 54 issues_destroy_confirmation_message(Issue.find(1))
56 55 end
57 56
58 57 def test_issues_destroy_confirmation_message_with_one_parent_issue_and_its_child
59 58 Issue.find(2).update_attribute :parent_issue_id, 1
60 59 assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find([1, 2]))
61 60 end
62 61
63 62 context "IssuesHelper#show_detail" do
64 63 context "with no_html" do
65 64 should 'show a changing attribute' do
66 65 @detail = JournalDetail.generate!(:property => 'attr', :old_value => '40', :value => '100', :prop_key => 'done_ratio')
67 66 assert_equal "% Done changed from 40 to 100", show_detail(@detail, true)
68 67 end
69 68
70 69 should 'show a new attribute' do
71 70 @detail = JournalDetail.generate!(:property => 'attr', :old_value => nil, :value => '100', :prop_key => 'done_ratio')
72 71 assert_equal "% Done set to 100", show_detail(@detail, true)
73 72 end
74 73
75 74 should 'show a deleted attribute' do
76 75 @detail = JournalDetail.generate!(:property => 'attr', :old_value => '50', :value => nil, :prop_key => 'done_ratio')
77 76 assert_equal "% Done deleted (50)", show_detail(@detail, true)
78 77 end
79 78 end
80 79
81 80 context "with html" do
82 81 should 'show a changing attribute with HTML highlights' do
83 82 @detail = JournalDetail.generate!(:property => 'attr', :old_value => '40', :value => '100', :prop_key => 'done_ratio')
84 83 html = show_detail(@detail, false)
85 84
86 85 assert_include '<strong>% Done</strong>', html
87 86 assert_include '<i>40</i>', html
88 87 assert_include '<i>100</i>', html
89 88 end
90 89
91 90 should 'show a new attribute with HTML highlights' do
92 91 @detail = JournalDetail.generate!(:property => 'attr', :old_value => nil, :value => '100', :prop_key => 'done_ratio')
93 92 html = show_detail(@detail, false)
94 93
95 94 assert_include '<strong>% Done</strong>', html
96 95 assert_include '<i>100</i>', html
97 96 end
98 97
99 98 should 'show a deleted attribute with HTML highlights' do
100 99 @detail = JournalDetail.generate!(:property => 'attr', :old_value => '50', :value => nil, :prop_key => 'done_ratio')
101 100 html = show_detail(@detail, false)
102 101
103 102 assert_include '<strong>% Done</strong>', html
104 103 assert_include '<strike><i>50</i></strike>', html
105 104 end
106 105 end
107 106
108 107 context "with a start_date attribute" do
109 108 should "format the current date" do
110 109 @detail = JournalDetail.generate!(:property => 'attr', :old_value => '2010-01-01', :value => '2010-01-31', :prop_key => 'start_date')
111 110 assert_match "01/31/2010", show_detail(@detail, true)
112 111 end
113 112
114 113 should "format the old date" do
115 114 @detail = JournalDetail.generate!(:property => 'attr', :old_value => '2010-01-01', :value => '2010-01-31', :prop_key => 'start_date')
116 115 assert_match "01/01/2010", show_detail(@detail, true)
117 116 end
118 117 end
119 118
120 119 context "with a due_date attribute" do
121 120 should "format the current date" do
122 121 @detail = JournalDetail.generate!(:property => 'attr', :old_value => '2010-01-01', :value => '2010-01-31', :prop_key => 'due_date')
123 122 assert_match "01/31/2010", show_detail(@detail, true)
124 123 end
125 124
126 125 should "format the old date" do
127 126 @detail = JournalDetail.generate!(:property => 'attr', :old_value => '2010-01-01', :value => '2010-01-31', :prop_key => 'due_date')
128 127 assert_match "01/01/2010", show_detail(@detail, true)
129 128 end
130 129 end
131 130
132 131 context "with a project attribute" do
133 132 should_show_the_old_and_new_values_for('project_id', Project)
134 133 end
135 134
136 135 context "with a issue status attribute" do
137 136 should_show_the_old_and_new_values_for('status_id', IssueStatus)
138 137 end
139 138
140 139 context "with a tracker attribute" do
141 140 should_show_the_old_and_new_values_for('tracker_id', Tracker)
142 141 end
143 142
144 143 context "with a assigned to attribute" do
145 144 should_show_the_old_and_new_values_for('assigned_to_id', User)
146 145 end
147 146
148 147 context "with a priority attribute" do
149 148 should_show_the_old_and_new_values_for('priority_id', IssuePriority) do
150 149 @old_value = IssuePriority.generate!(:type => 'IssuePriority')
151 150 @new_value = IssuePriority.generate!(:type => 'IssuePriority')
152 151 end
153 152 end
154 153
155 154 context "with a category attribute" do
156 155 should_show_the_old_and_new_values_for('category_id', IssueCategory)
157 156 end
158 157
159 158 context "with a fixed version attribute" do
160 159 should_show_the_old_and_new_values_for('fixed_version_id', Version)
161 160 end
162 161
163 162 context "with a estimated hours attribute" do
164 163 should "format the time into two decimal places"
165 164 should "format the old time into two decimal places"
166 165 end
167 166
168 167 should "test custom fields"
169 168 should "test attachments"
170 169 end
171 170 end
General Comments 0
You need to be logged in to leave comments. Login now