1 class ControllerSpecController < ActionController::Base
2 before_filter :raise_error, :only => :action_with_skipped_before_filter
5 raise "from a before filter"
8 skip_before_filter :raise_error
10 prepend_view_path File.join(File.dirname(__FILE__), "..", "views")
13 render :template => "template/that/does/not/actually/exist"
16 def some_action_with_implied_template
19 def action_with_template
20 render :template => "controller_spec/action_with_template"
23 def action_which_sets_flash
24 flash[:flash_key] = "flash value"
28 def action_which_gets_session
29 raise "expected #{params[:session_key].inspect}\ngot #{session[:session_key].inspect}" unless (session[:session_key] == params[:expected])
33 def action_which_sets_session
34 session[:session_key] = "session value"
37 def action_which_gets_cookie
38 raise "expected #{params[:expected].inspect}, got #{cookies[:cookie_key].inspect}" unless (cookies[:cookie_key] == params[:expected])
42 def action_which_sets_cookie
43 cookies['cookie_key'] = params[:value]
47 def action_with_partial
48 render :partial => "controller_spec/partial"
51 def action_with_partial_with_object
52 render :partial => "controller_spec/partial", :object => params[:thing]
55 def action_with_partial_with_locals
56 render :partial => "controller_spec/partial", :locals => {:thing => params[:thing]}
59 def action_with_errors_in_template
60 render :template => "controller_spec/action_with_errors_in_template"
63 def action_setting_the_assigns_hash
64 @indirect_assigns_key = :indirect_assigns_key_value
67 def action_setting_flash_after_session_reset
69 flash[:after_reset] = "available"
72 def action_setting_flash_before_session_reset
73 flash[:before_reset] = 'available'
77 def action_with_render_update
78 render :update do |page|
79 page.replace :bottom, 'replace_me',
80 :partial => 'non_existent_partial'
84 def action_with_skipped_before_filter
88 def action_that_renders_inline
89 render :inline => "<%= 'inline code' %>"
92 def action_that_assigns_false_to_a_variable
97 def action_with_two_arg_render
98 render :update, :status => 404 do |page|
99 page.visual_effect :highlight, 'user_list'
103 class RescuedError < Exception; end
104 class UnRescuedError < Exception; end
106 rescue_from RescuedError do |e|
107 render :text => 'Rescued!'
110 def rescued_error_action
111 raise ControllerSpecController::RescuedError
114 def un_rescued_error_action
115 raise ControllerSpecController::UnRescuedError
118 def action_that_returns_headers
119 render :text => request.headers[params[:header]]
123 class ControllerInheritingFromApplicationControllerController < ApplicationController
124 def action_with_inherited_before_filter