diff --git a/app/controllers/setup_controller.rb b/app/controllers/setup_controller.rb index bd628c31..df4203f5 100644 --- a/app/controllers/setup_controller.rb +++ b/app/controllers/setup_controller.rb @@ -1,5 +1,6 @@ class SetupController < ApplicationController skip_before_filter :ensure_set_up + before_filter :ensure_not_set_up_yet skip_before_filter :ensure_organisation_exists skip_before_filter :ensure_authenticated skip_before_filter :ensure_member_active @@ -33,4 +34,13 @@ def set_single_organisation_mode Setting[:base_domain] = request.host_with_port redirect_to(new_organisation_path) end + + protected + + def ensure_not_set_up_yet + if OneClickOrgs::Setup.complete? + redirect_to('/') + end + end + end diff --git a/spec/requests/multi_tenancy_spec.rb b/spec/requests/multi_tenancy_spec.rb index 8361fa94..a2ff2204 100644 --- a/spec/requests/multi_tenancy_spec.rb +++ b/spec/requests/multi_tenancy_spec.rb @@ -53,6 +53,11 @@ Setting[:signup_domain] = 'signup.oneclickorgs.com' end + it "should redirect all setup requests to the homepage" do + get 'http://oneclickorgs.com/setup' + response.should redirect_to 'http://oneclickorgs.com/' + end + it "should redirect all unrecognised subdomain requests back to the new organisation page" do get 'http://nonexistent.oneclickorgs.com/' response.should redirect_to 'http://signup.oneclickorgs.com/organisations/new'