Sha256: 12b8334e908b3f80ce102cd0983d85debc3e8ea517614d563163b5a7ac506675

Contents?: true

Size: 1.53 KB

Versions: 10

Compression:

Stored size: 1.53 KB

Contents

class Kaui::FunctionalTestHelperNoSetup < ActionController::TestCase

  include Devise::TestHelpers
  include Kaui::KillbillTestHelper

  protected

  self.fixture_path = Kaui::Engine.root.join('test', "fixtures")

  #
  # 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
  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['recordsTotal'] >= min
    assert body['recordsFiltered'] >= min
    assert body['data'].instance_of?(Array)
    assert body['error'].nil?
  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

10 entries across 10 versions & 1 rubygems

Version Path
kaui-0.15.5 test/functional/kaui/functional_test_helper_nosetup.rb
kaui-0.15.4 test/functional/kaui/functional_test_helper_nosetup.rb
kaui-0.15.3 test/functional/kaui/functional_test_helper_nosetup.rb
kaui-0.15.2 test/functional/kaui/functional_test_helper_nosetup.rb
kaui-0.15.1 test/functional/kaui/functional_test_helper_nosetup.rb
kaui-0.15.0 test/functional/kaui/functional_test_helper_nosetup.rb
kaui-0.14.2 test/functional/kaui/functional_test_helper_nosetup.rb
kaui-0.14.1 test/functional/kaui/functional_test_helper_nosetup.rb
kaui-0.14.0 test/functional/kaui/functional_test_helper_nosetup.rb
kaui-0.12.0 test/functional/kaui/functional_test_helper_nosetup.rb