@@ -1,182 +1,182 | |||
|
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 |
class IssuesHelperTest < |
|
|
20 | class IssuesHelperTest < HelperTestCase | |
|
21 | 21 | include ApplicationHelper |
|
22 | 22 | include IssuesHelper |
|
23 | 23 | |
|
24 | 24 | include ActionController::Assertions::SelectorAssertions |
|
25 | 25 | fixtures :all |
|
26 | 26 | |
|
27 | 27 | # Used by assert_select |
|
28 | 28 | def html_document |
|
29 | 29 | HTML::Document.new(@response.body) |
|
30 | 30 | end |
|
31 | 31 | |
|
32 | 32 | def setup |
|
33 | 33 | super |
|
34 | 34 | set_language_if_valid('en') |
|
35 | 35 | User.current = nil |
|
36 | 36 | @response = ActionController::TestResponse.new |
|
37 | 37 | end |
|
38 | 38 | |
|
39 | 39 | def controller |
|
40 | 40 | @controller ||= IssuesController.new |
|
41 | 41 | end |
|
42 | 42 | |
|
43 | 43 | def request |
|
44 | 44 | @request ||= ActionController::TestRequest.new |
|
45 | 45 | end |
|
46 | 46 | |
|
47 | 47 | def test_issue_heading |
|
48 | 48 | assert_equal "Bug #1", issue_heading(Issue.find(1)) |
|
49 | 49 | end |
|
50 | 50 | |
|
51 | 51 | def test_issues_destroy_confirmation_message_with_one_root_issue |
|
52 | 52 | assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find(1)) |
|
53 | 53 | end |
|
54 | 54 | |
|
55 | 55 | def test_issues_destroy_confirmation_message_with_an_arrayt_of_root_issues |
|
56 | 56 | assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find([1, 2])) |
|
57 | 57 | end |
|
58 | 58 | |
|
59 | 59 | def test_issues_destroy_confirmation_message_with_one_parent_issue |
|
60 | 60 | Issue.find(2).update_attribute :parent_issue_id, 1 |
|
61 | 61 | assert_equal l(:text_issues_destroy_confirmation) + "\n" + l(:text_issues_destroy_descendants_confirmation, :count => 1), |
|
62 | 62 | issues_destroy_confirmation_message(Issue.find(1)) |
|
63 | 63 | end |
|
64 | 64 | |
|
65 | 65 | def test_issues_destroy_confirmation_message_with_one_parent_issue_and_its_child |
|
66 | 66 | Issue.find(2).update_attribute :parent_issue_id, 1 |
|
67 | 67 | assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find([1, 2])) |
|
68 | 68 | end |
|
69 | 69 | |
|
70 | 70 | context "IssuesHelper#show_detail" do |
|
71 | 71 | context "with no_html" do |
|
72 | 72 | should 'show a changing attribute' do |
|
73 | 73 | @detail = JournalDetail.generate!(:property => 'attr', :old_value => '40', :value => '100', :prop_key => 'done_ratio') |
|
74 | 74 | assert_equal "% Done changed from 40 to 100", show_detail(@detail, true) |
|
75 | 75 | end |
|
76 | 76 | |
|
77 | 77 | should 'show a new attribute' do |
|
78 | 78 | @detail = JournalDetail.generate!(:property => 'attr', :old_value => nil, :value => '100', :prop_key => 'done_ratio') |
|
79 | 79 | assert_equal "% Done set to 100", show_detail(@detail, true) |
|
80 | 80 | end |
|
81 | 81 | |
|
82 | 82 | should 'show a deleted attribute' do |
|
83 | 83 | @detail = JournalDetail.generate!(:property => 'attr', :old_value => '50', :value => nil, :prop_key => 'done_ratio') |
|
84 | 84 | assert_equal "% Done deleted (50)", show_detail(@detail, true) |
|
85 | 85 | end |
|
86 | 86 | end |
|
87 | 87 | |
|
88 | 88 | context "with html" do |
|
89 | 89 | should 'show a changing attribute with HTML highlights' do |
|
90 | 90 | @detail = JournalDetail.generate!(:property => 'attr', :old_value => '40', :value => '100', :prop_key => 'done_ratio') |
|
91 | 91 | @response.body = show_detail(@detail, false) |
|
92 | 92 | |
|
93 | 93 | assert_select 'strong', :text => '% Done' |
|
94 | 94 | assert_select 'i', :text => '40' |
|
95 | 95 | assert_select 'i', :text => '100' |
|
96 | 96 | end |
|
97 | 97 | |
|
98 | 98 | should 'show a new attribute with HTML highlights' do |
|
99 | 99 | @detail = JournalDetail.generate!(:property => 'attr', :old_value => nil, :value => '100', :prop_key => 'done_ratio') |
|
100 | 100 | @response.body = show_detail(@detail, false) |
|
101 | 101 | |
|
102 | 102 | assert_select 'strong', :text => '% Done' |
|
103 | 103 | assert_select 'i', :text => '100' |
|
104 | 104 | end |
|
105 | 105 | |
|
106 | 106 | should 'show a deleted attribute with HTML highlights' do |
|
107 | 107 | @detail = JournalDetail.generate!(:property => 'attr', :old_value => '50', :value => nil, :prop_key => 'done_ratio') |
|
108 | 108 | @response.body = show_detail(@detail, false) |
|
109 | 109 | |
|
110 | 110 | assert_select 'strong', :text => '% Done' |
|
111 | 111 | assert_select 'strike' do |
|
112 | 112 | assert_select 'i', :text => '50' |
|
113 | 113 | end |
|
114 | 114 | end |
|
115 | 115 | end |
|
116 | 116 | |
|
117 | 117 | context "with a start_date attribute" do |
|
118 | 118 | should "format the current date" do |
|
119 | 119 | @detail = JournalDetail.generate!(:property => 'attr', :old_value => '2010-01-01', :value => '2010-01-31', :prop_key => 'start_date') |
|
120 | 120 | assert_match "01/31/2010", show_detail(@detail, true) |
|
121 | 121 | end |
|
122 | 122 | |
|
123 | 123 | should "format the old date" do |
|
124 | 124 | @detail = JournalDetail.generate!(:property => 'attr', :old_value => '2010-01-01', :value => '2010-01-31', :prop_key => 'start_date') |
|
125 | 125 | assert_match "01/01/2010", show_detail(@detail, true) |
|
126 | 126 | end |
|
127 | 127 | end |
|
128 | 128 | |
|
129 | 129 | context "with a due_date attribute" do |
|
130 | 130 | should "format the current date" do |
|
131 | 131 | @detail = JournalDetail.generate!(:property => 'attr', :old_value => '2010-01-01', :value => '2010-01-31', :prop_key => 'due_date') |
|
132 | 132 | assert_match "01/31/2010", show_detail(@detail, true) |
|
133 | 133 | end |
|
134 | 134 | |
|
135 | 135 | should "format the old date" do |
|
136 | 136 | @detail = JournalDetail.generate!(:property => 'attr', :old_value => '2010-01-01', :value => '2010-01-31', :prop_key => 'due_date') |
|
137 | 137 | assert_match "01/01/2010", show_detail(@detail, true) |
|
138 | 138 | end |
|
139 | 139 | end |
|
140 | 140 | |
|
141 | 141 | context "with a project attribute" do |
|
142 | 142 | should_show_the_old_and_new_values_for('project_id', Project) |
|
143 | 143 | end |
|
144 | 144 | |
|
145 | 145 | context "with a issue status attribute" do |
|
146 | 146 | should_show_the_old_and_new_values_for('status_id', IssueStatus) |
|
147 | 147 | end |
|
148 | 148 | |
|
149 | 149 | context "with a tracker attribute" do |
|
150 | 150 | should_show_the_old_and_new_values_for('tracker_id', Tracker) |
|
151 | 151 | end |
|
152 | 152 | |
|
153 | 153 | context "with a assigned to attribute" do |
|
154 | 154 | should_show_the_old_and_new_values_for('assigned_to_id', User) |
|
155 | 155 | end |
|
156 | 156 | |
|
157 | 157 | context "with a priority attribute" do |
|
158 | 158 | should_show_the_old_and_new_values_for('priority_id', IssuePriority) do |
|
159 | 159 | @old_value = IssuePriority.generate!(:type => 'IssuePriority') |
|
160 | 160 | @new_value = IssuePriority.generate!(:type => 'IssuePriority') |
|
161 | 161 | end |
|
162 | 162 | end |
|
163 | 163 | |
|
164 | 164 | context "with a category attribute" do |
|
165 | 165 | should_show_the_old_and_new_values_for('category_id', IssueCategory) |
|
166 | 166 | end |
|
167 | 167 | |
|
168 | 168 | context "with a fixed version attribute" do |
|
169 | 169 | should_show_the_old_and_new_values_for('fixed_version_id', Version) |
|
170 | 170 | end |
|
171 | 171 | |
|
172 | 172 | context "with a estimated hours attribute" do |
|
173 | 173 | should "format the time into two decimal places" |
|
174 | 174 | should "format the old time into two decimal places" |
|
175 | 175 | end |
|
176 | 176 | |
|
177 | 177 | should "test custom fields" |
|
178 | 178 | should "test attachments" |
|
179 | 179 | |
|
180 | 180 | end |
|
181 | 181 | |
|
182 | 182 | end |
General Comments 0
You need to be logged in to leave comments.
Login now