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