Files
grecia/spec/system/admin/tenants_spec.rb
Javi Martín 7bcdb6a9db Use the tenant URL as a link to the tenant
In general, we don't use links inside admin tables because we don't know
where the link will point to, and use "view" actions/links instead.

However, in this case, we're showing a URL, so it's perfectly obvious
where the link will point to. And so it makes sense to use the URL as a
link instead of using a "view" action/link.
2022-12-14 13:52:26 +01:00

67 lines
1.8 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"
click_link "earth.lvh.me"
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"
click_link "earth.lvh.me"
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"
click_link "the-moon.lvh.me"
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