@@ -210,37 +210,6 class ActiveSupport::TestCase | |||
|
210 | 210 | end |
|
211 | 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 | 213 | # Test that a request allows the three types of API authentication |
|
245 | 214 | # |
|
246 | 215 | # * HTTP Basic with username and password |
@@ -20,6 +20,7 require File.expand_path('../../../test_helper', __FILE__) | |||
|
20 | 20 | class IssuesHelperTest < ActionView::TestCase |
|
21 | 21 | include ApplicationHelper |
|
22 | 22 | include IssuesHelper |
|
23 | include CustomFieldsHelper | |
|
23 | 24 | include ERB::Util |
|
24 | 25 | |
|
25 | 26 | fixtures :projects, :trackers, :issue_statuses, :issues, |
@@ -29,7 +30,9 class IssuesHelperTest < ActionView::TestCase | |||
|
29 | 30 | :member_roles, |
|
30 | 31 | :members, |
|
31 | 32 | :enabled_modules, |
|
32 | :workflows | |
|
33 | :workflows, | |
|
34 | :custom_fields, | |
|
35 | :attachments | |
|
33 | 36 | |
|
34 | 37 | def setup |
|
35 | 38 | super |
@@ -129,43 +132,67 class IssuesHelperTest < ActionView::TestCase | |||
|
129 | 132 | end |
|
130 | 133 | end |
|
131 | 134 | |
|
132 |
|
|
|
133 | should_show_the_old_and_new_values_for('project_id', Project) | |
|
135 | should "show old and new values with a project attribute" do | |
|
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 | 139 | end |
|
135 | 140 | |
|
136 |
|
|
|
137 | should_show_the_old_and_new_values_for('status_id', IssueStatus) | |
|
141 | should "show old and new values with a issue status attribute" do | |
|
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 | 145 | end |
|
139 | 146 | |
|
140 |
|
|
|
141 | should_show_the_old_and_new_values_for('tracker_id', Tracker) | |
|
147 | should "show old and new values with a tracker attribute" do | |
|
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 | 151 | end |
|
143 | 152 | |
|
144 |
|
|
|
145 | should_show_the_old_and_new_values_for('assigned_to_id', User) | |
|
153 | should "show old and new values with a assigned to attribute" do | |
|
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 | 157 | end |
|
147 | 158 | |
|
148 |
|
|
|
149 | should_show_the_old_and_new_values_for('priority_id', IssuePriority) do | |
|
150 | @old_value = IssuePriority.generate!(:type => 'IssuePriority') | |
|
151 | @new_value = IssuePriority.generate!(:type => 'IssuePriority') | |
|
152 |
|
|
|
159 | should "show old and new values with a priority attribute" do | |
|
160 | detail = JournalDetail.generate!(:property => 'attr', :prop_key => 'priority_id', :old_value => 4, :value => 5) | |
|
161 | assert_match 'Low', show_detail(detail, true) | |
|
162 | assert_match 'Normal', show_detail(detail, true) | |
|
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 | 169 | end |
|
154 | 170 | |
|
155 | context "with a category attribute" do | |
|
156 | should_show_the_old_and_new_values_for('category_id', IssueCategory) | |
|
171 | should "show old and new values with a fixed version attribute" do | |
|
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 | 175 | end |
|
158 | 176 | |
|
159 | context "with a fixed version attribute" do | |
|
160 | should_show_the_old_and_new_values_for('fixed_version_id', Version) | |
|
177 | should "show old and new values with a estimated hours attribute" do | |
|
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 | 181 | end |
|
162 | 182 | |
|
163 | context "with a estimated hours attribute" do | |
|
164 | should "format the time into two decimal places" | |
|
165 | should "format the old time into two decimal places" | |
|
183 | should "show old and new values with a custom field" do | |
|
184 | detail = JournalDetail.generate!(:property => 'cf', :prop_key => '1', :old_value => 'MySQL', :value => 'PostgreSQL') | |
|
185 | assert_equal 'Database changed from MySQL to PostgreSQL', show_detail(detail, true) | |
|
166 | 186 | end |
|
167 | 187 | |
|
168 | should "test custom fields" | |
|
169 | should "test attachments" | |
|
188 | should "show added file" do | |
|
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 | 197 | end |
|
171 | 198 | end |
General Comments 0
You need to be logged in to leave comments.
Login now