diff --git a/Guardfile b/Guardfile index d36a7e641..98d50fb63 100644 --- a/Guardfile +++ b/Guardfile @@ -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 diff --git a/config/routes.rb b/config/routes.rb index 6f07c4f23..66fb97555 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 diff --git a/spec/requests/redirects_spec.rb b/spec/requests/redirects_spec.rb new file mode 100644 index 000000000..4a9dec8b8 --- /dev/null +++ b/spec/requests/redirects_spec.rb @@ -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 \ No newline at end of file