<commit_before>[![Build Status](https://travis-ci.org/killbill/killbill-admin-ui.png)](https://travis-ci.org/killbill/killbill-admin-ui)
[![Code Climate](https://codeclimate.com/github/killbill/killbill-admin-ui.png)](https://codeclimate.com/github/killbill/killbill-admin-ui)

Getting started
===============

Running Kaui
------------

You can run Kaui locally using the sandbox script:

    # Point to your killbill installation
    export KILLBILL_URL="http://killbill.company.com:8080"
    # Run the sandbox script
    script/sandbox 
    # Start the Rails app
    cd sandbox
    rails s


Mounting Kaui into your own Rails app
-------------------------------------

The Kaui gem comes with a `kaui` script to mount it in your existing Rails app. See the [Getting Started](http://killbilling.org/start.html#kaui_deployment) guide.

Kaui expects the container app to define the <tt>current_user</tt> method, which returns the
name of the logged-in user. This is used by Killbill for auditing purposes.

Finally, Killbill server needs to be running for Kaui to fetch its information. Set the `KILLBILL_URL`
variable to point to your existing Killbill installation (e.g. http://killbill.company.com:8080).


Multi-Tenancy
-------------

If you are using Kaui against a single tenant, specify your api key and secret in ```config/initializers/killbill_client.rb```:

```
KillBillClient.api_key = 'bob'
KillBillClient.api_secret = 'lazar'
```

Sharing a Kaui instance across multiple tenants is not supported yet (you need to spawn one instance per tenant).


Running tests
-------------

Prepare a kaui_test database locally to be able to run the test suite:

    create database kaui_test;
    grant all privileges on kaui_test.* to 'root'@'localhost' identified by '';

You can run tests using rake:

    rake test<commit_msg>Update README for tests<commit_after>[![Build Status](https://travis-ci.org/killbill/killbill-admin-ui.png)](https://travis-ci.org/killbill/killbill-admin-ui)
[![Code Climate](https://codeclimate.com/github/killbill/killbill-admin-ui.png)](https://codeclimate.com/github/killbill/killbill-admin-ui)

Getting started
===============

Running Kaui
------------

You can run Kaui locally using the sandbox script:

    # Point to your killbill installation
    export KILLBILL_URL="http://killbill.company.com:8080"
    # Run the sandbox script
    script/sandbox 
    # Start the Rails app
    cd sandbox
    rails s


Mounting Kaui into your own Rails app
-------------------------------------

The Kaui gem comes with a `kaui` script to mount it in your existing Rails app. See the [Getting Started](http://killbilling.org/start.html#kaui_deployment) guide.

Kaui expects the container app to define the <tt>current_user</tt> method, which returns the
name of the logged-in user. This is used by Killbill for auditing purposes.

Finally, Killbill server needs to be running for Kaui to fetch its information. Set the `KILLBILL_URL`
variable to point to your existing Killbill installation (e.g. http://killbill.company.com:8080).


Multi-Tenancy
-------------

If you are using Kaui against a single tenant, specify your api key and secret in ```config/initializers/killbill_client.rb```:

```
KillBillClient.api_key = 'bob'
KillBillClient.api_secret = 'lazar'
```

Sharing a Kaui instance across multiple tenants is not supported yet (you need to spawn one instance per tenant).


Running tests
-------------

Go into 'test/dummy': 
> cd test/dummy/

Run mkigrations:
> export RAILS_ENV=test
> rake kaui:install:migrations
> rake db:migrate

Run the tests:
(Move back to top level)
> cd ../..
> rake test
{'fraction_non_alphanumeric': 0.1375894331315355, 'fraction_numerical': 0.004402861860209136, 'mean_word_length': 3.4876543209876543, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 8, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1901838', 'n_tokens_mistral': 1174, 'n_tokens_neox': 1084, 'n_words': 379}