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