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