Created
November 24, 2010 02:02
-
-
Save jrbruce/712968 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#admin_routes_spec.rb | |
require "spec_helper" | |
describe "Admin Routes" do | |
describe "GET '/admin'" do | |
it "should block access if not on www" do | |
{ :get => "http://foo.example.com/admin" }.should_not be_routable | |
end | |
it "should allow access if on www" do | |
{ :get => "http://www.example.com/admin" }.should route_to(:controller => "admin/dashboards", :action => "show") | |
end | |
end | |
end | |
# routes.rb (excerpt) | |
namespace :admin do | |
constraints(RootDomain) do | |
resource :dashboard, :only => :show | |
root :to => "dashboards#show" | |
end | |
end | |
# app/lib/root_domain.rb | |
class RootDomain | |
def self.matches?(request) | |
request.subdomain.blank? || request.subdomain == "www" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment