@@ -0,0 +1,6 | |||||
|
1 | <h2><%=h @status %></h2> | |||
|
2 | ||||
|
3 | <p id="errorExplanation"><%=h @message %></p> | |||
|
4 | <p><a href="javascript:history.back()">Back</a></p> | |||
|
5 | ||||
|
6 | <% html_title @status %> |
@@ -275,39 +275,31 class ApplicationController < ActionController::Base | |||||
275 |
|
275 | |||
276 | def render_403(options={}) |
|
276 | def render_403(options={}) | |
277 | @project = nil |
|
277 | @project = nil | |
278 | @message = options[:message] || :notice_not_authorized |
|
278 | render_error({:message => :notice_not_authorized, :status => 403}.merge(options)) | |
279 | @message = l(@message) if @message.is_a?(Symbol) |
|
|||
280 | respond_to do |format| |
|
|||
281 | format.html { render :template => "common/403", :layout => use_layout, :status => 403 } |
|
|||
282 | format.atom { head 403 } |
|
|||
283 | format.xml { head 403 } |
|
|||
284 | format.js { head 403 } |
|
|||
285 | format.json { head 403 } |
|
|||
286 | end |
|
|||
287 | return false |
|
279 | return false | |
288 | end |
|
280 | end | |
289 |
|
281 | |||
290 | def render_404 |
|
282 | def render_404(options={}) | |
291 | respond_to do |format| |
|
283 | render_error({:message => :notice_file_not_found, :status => 404}.merge(options)) | |
292 | format.html { render :template => "common/404", :layout => use_layout, :status => 404 } |
|
|||
293 | format.atom { head 404 } |
|
|||
294 | format.xml { head 404 } |
|
|||
295 | format.js { head 404 } |
|
|||
296 | format.json { head 404 } |
|
|||
297 | end |
|
|||
298 | return false |
|
284 | return false | |
299 | end |
|
285 | end | |
300 |
|
286 | |||
301 | def render_error(msg) |
|
287 | # Renders an error response | |
|
288 | def render_error(arg) | |||
|
289 | arg = {:message => arg} unless arg.is_a?(Hash) | |||
|
290 | ||||
|
291 | @message = arg[:message] | |||
|
292 | @message = l(@message) if @message.is_a?(Symbol) | |||
|
293 | @status = arg[:status] || 500 | |||
|
294 | ||||
302 | respond_to do |format| |
|
295 | respond_to do |format| | |
303 |
format.html { |
|
296 | format.html { | |
304 | flash.now[:error] = msg |
|
297 | render :template => 'common/error', :layout => use_layout, :status => @status | |
305 | render :text => '', :layout => use_layout, :status => 500 |
|
|||
306 | } |
|
298 | } | |
307 |
format.atom { head |
|
299 | format.atom { head @status } | |
308 |
format.xml { head |
|
300 | format.xml { head @status } | |
309 |
format.js { head |
|
301 | format.js { head @status } | |
310 |
format.json { head |
|
302 | format.json { head @status } | |
311 | end |
|
303 | end | |
312 | end |
|
304 | end | |
313 |
|
305 |
@@ -340,9 +340,7 class IssuesControllerTest < ActionController::TestCase | |||||
340 |
|
340 | |||
341 | get :new, :project_id => 1 |
|
341 | get :new, :project_id => 1 | |
342 | assert_response 500 |
|
342 | assert_response 500 | |
343 | assert_not_nil flash[:error] |
|
343 | assert_error_tag :content => /No default issue/ | |
344 | assert_tag :tag => 'div', :attributes => { :class => /error/ }, |
|
|||
345 | :content => /No default issue/ |
|
|||
346 | end |
|
344 | end | |
347 |
|
345 | |||
348 | def test_get_new_with_no_tracker_should_display_an_error |
|
346 | def test_get_new_with_no_tracker_should_display_an_error | |
@@ -351,9 +349,7 class IssuesControllerTest < ActionController::TestCase | |||||
351 |
|
349 | |||
352 | get :new, :project_id => 1 |
|
350 | get :new, :project_id => 1 | |
353 | assert_response 500 |
|
351 | assert_response 500 | |
354 | assert_not_nil flash[:error] |
|
352 | assert_error_tag :content => /No tracker/ | |
355 | assert_tag :tag => 'div', :attributes => { :class => /error/ }, |
|
|||
356 | :content => /No tracker/ |
|
|||
357 | end |
|
353 | end | |
358 |
|
354 | |||
359 | def test_update_new_form |
|
355 | def test_update_new_form |
@@ -113,11 +113,15 class ActiveSupport::TestCase | |||||
113 | def self.repository_configured?(vendor) |
|
113 | def self.repository_configured?(vendor) | |
114 | File.directory?(repository_path(vendor)) |
|
114 | File.directory?(repository_path(vendor)) | |
115 | end |
|
115 | end | |
|
116 | ||||
|
117 | def assert_error_tag(options={}) | |||
|
118 | assert_tag({:tag => 'p', :attributes => { :id => 'errorExplanation' }}.merge(options)) | |||
|
119 | end | |||
116 |
|
120 | |||
117 | # Shoulda macros |
|
121 | # Shoulda macros | |
118 | def self.should_render_404 |
|
122 | def self.should_render_404 | |
119 | should_respond_with :not_found |
|
123 | should_respond_with :not_found | |
120 |
should_render_template 'common/ |
|
124 | should_render_template 'common/error' | |
121 | end |
|
125 | end | |
122 |
|
126 | |||
123 | def self.should_have_before_filter(expected_method, options = {}) |
|
127 | def self.should_have_before_filter(expected_method, options = {}) |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now