Mercurial > hg > soundsoftware-site
comparison .svn/pristine/69/69209f3722ef1c32ee917d4039ec4d55989dd5fc.svn-base @ 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 | |
2 # Copyright (C) 2006-2013 Jean-Philippe Lang | |
3 # | |
4 # This program is free software; you can redistribute it and/or | |
5 # modify it under the terms of the GNU General Public License | |
6 # as published by the Free Software Foundation; either version 2 | |
7 # of the License, or (at your option) any later version. | |
8 # | |
9 # This program is distributed in the hope that it will be useful, | |
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 # GNU General Public License for more details. | |
13 # | |
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 | |
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 | |
18 require File.expand_path('../../../test_helper', __FILE__) | |
19 | |
20 class IssuesHelperTest < ActionView::TestCase | |
21 include ApplicationHelper | |
22 include IssuesHelper | |
23 include CustomFieldsHelper | |
24 include ERB::Util | |
25 | |
26 fixtures :projects, :trackers, :issue_statuses, :issues, | |
27 :enumerations, :users, :issue_categories, | |
28 :projects_trackers, | |
29 :roles, | |
30 :member_roles, | |
31 :members, | |
32 :enabled_modules, | |
33 :custom_fields, | |
34 :attachments, | |
35 :versions | |
36 | |
37 def setup | |
38 super | |
39 set_language_if_valid('en') | |
40 User.current = nil | |
41 end | |
42 | |
43 def test_issue_heading | |
44 assert_equal "Bug #1", issue_heading(Issue.find(1)) | |
45 end | |
46 | |
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)) | |
49 end | |
50 | |
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])) | |
53 end | |
54 | |
55 def test_issues_destroy_confirmation_message_with_one_parent_issue | |
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), | |
58 issues_destroy_confirmation_message(Issue.find(1)) | |
59 end | |
60 | |
61 def test_issues_destroy_confirmation_message_with_one_parent_issue_and_its_child | |
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])) | |
64 end | |
65 | |
66 test 'IssuesHelper#show_detail with no_html should show a changing attribute' do | |
67 detail = JournalDetail.new(:property => 'attr', :old_value => '40', :value => '100', :prop_key => 'done_ratio') | |
68 assert_equal "% Done changed from 40 to 100", show_detail(detail, true) | |
69 end | |
70 | |
71 test 'IssuesHelper#show_detail with no_html should show a new attribute' do | |
72 detail = JournalDetail.new(:property => 'attr', :old_value => nil, :value => '100', :prop_key => 'done_ratio') | |
73 assert_equal "% Done set to 100", show_detail(detail, true) | |
74 end | |
75 | |
76 test 'IssuesHelper#show_detail with no_html should show a deleted attribute' do | |
77 detail = JournalDetail.new(:property => 'attr', :old_value => '50', :value => nil, :prop_key => 'done_ratio') | |
78 assert_equal "% Done deleted (50)", show_detail(detail, true) | |
79 end | |
80 | |
81 test 'IssuesHelper#show_detail with html should show a changing attribute with HTML highlights' do | |
82 detail = JournalDetail.new(:property => 'attr', :old_value => '40', :value => '100', :prop_key => 'done_ratio') | |
83 html = show_detail(detail, false) | |
84 | |
85 assert_include '<strong>% Done</strong>', html | |
86 assert_include '<i>40</i>', html | |
87 assert_include '<i>100</i>', html | |
88 end | |
89 | |
90 test 'IssuesHelper#show_detail with html should show a new attribute with HTML highlights' do | |
91 detail = JournalDetail.new(:property => 'attr', :old_value => nil, :value => '100', :prop_key => 'done_ratio') | |
92 html = show_detail(detail, false) | |
93 | |
94 assert_include '<strong>% Done</strong>', html | |
95 assert_include '<i>100</i>', html | |
96 end | |
97 | |
98 test 'IssuesHelper#show_detail with html should show a deleted attribute with HTML highlights' do | |
99 detail = JournalDetail.new(:property => 'attr', :old_value => '50', :value => nil, :prop_key => 'done_ratio') | |
100 html = show_detail(detail, false) | |
101 | |
102 assert_include '<strong>% Done</strong>', html | |
103 assert_include '<del><i>50</i></del>', html | |
104 end | |
105 | |
106 test 'IssuesHelper#show_detail with a start_date attribute should format the dates' do | |
107 detail = JournalDetail.new( | |
108 :property => 'attr', | |
109 :old_value => '2010-01-01', | |
110 :value => '2010-01-31', | |
111 :prop_key => 'start_date' | |
112 ) | |
113 with_settings :date_format => '%m/%d/%Y' do | |
114 assert_match "01/31/2010", show_detail(detail, true) | |
115 assert_match "01/01/2010", show_detail(detail, true) | |
116 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 | |
194 end |