Skip to content

Commit

Permalink
Redirect requests to root of api.planningalerts.org.au
Browse files Browse the repository at this point in the history
  • Loading branch information
mlandauer committed Sep 6, 2012
1 parent e4f0456 commit fa918e8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions Guardfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ guard 'rspec', :version => 2 do
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
#watch('config/routes.rb') { "spec/routing" }
watch('config/routes.rb') { "spec/requests" }
watch('app/controllers/application_controller.rb') { "spec/controllers" }

# Capybara request specs
Expand Down
4 changes: 4 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
PlanningalertsApp::Application.routes.draw do
constraints :subdomain => "api" do
match "/" => redirect("http://www.planningalerts.org.au")
end

ActiveAdmin.routes(self)

devise_for :users, ActiveAdmin::Devise.config
Expand Down
17 changes: 17 additions & 0 deletions spec/requests/redirects_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require 'spec_helper'

describe "redirects" do
describe "api redirects" do
it "should not redirect the normal home page on the normal subdomain" do
get "http://www.planningalerts.org.au"
response.should_not be_redirect
end

describe "requests on the api subdomain" do
it "to the home page should redirect" do
get "http://api.planningalerts.org.au"
response.should redirect_to "http://www.planningalerts.org.au"
end
end
end
end

0 comments on commit fa918e8

Please sign in to comment.