Files
nairobi/spec/system/admin/tenants_spec.rb
Javi Martín 58c9e8462d Only seed tenants when necessary in tests
On my machine, seeding a tenant takes about one second, so skipping this
action when it isn't necessary makes tests creating tenants faster
(although creating a tenant still takes about 3-4 seconds on my
machine).
2022-11-11 01:40:02 +01:00

46 lines
1.2 KiB
Ruby

require "rails_helper"
describe "Tenants", :admin, :seed_tenants do
before { allow(Tenant).to receive(:default_host).and_return("localhost") }
scenario "Create" 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") { click_link "View" }
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 "Update" do
create(:tenant, schema: "moon")
visit admin_tenants_path
within("tr", text: "moon") { click_link "Edit" }
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