Skip to content

Commit

Permalink
Make sure :via works with mount
Browse files Browse the repository at this point in the history
  • Loading branch information
lifo committed Aug 20, 2012
1 parent 6904af1 commit 6a5d1c7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 3 additions & 2 deletions actionpack/lib/action_dispatch/routing/mapper.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -444,9 +444,10 @@ def mount(app, options = nil)


raise "A rack application must be specified" unless path raise "A rack application must be specified" unless path


options[:as] ||= app_name(app) options[:as] ||= app_name(app)
options[:via] ||= :all


match(path, options.merge(:to => app, :anchor => false, :format => false, :via => :all)) match(path, options.merge(:to => app, :anchor => false, :format => false))


define_generate_prefix(app, options[:as]) define_generate_prefix(app, options[:as])
self self
Expand Down
9 changes: 9 additions & 0 deletions actionpack/test/dispatch/mount_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def self.call(env)
mount SprocketsApp => "/shorthand" mount SprocketsApp => "/shorthand"


mount FakeEngine, :at => "/fakeengine" mount FakeEngine, :at => "/fakeengine"
mount FakeEngine, :at => "/getfake", :via => :get


scope "/its_a" do scope "/its_a" do
mount SprocketsApp, :at => "/sprocket" mount SprocketsApp, :at => "/sprocket"
Expand Down Expand Up @@ -52,6 +53,14 @@ def test_mounting_with_shorthand
assert_equal "/shorthand -- /omg", response.body assert_equal "/shorthand -- /omg", response.body
end end


def test_mounting_works_with_via
get "/getfake"
assert_equal "OK", response.body

post "/getfake"
assert_response :not_found
end

def test_with_fake_engine_does_not_call_invalid_method def test_with_fake_engine_does_not_call_invalid_method
get "/fakeengine" get "/fakeengine"
assert_equal "OK", response.body assert_equal "OK", response.body
Expand Down

0 comments on commit 6a5d1c7

Please sign in to comment.