diff options
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/lib/action_controller/testing/process.rb | 2 | ||||
-rw-r--r-- | actionpack/test/lib/controller/fake_controllers.rb | 2 | ||||
-rw-r--r-- | actionpack/test/template/url_helper_test.rb | 118 |
3 files changed, 58 insertions, 64 deletions
diff --git a/actionpack/lib/action_controller/testing/process.rb b/actionpack/lib/action_controller/testing/process.rb index 5fb244e3eb..2fccf01040 100644 --- a/actionpack/lib/action_controller/testing/process.rb +++ b/actionpack/lib/action_controller/testing/process.rb @@ -133,7 +133,7 @@ module ActionController #:nodoc: @request.env['REQUEST_METHOD'] = http_method parameters ||= {} - @request.assign_parameters(@controller.class.controller_path, action.to_s, parameters) + @request.assign_parameters(@controller.class.name.underscore.sub(/_controller$/, ''), action.to_s, parameters) @request.session = ActionController::TestSession.new(session) unless session.nil? @request.session["flash"] = ActionController::Flash::FlashHash.new.update(flash) if flash diff --git a/actionpack/test/lib/controller/fake_controllers.rb b/actionpack/test/lib/controller/fake_controllers.rb index e7589e29ca..b96e91f4f7 100644 --- a/actionpack/test/lib/controller/fake_controllers.rb +++ b/actionpack/test/lib/controller/fake_controllers.rb @@ -11,6 +11,7 @@ module Admin end class ElsewhereController < ActionController::Base; end class AddressesController < ActionController::Base; end +class SessionsController < ActionController::Base; end # For speed test class SpeedController < ActionController::Base; end @@ -25,7 +26,6 @@ class UsersController < SpeedController; end class SettingsController < SpeedController; end class ChannelsController < SpeedController; end class ChannelVideosController < SpeedController; end -class SessionsController < SpeedController; end class LostPasswordsController < SpeedController; end class PagesController < SpeedController; end diff --git a/actionpack/test/template/url_helper_test.rb b/actionpack/test/template/url_helper_test.rb index 0e24fbd24d..44f1925653 100644 --- a/actionpack/test/template/url_helper_test.rb +++ b/actionpack/test/template/url_helper_test.rb @@ -367,25 +367,25 @@ class UrlHelperTest < ActionView::TestCase end end -class UrlHelperWithControllerTest < ActionView::TestCase - class UrlHelperController < ActionController::Base - def self.controller_path; 'url_helper_with_controller' end - - def show_url_for - render :inline => "<%= url_for :controller => 'url_helper_with_controller', :action => 'show_url_for' %>" - end +class UrlHelperController < ActionController::Base + def self.controller_path; 'url_helper_with_controller' end - def show_named_route - render :inline => "<%= show_named_route_#{params[:kind]} %>" - end + def show_url_for + render :inline => "<%= url_for :controller => 'url_helper_with_controller', :action => 'show_url_for' %>" + end - def nil_url_for - render :inline => '<%= url_for(nil) %>' - end + def show_named_route + render :inline => "<%= show_named_route_#{params[:kind]} %>" + end - def rescue_action(e) raise e end + def nil_url_for + render :inline => '<%= url_for(nil) %>' end + def rescue_action(e) raise e end +end + +class UrlHelperWithControllerTest < ActionView::TestCase tests ActionView::Helpers::UrlHelper def setup @@ -416,7 +416,7 @@ class UrlHelperWithControllerTest < ActionView::TestCase def test_url_for_nil_returns_current_path get :nil_url_for - assert_equal '/url_helper_with_controller/nil_url_for', @response.body + assert_equal '/url_helper/nil_url_for', @response.body end def test_named_route_should_show_host_and_path_using_controller_default_url_options @@ -436,35 +436,33 @@ class UrlHelperWithControllerTest < ActionView::TestCase def with_url_helper_routing with_routing do |set| set.draw do |map| - map.show_named_route 'url_helper_with_controller/show_named_route', :controller => 'url_helper_with_controller', :action => 'show_named_route' + map.show_named_route 'url_helper_with_controller/show_named_route', :controller => 'url_helper', :action => 'show_named_route' end yield end end end -class LinkToUnlessCurrentWithControllerTest < ActionView::TestCase - class TasksController < ActionController::Base - def self.controller_path; 'tasks' end - - def index - render_default - end +class TasksController < ActionController::Base + def index + render_default + end - def show - render_default - end + def show + render_default + end - def rescue_action(e) raise e end + def rescue_action(e) raise e end - protected - def render_default - render :inline => - "<%= link_to_unless_current(\"tasks\", tasks_path) %>\n" + - "<%= link_to_unless_current(\"tasks\", tasks_url) %>" - end - end + protected + def render_default + render :inline => + "<%= link_to_unless_current(\"tasks\", tasks_path) %>\n" + + "<%= link_to_unless_current(\"tasks\", tasks_url) %>" + end +end +class LinkToUnlessCurrentWithControllerTest < ActionView::TestCase tests ActionView::Helpers::UrlHelper def setup @@ -537,41 +535,37 @@ class Session end end -class PolymorphicControllerTest < ActionView::TestCase - class WorkshopsController < ActionController::Base - def self.controller_path; 'workshops' end - - def index - @workshop = Workshop.new(1, true) - render :inline => "<%= url_for(@workshop) %>\n<%= link_to('Workshop', @workshop) %>" - end - - def show - @workshop = Workshop.new(params[:id], false) - render :inline => "<%= url_for(@workshop) %>\n<%= link_to('Workshop', @workshop) %>" - end - - def rescue_action(e) raise e end +class WorkshopsController < ActionController::Base + def index + @workshop = Workshop.new(1, true) + render :inline => "<%= url_for(@workshop) %>\n<%= link_to('Workshop', @workshop) %>" end - class SessionsController < ActionController::Base - def self.controller_path; 'sessions' end + def show + @workshop = Workshop.new(params[:id], false) + render :inline => "<%= url_for(@workshop) %>\n<%= link_to('Workshop', @workshop) %>" + end - def index - @workshop = Workshop.new(params[:workshop_id], false) - @session = Session.new(1, true) - render :inline => "<%= url_for([@workshop, @session]) %>\n<%= link_to('Session', [@workshop, @session]) %>" - end + def rescue_action(e) raise e end +end - def show - @workshop = Workshop.new(params[:workshop_id], false) - @session = Session.new(params[:id], false) - render :inline => "<%= url_for([@workshop, @session]) %>\n<%= link_to('Session', [@workshop, @session]) %>" - end +class SessionsController < ActionController::Base + def index + @workshop = Workshop.new(params[:workshop_id], false) + @session = Session.new(1, true) + render :inline => "<%= url_for([@workshop, @session]) %>\n<%= link_to('Session', [@workshop, @session]) %>" + end - def rescue_action(e) raise e end + def show + @workshop = Workshop.new(params[:workshop_id], false) + @session = Session.new(params[:id], false) + render :inline => "<%= url_for([@workshop, @session]) %>\n<%= link_to('Session', [@workshop, @session]) %>" end + def rescue_action(e) raise e end +end + +class PolymorphicControllerTest < ActionView::TestCase tests ActionView::Helpers::UrlHelper def setup |