Chris@0
|
1 # Redmine - project management software
|
Chris@1295
|
2 # Copyright (C) 2006-2013 Jean-Philippe Lang
|
Chris@0
|
3 #
|
Chris@0
|
4 # This program is free software; you can redistribute it and/or
|
Chris@0
|
5 # modify it under the terms of the GNU General Public License
|
Chris@0
|
6 # as published by the Free Software Foundation; either version 2
|
Chris@0
|
7 # of the License, or (at your option) any later version.
|
Chris@441
|
8 #
|
Chris@0
|
9 # This program is distributed in the hope that it will be useful,
|
Chris@0
|
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
Chris@0
|
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
Chris@0
|
12 # GNU General Public License for more details.
|
Chris@441
|
13 #
|
Chris@0
|
14 # You should have received a copy of the GNU General Public License
|
Chris@0
|
15 # along with this program; if not, write to the Free Software
|
Chris@0
|
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
Chris@0
|
17
|
Chris@119
|
18 require File.expand_path('../../../test_helper', __FILE__)
|
Chris@0
|
19
|
Chris@1115
|
20 class IssuesHelperTest < ActionView::TestCase
|
Chris@0
|
21 include ApplicationHelper
|
Chris@0
|
22 include IssuesHelper
|
Chris@1115
|
23 include CustomFieldsHelper
|
Chris@1115
|
24 include ERB::Util
|
Chris@0
|
25
|
Chris@909
|
26 fixtures :projects, :trackers, :issue_statuses, :issues,
|
Chris@909
|
27 :enumerations, :users, :issue_categories,
|
Chris@909
|
28 :projects_trackers,
|
Chris@909
|
29 :roles,
|
Chris@909
|
30 :member_roles,
|
Chris@909
|
31 :members,
|
Chris@909
|
32 :enabled_modules,
|
Chris@1115
|
33 :custom_fields,
|
Chris@1115
|
34 :attachments,
|
Chris@1115
|
35 :versions
|
Chris@0
|
36
|
Chris@0
|
37 def setup
|
Chris@0
|
38 super
|
Chris@0
|
39 set_language_if_valid('en')
|
Chris@0
|
40 User.current = nil
|
Chris@0
|
41 end
|
Chris@0
|
42
|
Chris@441
|
43 def test_issue_heading
|
Chris@441
|
44 assert_equal "Bug #1", issue_heading(Issue.find(1))
|
Chris@441
|
45 end
|
Chris@441
|
46
|
Chris@441
|
47 def test_issues_destroy_confirmation_message_with_one_root_issue
|
Chris@441
|
48 assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find(1))
|
Chris@441
|
49 end
|
Chris@441
|
50
|
Chris@441
|
51 def test_issues_destroy_confirmation_message_with_an_arrayt_of_root_issues
|
Chris@441
|
52 assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find([1, 2]))
|
Chris@441
|
53 end
|
Chris@441
|
54
|
Chris@441
|
55 def test_issues_destroy_confirmation_message_with_one_parent_issue
|
Chris@441
|
56 Issue.find(2).update_attribute :parent_issue_id, 1
|
Chris@441
|
57 assert_equal l(:text_issues_destroy_confirmation) + "\n" + l(:text_issues_destroy_descendants_confirmation, :count => 1),
|
Chris@441
|
58 issues_destroy_confirmation_message(Issue.find(1))
|
Chris@441
|
59 end
|
Chris@441
|
60
|
Chris@441
|
61 def test_issues_destroy_confirmation_message_with_one_parent_issue_and_its_child
|
Chris@441
|
62 Issue.find(2).update_attribute :parent_issue_id, 1
|
Chris@441
|
63 assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find([1, 2]))
|
Chris@441
|
64 end
|
Chris@441
|
65
|
Chris@1295
|
66 test 'IssuesHelper#show_detail with no_html should show a changing attribute' do
|
Chris@1295
|
67 detail = JournalDetail.new(:property => 'attr', :old_value => '40', :value => '100', :prop_key => 'done_ratio')
|
Chris@1295
|
68 assert_equal "% Done changed from 40 to 100", show_detail(detail, true)
|
Chris@1295
|
69 end
|
Chris@0
|
70
|
Chris@1295
|
71 test 'IssuesHelper#show_detail with no_html should show a new attribute' do
|
Chris@1295
|
72 detail = JournalDetail.new(:property => 'attr', :old_value => nil, :value => '100', :prop_key => 'done_ratio')
|
Chris@1295
|
73 assert_equal "% Done set to 100", show_detail(detail, true)
|
Chris@1295
|
74 end
|
Chris@0
|
75
|
Chris@1295
|
76 test 'IssuesHelper#show_detail with no_html should show a deleted attribute' do
|
Chris@1295
|
77 detail = JournalDetail.new(:property => 'attr', :old_value => '50', :value => nil, :prop_key => 'done_ratio')
|
Chris@1295
|
78 assert_equal "% Done deleted (50)", show_detail(detail, true)
|
Chris@1295
|
79 end
|
Chris@0
|
80
|
Chris@1295
|
81 test 'IssuesHelper#show_detail with html should show a changing attribute with HTML highlights' do
|
Chris@1295
|
82 detail = JournalDetail.new(:property => 'attr', :old_value => '40', :value => '100', :prop_key => 'done_ratio')
|
Chris@1295
|
83 html = show_detail(detail, false)
|
Chris@0
|
84
|
Chris@1295
|
85 assert_include '<strong>% Done</strong>', html
|
Chris@1295
|
86 assert_include '<i>40</i>', html
|
Chris@1295
|
87 assert_include '<i>100</i>', html
|
Chris@1295
|
88 end
|
Chris@0
|
89
|
Chris@1295
|
90 test 'IssuesHelper#show_detail with html should show a new attribute with HTML highlights' do
|
Chris@1295
|
91 detail = JournalDetail.new(:property => 'attr', :old_value => nil, :value => '100', :prop_key => 'done_ratio')
|
Chris@1295
|
92 html = show_detail(detail, false)
|
Chris@0
|
93
|
Chris@1295
|
94 assert_include '<strong>% Done</strong>', html
|
Chris@1295
|
95 assert_include '<i>100</i>', html
|
Chris@1295
|
96 end
|
Chris@0
|
97
|
Chris@1295
|
98 test 'IssuesHelper#show_detail with html should show a deleted attribute with HTML highlights' do
|
Chris@1295
|
99 detail = JournalDetail.new(:property => 'attr', :old_value => '50', :value => nil, :prop_key => 'done_ratio')
|
Chris@1295
|
100 html = show_detail(detail, false)
|
Chris@0
|
101
|
Chris@1295
|
102 assert_include '<strong>% Done</strong>', html
|
Chris@1295
|
103 assert_include '<del><i>50</i></del>', html
|
Chris@1295
|
104 end
|
Chris@0
|
105
|
Chris@1295
|
106 test 'IssuesHelper#show_detail with a start_date attribute should format the dates' do
|
Chris@1295
|
107 detail = JournalDetail.new(
|
Chris@1295
|
108 :property => 'attr',
|
Chris@1295
|
109 :old_value => '2010-01-01',
|
Chris@1295
|
110 :value => '2010-01-31',
|
Chris@1295
|
111 :prop_key => 'start_date'
|
Chris@1295
|
112 )
|
Chris@1295
|
113 with_settings :date_format => '%m/%d/%Y' do
|
Chris@1295
|
114 assert_match "01/31/2010", show_detail(detail, true)
|
Chris@1295
|
115 assert_match "01/01/2010", show_detail(detail, true)
|
Chris@1115
|
116 end
|
Chris@0
|
117 end
|
Chris@1295
|
118
|
Chris@1295
|
119 test 'IssuesHelper#show_detail with a due_date attribute should format the dates' do
|
Chris@1295
|
120 detail = JournalDetail.new(
|
Chris@1295
|
121 :property => 'attr',
|
Chris@1295
|
122 :old_value => '2010-01-01',
|
Chris@1295
|
123 :value => '2010-01-31',
|
Chris@1295
|
124 :prop_key => 'due_date'
|
Chris@1295
|
125 )
|
Chris@1295
|
126 with_settings :date_format => '%m/%d/%Y' do
|
Chris@1295
|
127 assert_match "01/31/2010", show_detail(detail, true)
|
Chris@1295
|
128 assert_match "01/01/2010", show_detail(detail, true)
|
Chris@1295
|
129 end
|
Chris@1295
|
130 end
|
Chris@1295
|
131
|
Chris@1295
|
132 test 'IssuesHelper#show_detail should show old and new values with a project attribute' do
|
Chris@1295
|
133 detail = JournalDetail.new(:property => 'attr', :prop_key => 'project_id', :old_value => 1, :value => 2)
|
Chris@1295
|
134 assert_match 'eCookbook', show_detail(detail, true)
|
Chris@1295
|
135 assert_match 'OnlineStore', show_detail(detail, true)
|
Chris@1295
|
136 end
|
Chris@1295
|
137
|
Chris@1295
|
138 test 'IssuesHelper#show_detail should show old and new values with a issue status attribute' do
|
Chris@1295
|
139 detail = JournalDetail.new(:property => 'attr', :prop_key => 'status_id', :old_value => 1, :value => 2)
|
Chris@1295
|
140 assert_match 'New', show_detail(detail, true)
|
Chris@1295
|
141 assert_match 'Assigned', show_detail(detail, true)
|
Chris@1295
|
142 end
|
Chris@1295
|
143
|
Chris@1295
|
144 test 'IssuesHelper#show_detail should show old and new values with a tracker attribute' do
|
Chris@1295
|
145 detail = JournalDetail.new(:property => 'attr', :prop_key => 'tracker_id', :old_value => 1, :value => 2)
|
Chris@1295
|
146 assert_match 'Bug', show_detail(detail, true)
|
Chris@1295
|
147 assert_match 'Feature request', show_detail(detail, true)
|
Chris@1295
|
148 end
|
Chris@1295
|
149
|
Chris@1295
|
150 test 'IssuesHelper#show_detail should show old and new values with a assigned to attribute' do
|
Chris@1295
|
151 detail = JournalDetail.new(:property => 'attr', :prop_key => 'assigned_to_id', :old_value => 1, :value => 2)
|
Chris@1295
|
152 assert_match 'Redmine Admin', show_detail(detail, true)
|
Chris@1295
|
153 assert_match 'John Smith', show_detail(detail, true)
|
Chris@1295
|
154 end
|
Chris@1295
|
155
|
Chris@1295
|
156 test 'IssuesHelper#show_detail should show old and new values with a priority attribute' do
|
Chris@1295
|
157 detail = JournalDetail.new(:property => 'attr', :prop_key => 'priority_id', :old_value => 4, :value => 5)
|
Chris@1295
|
158 assert_match 'Low', show_detail(detail, true)
|
Chris@1295
|
159 assert_match 'Normal', show_detail(detail, true)
|
Chris@1295
|
160 end
|
Chris@1295
|
161
|
Chris@1295
|
162 test 'IssuesHelper#show_detail should show old and new values with a category attribute' do
|
Chris@1295
|
163 detail = JournalDetail.new(:property => 'attr', :prop_key => 'category_id', :old_value => 1, :value => 2)
|
Chris@1295
|
164 assert_match 'Printing', show_detail(detail, true)
|
Chris@1295
|
165 assert_match 'Recipes', show_detail(detail, true)
|
Chris@1295
|
166 end
|
Chris@1295
|
167
|
Chris@1295
|
168 test 'IssuesHelper#show_detail should show old and new values with a fixed version attribute' do
|
Chris@1295
|
169 detail = JournalDetail.new(:property => 'attr', :prop_key => 'fixed_version_id', :old_value => 1, :value => 2)
|
Chris@1295
|
170 assert_match '0.1', show_detail(detail, true)
|
Chris@1295
|
171 assert_match '1.0', show_detail(detail, true)
|
Chris@1295
|
172 end
|
Chris@1295
|
173
|
Chris@1295
|
174 test 'IssuesHelper#show_detail should show old and new values with a estimated hours attribute' do
|
Chris@1295
|
175 detail = JournalDetail.new(:property => 'attr', :prop_key => 'estimated_hours', :old_value => '5', :value => '6.3')
|
Chris@1295
|
176 assert_match '5.00', show_detail(detail, true)
|
Chris@1295
|
177 assert_match '6.30', show_detail(detail, true)
|
Chris@1295
|
178 end
|
Chris@1295
|
179
|
Chris@1295
|
180 test 'IssuesHelper#show_detail should show old and new values with a custom field' do
|
Chris@1295
|
181 detail = JournalDetail.new(:property => 'cf', :prop_key => '1', :old_value => 'MySQL', :value => 'PostgreSQL')
|
Chris@1295
|
182 assert_equal 'Database changed from MySQL to PostgreSQL', show_detail(detail, true)
|
Chris@1295
|
183 end
|
Chris@1295
|
184
|
Chris@1295
|
185 test 'IssuesHelper#show_detail should show added file' do
|
Chris@1295
|
186 detail = JournalDetail.new(:property => 'attachment', :prop_key => '1', :old_value => nil, :value => 'error281.txt')
|
Chris@1295
|
187 assert_match 'error281.txt', show_detail(detail, true)
|
Chris@1295
|
188 end
|
Chris@1295
|
189
|
Chris@1295
|
190 test 'IssuesHelper#show_detail should show removed file' do
|
Chris@1295
|
191 detail = JournalDetail.new(:property => 'attachment', :prop_key => '1', :old_value => 'error281.txt', :value => nil)
|
Chris@1295
|
192 assert_match 'error281.txt', show_detail(detail, true)
|
Chris@1295
|
193 end
|
Chris@0
|
194 end
|