Sha256: 988615f2d77e65f486803d9da653c807275021fd9810aa6cfd9f5f1d77a2d419

Contents?: true

Size: 1.91 KB

Versions: 15

Compression:

Stored size: 1.91 KB

Contents

require 'test_helper'

class Kaui::TenantsControllerTest < Kaui::FunctionalTestHelperNoSetup

  setup do
    # Do nothing and let the test initialize with correct # tenants
  end

  teardown do
    # Do nothing and let the test initialize with correct # tenants
  end

  #
  # We don't configure the tenants in 'kaui_tenants' and don't set KillBillClient.api_key
  #
  test 'should get index with 0 tenant with NO KillBillClient.api_key set' do
    setup_functional_test(0, false)
    get :index, :use_route => 'kaui'
    # Sign-up flow
    assert_redirected_to new_admin_tenant_path
  end

  #
  # We don't configure the tenants in 'kaui_tenants' but we set KillBillClient.api_key (default use case for non multi-tenant UI)
  #
  test 'should get index with 0 tenant with KillBillClient.api_key set' do
    setup_functional_test(0)
    get :index, :use_route => 'kaui'
    assert_response 302
    assert_redirected_to Kaui::IntegrationTestHelper::HOME_PATH
    assert_equal 'Signed in successfully.', flash[:notice]
  end

  #
  # We configure 1 tenant in 'kaui_tenants' (the one we created with Kill Bill) and verify we skip the tenant screen
  #
  test 'should get index with 1 tenant' do
    setup_functional_test(1)
    get :index, :use_route => 'kaui'
    assert_includes (200..399), response.code.to_i
    assert_equal 'Signed in successfully.', flash[:notice]
  end

  #
  # We configure 2 tenants in 'kaui_tenants' (the one we created with Kill Bill and another one) and verify we land on the view for the
  # user to chose his tenant.
  #
  test 'should get index with 2 tenant' do
    setup_functional_test(2)
    get :index, :use_route => 'kaui'
    assert_response :success
    assert_equal 'Signed in successfully.', flash[:notice]
  end

  test 'should select a tenant' do
    setup_functional_test
    post :select_tenant, :kb_tenant_id => session[:kb_tenant_id]
    assert_redirected_to Kaui::IntegrationTestHelper::HOME_PATH
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
kaui-2.1.0 test/functional/kaui/tenants_controller_test.rb
kaui-2.0.4 test/functional/kaui/tenants_controller_test.rb
kaui-2.0.3 test/functional/kaui/tenants_controller_test.rb
kaui-2.0.2 test/functional/kaui/tenants_controller_test.rb
kaui-2.0.1 test/functional/kaui/tenants_controller_test.rb
kaui-2.0.0 test/functional/kaui/tenants_controller_test.rb
kaui-1.4.1 test/functional/kaui/tenants_controller_test.rb
kaui-1.4.0 test/functional/kaui/tenants_controller_test.rb
kaui-1.3.0 test/functional/kaui/tenants_controller_test.rb
kaui-1.2.0 test/functional/kaui/tenants_controller_test.rb
kaui-1.1.0 test/functional/kaui/tenants_controller_test.rb
kaui-1.0.0 test/functional/kaui/tenants_controller_test.rb
kaui-0.16.2 test/functional/kaui/tenants_controller_test.rb
kaui-0.16.1 test/functional/kaui/tenants_controller_test.rb
kaui-0.16.0 test/functional/kaui/tenants_controller_test.rb