diff options
Diffstat (limited to 'vendor/gems/rspec-rails-1.3.3/spec/resources/controllers')
7 files changed, 301 insertions, 0 deletions
diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/action_view_base_spec_controller.rb b/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/action_view_base_spec_controller.rb new file mode 100644 index 000000000..924022178 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/action_view_base_spec_controller.rb @@ -0,0 +1,2 @@ +class ActionViewBaseSpecController < ActionController::Base +end diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/application.rb b/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/application.rb new file mode 100644 index 000000000..343fdd7bc --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/application.rb @@ -0,0 +1,9 @@ +class ApplicationController < ActionController::Base + before_filter :i_should_only_be_run_once, + :only => 'action_with_inherited_before_filter' + + def i_should_only_be_run_once + true + end + private :i_should_only_be_run_once +end
\ No newline at end of file diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/controller_spec_controller.rb b/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/controller_spec_controller.rb new file mode 100644 index 000000000..d5b5627d1 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/controller_spec_controller.rb @@ -0,0 +1,127 @@ +class ControllerSpecController < ActionController::Base + before_filter :raise_error, :only => :action_with_skipped_before_filter + + def raise_error + raise "from a before filter" + end + + skip_before_filter :raise_error + + prepend_view_path File.join(File.dirname(__FILE__), "..", "views") + + def some_action + render :template => "template/that/does/not/actually/exist" + end + + def some_action_with_implied_template + end + + def action_with_template + render :template => "controller_spec/action_with_template" + end + + def action_which_sets_flash + flash[:flash_key] = "flash value" + render :text => "" + end + + def action_which_gets_session + raise "expected #{params[:session_key].inspect}\ngot #{session[:session_key].inspect}" unless (session[:session_key] == params[:expected]) + render :text => "" + end + + def action_which_sets_session + session[:session_key] = "session value" + end + + def action_which_gets_cookie + raise "expected #{params[:expected].inspect}, got #{cookies[:cookie_key].inspect}" unless (cookies[:cookie_key] == params[:expected]) + render :text => "" + end + + def action_which_sets_cookie + cookies['cookie_key'] = params[:value] + render :text => "" + end + + def action_with_partial + render :partial => "controller_spec/partial" + end + + def action_with_partial_with_object + render :partial => "controller_spec/partial", :object => params[:thing] + end + + def action_with_partial_with_locals + render :partial => "controller_spec/partial", :locals => {:thing => params[:thing]} + end + + def action_with_errors_in_template + render :template => "controller_spec/action_with_errors_in_template" + end + + def action_setting_the_assigns_hash + @indirect_assigns_key = :indirect_assigns_key_value + end + + def action_setting_flash_after_session_reset + reset_session + flash[:after_reset] = "available" + end + + def action_setting_flash_before_session_reset + flash[:before_reset] = 'available' + reset_session + end + + def action_with_render_update + render :update do |page| + page.replace :bottom, 'replace_me', + :partial => 'non_existent_partial' + end + end + + def action_with_skipped_before_filter + render :text => "" + end + + def action_that_renders_inline + render :inline => "<%= 'inline code' %>" + end + + def action_that_assigns_false_to_a_variable + @a_variable = false + render :text => "" + end + + def action_with_two_arg_render + render :update, :status => 404 do |page| + page.visual_effect :highlight, 'user_list' + end + end + + class RescuedError < Exception; end + class UnRescuedError < Exception; end + + rescue_from RescuedError do |e| + render :text => 'Rescued!' + end + + def rescued_error_action + raise ControllerSpecController::RescuedError + end + + def un_rescued_error_action + raise ControllerSpecController::UnRescuedError + end + + def action_that_returns_headers + render :text => request.headers[params[:header]] + end +end + +class ControllerInheritingFromApplicationControllerController < ApplicationController + def action_with_inherited_before_filter + render :text => "" + end +end diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/example.txt b/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/example.txt new file mode 100644 index 000000000..380965314 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/example.txt @@ -0,0 +1 @@ +This is an example file to download.
\ No newline at end of file diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/redirect_spec_controller.rb b/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/redirect_spec_controller.rb new file mode 100644 index 000000000..7b63c99f2 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/redirect_spec_controller.rb @@ -0,0 +1,70 @@ +class RedirectSpecController < ApplicationController + + def action_with_no_redirect + render :text => "this is just here to keep this from causing a MissingTemplate error" + end + + def action_with_redirect_to_somewhere + redirect_to :action => 'somewhere' + end + + def action_with_redirect_to_other_somewhere + redirect_to :controller => 'render_spec', :action => 'text_action' + end + + def action_with_redirect_to_somewhere_and_return + redirect_to :action => 'somewhere' and return + render :text => "this is after the return" + end + + def somewhere + render :text => "this is just here to keep this from causing a MissingTemplate error" + end + + def action_with_redirect_to_rspec_site + redirect_to "http://rspec.rubyforge.org" + end + + def action_with_redirect_back + redirect_to :back + end + + def action_with_redirect_in_respond_to + respond_to do |wants| + wants.html { redirect_to :action => 'somewhere' } + end + end + + def action_with_redirect_which_creates_query_string + redirect_to :action => "somewhere", :id => 1111, :param1 => "value1", :param2 => "value2" + end + + # note: sometimes this is the URL which rails will generate from the hash in + # action_with_redirect_which_creates_query_string + def action_with_redirect_with_query_string_order1 + redirect_to "http://test.host/redirect_spec/somewhere/1111?param1=value1¶m2=value2" + end + + # note: sometimes this is the URL which rails will generate from the hash in + # action_with_redirect_which_creates_query_string + def action_with_redirect_with_query_string_order2 + redirect_to "http://test.host/redirect_spec/somewhere/1111?param2=value2¶m1=value1" + end + + def action_with_redirect_to_unroutable_url_inside_app + redirect_to :controller => "nonexistant", :action => "none" + end + + def action_with_method_restriction + render :text => '' + end + + def action_to_redirect_to_action_with_method_restriction + redirect_to :action => 'action_with_method_restriction' + end + + def action_with_redirect_to_somewhere_with_status + redirect_to :action => 'somewhere', :status => 301 + end +end + diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/render_spec_controller.rb b/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/render_spec_controller.rb new file mode 100644 index 000000000..1efe61ff8 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/render_spec_controller.rb @@ -0,0 +1,34 @@ +class RenderSpecController < ApplicationController + prepend_view_path File.join(File.dirname(__FILE__), "..", "views") + + def some_action + respond_to do |format| + format.html + format.js + end + end + + def action_which_renders_template_from_other_controller + render :template => 'controller_spec/action_with_template' + end + + def text_action + render :text => "this is the text for this action" + end + + def action_with_redirect + redirect_to :action => :some_action + end + + def action_with_partial + render :partial => "a_partial" + end + + def action_that_renders_nothing + render :nothing => true + end + + def action_with_alternate_layout + render :layout => 'simple' + end +end diff --git a/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/rjs_spec_controller.rb b/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/rjs_spec_controller.rb new file mode 100644 index 000000000..4fd9a41c0 --- /dev/null +++ b/vendor/gems/rspec-rails-1.3.3/spec/resources/controllers/rjs_spec_controller.rb @@ -0,0 +1,58 @@ +class RjsSpecController < ApplicationController + prepend_view_path File.join(File.dirname(__FILE__), "..", "views") + + def replace_html + end + + def insert_html + end + + def replace + end + + def hide_div + end + + def hide_page_element + end + + def replace_html_with_partial + end + + def render_replace_html + render :update do |page| + page.replace_html 'mydiv', 'replacement text' + page.replace_html 'myotherdiv', 'other replacement text' + end + end + + def render_replace_html_with_partial + render :update do |page| + page.replace_html 'mydiv', :partial => 'rjs_spec/replacement_partial' + end + end + + def render_insert_html + render :update do |page| + page.insert_html 'mydiv', 'replacement text' + end + end + + def render_replace + render :update do |page| + page.replace 'mydiv', 'replacement text' + end + end + + def render_hide_div + render :update do |page| + page.hide 'mydiv' + end + end + + def render_hide_page_element + render :update do |page| + page['mydiv'].hide + end + end +end |