comparison test/unit/helpers/issues_helper_test.rb @ 1298:4f746d8966dd redmine_2.3_integration

Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author Chris Cannam
date Fri, 14 Jun 2013 09:28:30 +0100
parents 622f24f53b42
children
comparison
equal deleted inserted replaced
1297:0a574315af3e 1298:4f746d8966dd
1 # Redmine - project management software 1 # Redmine - project management software
2 # Copyright (C) 2006-2012 Jean-Philippe Lang 2 # Copyright (C) 2006-2013 Jean-Philippe Lang
3 # 3 #
4 # This program is free software; you can redistribute it and/or 4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License 5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2 6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version. 7 # of the License, or (at your option) any later version.
28 :projects_trackers, 28 :projects_trackers,
29 :roles, 29 :roles,
30 :member_roles, 30 :member_roles,
31 :members, 31 :members,
32 :enabled_modules, 32 :enabled_modules,
33 :workflows,
34 :custom_fields, 33 :custom_fields,
35 :attachments, 34 :attachments,
36 :versions 35 :versions
37 36
38 def setup 37 def setup
62 def test_issues_destroy_confirmation_message_with_one_parent_issue_and_its_child 61 def test_issues_destroy_confirmation_message_with_one_parent_issue_and_its_child
63 Issue.find(2).update_attribute :parent_issue_id, 1 62 Issue.find(2).update_attribute :parent_issue_id, 1
64 assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find([1, 2])) 63 assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find([1, 2]))
65 end 64 end
66 65
67 context "IssuesHelper#show_detail" do 66 test 'IssuesHelper#show_detail with no_html should show a changing attribute' do
68 context "with no_html" do 67 detail = JournalDetail.new(:property => 'attr', :old_value => '40', :value => '100', :prop_key => 'done_ratio')
69 should 'show a changing attribute' do 68 assert_equal "% Done changed from 40 to 100", show_detail(detail, true)
70 @detail = JournalDetail.new(:property => 'attr', :old_value => '40', :value => '100', :prop_key => 'done_ratio') 69 end
71 assert_equal "% Done changed from 40 to 100", show_detail(@detail, true)
72 end
73 70
74 should 'show a new attribute' do 71 test 'IssuesHelper#show_detail with no_html should show a new attribute' do
75 @detail = JournalDetail.new(:property => 'attr', :old_value => nil, :value => '100', :prop_key => 'done_ratio') 72 detail = JournalDetail.new(:property => 'attr', :old_value => nil, :value => '100', :prop_key => 'done_ratio')
76 assert_equal "% Done set to 100", show_detail(@detail, true) 73 assert_equal "% Done set to 100", show_detail(detail, true)
77 end 74 end
78 75
79 should 'show a deleted attribute' do 76 test 'IssuesHelper#show_detail with no_html should show a deleted attribute' do
80 @detail = JournalDetail.new(:property => 'attr', :old_value => '50', :value => nil, :prop_key => 'done_ratio') 77 detail = JournalDetail.new(:property => 'attr', :old_value => '50', :value => nil, :prop_key => 'done_ratio')
81 assert_equal "% Done deleted (50)", show_detail(@detail, true) 78 assert_equal "% Done deleted (50)", show_detail(detail, true)
82 end 79 end
83 end
84 80
85 context "with html" do 81 test 'IssuesHelper#show_detail with html should show a changing attribute with HTML highlights' do
86 should 'show a changing attribute with HTML highlights' do 82 detail = JournalDetail.new(:property => 'attr', :old_value => '40', :value => '100', :prop_key => 'done_ratio')
87 @detail = JournalDetail.new(:property => 'attr', :old_value => '40', :value => '100', :prop_key => 'done_ratio') 83 html = show_detail(detail, false)
88 html = show_detail(@detail, false)
89 84
90 assert_include '<strong>% Done</strong>', html 85 assert_include '<strong>% Done</strong>', html
91 assert_include '<i>40</i>', html 86 assert_include '<i>40</i>', html
92 assert_include '<i>100</i>', html 87 assert_include '<i>100</i>', html
93 end 88 end
94 89
95 should 'show a new attribute with HTML highlights' do 90 test 'IssuesHelper#show_detail with html should show a new attribute with HTML highlights' do
96 @detail = JournalDetail.new(:property => 'attr', :old_value => nil, :value => '100', :prop_key => 'done_ratio') 91 detail = JournalDetail.new(:property => 'attr', :old_value => nil, :value => '100', :prop_key => 'done_ratio')
97 html = show_detail(@detail, false) 92 html = show_detail(detail, false)
98 93
99 assert_include '<strong>% Done</strong>', html 94 assert_include '<strong>% Done</strong>', html
100 assert_include '<i>100</i>', html 95 assert_include '<i>100</i>', html
101 end 96 end
102 97
103 should 'show a deleted attribute with HTML highlights' do 98 test 'IssuesHelper#show_detail with html should show a deleted attribute with HTML highlights' do
104 @detail = JournalDetail.new(:property => 'attr', :old_value => '50', :value => nil, :prop_key => 'done_ratio') 99 detail = JournalDetail.new(:property => 'attr', :old_value => '50', :value => nil, :prop_key => 'done_ratio')
105 html = show_detail(@detail, false) 100 html = show_detail(detail, false)
106 101
107 assert_include '<strong>% Done</strong>', html 102 assert_include '<strong>% Done</strong>', html
108 assert_include '<del><i>50</i></del>', html 103 assert_include '<del><i>50</i></del>', html
109 end 104 end
110 end
111 105
112 context "with a start_date attribute" do 106 test 'IssuesHelper#show_detail with a start_date attribute should format the dates' do
113 should "format the current date" do 107 detail = JournalDetail.new(
114 @detail = JournalDetail.new( 108 :property => 'attr',
115 :property => 'attr', 109 :old_value => '2010-01-01',
116 :old_value => '2010-01-01', 110 :value => '2010-01-31',
117 :value => '2010-01-31', 111 :prop_key => 'start_date'
118 :prop_key => 'start_date' 112 )
119 ) 113 with_settings :date_format => '%m/%d/%Y' do
120 with_settings :date_format => '%m/%d/%Y' do 114 assert_match "01/31/2010", show_detail(detail, true)
121 assert_match "01/31/2010", show_detail(@detail, true) 115 assert_match "01/01/2010", show_detail(detail, true)
122 end
123 end
124
125 should "format the old date" do
126 @detail = JournalDetail.new(
127 :property => 'attr',
128 :old_value => '2010-01-01',
129 :value => '2010-01-31',
130 :prop_key => 'start_date'
131 )
132 with_settings :date_format => '%m/%d/%Y' do
133 assert_match "01/01/2010", show_detail(@detail, true)
134 end
135 end
136 end
137
138 context "with a due_date attribute" do
139 should "format the current date" do
140 @detail = JournalDetail.new(
141 :property => 'attr',
142 :old_value => '2010-01-01',
143 :value => '2010-01-31',
144 :prop_key => 'due_date'
145 )
146 with_settings :date_format => '%m/%d/%Y' do
147 assert_match "01/31/2010", show_detail(@detail, true)
148 end
149 end
150
151 should "format the old date" do
152 @detail = JournalDetail.new(
153 :property => 'attr',
154 :old_value => '2010-01-01',
155 :value => '2010-01-31',
156 :prop_key => 'due_date'
157 )
158 with_settings :date_format => '%m/%d/%Y' do
159 assert_match "01/01/2010", show_detail(@detail, true)
160 end
161 end
162 end
163
164 should "show old and new values with a project attribute" do
165 detail = JournalDetail.new(:property => 'attr', :prop_key => 'project_id', :old_value => 1, :value => 2)
166 assert_match 'eCookbook', show_detail(detail, true)
167 assert_match 'OnlineStore', show_detail(detail, true)
168 end
169
170 should "show old and new values with a issue status attribute" do
171 detail = JournalDetail.new(:property => 'attr', :prop_key => 'status_id', :old_value => 1, :value => 2)
172 assert_match 'New', show_detail(detail, true)
173 assert_match 'Assigned', show_detail(detail, true)
174 end
175
176 should "show old and new values with a tracker attribute" do
177 detail = JournalDetail.new(:property => 'attr', :prop_key => 'tracker_id', :old_value => 1, :value => 2)
178 assert_match 'Bug', show_detail(detail, true)
179 assert_match 'Feature request', show_detail(detail, true)
180 end
181
182 should "show old and new values with a assigned to attribute" do
183 detail = JournalDetail.new(:property => 'attr', :prop_key => 'assigned_to_id', :old_value => 1, :value => 2)
184 assert_match 'redMine Admin', show_detail(detail, true)
185 assert_match 'John Smith', show_detail(detail, true)
186 end
187
188 should "show old and new values with a priority attribute" do
189 detail = JournalDetail.new(:property => 'attr', :prop_key => 'priority_id', :old_value => 4, :value => 5)
190 assert_match 'Low', show_detail(detail, true)
191 assert_match 'Normal', show_detail(detail, true)
192 end
193
194 should "show old and new values with a category attribute" do
195 detail = JournalDetail.new(:property => 'attr', :prop_key => 'category_id', :old_value => 1, :value => 2)
196 assert_match 'Printing', show_detail(detail, true)
197 assert_match 'Recipes', show_detail(detail, true)
198 end
199
200 should "show old and new values with a fixed version attribute" do
201 detail = JournalDetail.new(:property => 'attr', :prop_key => 'fixed_version_id', :old_value => 1, :value => 2)
202 assert_match '0.1', show_detail(detail, true)
203 assert_match '1.0', show_detail(detail, true)
204 end
205
206 should "show old and new values with a estimated hours attribute" do
207 detail = JournalDetail.new(:property => 'attr', :prop_key => 'estimated_hours', :old_value => '5', :value => '6.3')
208 assert_match '5.00', show_detail(detail, true)
209 assert_match '6.30', show_detail(detail, true)
210 end
211
212 should "show old and new values with a custom field" do
213 detail = JournalDetail.new(:property => 'cf', :prop_key => '1', :old_value => 'MySQL', :value => 'PostgreSQL')
214 assert_equal 'Database changed from MySQL to PostgreSQL', show_detail(detail, true)
215 end
216
217 should "show added file" do
218 detail = JournalDetail.new(:property => 'attachment', :prop_key => '1', :old_value => nil, :value => 'error281.txt')
219 assert_match 'error281.txt', show_detail(detail, true)
220 end
221
222 should "show removed file" do
223 detail = JournalDetail.new(:property => 'attachment', :prop_key => '1', :old_value => 'error281.txt', :value => nil)
224 assert_match 'error281.txt', show_detail(detail, true)
225 end 116 end
226 end 117 end
118
119 test 'IssuesHelper#show_detail with a due_date attribute should format the dates' do
120 detail = JournalDetail.new(
121 :property => 'attr',
122 :old_value => '2010-01-01',
123 :value => '2010-01-31',
124 :prop_key => 'due_date'
125 )
126 with_settings :date_format => '%m/%d/%Y' do
127 assert_match "01/31/2010", show_detail(detail, true)
128 assert_match "01/01/2010", show_detail(detail, true)
129 end
130 end
131
132 test 'IssuesHelper#show_detail should show old and new values with a project attribute' do
133 detail = JournalDetail.new(:property => 'attr', :prop_key => 'project_id', :old_value => 1, :value => 2)
134 assert_match 'eCookbook', show_detail(detail, true)
135 assert_match 'OnlineStore', show_detail(detail, true)
136 end
137
138 test 'IssuesHelper#show_detail should show old and new values with a issue status attribute' do
139 detail = JournalDetail.new(:property => 'attr', :prop_key => 'status_id', :old_value => 1, :value => 2)
140 assert_match 'New', show_detail(detail, true)
141 assert_match 'Assigned', show_detail(detail, true)
142 end
143
144 test 'IssuesHelper#show_detail should show old and new values with a tracker attribute' do
145 detail = JournalDetail.new(:property => 'attr', :prop_key => 'tracker_id', :old_value => 1, :value => 2)
146 assert_match 'Bug', show_detail(detail, true)
147 assert_match 'Feature request', show_detail(detail, true)
148 end
149
150 test 'IssuesHelper#show_detail should show old and new values with a assigned to attribute' do
151 detail = JournalDetail.new(:property => 'attr', :prop_key => 'assigned_to_id', :old_value => 1, :value => 2)
152 assert_match 'Redmine Admin', show_detail(detail, true)
153 assert_match 'John Smith', show_detail(detail, true)
154 end
155
156 test 'IssuesHelper#show_detail should show old and new values with a priority attribute' do
157 detail = JournalDetail.new(:property => 'attr', :prop_key => 'priority_id', :old_value => 4, :value => 5)
158 assert_match 'Low', show_detail(detail, true)
159 assert_match 'Normal', show_detail(detail, true)
160 end
161
162 test 'IssuesHelper#show_detail should show old and new values with a category attribute' do
163 detail = JournalDetail.new(:property => 'attr', :prop_key => 'category_id', :old_value => 1, :value => 2)
164 assert_match 'Printing', show_detail(detail, true)
165 assert_match 'Recipes', show_detail(detail, true)
166 end
167
168 test 'IssuesHelper#show_detail should show old and new values with a fixed version attribute' do
169 detail = JournalDetail.new(:property => 'attr', :prop_key => 'fixed_version_id', :old_value => 1, :value => 2)
170 assert_match '0.1', show_detail(detail, true)
171 assert_match '1.0', show_detail(detail, true)
172 end
173
174 test 'IssuesHelper#show_detail should show old and new values with a estimated hours attribute' do
175 detail = JournalDetail.new(:property => 'attr', :prop_key => 'estimated_hours', :old_value => '5', :value => '6.3')
176 assert_match '5.00', show_detail(detail, true)
177 assert_match '6.30', show_detail(detail, true)
178 end
179
180 test 'IssuesHelper#show_detail should show old and new values with a custom field' do
181 detail = JournalDetail.new(:property => 'cf', :prop_key => '1', :old_value => 'MySQL', :value => 'PostgreSQL')
182 assert_equal 'Database changed from MySQL to PostgreSQL', show_detail(detail, true)
183 end
184
185 test 'IssuesHelper#show_detail should show added file' do
186 detail = JournalDetail.new(:property => 'attachment', :prop_key => '1', :old_value => nil, :value => 'error281.txt')
187 assert_match 'error281.txt', show_detail(detail, true)
188 end
189
190 test 'IssuesHelper#show_detail should show removed file' do
191 detail = JournalDetail.new(:property => 'attachment', :prop_key => '1', :old_value => 'error281.txt', :value => nil)
192 assert_match 'error281.txt', show_detail(detail, true)
193 end
227 end 194 end