+ <% @signup.errors.full_messages.each do |message| %>
+
<%= message %>
+ <% end %>
+
+
+ <% end %>
+
+
+ <% end %>
+
+
+
diff --git a/config/initializers/tenanting.rb b/config/initializers/tenanting.rb
index 78e5d8e05..ce4193330 100644
--- a/config/initializers/tenanting.rb
+++ b/config/initializers/tenanting.rb
@@ -2,10 +2,17 @@ Rails.application.config.after_initialize do
# in production and staging, we're using a two-level subdomain like "tenant.fizzy.37signals.com".
# in development and beta it's only a single-level subdomain.
Rails.application.config.active_record_tenanted.tenant_resolver = ->(request) do
- next nil if request.path == "/up"
-
tld_length = [ "37signals.com", "37signals-staging.com" ].include?(request.domain) ? 2 : 1
- request.subdomain(tld_length).presence || "return-404" # this is a quick fix for now
+
+ if request.path == "/up"
+ nil
+ elsif subdomain = request.subdomain(tld_length).presence
+ subdomain
+ elsif optional = request.path =~ %r{^/signup\b}
+ nil
+ else
+ "return-404" # this is a quick fix for now
+ end
end
end
diff --git a/config/routes.rb b/config/routes.rb
index 7cf104da4..ad780b0da 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -88,6 +88,11 @@ Rails.application.routes.draw do
get "launchpad", to: "sessions/launchpad#show"
end
+ namespace :signup do
+ get "/" => "accounts#new"
+ resources :accounts, only: %i[ new create ]
+ end
+
resources :users do
scope module: :users do
resource :avatar
diff --git a/test/controllers/signup/accounts_controller_test.rb b/test/controllers/signup/accounts_controller_test.rb
new file mode 100644
index 000000000..f7c2a6ad7
--- /dev/null
+++ b/test/controllers/signup/accounts_controller_test.rb
@@ -0,0 +1,39 @@
+require "test_helper"
+
+class Signup::AccountsControllerTest < ActionDispatch::IntegrationTest
+ test "new at a tenanted domain" do
+ get new_signup_account_url
+
+ assert_redirected_to root_url
+ end
+
+ test "new at an untenanted domain" do
+ integration_session.host = "example.com" # no subdomain
+
+ get new_signup_account_url
+
+ assert_response :success
+ end
+
+ test "create with invalid params" do
+ integration_session.host = "example.com" # no subdomain
+
+ post signup_accounts_url, params: { signup: { full_name: "Jim", email_address: "jim@example.com", password: "", company_name: "" } }
+
+ assert_response :unprocessable_entity
+ assert_select "div.alert--error", text: /you need to choose a password/i
+ end
+
+ test "create for a new " do
+ integration_session.host = "example.com" # no subdomain
+
+ assert_difference -> { SignalId::Identity.count }, +1 do
+ assert_difference -> { SignalId::Account.count }, +1 do
+ post signup_accounts_url, params: { signup: { full_name: "Jim", email_address: "jim@example.com", password: SecureRandom.hex(12), company_name: "signup-accounts-controller-test-1" } }
+ end
+ end
+
+ signal_account = SignalId::Account.last
+ assert_redirected_to(/#{signal_account.login_url}/)
+ end
+end