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