Chris@0
|
1 # Redmine - project management software
|
Chris@441
|
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
|
Chris@0
|
3 #
|
Chris@0
|
4 # This program is free software; you can redistribute it and/or
|
Chris@0
|
5 # modify it under the terms of the GNU General Public License
|
Chris@0
|
6 # as published by the Free Software Foundation; either version 2
|
Chris@0
|
7 # of the License, or (at your option) any later version.
|
Chris@441
|
8 #
|
Chris@0
|
9 # This program is distributed in the hope that it will be useful,
|
Chris@0
|
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
Chris@0
|
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
Chris@0
|
12 # GNU General Public License for more details.
|
Chris@441
|
13 #
|
Chris@0
|
14 # You should have received a copy of the GNU General Public License
|
Chris@0
|
15 # along with this program; if not, write to the Free Software
|
Chris@0
|
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
Chris@0
|
17
|
Chris@119
|
18 require File.expand_path('../../../test_helper', __FILE__)
|
Chris@0
|
19
|
Chris@0
|
20 class IssuesHelperTest < HelperTestCase
|
Chris@0
|
21 include ApplicationHelper
|
Chris@0
|
22 include IssuesHelper
|
Chris@0
|
23
|
Chris@0
|
24 include ActionController::Assertions::SelectorAssertions
|
Chris@0
|
25 fixtures :all
|
Chris@0
|
26
|
Chris@0
|
27 # Used by assert_select
|
Chris@0
|
28 def html_document
|
Chris@0
|
29 HTML::Document.new(@response.body)
|
Chris@0
|
30 end
|
Chris@0
|
31
|
Chris@0
|
32 def setup
|
Chris@0
|
33 super
|
Chris@0
|
34 set_language_if_valid('en')
|
Chris@0
|
35 User.current = nil
|
Chris@0
|
36 @response = ActionController::TestResponse.new
|
Chris@0
|
37 end
|
Chris@0
|
38
|
Chris@0
|
39 def controller
|
Chris@0
|
40 @controller ||= IssuesController.new
|
Chris@0
|
41 end
|
Chris@0
|
42
|
Chris@0
|
43 def request
|
Chris@0
|
44 @request ||= ActionController::TestRequest.new
|
Chris@0
|
45 end
|
Chris@0
|
46
|
Chris@441
|
47 def test_issue_heading
|
Chris@441
|
48 assert_equal "Bug #1", issue_heading(Issue.find(1))
|
Chris@441
|
49 end
|
Chris@441
|
50
|
Chris@441
|
51 def test_issues_destroy_confirmation_message_with_one_root_issue
|
Chris@441
|
52 assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find(1))
|
Chris@441
|
53 end
|
Chris@441
|
54
|
Chris@441
|
55 def test_issues_destroy_confirmation_message_with_an_arrayt_of_root_issues
|
Chris@441
|
56 assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find([1, 2]))
|
Chris@441
|
57 end
|
Chris@441
|
58
|
Chris@441
|
59 def test_issues_destroy_confirmation_message_with_one_parent_issue
|
Chris@441
|
60 Issue.find(2).update_attribute :parent_issue_id, 1
|
Chris@441
|
61 assert_equal l(:text_issues_destroy_confirmation) + "\n" + l(:text_issues_destroy_descendants_confirmation, :count => 1),
|
Chris@441
|
62 issues_destroy_confirmation_message(Issue.find(1))
|
Chris@441
|
63 end
|
Chris@441
|
64
|
Chris@441
|
65 def test_issues_destroy_confirmation_message_with_one_parent_issue_and_its_child
|
Chris@441
|
66 Issue.find(2).update_attribute :parent_issue_id, 1
|
Chris@441
|
67 assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find([1, 2]))
|
Chris@441
|
68 end
|
Chris@441
|
69
|
Chris@0
|
70 context "IssuesHelper#show_detail" do
|
Chris@0
|
71 context "with no_html" do
|
Chris@0
|
72 should 'show a changing attribute' do
|
Chris@0
|
73 @detail = JournalDetail.generate!(:property => 'attr', :old_value => '40', :value => '100', :prop_key => 'done_ratio')
|
Chris@0
|
74 assert_equal "% Done changed from 40 to 100", show_detail(@detail, true)
|
Chris@0
|
75 end
|
Chris@0
|
76
|
Chris@0
|
77 should 'show a new attribute' do
|
Chris@0
|
78 @detail = JournalDetail.generate!(:property => 'attr', :old_value => nil, :value => '100', :prop_key => 'done_ratio')
|
Chris@0
|
79 assert_equal "% Done set to 100", show_detail(@detail, true)
|
Chris@0
|
80 end
|
Chris@0
|
81
|
Chris@0
|
82 should 'show a deleted attribute' do
|
Chris@0
|
83 @detail = JournalDetail.generate!(:property => 'attr', :old_value => '50', :value => nil, :prop_key => 'done_ratio')
|
Chris@0
|
84 assert_equal "% Done deleted (50)", show_detail(@detail, true)
|
Chris@0
|
85 end
|
Chris@0
|
86 end
|
Chris@0
|
87
|
Chris@0
|
88 context "with html" do
|
Chris@0
|
89 should 'show a changing attribute with HTML highlights' do
|
Chris@0
|
90 @detail = JournalDetail.generate!(:property => 'attr', :old_value => '40', :value => '100', :prop_key => 'done_ratio')
|
Chris@0
|
91 @response.body = show_detail(@detail, false)
|
Chris@0
|
92
|
Chris@0
|
93 assert_select 'strong', :text => '% Done'
|
Chris@0
|
94 assert_select 'i', :text => '40'
|
Chris@0
|
95 assert_select 'i', :text => '100'
|
Chris@0
|
96 end
|
Chris@0
|
97
|
Chris@0
|
98 should 'show a new attribute with HTML highlights' do
|
Chris@0
|
99 @detail = JournalDetail.generate!(:property => 'attr', :old_value => nil, :value => '100', :prop_key => 'done_ratio')
|
Chris@0
|
100 @response.body = show_detail(@detail, false)
|
Chris@0
|
101
|
Chris@0
|
102 assert_select 'strong', :text => '% Done'
|
Chris@0
|
103 assert_select 'i', :text => '100'
|
Chris@0
|
104 end
|
Chris@0
|
105
|
Chris@0
|
106 should 'show a deleted attribute with HTML highlights' do
|
Chris@0
|
107 @detail = JournalDetail.generate!(:property => 'attr', :old_value => '50', :value => nil, :prop_key => 'done_ratio')
|
Chris@0
|
108 @response.body = show_detail(@detail, false)
|
Chris@0
|
109
|
Chris@0
|
110 assert_select 'strong', :text => '% Done'
|
Chris@0
|
111 assert_select 'strike' do
|
Chris@0
|
112 assert_select 'i', :text => '50'
|
Chris@0
|
113 end
|
Chris@0
|
114 end
|
Chris@0
|
115 end
|
Chris@0
|
116
|
Chris@0
|
117 context "with a start_date attribute" do
|
Chris@0
|
118 should "format the current date" do
|
Chris@0
|
119 @detail = JournalDetail.generate!(:property => 'attr', :old_value => '2010-01-01', :value => '2010-01-31', :prop_key => 'start_date')
|
Chris@0
|
120 assert_match "01/31/2010", show_detail(@detail, true)
|
Chris@0
|
121 end
|
Chris@0
|
122
|
Chris@0
|
123 should "format the old date" do
|
Chris@0
|
124 @detail = JournalDetail.generate!(:property => 'attr', :old_value => '2010-01-01', :value => '2010-01-31', :prop_key => 'start_date')
|
Chris@0
|
125 assert_match "01/01/2010", show_detail(@detail, true)
|
Chris@0
|
126 end
|
Chris@0
|
127 end
|
Chris@0
|
128
|
Chris@0
|
129 context "with a due_date attribute" do
|
Chris@0
|
130 should "format the current date" do
|
Chris@0
|
131 @detail = JournalDetail.generate!(:property => 'attr', :old_value => '2010-01-01', :value => '2010-01-31', :prop_key => 'due_date')
|
Chris@0
|
132 assert_match "01/31/2010", show_detail(@detail, true)
|
Chris@0
|
133 end
|
Chris@0
|
134
|
Chris@0
|
135 should "format the old date" do
|
Chris@0
|
136 @detail = JournalDetail.generate!(:property => 'attr', :old_value => '2010-01-01', :value => '2010-01-31', :prop_key => 'due_date')
|
Chris@0
|
137 assert_match "01/01/2010", show_detail(@detail, true)
|
Chris@0
|
138 end
|
Chris@0
|
139 end
|
Chris@0
|
140
|
Chris@0
|
141 context "with a project attribute" do
|
Chris@0
|
142 should_show_the_old_and_new_values_for('project_id', Project)
|
Chris@0
|
143 end
|
Chris@0
|
144
|
Chris@0
|
145 context "with a issue status attribute" do
|
Chris@0
|
146 should_show_the_old_and_new_values_for('status_id', IssueStatus)
|
Chris@0
|
147 end
|
Chris@0
|
148
|
Chris@0
|
149 context "with a tracker attribute" do
|
Chris@0
|
150 should_show_the_old_and_new_values_for('tracker_id', Tracker)
|
Chris@0
|
151 end
|
Chris@0
|
152
|
Chris@0
|
153 context "with a assigned to attribute" do
|
Chris@0
|
154 should_show_the_old_and_new_values_for('assigned_to_id', User)
|
Chris@0
|
155 end
|
Chris@0
|
156
|
Chris@0
|
157 context "with a priority attribute" do
|
Chris@0
|
158 should_show_the_old_and_new_values_for('priority_id', IssuePriority) do
|
Chris@0
|
159 @old_value = IssuePriority.generate!(:type => 'IssuePriority')
|
Chris@0
|
160 @new_value = IssuePriority.generate!(:type => 'IssuePriority')
|
Chris@0
|
161 end
|
Chris@0
|
162 end
|
Chris@0
|
163
|
Chris@0
|
164 context "with a category attribute" do
|
Chris@0
|
165 should_show_the_old_and_new_values_for('category_id', IssueCategory)
|
Chris@0
|
166 end
|
Chris@0
|
167
|
Chris@0
|
168 context "with a fixed version attribute" do
|
Chris@0
|
169 should_show_the_old_and_new_values_for('fixed_version_id', Version)
|
Chris@0
|
170 end
|
Chris@0
|
171
|
Chris@0
|
172 context "with a estimated hours attribute" do
|
Chris@0
|
173 should "format the time into two decimal places"
|
Chris@0
|
174 should "format the old time into two decimal places"
|
Chris@0
|
175 end
|
Chris@0
|
176
|
Chris@0
|
177 should "test custom fields"
|
Chris@0
|
178 should "test attachments"
|
Chris@0
|
179
|
Chris@0
|
180 end
|
Chris@0
|
181
|
Chris@0
|
182 end
|