##// END OF EJS Templates
Additional tests for IssuesHelper#show_detail....
Jean-Philippe Lang -
r9332:4598c64ebd6d
parent child
Show More
@@ -210,37 +210,6 class ActiveSupport::TestCase
210 end
210 end
211 end
211 end
212
212
213 def self.should_show_the_old_and_new_values_for(prop_key, model, &block)
214 context "" do
215 setup do
216 if block_given?
217 instance_eval &block
218 else
219 @old_value = model.generate!
220 @new_value = model.generate!
221 end
222 end
223
224 should "use the new value's name" do
225 @detail = JournalDetail.generate!(:property => 'attr',
226 :old_value => @old_value.id,
227 :value => @new_value.id,
228 :prop_key => prop_key)
229
230 assert_match @new_value.name, show_detail(@detail, true)
231 end
232
233 should "use the old value's name" do
234 @detail = JournalDetail.generate!(:property => 'attr',
235 :old_value => @old_value.id,
236 :value => @new_value.id,
237 :prop_key => prop_key)
238
239 assert_match @old_value.name, show_detail(@detail, true)
240 end
241 end
242 end
243
244 # Test that a request allows the three types of API authentication
213 # Test that a request allows the three types of API authentication
245 #
214 #
246 # * HTTP Basic with username and password
215 # * HTTP Basic with username and password
@@ -20,6 +20,7 require File.expand_path('../../../test_helper', __FILE__)
20 class IssuesHelperTest < ActionView::TestCase
20 class IssuesHelperTest < ActionView::TestCase
21 include ApplicationHelper
21 include ApplicationHelper
22 include IssuesHelper
22 include IssuesHelper
23 include CustomFieldsHelper
23 include ERB::Util
24 include ERB::Util
24
25
25 fixtures :projects, :trackers, :issue_statuses, :issues,
26 fixtures :projects, :trackers, :issue_statuses, :issues,
@@ -29,7 +30,9 class IssuesHelperTest < ActionView::TestCase
29 :member_roles,
30 :member_roles,
30 :members,
31 :members,
31 :enabled_modules,
32 :enabled_modules,
32 :workflows
33 :workflows,
34 :custom_fields,
35 :attachments
33
36
34 def setup
37 def setup
35 super
38 super
@@ -129,43 +132,67 class IssuesHelperTest < ActionView::TestCase
129 end
132 end
130 end
133 end
131
134
132 context "with a project attribute" do
135 should "show old and new values with a project attribute" do
133 should_show_the_old_and_new_values_for('project_id', Project)
136 detail = JournalDetail.generate!(:property => 'attr', :prop_key => 'project_id', :old_value => 1, :value => 2)
137 assert_match 'eCookbook', show_detail(detail, true)
138 assert_match 'OnlineStore', show_detail(detail, true)
134 end
139 end
135
140
136 context "with a issue status attribute" do
141 should "show old and new values with a issue status attribute" do
137 should_show_the_old_and_new_values_for('status_id', IssueStatus)
142 detail = JournalDetail.generate!(:property => 'attr', :prop_key => 'status_id', :old_value => 1, :value => 2)
143 assert_match 'New', show_detail(detail, true)
144 assert_match 'Assigned', show_detail(detail, true)
138 end
145 end
139
146
140 context "with a tracker attribute" do
147 should "show old and new values with a tracker attribute" do
141 should_show_the_old_and_new_values_for('tracker_id', Tracker)
148 detail = JournalDetail.generate!(:property => 'attr', :prop_key => 'tracker_id', :old_value => 1, :value => 2)
149 assert_match 'Bug', show_detail(detail, true)
150 assert_match 'Feature request', show_detail(detail, true)
142 end
151 end
143
152
144 context "with a assigned to attribute" do
153 should "show old and new values with a assigned to attribute" do
145 should_show_the_old_and_new_values_for('assigned_to_id', User)
154 detail = JournalDetail.generate!(:property => 'attr', :prop_key => 'assigned_to_id', :old_value => 1, :value => 2)
155 assert_match 'redMine Admin', show_detail(detail, true)
156 assert_match 'John Smith', show_detail(detail, true)
146 end
157 end
147
158
148 context "with a priority attribute" do
159 should "show old and new values with a priority attribute" do
149 should_show_the_old_and_new_values_for('priority_id', IssuePriority) do
160 detail = JournalDetail.generate!(:property => 'attr', :prop_key => 'priority_id', :old_value => 4, :value => 5)
150 @old_value = IssuePriority.generate!(:type => 'IssuePriority')
161 assert_match 'Low', show_detail(detail, true)
151 @new_value = IssuePriority.generate!(:type => 'IssuePriority')
162 assert_match 'Normal', show_detail(detail, true)
152 end
163 end
164
165 should "show old and new values with a category attribute" do
166 detail = JournalDetail.generate!(:property => 'attr', :prop_key => 'category_id', :old_value => 1, :value => 2)
167 assert_match 'Printing', show_detail(detail, true)
168 assert_match 'Recipes', show_detail(detail, true)
153 end
169 end
154
170
155 context "with a category attribute" do
171 should "show old and new values with a fixed version attribute" do
156 should_show_the_old_and_new_values_for('category_id', IssueCategory)
172 detail = JournalDetail.generate!(:property => 'attr', :prop_key => 'fixed_version_id', :old_value => 1, :value => 2)
173 assert_match '0.1', show_detail(detail, true)
174 assert_match '1.0', show_detail(detail, true)
157 end
175 end
158
176
159 context "with a fixed version attribute" do
177 should "show old and new values with a estimated hours attribute" do
160 should_show_the_old_and_new_values_for('fixed_version_id', Version)
178 detail = JournalDetail.generate!(:property => 'attr', :prop_key => 'estimated_hours', :old_value => '5', :value => '6.3')
179 assert_match '5.00', show_detail(detail, true)
180 assert_match '6.30', show_detail(detail, true)
161 end
181 end
162
182
163 context "with a estimated hours attribute" do
183 should "show old and new values with a custom field" do
164 should "format the time into two decimal places"
184 detail = JournalDetail.generate!(:property => 'cf', :prop_key => '1', :old_value => 'MySQL', :value => 'PostgreSQL')
165 should "format the old time into two decimal places"
185 assert_equal 'Database changed from MySQL to PostgreSQL', show_detail(detail, true)
166 end
186 end
167
187
168 should "test custom fields"
188 should "show added file" do
169 should "test attachments"
189 detail = JournalDetail.generate!(:property => 'attachment', :prop_key => '1', :old_value => nil, :value => 'error281.txt')
190 assert_match 'error281.txt', show_detail(detail, true)
191 end
192
193 should "show removed file" do
194 detail = JournalDetail.generate!(:property => 'attachment', :prop_key => '1', :old_value => 'error281.txt', :value => nil)
195 assert_match 'error281.txt', show_detail(detail, true)
196 end
170 end
197 end
171 end
198 end
General Comments 0
You need to be logged in to leave comments. Login now