Sha256: b63d3e158df358fe0be2ae028a4cd4ffcf333a8c5e08e6492956308b777b2d24

Contents?: true

Size: 1.47 KB

Versions: 8

Compression:

Stored size: 1.47 KB

Contents

class Kaui::FunctionalTestHelperNoSetup < ActionController::TestCase

  include Devise::TestHelpers
  include Kaui::KillbillTestHelper

  protected

  #
  # Rails helpers
  #

  def setup_functional_test(nb_configured_tenants = 1, setup_tenant_key_secret=true)
    # Create useful data to exercise the code
    created_tenant = setup_test_data(nb_configured_tenants, setup_tenant_key_secret)

    @routes                        = Kaui::Engine.routes
    @request.env['devise.mapping'] = Devise.mappings[:user]

    # Login
    login_as_admin
    # Set the tenant parameter in the session manually since  login_as_admin will erase the previous value
    session[:kb_tenant_id] = created_tenant.tenant_id
  end

  def teardown_functional_test
    check_no_flash_error
  end

  def verify_pagination_results!(min = 0)
    assert_response 200

    body = MultiJson.decode(@response.body)
    # We could probably do better checks here since each test runs in its own tenant
    assert body['iTotalRecords'] >= min
    assert body['iTotalDisplayRecords'] >= min
    assert body['aaData'].instance_of?(Array)
  end

  def login_as_admin
    wrap_with_controller do
      get :new
      post :create, {:user => {:kb_username => USERNAME, :password => PASSWORD}}
    end
  end

  # Cheat to access a different controller
  def wrap_with_controller(new_controller = Kaui::SessionsController)
    old_controller = @controller
    @controller    = new_controller.new
    yield
    @controller = old_controller
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
kaui-0.11.0 test/functional/kaui/functional_test_helper_nosetup.rb
kaui-0.10.0 test/functional/kaui/functional_test_helper_nosetup.rb
kaui-0.9.0 test/functional/kaui/functional_test_helper_nosetup.rb
kaui-0.8.4 test/functional/kaui/functional_test_helper_nosetup.rb
kaui-0.8.3 test/functional/kaui/functional_test_helper_nosetup.rb
kaui-0.8.2 test/functional/kaui/functional_test_helper_nosetup.rb
kaui-0.8.1 test/functional/kaui/functional_test_helper_nosetup.rb
kaui-0.8.0 test/functional/kaui/functional_test_helper_nosetup.rb