##// END OF EJS Templates
Merged r10253, r10257, r10263 and r10264 from trunk to 1.4-stable...
Toshi MARUYAMA -
r10083:5d3bdb66cd8b
parent child
Show More
@@ -1,171 +1,195
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 ERB::Util
24 24
25 25 fixtures :projects, :trackers, :issue_statuses, :issues,
26 26 :enumerations, :users, :issue_categories,
27 27 :projects_trackers,
28 28 :roles,
29 29 :member_roles,
30 30 :members,
31 31 :enabled_modules,
32 32 :workflows
33 33
34 34 def setup
35 35 super
36 36 set_language_if_valid('en')
37 37 User.current = nil
38 38 end
39 39
40 40 def test_issue_heading
41 41 assert_equal "Bug #1", issue_heading(Issue.find(1))
42 42 end
43 43
44 44 def test_issues_destroy_confirmation_message_with_one_root_issue
45 45 assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find(1))
46 46 end
47 47
48 48 def test_issues_destroy_confirmation_message_with_an_arrayt_of_root_issues
49 49 assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find([1, 2]))
50 50 end
51 51
52 52 def test_issues_destroy_confirmation_message_with_one_parent_issue
53 53 Issue.find(2).update_attribute :parent_issue_id, 1
54 54 assert_equal l(:text_issues_destroy_confirmation) + "\n" + l(:text_issues_destroy_descendants_confirmation, :count => 1),
55 55 issues_destroy_confirmation_message(Issue.find(1))
56 56 end
57 57
58 58 def test_issues_destroy_confirmation_message_with_one_parent_issue_and_its_child
59 59 Issue.find(2).update_attribute :parent_issue_id, 1
60 60 assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find([1, 2]))
61 61 end
62 62
63 63 context "IssuesHelper#show_detail" do
64 64 context "with no_html" do
65 65 should 'show a changing attribute' do
66 66 @detail = JournalDetail.new(:property => 'attr', :old_value => '40', :value => '100', :prop_key => 'done_ratio')
67 67 assert_equal "% Done changed from 40 to 100", show_detail(@detail, true)
68 68 end
69 69
70 70 should 'show a new attribute' do
71 71 @detail = JournalDetail.new(:property => 'attr', :old_value => nil, :value => '100', :prop_key => 'done_ratio')
72 72 assert_equal "% Done set to 100", show_detail(@detail, true)
73 73 end
74 74
75 75 should 'show a deleted attribute' do
76 76 @detail = JournalDetail.new(:property => 'attr', :old_value => '50', :value => nil, :prop_key => 'done_ratio')
77 77 assert_equal "% Done deleted (50)", show_detail(@detail, true)
78 78 end
79 79 end
80 80
81 81 context "with html" do
82 82 should 'show a changing attribute with HTML highlights' do
83 83 @detail = JournalDetail.new(:property => 'attr', :old_value => '40', :value => '100', :prop_key => 'done_ratio')
84 84 html = show_detail(@detail, false)
85 85
86 86 assert_include '<strong>% Done</strong>', html
87 87 assert_include '<i>40</i>', html
88 88 assert_include '<i>100</i>', html
89 89 end
90 90
91 91 should 'show a new attribute with HTML highlights' do
92 92 @detail = JournalDetail.new(:property => 'attr', :old_value => nil, :value => '100', :prop_key => 'done_ratio')
93 93 html = show_detail(@detail, false)
94 94
95 95 assert_include '<strong>% Done</strong>', html
96 96 assert_include '<i>100</i>', html
97 97 end
98 98
99 99 should 'show a deleted attribute with HTML highlights' do
100 100 @detail = JournalDetail.new(:property => 'attr', :old_value => '50', :value => nil, :prop_key => 'done_ratio')
101 101 html = show_detail(@detail, false)
102 102
103 103 assert_include '<strong>% Done</strong>', html
104 104 assert_include '<strike><i>50</i></strike>', html
105 105 end
106 106 end
107 107
108 context "with a start_date attribute" do
109 should "format the current date" do
110 @detail = JournalDetail.new(:property => 'attr', :old_value => '2010-01-01', :value => '2010-01-31', :prop_key => 'start_date')
108 def test_with_a_start_date_attribute_should_format_the_current_date
109 @detail = JournalDetail.new(
110 :property => 'attr',
111 :old_value => '2010-01-01',
112 :value => '2010-01-31',
113 :prop_key => 'start_date'
114 )
115 with_settings :date_format => '%m/%d/%Y' do
111 116 assert_match "01/31/2010", show_detail(@detail, true)
112 117 end
118 end
113 119
114 should "format the old date" do
115 @detail = JournalDetail.new(:property => 'attr', :old_value => '2010-01-01', :value => '2010-01-31', :prop_key => 'start_date')
120 def test_with_a_start_date_attribute_should_format_the_old_date
121 @detail = JournalDetail.new(
122 :property => 'attr',
123 :old_value => '2010-01-01',
124 :value => '2010-01-31',
125 :prop_key => 'start_date'
126 )
127 with_settings :date_format => '%m/%d/%Y' do
116 128 assert_match "01/01/2010", show_detail(@detail, true)
117 129 end
118 130 end
119 131
120 context "with a due_date attribute" do
121 should "format the current date" do
122 @detail = JournalDetail.new(:property => 'attr', :old_value => '2010-01-01', :value => '2010-01-31', :prop_key => 'due_date')
132 def test_with_a_due_date_attribute_should_with_a_due_date_attribute
133 @detail = JournalDetail.new(
134 :property => 'attr',
135 :old_value => '2010-01-01',
136 :value => '2010-01-31',
137 :prop_key => 'due_date'
138 )
139 with_settings :date_format => '%m/%d/%Y' do
123 140 assert_match "01/31/2010", show_detail(@detail, true)
124 141 end
142 end
125 143
126 should "format the old date" do
127 @detail = JournalDetail.new(:property => 'attr', :old_value => '2010-01-01', :value => '2010-01-31', :prop_key => 'due_date')
144 def test_with_a_due_date_attribute_should_format_the_old_date
145 @detail = JournalDetail.new(
146 :property => 'attr',
147 :old_value => '2010-01-01',
148 :value => '2010-01-31',
149 :prop_key => 'due_date'
150 )
151 with_settings :date_format => '%m/%d/%Y' do
128 152 assert_match "01/01/2010", show_detail(@detail, true)
129 153 end
130 154 end
131 155
132 156 context "with a project attribute" do
133 157 should_show_the_old_and_new_values_for('project_id', Project)
134 158 end
135 159
136 160 context "with a issue status attribute" do
137 161 should_show_the_old_and_new_values_for('status_id', IssueStatus)
138 162 end
139 163
140 164 context "with a tracker attribute" do
141 165 should_show_the_old_and_new_values_for('tracker_id', Tracker)
142 166 end
143 167
144 168 context "with a assigned to attribute" do
145 169 should_show_the_old_and_new_values_for('assigned_to_id', User)
146 170 end
147 171
148 172 context "with a priority attribute" do
149 173 should_show_the_old_and_new_values_for('priority_id', IssuePriority) do
150 174 @old_value = IssuePriority.generate!(:type => 'IssuePriority')
151 175 @new_value = IssuePriority.generate!(:type => 'IssuePriority')
152 176 end
153 177 end
154 178
155 179 context "with a category attribute" do
156 180 should_show_the_old_and_new_values_for('category_id', IssueCategory)
157 181 end
158 182
159 183 context "with a fixed version attribute" do
160 184 should_show_the_old_and_new_values_for('fixed_version_id', Version)
161 185 end
162 186
163 187 context "with a estimated hours attribute" do
164 188 should "format the time into two decimal places"
165 189 should "format the old time into two decimal places"
166 190 end
167 191
168 192 should "test custom fields"
169 193 should "test attachments"
170 194 end
171 195 end
General Comments 0
You need to be logged in to leave comments. Login now