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