##// END OF EJS Templates
Merged r10688 from trunk to 2.1-stable...
Toshi MARUYAMA -
r10479:b7e999d1aa84
parent child
Show More
@@ -1,223 +1,225
1 1 # Redmine - project management software
2 2 # Copyright (C) 2006-2012 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 include CustomFieldsHelper
24 24 include ERB::Util
25 25
26 26 fixtures :projects, :trackers, :issue_statuses, :issues,
27 27 :enumerations, :users, :issue_categories,
28 28 :projects_trackers,
29 29 :roles,
30 30 :member_roles,
31 31 :members,
32 32 :enabled_modules,
33 33 :workflows,
34 34 :custom_fields,
35 35 :attachments,
36 36 :versions
37 37
38 38 def setup
39 39 super
40 40 set_language_if_valid('en')
41 41 User.current = nil
42 42 end
43 43
44 44 def test_issue_heading
45 45 assert_equal "Bug #1", issue_heading(Issue.find(1))
46 46 end
47 47
48 48 def test_issues_destroy_confirmation_message_with_one_root_issue
49 49 assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find(1))
50 50 end
51 51
52 52 def test_issues_destroy_confirmation_message_with_an_arrayt_of_root_issues
53 53 assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find([1, 2]))
54 54 end
55 55
56 56 def test_issues_destroy_confirmation_message_with_one_parent_issue
57 57 Issue.find(2).update_attribute :parent_issue_id, 1
58 58 assert_equal l(:text_issues_destroy_confirmation) + "\n" + l(:text_issues_destroy_descendants_confirmation, :count => 1),
59 59 issues_destroy_confirmation_message(Issue.find(1))
60 60 end
61 61
62 62 def test_issues_destroy_confirmation_message_with_one_parent_issue_and_its_child
63 63 Issue.find(2).update_attribute :parent_issue_id, 1
64 64 assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find([1, 2]))
65 65 end
66 66
67 67 context "IssuesHelper#show_detail" do
68 68 context "with no_html" do
69 69 should 'show a changing attribute' do
70 70 @detail = JournalDetail.new(:property => 'attr', :old_value => '40', :value => '100', :prop_key => 'done_ratio')
71 71 assert_equal "% Done changed from 40 to 100", show_detail(@detail, true)
72 72 end
73 73
74 74 should 'show a new attribute' do
75 75 @detail = JournalDetail.new(:property => 'attr', :old_value => nil, :value => '100', :prop_key => 'done_ratio')
76 76 assert_equal "% Done set to 100", show_detail(@detail, true)
77 77 end
78 78
79 79 should 'show a deleted attribute' do
80 80 @detail = JournalDetail.new(:property => 'attr', :old_value => '50', :value => nil, :prop_key => 'done_ratio')
81 81 assert_equal "% Done deleted (50)", show_detail(@detail, true)
82 82 end
83 83 end
84 84
85 85 context "with html" do
86 86 should 'show a changing attribute with HTML highlights' do
87 87 @detail = JournalDetail.new(:property => 'attr', :old_value => '40', :value => '100', :prop_key => 'done_ratio')
88 88 html = show_detail(@detail, false)
89 89
90 90 assert_include '<strong>% Done</strong>', html
91 91 assert_include '<i>40</i>', html
92 92 assert_include '<i>100</i>', html
93 93 end
94 94
95 95 should 'show a new attribute with HTML highlights' do
96 96 @detail = JournalDetail.new(:property => 'attr', :old_value => nil, :value => '100', :prop_key => 'done_ratio')
97 97 html = show_detail(@detail, false)
98 98
99 99 assert_include '<strong>% Done</strong>', html
100 100 assert_include '<i>100</i>', html
101 101 end
102 102
103 103 should 'show a deleted attribute with HTML highlights' do
104 104 @detail = JournalDetail.new(:property => 'attr', :old_value => '50', :value => nil, :prop_key => 'done_ratio')
105 105 html = show_detail(@detail, false)
106 106
107 107 assert_include '<strong>% Done</strong>', html
108 108 assert_include '<del><i>50</i></del>', html
109 109 end
110 110 end
111 111
112 def test_with_a_start_date_attribute_should_format_the_current_date
113 @detail = JournalDetail.new(
112 context "with a start_date attribute" do
113 should "format the current date" do
114 @detail = JournalDetail.new(
114 115 :property => 'attr',
115 116 :old_value => '2010-01-01',
116 117 :value => '2010-01-31',
117 118 :prop_key => 'start_date'
118 119 )
119 with_settings :date_format => '%m/%d/%Y' do
120 assert_match "01/31/2010", show_detail(@detail, true)
120 with_settings :date_format => '%m/%d/%Y' do
121 assert_match "01/31/2010", show_detail(@detail, true)
122 end
121 123 end
122 end
123 124
124 def test_with_a_start_date_attribute_should_format_the_old_date
125 @detail = JournalDetail.new(
125 should "format the old date" do
126 @detail = JournalDetail.new(
126 127 :property => 'attr',
127 128 :old_value => '2010-01-01',
128 129 :value => '2010-01-31',
129 130 :prop_key => 'start_date'
130 131 )
131 with_settings :date_format => '%m/%d/%Y' do
132 assert_match "01/01/2010", show_detail(@detail, true)
132 with_settings :date_format => '%m/%d/%Y' do
133 assert_match "01/01/2010", show_detail(@detail, true)
134 end
133 135 end
134 136 end
135 137
136 138 def test_with_a_due_date_attribute_should_with_a_due_date_attribute
137 139 @detail = JournalDetail.new(
138 140 :property => 'attr',
139 141 :old_value => '2010-01-01',
140 142 :value => '2010-01-31',
141 143 :prop_key => 'due_date'
142 144 )
143 145 with_settings :date_format => '%m/%d/%Y' do
144 146 assert_match "01/31/2010", show_detail(@detail, true)
145 147 end
146 148 end
147 149
148 150 def test_with_a_due_date_attribute_should_format_the_old_date
149 151 @detail = JournalDetail.new(
150 152 :property => 'attr',
151 153 :old_value => '2010-01-01',
152 154 :value => '2010-01-31',
153 155 :prop_key => 'due_date'
154 156 )
155 157 with_settings :date_format => '%m/%d/%Y' do
156 158 assert_match "01/01/2010", show_detail(@detail, true)
157 159 end
158 160 end
159 161
160 162 should "show old and new values with a project attribute" do
161 163 detail = JournalDetail.new(:property => 'attr', :prop_key => 'project_id', :old_value => 1, :value => 2)
162 164 assert_match 'eCookbook', show_detail(detail, true)
163 165 assert_match 'OnlineStore', show_detail(detail, true)
164 166 end
165 167
166 168 should "show old and new values with a issue status attribute" do
167 169 detail = JournalDetail.new(:property => 'attr', :prop_key => 'status_id', :old_value => 1, :value => 2)
168 170 assert_match 'New', show_detail(detail, true)
169 171 assert_match 'Assigned', show_detail(detail, true)
170 172 end
171 173
172 174 should "show old and new values with a tracker attribute" do
173 175 detail = JournalDetail.new(:property => 'attr', :prop_key => 'tracker_id', :old_value => 1, :value => 2)
174 176 assert_match 'Bug', show_detail(detail, true)
175 177 assert_match 'Feature request', show_detail(detail, true)
176 178 end
177 179
178 180 should "show old and new values with a assigned to attribute" do
179 181 detail = JournalDetail.new(:property => 'attr', :prop_key => 'assigned_to_id', :old_value => 1, :value => 2)
180 182 assert_match 'redMine Admin', show_detail(detail, true)
181 183 assert_match 'John Smith', show_detail(detail, true)
182 184 end
183 185
184 186 should "show old and new values with a priority attribute" do
185 187 detail = JournalDetail.new(:property => 'attr', :prop_key => 'priority_id', :old_value => 4, :value => 5)
186 188 assert_match 'Low', show_detail(detail, true)
187 189 assert_match 'Normal', show_detail(detail, true)
188 190 end
189 191
190 192 should "show old and new values with a category attribute" do
191 193 detail = JournalDetail.new(:property => 'attr', :prop_key => 'category_id', :old_value => 1, :value => 2)
192 194 assert_match 'Printing', show_detail(detail, true)
193 195 assert_match 'Recipes', show_detail(detail, true)
194 196 end
195 197
196 198 should "show old and new values with a fixed version attribute" do
197 199 detail = JournalDetail.new(:property => 'attr', :prop_key => 'fixed_version_id', :old_value => 1, :value => 2)
198 200 assert_match '0.1', show_detail(detail, true)
199 201 assert_match '1.0', show_detail(detail, true)
200 202 end
201 203
202 204 should "show old and new values with a estimated hours attribute" do
203 205 detail = JournalDetail.new(:property => 'attr', :prop_key => 'estimated_hours', :old_value => '5', :value => '6.3')
204 206 assert_match '5.00', show_detail(detail, true)
205 207 assert_match '6.30', show_detail(detail, true)
206 208 end
207 209
208 210 should "show old and new values with a custom field" do
209 211 detail = JournalDetail.new(:property => 'cf', :prop_key => '1', :old_value => 'MySQL', :value => 'PostgreSQL')
210 212 assert_equal 'Database changed from MySQL to PostgreSQL', show_detail(detail, true)
211 213 end
212 214
213 215 should "show added file" do
214 216 detail = JournalDetail.new(:property => 'attachment', :prop_key => '1', :old_value => nil, :value => 'error281.txt')
215 217 assert_match 'error281.txt', show_detail(detail, true)
216 218 end
217 219
218 220 should "show removed file" do
219 221 detail = JournalDetail.new(:property => 'attachment', :prop_key => '1', :old_value => 'error281.txt', :value => nil)
220 222 assert_match 'error281.txt', show_detail(detail, true)
221 223 end
222 224 end
223 225 end
General Comments 0
You need to be logged in to leave comments. Login now