@@ -1,195 +1,194 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2013 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 | :workflows, | |
|
34 | 33 | :custom_fields, |
|
35 | 34 | :attachments, |
|
36 | 35 | :versions |
|
37 | 36 | |
|
38 | 37 | def setup |
|
39 | 38 | super |
|
40 | 39 | set_language_if_valid('en') |
|
41 | 40 | User.current = nil |
|
42 | 41 | end |
|
43 | 42 | |
|
44 | 43 | def test_issue_heading |
|
45 | 44 | assert_equal "Bug #1", issue_heading(Issue.find(1)) |
|
46 | 45 | end |
|
47 | 46 | |
|
48 | 47 | def test_issues_destroy_confirmation_message_with_one_root_issue |
|
49 | 48 | assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find(1)) |
|
50 | 49 | end |
|
51 | 50 | |
|
52 | 51 | def test_issues_destroy_confirmation_message_with_an_arrayt_of_root_issues |
|
53 | 52 | assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find([1, 2])) |
|
54 | 53 | end |
|
55 | 54 | |
|
56 | 55 | def test_issues_destroy_confirmation_message_with_one_parent_issue |
|
57 | 56 | Issue.find(2).update_attribute :parent_issue_id, 1 |
|
58 | 57 | assert_equal l(:text_issues_destroy_confirmation) + "\n" + l(:text_issues_destroy_descendants_confirmation, :count => 1), |
|
59 | 58 | issues_destroy_confirmation_message(Issue.find(1)) |
|
60 | 59 | end |
|
61 | 60 | |
|
62 | 61 | def test_issues_destroy_confirmation_message_with_one_parent_issue_and_its_child |
|
63 | 62 | Issue.find(2).update_attribute :parent_issue_id, 1 |
|
64 | 63 | assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find([1, 2])) |
|
65 | 64 | end |
|
66 | 65 | |
|
67 | 66 | test 'IssuesHelper#show_detail with no_html should show a changing attribute' do |
|
68 | 67 | detail = JournalDetail.new(:property => 'attr', :old_value => '40', :value => '100', :prop_key => 'done_ratio') |
|
69 | 68 | assert_equal "% Done changed from 40 to 100", show_detail(detail, true) |
|
70 | 69 | end |
|
71 | 70 | |
|
72 | 71 | test 'IssuesHelper#show_detail with no_html should show a new attribute' do |
|
73 | 72 | detail = JournalDetail.new(:property => 'attr', :old_value => nil, :value => '100', :prop_key => 'done_ratio') |
|
74 | 73 | assert_equal "% Done set to 100", show_detail(detail, true) |
|
75 | 74 | end |
|
76 | 75 | |
|
77 | 76 | test 'IssuesHelper#show_detail with no_html should show a deleted attribute' do |
|
78 | 77 | detail = JournalDetail.new(:property => 'attr', :old_value => '50', :value => nil, :prop_key => 'done_ratio') |
|
79 | 78 | assert_equal "% Done deleted (50)", show_detail(detail, true) |
|
80 | 79 | end |
|
81 | 80 | |
|
82 | 81 | test 'IssuesHelper#show_detail with html should show a changing attribute with HTML highlights' do |
|
83 | 82 | detail = JournalDetail.new(: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 | test 'IssuesHelper#show_detail with html should show a new attribute with HTML highlights' do |
|
92 | 91 | detail = JournalDetail.new(: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 | test 'IssuesHelper#show_detail with html should show a deleted attribute with HTML highlights' do |
|
100 | 99 | detail = JournalDetail.new(: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 '<del><i>50</i></del>', html |
|
105 | 104 | end |
|
106 | 105 | |
|
107 | 106 | test 'IssuesHelper#show_detail with a start_date attribute should format the dates' do |
|
108 | 107 | detail = JournalDetail.new( |
|
109 | 108 | :property => 'attr', |
|
110 | 109 | :old_value => '2010-01-01', |
|
111 | 110 | :value => '2010-01-31', |
|
112 | 111 | :prop_key => 'start_date' |
|
113 | 112 | ) |
|
114 | 113 | with_settings :date_format => '%m/%d/%Y' do |
|
115 | 114 | assert_match "01/31/2010", show_detail(detail, true) |
|
116 | 115 | assert_match "01/01/2010", show_detail(detail, true) |
|
117 | 116 | end |
|
118 | 117 | end |
|
119 | 118 | |
|
120 | 119 | test 'IssuesHelper#show_detail with a due_date attribute should format the dates' do |
|
121 | 120 | detail = JournalDetail.new( |
|
122 | 121 | :property => 'attr', |
|
123 | 122 | :old_value => '2010-01-01', |
|
124 | 123 | :value => '2010-01-31', |
|
125 | 124 | :prop_key => 'due_date' |
|
126 | 125 | ) |
|
127 | 126 | with_settings :date_format => '%m/%d/%Y' do |
|
128 | 127 | assert_match "01/31/2010", show_detail(detail, true) |
|
129 | 128 | assert_match "01/01/2010", show_detail(detail, true) |
|
130 | 129 | end |
|
131 | 130 | end |
|
132 | 131 | |
|
133 | 132 | test 'IssuesHelper#show_detail should show old and new values with a project attribute' do |
|
134 | 133 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'project_id', :old_value => 1, :value => 2) |
|
135 | 134 | assert_match 'eCookbook', show_detail(detail, true) |
|
136 | 135 | assert_match 'OnlineStore', show_detail(detail, true) |
|
137 | 136 | end |
|
138 | 137 | |
|
139 | 138 | test 'IssuesHelper#show_detail should show old and new values with a issue status attribute' do |
|
140 | 139 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'status_id', :old_value => 1, :value => 2) |
|
141 | 140 | assert_match 'New', show_detail(detail, true) |
|
142 | 141 | assert_match 'Assigned', show_detail(detail, true) |
|
143 | 142 | end |
|
144 | 143 | |
|
145 | 144 | test 'IssuesHelper#show_detail should show old and new values with a tracker attribute' do |
|
146 | 145 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'tracker_id', :old_value => 1, :value => 2) |
|
147 | 146 | assert_match 'Bug', show_detail(detail, true) |
|
148 | 147 | assert_match 'Feature request', show_detail(detail, true) |
|
149 | 148 | end |
|
150 | 149 | |
|
151 | 150 | test 'IssuesHelper#show_detail should show old and new values with a assigned to attribute' do |
|
152 | 151 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'assigned_to_id', :old_value => 1, :value => 2) |
|
153 | 152 | assert_match 'Redmine Admin', show_detail(detail, true) |
|
154 | 153 | assert_match 'John Smith', show_detail(detail, true) |
|
155 | 154 | end |
|
156 | 155 | |
|
157 | 156 | test 'IssuesHelper#show_detail should show old and new values with a priority attribute' do |
|
158 | 157 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'priority_id', :old_value => 4, :value => 5) |
|
159 | 158 | assert_match 'Low', show_detail(detail, true) |
|
160 | 159 | assert_match 'Normal', show_detail(detail, true) |
|
161 | 160 | end |
|
162 | 161 | |
|
163 | 162 | test 'IssuesHelper#show_detail should show old and new values with a category attribute' do |
|
164 | 163 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'category_id', :old_value => 1, :value => 2) |
|
165 | 164 | assert_match 'Printing', show_detail(detail, true) |
|
166 | 165 | assert_match 'Recipes', show_detail(detail, true) |
|
167 | 166 | end |
|
168 | 167 | |
|
169 | 168 | test 'IssuesHelper#show_detail should show old and new values with a fixed version attribute' do |
|
170 | 169 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'fixed_version_id', :old_value => 1, :value => 2) |
|
171 | 170 | assert_match '0.1', show_detail(detail, true) |
|
172 | 171 | assert_match '1.0', show_detail(detail, true) |
|
173 | 172 | end |
|
174 | 173 | |
|
175 | 174 | test 'IssuesHelper#show_detail should show old and new values with a estimated hours attribute' do |
|
176 | 175 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'estimated_hours', :old_value => '5', :value => '6.3') |
|
177 | 176 | assert_match '5.00', show_detail(detail, true) |
|
178 | 177 | assert_match '6.30', show_detail(detail, true) |
|
179 | 178 | end |
|
180 | 179 | |
|
181 | 180 | test 'IssuesHelper#show_detail should show old and new values with a custom field' do |
|
182 | 181 | detail = JournalDetail.new(:property => 'cf', :prop_key => '1', :old_value => 'MySQL', :value => 'PostgreSQL') |
|
183 | 182 | assert_equal 'Database changed from MySQL to PostgreSQL', show_detail(detail, true) |
|
184 | 183 | end |
|
185 | 184 | |
|
186 | 185 | test 'IssuesHelper#show_detail should show added file' do |
|
187 | 186 | detail = JournalDetail.new(:property => 'attachment', :prop_key => '1', :old_value => nil, :value => 'error281.txt') |
|
188 | 187 | assert_match 'error281.txt', show_detail(detail, true) |
|
189 | 188 | end |
|
190 | 189 | |
|
191 | 190 | test 'IssuesHelper#show_detail should show removed file' do |
|
192 | 191 | detail = JournalDetail.new(:property => 'attachment', :prop_key => '1', :old_value => 'error281.txt', :value => nil) |
|
193 | 192 | assert_match 'error281.txt', show_detail(detail, true) |
|
194 | 193 | end |
|
195 | 194 | end |
General Comments 0
You need to be logged in to leave comments.
Login now