comparison .svn/pristine/bf/bf2ac6b68f1bf52b38aa5edf740dc770dd339482.svn-base @ 1517:dffacf8a6908 redmine-2.5

Update to Redmine SVN revision 13367 on 2.5-stable branch
author Chris Cannam
date Tue, 09 Sep 2014 09:29:00 +0100
parents
children
comparison
equal deleted inserted replaced
1516:b450a9d58aed 1517:dffacf8a6908
1 # Redmine - project management software
2 # Copyright (C) 2006-2014 Jean-Philippe Lang
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 require File.expand_path('../../../test_helper', __FILE__)
19
20 class IssuesHelperTest < ActionView::TestCase
21 include Redmine::I18n
22 include IssuesHelper
23 include CustomFieldsHelper
24 include ERB::Util
25 include Rails.application.routes.url_helpers
26
27 fixtures :projects, :trackers, :issue_statuses, :issues,
28 :enumerations, :users, :issue_categories,
29 :projects_trackers,
30 :roles,
31 :member_roles,
32 :members,
33 :enabled_modules,
34 :custom_fields,
35 :attachments,
36 :versions
37
38 def setup
39 super
40 set_language_if_valid('en')
41 User.current = nil
42 end
43
44 def test_issue_heading
45 assert_equal "Bug #1", issue_heading(Issue.find(1))
46 end
47
48 def test_issues_destroy_confirmation_message_with_one_root_issue
49 assert_equal l(:text_issues_destroy_confirmation),
50 issues_destroy_confirmation_message(Issue.find(1))
51 end
52
53 def test_issues_destroy_confirmation_message_with_an_arrayt_of_root_issues
54 assert_equal l(:text_issues_destroy_confirmation),
55 issues_destroy_confirmation_message(Issue.find([1, 2]))
56 end
57
58 def test_issues_destroy_confirmation_message_with_one_parent_issue
59 Issue.find(2).update_attribute :parent_issue_id, 1
60 assert_equal l(:text_issues_destroy_confirmation) + "\n" +
61 l(:text_issues_destroy_descendants_confirmation, :count => 1),
62 issues_destroy_confirmation_message(Issue.find(1))
63 end
64
65 def test_issues_destroy_confirmation_message_with_one_parent_issue_and_its_child
66 Issue.find(2).update_attribute :parent_issue_id, 1
67 assert_equal l(:text_issues_destroy_confirmation),
68 issues_destroy_confirmation_message(Issue.find([1, 2]))
69 end
70
71 test 'show_detail with no_html should show a changing attribute' do
72 detail = JournalDetail.new(:property => 'attr', :old_value => '40',
73 :value => '100', :prop_key => 'done_ratio')
74 assert_equal "% Done changed from 40 to 100", show_detail(detail, true)
75 end
76
77 test 'show_detail with no_html should show a new attribute' do
78 detail = JournalDetail.new(:property => 'attr', :old_value => nil,
79 :value => '100', :prop_key => 'done_ratio')
80 assert_equal "% Done set to 100", show_detail(detail, true)
81 end
82
83 test 'show_detail with no_html should show a deleted attribute' do
84 detail = JournalDetail.new(:property => 'attr', :old_value => '50',
85 :value => nil, :prop_key => 'done_ratio')
86 assert_equal "% Done deleted (50)", show_detail(detail, true)
87 end
88
89 test 'show_detail with html should show a changing attribute with HTML highlights' do
90 detail = JournalDetail.new(:property => 'attr', :old_value => '40',
91 :value => '100', :prop_key => 'done_ratio')
92 html = show_detail(detail, false)
93 assert_include '<strong>% Done</strong>', html
94 assert_include '<i>40</i>', html
95 assert_include '<i>100</i>', html
96 end
97
98 test 'show_detail with html should show a new attribute with HTML highlights' do
99 detail = JournalDetail.new(:property => 'attr', :old_value => nil,
100 :value => '100', :prop_key => 'done_ratio')
101 html = show_detail(detail, false)
102 assert_include '<strong>% Done</strong>', html
103 assert_include '<i>100</i>', html
104 end
105
106 test 'show_detail with html should show a deleted attribute with HTML highlights' do
107 detail = JournalDetail.new(:property => 'attr', :old_value => '50',
108 :value => nil, :prop_key => 'done_ratio')
109 html = show_detail(detail, false)
110 assert_include '<strong>% Done</strong>', html
111 assert_include '<del><i>50</i></del>', html
112 end
113
114 test 'show_detail with a start_date attribute should format the dates' do
115 detail = JournalDetail.new(
116 :property => 'attr',
117 :old_value => '2010-01-01',
118 :value => '2010-01-31',
119 :prop_key => 'start_date'
120 )
121 with_settings :date_format => '%m/%d/%Y' do
122 assert_match "01/31/2010", show_detail(detail, true)
123 assert_match "01/01/2010", show_detail(detail, true)
124 end
125 end
126
127 test 'show_detail with a due_date attribute should format the dates' do
128 detail = JournalDetail.new(
129 :property => 'attr',
130 :old_value => '2010-01-01',
131 :value => '2010-01-31',
132 :prop_key => 'due_date'
133 )
134 with_settings :date_format => '%m/%d/%Y' do
135 assert_match "01/31/2010", show_detail(detail, true)
136 assert_match "01/01/2010", show_detail(detail, true)
137 end
138 end
139
140 test 'show_detail should show old and new values with a project attribute' do
141 detail = JournalDetail.new(:property => 'attr', :prop_key => 'project_id',
142 :old_value => 1, :value => 2)
143 assert_match 'eCookbook', show_detail(detail, true)
144 assert_match 'OnlineStore', show_detail(detail, true)
145 end
146
147 test 'show_detail should show old and new values with a issue status attribute' do
148 detail = JournalDetail.new(:property => 'attr', :prop_key => 'status_id',
149 :old_value => 1, :value => 2)
150 assert_match 'New', show_detail(detail, true)
151 assert_match 'Assigned', show_detail(detail, true)
152 end
153
154 test 'show_detail should show old and new values with a tracker attribute' do
155 detail = JournalDetail.new(:property => 'attr', :prop_key => 'tracker_id',
156 :old_value => 1, :value => 2)
157 assert_match 'Bug', show_detail(detail, true)
158 assert_match 'Feature request', show_detail(detail, true)
159 end
160
161 test 'show_detail should show old and new values with a assigned to attribute' do
162 detail = JournalDetail.new(:property => 'attr', :prop_key => 'assigned_to_id',
163 :old_value => 1, :value => 2)
164 assert_match 'Redmine Admin', show_detail(detail, true)
165 assert_match 'John Smith', show_detail(detail, true)
166 end
167
168 test 'show_detail should show old and new values with a priority attribute' do
169 detail = JournalDetail.new(:property => 'attr', :prop_key => 'priority_id',
170 :old_value => 4, :value => 5)
171 assert_match 'Low', show_detail(detail, true)
172 assert_match 'Normal', show_detail(detail, true)
173 end
174
175 test 'show_detail should show old and new values with a category attribute' do
176 detail = JournalDetail.new(:property => 'attr', :prop_key => 'category_id',
177 :old_value => 1, :value => 2)
178 assert_match 'Printing', show_detail(detail, true)
179 assert_match 'Recipes', show_detail(detail, true)
180 end
181
182 test 'show_detail should show old and new values with a fixed version attribute' do
183 detail = JournalDetail.new(:property => 'attr', :prop_key => 'fixed_version_id',
184 :old_value => 1, :value => 2)
185 assert_match '0.1', show_detail(detail, true)
186 assert_match '1.0', show_detail(detail, true)
187 end
188
189 test 'show_detail should show old and new values with a estimated hours attribute' do
190 detail = JournalDetail.new(:property => 'attr', :prop_key => 'estimated_hours',
191 :old_value => '5', :value => '6.3')
192 assert_match '5.00', show_detail(detail, true)
193 assert_match '6.30', show_detail(detail, true)
194 end
195
196 test 'show_detail should show old and new values with a custom field' do
197 detail = JournalDetail.new(:property => 'cf', :prop_key => '1',
198 :old_value => 'MySQL', :value => 'PostgreSQL')
199 assert_equal 'Database changed from MySQL to PostgreSQL', show_detail(detail, true)
200 end
201
202 test 'show_detail should show added file' do
203 detail = JournalDetail.new(:property => 'attachment', :prop_key => '1',
204 :old_value => nil, :value => 'error281.txt')
205 assert_match 'error281.txt', show_detail(detail, true)
206 end
207
208 test 'show_detail should show removed file' do
209 detail = JournalDetail.new(:property => 'attachment', :prop_key => '1',
210 :old_value => 'error281.txt', :value => nil)
211 assert_match 'error281.txt', show_detail(detail, true)
212 end
213
214 def test_show_detail_relation_added
215 detail = JournalDetail.new(:property => 'relation',
216 :prop_key => 'precedes',
217 :value => 1)
218 assert_equal "Precedes Bug #1: Can't print recipes added", show_detail(detail, true)
219 str = link_to("Bug #1", "/issues/1", :class => Issue.find(1).css_classes)
220 assert_equal "<strong>Precedes</strong> <i>#{str}: #{ESCAPED_UCANT} print recipes</i> added",
221 show_detail(detail, false)
222 end
223
224 def test_show_detail_relation_added_with_inexistant_issue
225 inexistant_issue_number = 9999
226 assert_nil Issue.find_by_id(inexistant_issue_number)
227 detail = JournalDetail.new(:property => 'relation',
228 :prop_key => 'precedes',
229 :value => inexistant_issue_number)
230 assert_equal "Precedes Issue ##{inexistant_issue_number} added", show_detail(detail, true)
231 assert_equal "<strong>Precedes</strong> <i>Issue ##{inexistant_issue_number}</i> added", show_detail(detail, false)
232 end
233
234 def test_show_detail_relation_added_should_not_disclose_issue_that_is_not_visible
235 issue = Issue.generate!(:is_private => true)
236 detail = JournalDetail.new(:property => 'relation',
237 :prop_key => 'precedes',
238 :value => issue.id)
239
240 assert_equal "Precedes Issue ##{issue.id} added", show_detail(detail, true)
241 assert_equal "<strong>Precedes</strong> <i>Issue ##{issue.id}</i> added", show_detail(detail, false)
242 end
243
244 def test_show_detail_relation_deleted
245 detail = JournalDetail.new(:property => 'relation',
246 :prop_key => 'precedes',
247 :old_value => 1)
248 assert_equal "Precedes deleted (Bug #1: Can't print recipes)", show_detail(detail, true)
249 str = link_to("Bug #1",
250 "/issues/1",
251 :class => Issue.find(1).css_classes)
252 assert_equal "<strong>Precedes</strong> deleted (<i>#{str}: #{ESCAPED_UCANT} print recipes</i>)",
253 show_detail(detail, false)
254 end
255
256 def test_show_detail_relation_deleted_with_inexistant_issue
257 inexistant_issue_number = 9999
258 assert_nil Issue.find_by_id(inexistant_issue_number)
259 detail = JournalDetail.new(:property => 'relation',
260 :prop_key => 'precedes',
261 :old_value => inexistant_issue_number)
262 assert_equal "Precedes deleted (Issue #9999)", show_detail(detail, true)
263 assert_equal "<strong>Precedes</strong> deleted (<i>Issue #9999</i>)", show_detail(detail, false)
264 end
265
266 def test_show_detail_relation_deleted_should_not_disclose_issue_that_is_not_visible
267 issue = Issue.generate!(:is_private => true)
268 detail = JournalDetail.new(:property => 'relation',
269 :prop_key => 'precedes',
270 :old_value => issue.id)
271
272 assert_equal "Precedes deleted (Issue ##{issue.id})", show_detail(detail, true)
273 assert_equal "<strong>Precedes</strong> deleted (<i>Issue ##{issue.id}</i>)", show_detail(detail, false)
274 end
275 end