Files
nairobi/spec/system/admin/tenants_spec.rb
Javi Martín e1e16d21c3 Allow having tenants with different domains
Some institutions using CONSUL have expressed interest in this feature
since some of their tenants might already have their own domains.

We've considered many options for the user interface to select whether
we're using a subdomain or a domain, like having two separate fields,
using a check box, ... In the end we've chosen radio buttons because
they make it easier to follow a logical sequence: first you decide
whether you're introducing a domain or subdomain, and then you enter it.

We've also considered hiding this option and assuming "if it's got a
dot, it's a domain". However, this wouldn't work with nested subdomains
and it wouldn't work with domains which are simply machine names.

Note that a group of radio buttons (or check boxes) is difficult to
style when the text of the label might expand over more than one line
(as is the case here on small screens); in this case, most solutions
result in the second line of the label appearing immediately under the
radio button, instead of being aligned with the first line of the label.
That's why I've added a container for the input+label combination.
2022-12-13 13:10:02 +01:00

75 lines
2.0 KiB
Ruby

require "rails_helper"
describe "Tenants", :admin, :seed_tenants do
before { allow(Tenant).to receive(:default_host).and_return("localhost") }
describe "Create" do
scenario "Tenant with subdomain" do
visit admin_root_path
within("#side_menu") do
click_link "Settings"
click_link "Multitenancy"
end
click_link "Create tenant"
fill_in "Subdomain", with: "earth"
fill_in "Name", with: "Earthlings"
click_button "Create tenant"
expect(page).to have_content "Tenant created successfully"
within("tr", text: "earth") do
expect(page).to have_content "earth.lvh.me"
click_link "View"
end
expect(current_host).to eq "http://earth.lvh.me"
expect(page).to have_current_path root_path
expect(page).to have_link "Sign in"
end
scenario "Tenant with domain" do
visit new_admin_tenant_path
choose "Use a different domain to access this tenant"
fill_in "Domain", with: "earth.lvh.me"
fill_in "Name", with: "Earthlings"
click_button "Create tenant"
within("tr", text: "earth") do
expect(page).to have_content "earth.lvh.me"
click_link "View"
end
expect(current_host).to eq "http://earth.lvh.me"
expect(page).to have_current_path root_path
expect(page).to have_link "Sign in"
end
end
scenario "Update" do
create(:tenant, schema: "moon")
visit admin_tenants_path
within("tr", text: "moon") { click_link "Edit" }
expect(page).to have_field "Use a subdomain in the lvh.me domain to access this tenant",
type: :radio,
checked: true
fill_in "Subdomain", with: "the-moon"
click_button "Update tenant"
expect(page).to have_content "Tenant updated successfully"
within("tr", text: "the-moon") { click_link "View" }
expect(current_host).to eq "http://the-moon.lvh.me"
expect(page).to have_current_path root_path
expect(page).to have_link "Sign in"
end
end