@@ -64,164 +64,132 class IssuesHelperTest < ActionView::TestCase | |||
|
64 | 64 | assert_equal l(:text_issues_destroy_confirmation), issues_destroy_confirmation_message(Issue.find([1, 2])) |
|
65 | 65 | end |
|
66 | 66 | |
|
67 | context "IssuesHelper#show_detail" do | |
|
68 | context "with no_html" do | |
|
69 | should 'show a changing attribute' do | |
|
70 | @detail = JournalDetail.new(:property => 'attr', :old_value => '40', :value => '100', :prop_key => 'done_ratio') | |
|
71 | assert_equal "% Done changed from 40 to 100", show_detail(@detail, true) | |
|
72 | end | |
|
73 | ||
|
74 | should 'show a new attribute' do | |
|
75 | @detail = JournalDetail.new(:property => 'attr', :old_value => nil, :value => '100', :prop_key => 'done_ratio') | |
|
76 | assert_equal "% Done set to 100", show_detail(@detail, true) | |
|
77 | end | |
|
78 | ||
|
79 | should 'show a deleted attribute' do | |
|
80 | @detail = JournalDetail.new(:property => 'attr', :old_value => '50', :value => nil, :prop_key => 'done_ratio') | |
|
81 | assert_equal "% Done deleted (50)", show_detail(@detail, true) | |
|
82 | end | |
|
83 | end | |
|
67 | test 'IssuesHelper#show_detail with no_html should show a changing attribute' do | |
|
68 | detail = JournalDetail.new(:property => 'attr', :old_value => '40', :value => '100', :prop_key => 'done_ratio') | |
|
69 | assert_equal "% Done changed from 40 to 100", show_detail(detail, true) | |
|
70 | end | |
|
84 | 71 | |
|
85 | context "with html" do | |
|
86 | should 'show a changing attribute with HTML highlights' do | |
|
87 | @detail = JournalDetail.new(:property => 'attr', :old_value => '40', :value => '100', :prop_key => 'done_ratio') | |
|
88 | html = show_detail(@detail, false) | |
|
72 | test 'IssuesHelper#show_detail with no_html should show a new attribute' do | |
|
73 | detail = JournalDetail.new(:property => 'attr', :old_value => nil, :value => '100', :prop_key => 'done_ratio') | |
|
74 | assert_equal "% Done set to 100", show_detail(detail, true) | |
|
75 | end | |
|
89 | 76 | |
|
90 | assert_include '<strong>% Done</strong>', html | |
|
91 | assert_include '<i>40</i>', html | |
|
92 | assert_include '<i>100</i>', html | |
|
93 |
|
|
|
77 | test 'IssuesHelper#show_detail with no_html should show a deleted attribute' do | |
|
78 | detail = JournalDetail.new(:property => 'attr', :old_value => '50', :value => nil, :prop_key => 'done_ratio') | |
|
79 | assert_equal "% Done deleted (50)", show_detail(detail, true) | |
|
80 | end | |
|
94 | 81 | |
|
95 |
|
|
|
96 |
|
|
|
97 |
|
|
|
82 | test 'IssuesHelper#show_detail with html should show a changing attribute with HTML highlights' do | |
|
83 | detail = JournalDetail.new(:property => 'attr', :old_value => '40', :value => '100', :prop_key => 'done_ratio') | |
|
84 | html = show_detail(detail, false) | |
|
98 | 85 | |
|
99 |
|
|
|
100 |
|
|
|
101 | end | |
|
86 | assert_include '<strong>% Done</strong>', html | |
|
87 | assert_include '<i>40</i>', html | |
|
88 | assert_include '<i>100</i>', html | |
|
89 | end | |
|
102 | 90 | |
|
103 |
|
|
|
104 |
|
|
|
105 |
|
|
|
91 | test 'IssuesHelper#show_detail with html should show a new attribute with HTML highlights' do | |
|
92 | detail = JournalDetail.new(:property => 'attr', :old_value => nil, :value => '100', :prop_key => 'done_ratio') | |
|
93 | html = show_detail(detail, false) | |
|
106 | 94 | |
|
107 |
|
|
|
108 |
|
|
|
109 |
|
|
|
110 | end | |
|
95 | assert_include '<strong>% Done</strong>', html | |
|
96 | assert_include '<i>100</i>', html | |
|
97 | end | |
|
111 | 98 | |
|
112 | context "with a start_date attribute" do | |
|
113 | should "format the current date" do | |
|
114 | @detail = JournalDetail.new( | |
|
115 | :property => 'attr', | |
|
116 | :old_value => '2010-01-01', | |
|
117 | :value => '2010-01-31', | |
|
118 | :prop_key => 'start_date' | |
|
119 | ) | |
|
120 | with_settings :date_format => '%m/%d/%Y' do | |
|
121 | assert_match "01/31/2010", show_detail(@detail, true) | |
|
122 | end | |
|
123 | end | |
|
124 | ||
|
125 | should "format the old date" do | |
|
126 | @detail = JournalDetail.new( | |
|
127 | :property => 'attr', | |
|
128 | :old_value => '2010-01-01', | |
|
129 | :value => '2010-01-31', | |
|
130 | :prop_key => 'start_date' | |
|
131 | ) | |
|
132 | with_settings :date_format => '%m/%d/%Y' do | |
|
133 | assert_match "01/01/2010", show_detail(@detail, true) | |
|
134 | end | |
|
135 | end | |
|
136 | end | |
|
99 | test 'IssuesHelper#show_detail with html should show a deleted attribute with HTML highlights' do | |
|
100 | detail = JournalDetail.new(:property => 'attr', :old_value => '50', :value => nil, :prop_key => 'done_ratio') | |
|
101 | html = show_detail(detail, false) | |
|
137 | 102 | |
|
138 | context "with a due_date attribute" do | |
|
139 | should "format the current date" do | |
|
140 | @detail = JournalDetail.new( | |
|
141 | :property => 'attr', | |
|
142 | :old_value => '2010-01-01', | |
|
143 | :value => '2010-01-31', | |
|
144 | :prop_key => 'due_date' | |
|
145 | ) | |
|
146 | with_settings :date_format => '%m/%d/%Y' do | |
|
147 | assert_match "01/31/2010", show_detail(@detail, true) | |
|
148 | end | |
|
149 | end | |
|
150 | ||
|
151 | should "format the old date" do | |
|
152 | @detail = JournalDetail.new( | |
|
153 | :property => 'attr', | |
|
154 | :old_value => '2010-01-01', | |
|
155 | :value => '2010-01-31', | |
|
156 | :prop_key => 'due_date' | |
|
157 | ) | |
|
158 | with_settings :date_format => '%m/%d/%Y' do | |
|
159 | assert_match "01/01/2010", show_detail(@detail, true) | |
|
160 | end | |
|
161 | end | |
|
162 | end | |
|
103 | assert_include '<strong>% Done</strong>', html | |
|
104 | assert_include '<del><i>50</i></del>', html | |
|
105 | end | |
|
163 | 106 | |
|
164 | should "show old and new values with a project attribute" do | |
|
165 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'project_id', :old_value => 1, :value => 2) | |
|
166 | assert_match 'eCookbook', show_detail(detail, true) | |
|
167 | assert_match 'OnlineStore', show_detail(detail, true) | |
|
107 | test 'IssuesHelper#show_detail with a start_date attribute should format the dates' do | |
|
108 | detail = JournalDetail.new( | |
|
109 | :property => 'attr', | |
|
110 | :old_value => '2010-01-01', | |
|
111 | :value => '2010-01-31', | |
|
112 | :prop_key => 'start_date' | |
|
113 | ) | |
|
114 | with_settings :date_format => '%m/%d/%Y' do | |
|
115 | assert_match "01/31/2010", show_detail(detail, true) | |
|
116 | assert_match "01/01/2010", show_detail(detail, true) | |
|
168 | 117 | end |
|
118 | end | |
|
169 | 119 | |
|
170 | should "show old and new values with a issue status attribute" do | |
|
171 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'status_id', :old_value => 1, :value => 2) | |
|
172 | assert_match 'New', show_detail(detail, true) | |
|
173 | assert_match 'Assigned', show_detail(detail, true) | |
|
120 | test 'IssuesHelper#show_detail with a due_date attribute should format the dates' do | |
|
121 | detail = JournalDetail.new( | |
|
122 | :property => 'attr', | |
|
123 | :old_value => '2010-01-01', | |
|
124 | :value => '2010-01-31', | |
|
125 | :prop_key => 'due_date' | |
|
126 | ) | |
|
127 | with_settings :date_format => '%m/%d/%Y' do | |
|
128 | assert_match "01/31/2010", show_detail(detail, true) | |
|
129 | assert_match "01/01/2010", show_detail(detail, true) | |
|
174 | 130 | end |
|
131 | end | |
|
175 | 132 | |
|
176 |
|
|
|
177 |
|
|
|
178 |
|
|
|
179 |
|
|
|
180 |
|
|
|
133 | test 'IssuesHelper#show_detail should show old and new values with a project attribute' do | |
|
134 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'project_id', :old_value => 1, :value => 2) | |
|
135 | assert_match 'eCookbook', show_detail(detail, true) | |
|
136 | assert_match 'OnlineStore', show_detail(detail, true) | |
|
137 | end | |
|
181 | 138 | |
|
182 |
|
|
|
183 |
|
|
|
184 |
|
|
|
185 |
|
|
|
186 |
|
|
|
139 | test 'IssuesHelper#show_detail should show old and new values with a issue status attribute' do | |
|
140 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'status_id', :old_value => 1, :value => 2) | |
|
141 | assert_match 'New', show_detail(detail, true) | |
|
142 | assert_match 'Assigned', show_detail(detail, true) | |
|
143 | end | |
|
187 | 144 | |
|
188 |
|
|
|
189 |
|
|
|
190 |
|
|
|
191 |
|
|
|
192 |
|
|
|
145 | test 'IssuesHelper#show_detail should show old and new values with a tracker attribute' do | |
|
146 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'tracker_id', :old_value => 1, :value => 2) | |
|
147 | assert_match 'Bug', show_detail(detail, true) | |
|
148 | assert_match 'Feature request', show_detail(detail, true) | |
|
149 | end | |
|
193 | 150 | |
|
194 |
|
|
|
195 |
|
|
|
196 |
|
|
|
197 |
|
|
|
198 |
|
|
|
151 | test 'IssuesHelper#show_detail should show old and new values with a assigned to attribute' do | |
|
152 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'assigned_to_id', :old_value => 1, :value => 2) | |
|
153 | assert_match 'Redmine Admin', show_detail(detail, true) | |
|
154 | assert_match 'John Smith', show_detail(detail, true) | |
|
155 | end | |
|
199 | 156 | |
|
200 |
|
|
|
201 |
|
|
|
202 |
|
|
|
203 |
|
|
|
204 |
|
|
|
157 | test 'IssuesHelper#show_detail should show old and new values with a priority attribute' do | |
|
158 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'priority_id', :old_value => 4, :value => 5) | |
|
159 | assert_match 'Low', show_detail(detail, true) | |
|
160 | assert_match 'Normal', show_detail(detail, true) | |
|
161 | end | |
|
205 | 162 | |
|
206 |
|
|
|
207 |
|
|
|
208 |
|
|
|
209 |
|
|
|
210 |
|
|
|
163 | test 'IssuesHelper#show_detail should show old and new values with a category attribute' do | |
|
164 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'category_id', :old_value => 1, :value => 2) | |
|
165 | assert_match 'Printing', show_detail(detail, true) | |
|
166 | assert_match 'Recipes', show_detail(detail, true) | |
|
167 | end | |
|
211 | 168 | |
|
212 |
|
|
|
213 |
|
|
|
214 |
|
|
|
215 | end | |
|
169 | test 'IssuesHelper#show_detail should show old and new values with a fixed version attribute' do | |
|
170 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'fixed_version_id', :old_value => 1, :value => 2) | |
|
171 | assert_match '0.1', show_detail(detail, true) | |
|
172 | assert_match '1.0', show_detail(detail, true) | |
|
173 | end | |
|
216 | 174 | |
|
217 | should "show added file" do | |
|
218 |
|
|
|
219 |
|
|
|
220 | end | |
|
175 | test 'IssuesHelper#show_detail should show old and new values with a estimated hours attribute' do | |
|
176 | detail = JournalDetail.new(:property => 'attr', :prop_key => 'estimated_hours', :old_value => '5', :value => '6.3') | |
|
177 | assert_match '5.00', show_detail(detail, true) | |
|
178 | assert_match '6.30', show_detail(detail, true) | |
|
179 | end | |
|
221 | 180 | |
|
222 | should "show removed file" do | |
|
223 |
|
|
|
224 |
|
|
|
225 |
|
|
|
181 | test 'IssuesHelper#show_detail should show old and new values with a custom field' do | |
|
182 | detail = JournalDetail.new(:property => 'cf', :prop_key => '1', :old_value => 'MySQL', :value => 'PostgreSQL') | |
|
183 | assert_equal 'Database changed from MySQL to PostgreSQL', show_detail(detail, true) | |
|
184 | end | |
|
185 | ||
|
186 | test 'IssuesHelper#show_detail should show added file' do | |
|
187 | detail = JournalDetail.new(:property => 'attachment', :prop_key => '1', :old_value => nil, :value => 'error281.txt') | |
|
188 | assert_match 'error281.txt', show_detail(detail, true) | |
|
189 | end | |
|
190 | ||
|
191 | test 'IssuesHelper#show_detail should show removed file' do | |
|
192 | detail = JournalDetail.new(:property => 'attachment', :prop_key => '1', :old_value => 'error281.txt', :value => nil) | |
|
193 | assert_match 'error281.txt', show_detail(detail, true) | |
|
226 | 194 | end |
|
227 | 195 | end |
General Comments 0
You need to be logged in to leave comments.
Login now