kaui 2.1.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +8 -7
- data/Rakefile +4 -2
- data/app/assets/config/kaui_manifest.js +45 -0
- data/app/assets/javascripts/jquery.spin.js +76 -0
- data/app/assets/javascripts/kaui/kaui.js +76 -0
- data/app/assets/javascripts/kaui_application.js +25 -0
- data/app/assets/javascripts/spin.js +76 -0
- data/app/assets/stylesheets/bootstrap_and_overrides.scss +240 -0
- data/app/assets/stylesheets/kaui/{account.less → account.scss} +4 -0
- data/app/assets/stylesheets/kaui/{audit.less → audit.scss} +5 -1
- data/app/assets/stylesheets/kaui/{common.less → common.scss} +17 -15
- data/app/assets/stylesheets/kaui/{datatable.less → datatable.scss} +6 -3
- data/app/assets/stylesheets/kaui/{header.less → header.scss} +16 -12
- data/app/assets/stylesheets/kaui/{home.less → home.scss} +7 -4
- data/app/assets/stylesheets/kaui/{invoice.less → invoice.scss} +7 -3
- data/app/assets/stylesheets/kaui/kaui.scss +265 -0
- data/app/assets/stylesheets/kaui/kaui_bootstrap.scss +3 -0
- data/app/assets/stylesheets/kaui/{overdue.less → overdue.scss} +3 -1
- data/app/assets/stylesheets/kaui/{payment.less → payment.scss} +3 -0
- data/app/assets/stylesheets/kaui/{subscription.less → subscription.scss} +4 -1
- data/app/assets/stylesheets/kaui/{tags.less → tags.scss} +9 -5
- data/app/assets/stylesheets/kaui/timeline.scss +7 -0
- data/app/assets/stylesheets/kaui/tooltip.scss +15 -0
- data/app/controllers/kaui/account_children_controller.rb +25 -28
- data/app/controllers/kaui/account_custom_fields_controller.rb +16 -15
- data/app/controllers/kaui/account_emails_controller.rb +28 -25
- data/app/controllers/kaui/account_tags_controller.rb +37 -34
- data/app/controllers/kaui/account_timelines_controller.rb +38 -33
- data/app/controllers/kaui/accounts_controller.rb +268 -250
- data/app/controllers/kaui/admin_allowed_users_controller.rb +105 -99
- data/app/controllers/kaui/admin_controller.rb +32 -31
- data/app/controllers/kaui/admin_tenants_controller.rb +434 -388
- data/app/controllers/kaui/audit_logs_controller.rb +86 -83
- data/app/controllers/kaui/bundle_tags_controller.rb +24 -20
- data/app/controllers/kaui/bundles_controller.rb +96 -82
- data/app/controllers/kaui/chargebacks_controller.rb +36 -33
- data/app/controllers/kaui/charges_controller.rb +23 -20
- data/app/controllers/kaui/credits_controller.rb +28 -25
- data/app/controllers/kaui/custom_fields_controller.rb +172 -38
- data/app/controllers/kaui/engine_controller.rb +2 -1
- data/app/controllers/kaui/engine_controller_util.rb +128 -117
- data/app/controllers/kaui/home_controller.rb +230 -217
- data/app/controllers/kaui/invoice_items_controller.rb +43 -39
- data/app/controllers/kaui/invoice_tags_controller.rb +24 -20
- data/app/controllers/kaui/invoices_controller.rb +132 -117
- data/app/controllers/kaui/login_proxy_controller.rb +2 -1
- data/app/controllers/kaui/payment_methods_controller.rb +102 -94
- data/app/controllers/kaui/payments_controller.rb +95 -92
- data/app/controllers/kaui/queues_controller.rb +47 -14
- data/app/controllers/kaui/refunds_controller.rb +36 -33
- data/app/controllers/kaui/registrations_controller.rb +7 -7
- data/app/controllers/kaui/role_definitions_controller.rb +17 -14
- data/app/controllers/kaui/sessions_controller.rb +7 -4
- data/app/controllers/kaui/subscriptions_controller.rb +197 -187
- data/app/controllers/kaui/tag_definitions_controller.rb +28 -27
- data/app/controllers/kaui/tags_controller.rb +25 -22
- data/app/controllers/kaui/tenants_controller.rb +30 -28
- data/app/controllers/kaui/transactions_controller.rb +43 -38
- data/app/helpers/kaui/account_helper.rb +16 -14
- data/app/helpers/kaui/application_helper.rb +8 -3
- data/app/helpers/kaui/date_helper.rb +4 -3
- data/app/helpers/kaui/home_helper.rb +2 -0
- data/app/helpers/kaui/locale_helper.rb +7 -6
- data/app/helpers/kaui/money_helper.rb +2 -1
- data/app/helpers/kaui/object_helper.rb +11 -10
- data/app/helpers/kaui/payment_helper.rb +7 -6
- data/app/helpers/kaui/payment_method_helper.rb +3 -2
- data/app/helpers/kaui/permissions_helper.rb +9 -9
- data/app/helpers/kaui/plugin_helper.rb +25 -23
- data/app/helpers/kaui/subscription_helper.rb +27 -29
- data/app/helpers/kaui/us_states_helper.rb +7 -6
- data/app/helpers/kaui/uuid_helper.rb +8 -6
- data/app/models/kaui/ability.rb +19 -12
- data/app/models/kaui/account.rb +45 -28
- data/app/models/kaui/account_email.rb +23 -20
- data/app/models/kaui/account_timeline.rb +5 -1
- data/app/models/kaui/admin.rb +65 -64
- data/app/models/kaui/admin_tenant.rb +81 -82
- data/app/models/kaui/allowed_user.rb +13 -9
- data/app/models/kaui/allowed_user_tenant.rb +4 -2
- data/app/models/kaui/application_record.rb +2 -0
- data/app/models/kaui/audit_log.rb +6 -3
- data/app/models/kaui/base.rb +13 -7
- data/app/models/kaui/bundle.rb +41 -24
- data/app/models/kaui/catalog.rb +118 -113
- data/app/models/kaui/chargeback.rb +5 -1
- data/app/models/kaui/credit.rb +4 -1
- data/app/models/kaui/custom_field.rb +9 -6
- data/app/models/kaui/invoice.rb +25 -22
- data/app/models/kaui/invoice_item.rb +9 -6
- data/app/models/kaui/invoice_payment.rb +49 -54
- data/app/models/kaui/killbill_authenticatable.rb +14 -8
- data/app/models/kaui/killbill_registerable.rb +7 -0
- data/app/models/kaui/overdue.rb +64 -65
- data/app/models/kaui/payment.rb +22 -19
- data/app/models/kaui/payment_method.rb +48 -39
- data/app/models/kaui/payment_state.rb +41 -38
- data/app/models/kaui/rails_methods.rb +9 -9
- data/app/models/kaui/refund.rb +7 -1
- data/app/models/kaui/role_definition.rb +5 -1
- data/app/models/kaui/simple_plan.rb +5 -3
- data/app/models/kaui/subscription.rb +10 -7
- data/app/models/kaui/tag.rb +25 -22
- data/app/models/kaui/tag_definition.rb +50 -45
- data/app/models/kaui/tenant.rb +6 -5
- data/app/models/kaui/transaction.rb +43 -31
- data/app/models/kaui/user.rb +10 -16
- data/app/models/kaui/user_role.rb +8 -5
- data/app/views/kaui/accounts/_billing_info.html.erb +1 -1
- data/app/views/kaui/accounts/_form.html.erb +2 -2
- data/app/views/kaui/accounts/index.html.erb +2 -0
- data/app/views/kaui/admin_allowed_users/_form.html.erb +3 -3
- data/app/views/kaui/admin_tenants/_form_catalog_translation.erb +1 -1
- data/app/views/kaui/admin_tenants/_form_invoice_template.erb +1 -1
- data/app/views/kaui/admin_tenants/_form_invoice_translation.erb +1 -1
- data/app/views/kaui/admin_tenants/_show_catalog_simple.erb +11 -5
- data/app/views/kaui/admin_tenants/new_catalog.html.erb +2 -2
- data/app/views/kaui/admin_tenants/new_overdue_config.html.erb +2 -2
- data/app/views/kaui/admin_tenants/new_plan_currency.html.erb +1 -1
- data/app/views/kaui/bundles/index.html.erb +1 -1
- data/app/views/kaui/bundles/transfer.html.erb +13 -5
- data/app/views/kaui/invoices/_invoice_table.html.erb +1 -1
- data/app/views/kaui/layouts/kaui_flash.html.erb +24 -0
- data/app/views/kaui/layouts/kaui_header.html.erb +19 -2
- data/app/views/kaui/payment_methods/_payment_methods_details_table.html.erb +13 -4
- data/app/views/kaui/payments/_payment_table.html.erb +21 -11
- data/app/views/kaui/payments/index.html.erb +9 -9
- data/app/views/kaui/queues/index.html.erb +1 -1
- data/app/views/kaui/subscriptions/_cancel_by_date_modal.html.erb +1 -4
- data/app/views/kaui/subscriptions/_edit_form.html.erb +1 -1
- data/app/views/kaui/subscriptions/_form.html.erb +1 -1
- data/app/views/kaui/subscriptions/_subscriptions_table.html.erb +3 -3
- data/app/views/kaui/subscriptions/edit_bcd.erb +1 -1
- data/app/views/kaui/tag_definitions/index.html.erb +2 -2
- data/app/views/kaui/tags/index.html.erb +1 -0
- data/config/initializers/bootstrap_datepicker_rails.rb +3 -0
- data/config/initializers/devise.rb +8 -6
- data/config/initializers/js_routes.rb +9 -0
- data/config/initializers/kilbill_client_init.rb +13 -0
- data/config/initializers/killbill_authenticatable.rb +71 -21
- data/config/initializers/killbill_registerable.rb +5 -3
- data/config/initializers/time_formats.rb +6 -4
- data/config/locales/en.yml +78 -1
- data/config/routes.rb +34 -32
- data/db/migrate/20130812155313_devise_create_kaui_users.rb +10 -8
- data/db/migrate/20150109214021_create_kaui_tenants.rb +10 -8
- data/db/migrate/20150112232813_create_kaui_allowed_users.rb +10 -8
- data/lib/generators/kaui/install/install_generator.rb +23 -20
- data/lib/generators/kaui/install/templates/config/initializers/kaui.rb +3 -1
- data/lib/kaui/engine.rb +17 -5
- data/lib/kaui/installer/installer.rb +27 -26
- data/lib/kaui/version.rb +3 -1
- data/lib/kaui.rb +28 -30
- data/lib/tasks/kaui_tasks.rake +1 -0
- metadata +136 -438
- data/app/assets/javascripts/application.js +0 -17
- data/app/assets/javascripts/kaui/bootstrap-tweaks.js +0 -172
- data/app/assets/stylesheets/bootstrap_and_overrides.css.less +0 -44
- data/app/assets/stylesheets/kaui/kaui.less +0 -21
- data/app/assets/stylesheets/kaui/timeline.less +0 -4
- data/config/initializers/asset.rb +0 -1
- data/config/initializers/kilbill-client-init.rb +0 -9
- data/db/schema.rb +0 -15
- data/test/dummy/README.rdoc +0 -261
- data/test/dummy/Rakefile +0 -7
- data/test/dummy/app/controllers/application_controller.rb +0 -9
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/bin/bundle +0 -3
- data/test/dummy/bin/rails +0 -4
- data/test/dummy/bin/rake +0 -4
- data/test/dummy/bin/setup +0 -38
- data/test/dummy/bin/update +0 -29
- data/test/dummy/bin/yarn +0 -11
- data/test/dummy/config/application.rb +0 -18
- data/test/dummy/config/boot.rb +0 -3
- data/test/dummy/config/database.yml +0 -27
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -58
- data/test/dummy/config/environments/production.rb +0 -91
- data/test/dummy/config/environments/test.rb +0 -49
- data/test/dummy/config/initializers/application_controller_renderer.rb +0 -6
- data/test/dummy/config/initializers/assets.rb +0 -14
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/cookies_serializer.rb +0 -5
- data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/test/dummy/config/initializers/inflections.rb +0 -16
- data/test/dummy/config/initializers/killbill_client.rb +0 -1
- data/test/dummy/config/initializers/mime_types.rb +0 -4
- data/test/dummy/config/initializers/money.rb +0 -2
- data/test/dummy/config/initializers/new_framework_defaults_5_1.rb +0 -14
- data/test/dummy/config/initializers/secret_token.rb +0 -7
- data/test/dummy/config/initializers/session_store.rb +0 -8
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/locales/en.yml +0 -33
- data/test/dummy/config/routes.rb +0 -3
- data/test/dummy/config/secrets.yml +0 -32
- data/test/dummy/config/symmetric-encryption.yml +0 -135
- data/test/dummy/config.ru +0 -4
- data/test/dummy/db/schema.rb +0 -52
- data/test/dummy/public/404.html +0 -26
- data/test/dummy/public/422.html +0 -26
- data/test/dummy/public/500.html +0 -25
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +0 -6
- data/test/fixtures/SpyCarAdvanced.xml +0 -824
- data/test/fixtures/catalog-v1.xml +0 -73
- data/test/fixtures/catalog_translation_fr-v1.properties +0 -1
- data/test/fixtures/invoice_template-v1.html +0 -100
- data/test/fixtures/invoice_translation_fr-v1.properties +0 -23
- data/test/fixtures/overdue-v1.xml +0 -49
- data/test/fixtures/stripe.yml +0 -2
- data/test/functional/kaui/account_children_controller_test.rb +0 -32
- data/test/functional/kaui/account_custom_fields_controller_test.rb +0 -29
- data/test/functional/kaui/account_emails_controller_test.rb +0 -55
- data/test/functional/kaui/account_tags_controller_test.rb +0 -48
- data/test/functional/kaui/account_timelines_controller_test.rb +0 -20
- data/test/functional/kaui/accounts_controller_test.rb +0 -297
- data/test/functional/kaui/admin_allowed_users_controller_test.rb +0 -234
- data/test/functional/kaui/admin_controller_test.rb +0 -45
- data/test/functional/kaui/admin_tenants_controller_test.rb +0 -352
- data/test/functional/kaui/audit_logs_controller_test.rb +0 -71
- data/test/functional/kaui/bundle_tags_controller_test.rb +0 -23
- data/test/functional/kaui/bundles_controller_test.rb +0 -130
- data/test/functional/kaui/chargebacks_controller_test.rb +0 -42
- data/test/functional/kaui/charges_controller_test.rb +0 -60
- data/test/functional/kaui/credits_controller_test.rb +0 -54
- data/test/functional/kaui/custom_fields_controller_test.rb +0 -52
- data/test/functional/kaui/functional_test_helper.rb +0 -13
- data/test/functional/kaui/functional_test_helper_nosetup.rb +0 -120
- data/test/functional/kaui/home_controller_test.rb +0 -407
- data/test/functional/kaui/invoice_items_controller_test.rb +0 -82
- data/test/functional/kaui/invoices_controller_test.rb +0 -88
- data/test/functional/kaui/login_proxy_controller_test.rb +0 -12
- data/test/functional/kaui/payment_methods_controller_test.rb +0 -52
- data/test/functional/kaui/payments_controller_test.rb +0 -59
- data/test/functional/kaui/queues_controller_test.rb +0 -17
- data/test/functional/kaui/refunds_controller_test.rb +0 -63
- data/test/functional/kaui/registrations_controller_test.rb +0 -49
- data/test/functional/kaui/role_definitions_controller_test.rb +0 -47
- data/test/functional/kaui/subscriptions_controller_test.rb +0 -194
- data/test/functional/kaui/tag_definitions_controller_test.rb +0 -29
- data/test/functional/kaui/tags_controller_test.rb +0 -21
- data/test/functional/kaui/tenants_controller_test.rb +0 -60
- data/test/functional/kaui/transactions_controller_test.rb +0 -90
- data/test/integration/kaui/date_helper_integration_test.rb +0 -16
- data/test/integration/kaui/integration_test_helper.rb +0 -32
- data/test/integration/kaui/navigation_test.rb +0 -43
- data/test/killbill_test_helper.rb +0 -219
- data/test/test_helper.rb +0 -22
- data/test/unit/helpers/kaui/admin_allowed_users_helper_test.rb +0 -6
- data/test/unit/helpers/kaui/admin_tenants_helper_test.rb +0 -6
- data/test/unit/helpers/kaui/payment_method_helper_test.rb +0 -17
- data/test/unit/helpers/kaui/tenants_helper_test.rb +0 -6
- data/test/unit/helpers/kaui/uuid_helper_test.rb +0 -16
- data/test/unit/kaui/account_email_test.rb +0 -19
- data/test/unit/kaui/account_test.rb +0 -14
- data/test/unit/kaui/admin_tenant_test.rb +0 -132
- data/test/unit/kaui/allowed_user_test.rb +0 -34
- data/test/unit/kaui/base_test.rb +0 -23
- data/test/unit/kaui/date_helper_test.rb +0 -26
- data/test/unit/kaui/invoice_item_test.rb +0 -11
- data/test/unit/kaui/invoice_payment_test.rb +0 -42
- data/test/unit/kaui/invoice_test.rb +0 -20
- data/test/unit/kaui/money_helper_test.rb +0 -16
- data/test/unit/kaui/payment_test.rb +0 -42
- data/test/unit/kaui/tag_definition_test.rb +0 -11
- data/test/unit/kaui/tenant_test.rb +0 -19
- /data/app/assets/stylesheets/{application.css → kaui_application.css} +0 -0
@@ -1,54 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class Kaui::CreditsControllerTest < Kaui::FunctionalTestHelper
|
4
|
-
|
5
|
-
test 'should handle Kill Bill errors in new screen' do
|
6
|
-
invoice_id = SecureRandom.uuid.to_s
|
7
|
-
get :new, :account_id => @account.account_id, :invoice_id => invoice_id
|
8
|
-
assert_redirected_to account_path(@account.account_id)
|
9
|
-
assert_equal "Error while communicating with the Kill Bill server: Object id=#{invoice_id} type=INVOICE doesn't exist!", flash[:error]
|
10
|
-
end
|
11
|
-
|
12
|
-
test 'should get new for new invoice' do
|
13
|
-
get :new, :account_id => @account.account_id
|
14
|
-
assert_response 200
|
15
|
-
end
|
16
|
-
|
17
|
-
test 'should get new for existing invoice' do
|
18
|
-
get :new, :account_id => @account.account_id, :invoice_id => @invoice_item.invoice_id
|
19
|
-
assert_response 200
|
20
|
-
end
|
21
|
-
|
22
|
-
test 'should handle Kill Bill errors during creation' do
|
23
|
-
invoice_id = SecureRandom.uuid.to_s
|
24
|
-
post :create,
|
25
|
-
:account_id => @account.account_id,
|
26
|
-
:credit => {
|
27
|
-
:invoice_id => invoice_id,
|
28
|
-
:amount => 5.34
|
29
|
-
}
|
30
|
-
assert_redirected_to account_path(@account.account_id)
|
31
|
-
assert_equal "Error while communicating with the Kill Bill server: Object id=#{invoice_id} type=INVOICE doesn't exist!", flash[:error]
|
32
|
-
end
|
33
|
-
|
34
|
-
test 'should create credit' do
|
35
|
-
post :create,
|
36
|
-
:account_id => @account.account_id,
|
37
|
-
:credit => {
|
38
|
-
:amount => 5.34
|
39
|
-
}
|
40
|
-
assert_redirected_to account_path(@account.account_id)
|
41
|
-
assert_equal 'Credit was successfully created', flash[:notice]
|
42
|
-
end
|
43
|
-
|
44
|
-
test 'should create credit for existing invoice' do
|
45
|
-
post :create,
|
46
|
-
:account_id => @account.account_id,
|
47
|
-
:credit => {
|
48
|
-
:invoice_id => @invoice_item.invoice_id,
|
49
|
-
:amount => 5.34
|
50
|
-
}
|
51
|
-
assert_redirected_to account_invoice_path(@account.account_id, @invoice_item.invoice_id)
|
52
|
-
assert_equal 'Credit was successfully created', flash[:notice]
|
53
|
-
end
|
54
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class Kaui::CustomFieldsControllerTest < Kaui::FunctionalTestHelper
|
4
|
-
|
5
|
-
test 'should get index' do
|
6
|
-
get :index
|
7
|
-
assert_response 200
|
8
|
-
end
|
9
|
-
|
10
|
-
test 'should list custom fields' do
|
11
|
-
# Test pagination
|
12
|
-
get :pagination, :format => :json
|
13
|
-
verify_pagination_results!
|
14
|
-
end
|
15
|
-
|
16
|
-
test 'should search custom fields' do
|
17
|
-
# Test search
|
18
|
-
get :pagination, :search => {:search => 'foo'}, :format => :json
|
19
|
-
verify_pagination_results!
|
20
|
-
end
|
21
|
-
|
22
|
-
test 'should create custom fields' do
|
23
|
-
get :new
|
24
|
-
assert_response 200
|
25
|
-
assert_not_nil assigns(:custom_field)
|
26
|
-
|
27
|
-
# TODO https://github.com/killbill/killbill-client-ruby/issues/17
|
28
|
-
{
|
29
|
-
:ACCOUNT => @account.account_id,
|
30
|
-
:BUNDLE => @bundle.bundle_id,
|
31
|
-
:SUBSCRIPTION => @bundle_invoice.items.first.subscription_id,
|
32
|
-
:INVOICE => @bundle_invoice.invoice_id,
|
33
|
-
:PAYMENT => @payment.payment_id,
|
34
|
-
:INVALID => 0
|
35
|
-
}.each do |object_type, object_id|
|
36
|
-
post :create,
|
37
|
-
:custom_field => {
|
38
|
-
:object_id => object_id,
|
39
|
-
:object_type => object_type,
|
40
|
-
:name => SecureRandom.uuid.to_s,
|
41
|
-
:value => SecureRandom.uuid.to_s,
|
42
|
-
}
|
43
|
-
if object_type.eql?(:INVALID)
|
44
|
-
assert_response :success
|
45
|
-
assert_equal 'Invalid object type INVALID',flash.now[:error]
|
46
|
-
else
|
47
|
-
assert_redirected_to custom_fields_path
|
48
|
-
assert_equal 'Custom field was successfully created', flash[:notice]
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
class Kaui::FunctionalTestHelper < Kaui::FunctionalTestHelperNoSetup
|
2
|
-
|
3
|
-
# Called before every single test
|
4
|
-
setup do
|
5
|
-
Kaui::ApplicationRecord.subclasses.each(&:delete_all)
|
6
|
-
setup_functional_test
|
7
|
-
end
|
8
|
-
|
9
|
-
# Called after every single test
|
10
|
-
teardown do
|
11
|
-
teardown_functional_test
|
12
|
-
end
|
13
|
-
end
|
@@ -1,120 +0,0 @@
|
|
1
|
-
class Kaui::FunctionalTestHelperNoSetup < ActionController::TestCase
|
2
|
-
|
3
|
-
include Devise::Test::ControllerHelpers
|
4
|
-
include Kaui::KillbillTestHelper
|
5
|
-
|
6
|
-
protected
|
7
|
-
|
8
|
-
self.fixture_path = Kaui::Engine.root.join('test', "fixtures")
|
9
|
-
|
10
|
-
#
|
11
|
-
# Rails helpers
|
12
|
-
#
|
13
|
-
|
14
|
-
def setup_functional_test(nb_configured_tenants = 1, setup_tenant_key_secret=true)
|
15
|
-
# Create useful data to exercise the code
|
16
|
-
created_tenant = setup_test_data(nb_configured_tenants, setup_tenant_key_secret)
|
17
|
-
|
18
|
-
@routes = Kaui::Engine.routes
|
19
|
-
@request.env['devise.mapping'] = Devise.mappings[:user]
|
20
|
-
|
21
|
-
# Login
|
22
|
-
login_as_admin
|
23
|
-
# Set the tenant parameter in the session manually since login_as_admin will erase the previous value
|
24
|
-
session[:kb_tenant_id] = created_tenant.tenant_id
|
25
|
-
|
26
|
-
# get the killbill server clock
|
27
|
-
@kb_clock = get_clock(@tenant)
|
28
|
-
end
|
29
|
-
|
30
|
-
def teardown_functional_test
|
31
|
-
reset_clock
|
32
|
-
end
|
33
|
-
|
34
|
-
def verify_pagination_results!(min = 0)
|
35
|
-
assert_response 200
|
36
|
-
|
37
|
-
body = MultiJson.decode(@response.body)
|
38
|
-
# We could probably do better checks here since each test runs in its own tenant
|
39
|
-
assert body['recordsTotal'] >= min
|
40
|
-
assert body['recordsFiltered'] >= min
|
41
|
-
assert body['data'].instance_of?(Array)
|
42
|
-
assert body['error'].nil?
|
43
|
-
end
|
44
|
-
|
45
|
-
def login_as_admin
|
46
|
-
wrap_with_controller do
|
47
|
-
get :new
|
48
|
-
post :create, {:user => {:kb_username => USERNAME, :password => PASSWORD}}
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def logout
|
53
|
-
wrap_with_controller do
|
54
|
-
post :destroy
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
# Cheat to access a different controller
|
59
|
-
def wrap_with_controller(new_controller = Kaui::SessionsController)
|
60
|
-
old_controller = @controller
|
61
|
-
@controller = new_controller.new
|
62
|
-
yield
|
63
|
-
@controller = old_controller
|
64
|
-
end
|
65
|
-
|
66
|
-
# To ease the upgrade... inspired by https://stackoverflow.com/a/43787973
|
67
|
-
# See https://github.com/rails/rails/blob/master/actionpack/lib/action_controller/test_case.rb
|
68
|
-
def get(action, **args)
|
69
|
-
res = process(action, method: "GET", params: args)
|
70
|
-
cookies.update res.cookies
|
71
|
-
res
|
72
|
-
end
|
73
|
-
def post(action, **args)
|
74
|
-
process(action, method: "POST", params: args)
|
75
|
-
end
|
76
|
-
def put(action, **args)
|
77
|
-
process(action, method: "PUT", params: args)
|
78
|
-
end
|
79
|
-
def delete(action, **args)
|
80
|
-
process(action, method: "DELETE", params: args)
|
81
|
-
end
|
82
|
-
def head(action, **args)
|
83
|
-
process(action, method: "HEAD", params: args)
|
84
|
-
end
|
85
|
-
def patch(action, **args)
|
86
|
-
process(action, method: "PATCH", params: args)
|
87
|
-
end
|
88
|
-
|
89
|
-
# response related methods
|
90
|
-
def response_path
|
91
|
-
return nil if @response.nil? || !@response.has_header?('Location')
|
92
|
-
|
93
|
-
URI(@response.get_header('Location')).path
|
94
|
-
end
|
95
|
-
|
96
|
-
def get_value_from_input_field(input_id_name)
|
97
|
-
return nil if input_id_name.nil? || @response.nil? || @response.body.nil?
|
98
|
-
|
99
|
-
#pattern where id/name is after the value
|
100
|
-
pattern_1 = Regexp.new('<input.*value="(?<value>.+?)".*(id=.'+input_id_name+'|name=.'+input_id_name+')..*>')
|
101
|
-
|
102
|
-
#pattern where id/name is before the value
|
103
|
-
pattern_2 = Regexp.new('<input.*(id=.'+input_id_name+'|name=.'+input_id_name+')..*value="(?<value>.+?)".*>')
|
104
|
-
|
105
|
-
input = pattern_1.match(@response.body)
|
106
|
-
input = pattern_2.match(@response.body) if input.nil?
|
107
|
-
|
108
|
-
input.nil? ? nil : input[:value]
|
109
|
-
end
|
110
|
-
|
111
|
-
def has_input_field(input_id_name)
|
112
|
-
return nil if input_id_name.nil? || @response.nil? || @response.body.nil?
|
113
|
-
|
114
|
-
pattern = Regexp.new('<input.*(id=.'+input_id_name+'|name=.'+input_id_name+')..*>')
|
115
|
-
input = pattern.match(@response.body)
|
116
|
-
|
117
|
-
!input.nil?
|
118
|
-
end
|
119
|
-
|
120
|
-
end
|
@@ -1,407 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class Kaui::HomeControllerTest < Kaui::FunctionalTestHelper
|
4
|
-
|
5
|
-
test 'should get index' do
|
6
|
-
get :index
|
7
|
-
assert_response :success
|
8
|
-
end
|
9
|
-
|
10
|
-
test 'should understand account search queries' do
|
11
|
-
dummy_uuid = SecureRandom.uuid.to_s
|
12
|
-
# search defaults using a UUID
|
13
|
-
get :search, :q => @account.account_id
|
14
|
-
assert_redirected_to account_path(@account.account_id)
|
15
|
-
|
16
|
-
# search defaults using a String
|
17
|
-
get :search, :q => @account.name
|
18
|
-
assert_redirected_to accounts_path(:fast => 0, :q => @account.name)
|
19
|
-
|
20
|
-
# search by ID
|
21
|
-
get :search, :q => query_builder('ACCOUNT',@account.account_id, 'ID')
|
22
|
-
assert_redirected_to account_path(@account.account_id)
|
23
|
-
|
24
|
-
# search by ID and fails
|
25
|
-
get :search, :q => query_builder('ACCOUNT',dummy_uuid, 'ID')
|
26
|
-
assert_redirected_to home_path
|
27
|
-
assert_equal "No account matches \"#{dummy_uuid}\"", flash[:error]
|
28
|
-
|
29
|
-
# search by EXTERNAL_KEY
|
30
|
-
get :search, :q => query_builder('ACCOUNT',@account.external_key, 'EXTERNAL_KEY')
|
31
|
-
assert_redirected_to account_path(@account.account_id)
|
32
|
-
|
33
|
-
# search by EXTERNAL_KEY and fails
|
34
|
-
get :search, :q => query_builder('ACCOUNT',dummy_uuid, 'EXTERNAL_KEY')
|
35
|
-
assert_redirected_to home_path
|
36
|
-
assert_equal "No account matches \"#{dummy_uuid}\"", flash[:error]
|
37
|
-
|
38
|
-
# search by BLANK only first
|
39
|
-
get :search, :q => query_builder('ACCOUNT',@account.name, nil, '1')
|
40
|
-
assert_redirected_to account_path(@account.account_id)
|
41
|
-
|
42
|
-
# search by BLANK
|
43
|
-
get :search, :q => query_builder('ACCOUNT',@account.name)
|
44
|
-
assert_redirected_to accounts_path(:fast => 0, :q => @account.name)
|
45
|
-
|
46
|
-
# search by BLANK and fails
|
47
|
-
get :search, :q => query_builder('ACCOUNT',dummy_uuid)
|
48
|
-
assert_redirected_to home_path
|
49
|
-
assert_equal "No account matches \"#{dummy_uuid}\"", flash[:error]
|
50
|
-
end
|
51
|
-
|
52
|
-
test 'should understand invoice search queries' do
|
53
|
-
# search by ID
|
54
|
-
get :search, :q => query_builder('INVOICE',@invoice_item.invoice_id, 'ID')
|
55
|
-
assert_redirected_to account_invoice_path(@invoice_item.account_id, @invoice_item.invoice_id)
|
56
|
-
|
57
|
-
# search by ID and fails
|
58
|
-
get :search, :q => query_builder('INVOICE','112', 'ID')
|
59
|
-
assert_redirected_to home_path
|
60
|
-
assert_equal "No invoice matches \"112\"", flash[:error]
|
61
|
-
|
62
|
-
# search by EXTERNAL_KEY and fails
|
63
|
-
get :search, :q => query_builder('INVOICE','112', 'EXTERNAL_KEY')
|
64
|
-
assert_redirected_to home_path
|
65
|
-
assert_equal "\"INVOICE\": Search by \"EXTERNAL KEY\" is not supported.", flash[:error]
|
66
|
-
|
67
|
-
# search by BLANK only first
|
68
|
-
get :search, :q => query_builder('INVOICE',@bundle_invoice.invoice_number, nil, '1')
|
69
|
-
assert_redirected_to account_invoice_path(@bundle_invoice.account_id, @bundle_invoice.invoice_id)
|
70
|
-
|
71
|
-
# search by BLANK only first (invoice item)
|
72
|
-
get :search, :q => query_builder('INVOICE',@bundle_invoice.items[0].invoice_item_id, nil, '1')
|
73
|
-
assert_redirected_to account_invoice_path(@bundle_invoice.account_id, @bundle_invoice.invoice_id)
|
74
|
-
|
75
|
-
# search by BLANK
|
76
|
-
get :search, :q => query_builder('INVOICE',@bundle_invoice.invoice_number)
|
77
|
-
assert_redirected_to account_invoices_path(:account_id => @bundle_invoice.account_id, :q => @bundle_invoice.invoice_number, :fast => '0')
|
78
|
-
|
79
|
-
# search by BLANK and fails
|
80
|
-
get :search, :q => query_builder('INVOICE','112')
|
81
|
-
assert_redirected_to home_path
|
82
|
-
assert_equal "No invoice matches \"112\"", flash[:error]
|
83
|
-
end
|
84
|
-
|
85
|
-
test 'should understand payment search queries' do
|
86
|
-
dummy_uuid = SecureRandom.uuid.to_s
|
87
|
-
# search by ID
|
88
|
-
get :search, :q => query_builder('PAYMENT',@payment.payment_id, 'ID')
|
89
|
-
assert_redirected_to account_payment_path(@payment.account_id,@payment.payment_id)
|
90
|
-
|
91
|
-
# search by ID and fails
|
92
|
-
get :search, :q => query_builder('PAYMENT',dummy_uuid, 'ID')
|
93
|
-
assert_redirected_to home_path
|
94
|
-
assert_equal "No payment matches \"#{dummy_uuid}\"", flash[:error]
|
95
|
-
|
96
|
-
# search by EXTERNAL_KEY
|
97
|
-
get :search, :q => query_builder('PAYMENT',@payment.payment_external_key, 'EXTERNAL_KEY')
|
98
|
-
assert_redirected_to account_payment_path(@payment.account_id,@payment.payment_id)
|
99
|
-
|
100
|
-
# search by EXTERNAL_KEY and fails
|
101
|
-
get :search, :q => query_builder('PAYMENT',dummy_uuid, 'EXTERNAL_KEY')
|
102
|
-
assert_redirected_to home_path
|
103
|
-
assert_equal "No payment matches \"#{dummy_uuid}\"", flash[:error]
|
104
|
-
|
105
|
-
# search by BLANK only first
|
106
|
-
get :search, :q => query_builder('PAYMENT','SUCCESS', nil, '1')
|
107
|
-
assert_redirected_to account_payment_path(@payment.account_id,@payment.payment_id)
|
108
|
-
|
109
|
-
# search by BLANK
|
110
|
-
get :search, :q => query_builder('PAYMENT','SUCCESS')
|
111
|
-
assert_redirected_to account_payments_path(:account_id => @payment.account_id, :q => 'SUCCESS', :fast => '0')
|
112
|
-
|
113
|
-
# search by BLANK and fails
|
114
|
-
get :search, :q => query_builder('PAYMENT','FAILED')
|
115
|
-
assert_redirected_to home_path
|
116
|
-
assert_equal "No payment matches \"FAILED\"", flash[:error]
|
117
|
-
end
|
118
|
-
|
119
|
-
test 'should understand transaction search queries' do
|
120
|
-
dummy_uuid = SecureRandom.uuid.to_s
|
121
|
-
# search by ID
|
122
|
-
get :search, :q => query_builder('TRANSACTION',@payment.transactions[0].transaction_id, 'ID')
|
123
|
-
assert_redirected_to account_payment_path(@payment.account_id, @payment.payment_id)
|
124
|
-
|
125
|
-
# search by ID and fails
|
126
|
-
get :search, :q => query_builder('TRANSACTION',dummy_uuid, 'ID')
|
127
|
-
assert_redirected_to home_path
|
128
|
-
assert_equal "No transaction matches \"#{dummy_uuid}\"", flash[:error]
|
129
|
-
|
130
|
-
# search by EXTERNAL_KEY
|
131
|
-
get :search, :q => query_builder('TRANSACTION',@payment.transactions[0].transaction_external_key, 'EXTERNAL_KEY')
|
132
|
-
assert_redirected_to account_payment_path(@payment.account_id,@payment.payment_id)
|
133
|
-
|
134
|
-
# search by EXTERNAL_KEY and fails
|
135
|
-
get :search, :q => query_builder('TRANSACTION',dummy_uuid, 'EXTERNAL_KEY')
|
136
|
-
assert_redirected_to home_path
|
137
|
-
assert_equal "No transaction matches \"#{dummy_uuid}\"", flash[:error]
|
138
|
-
|
139
|
-
# search by BLANK only first
|
140
|
-
get :search, :q => query_builder('TRANSACTION',@payment.transactions[0].transaction_id, nil, '1')
|
141
|
-
assert_redirected_to account_payment_path(@payment.account_id, @payment.payment_id)
|
142
|
-
|
143
|
-
# search by BLANK
|
144
|
-
get :search, :q => query_builder('TRANSACTION',@payment.transactions[0].transaction_id)
|
145
|
-
assert_redirected_to account_payment_path(@payment.account_id, @payment.payment_id)
|
146
|
-
|
147
|
-
# search by BLANK and fails
|
148
|
-
get :search, :q => query_builder('TRANSACTION','112')
|
149
|
-
assert_redirected_to home_path
|
150
|
-
assert_equal "No transaction matches \"112\"", flash[:error]
|
151
|
-
end
|
152
|
-
|
153
|
-
test 'should understand bundle search queries' do
|
154
|
-
dummy_uuid = SecureRandom.uuid.to_s
|
155
|
-
# search by ID
|
156
|
-
get :search, :q => query_builder('BUNDLE',@bundle.bundle_id, 'ID')
|
157
|
-
assert_redirected_to account_bundles_path(@bundle.account_id)
|
158
|
-
|
159
|
-
# search by ID and fails
|
160
|
-
get :search, :q => query_builder('BUNDLE',dummy_uuid, 'ID')
|
161
|
-
assert_redirected_to home_path
|
162
|
-
assert_equal "No bundle matches \"#{dummy_uuid}\"", flash[:error]
|
163
|
-
|
164
|
-
# search by EXTERNAL_KEY
|
165
|
-
get :search, :q => query_builder('BUNDLE',@bundle.external_key, 'EXTERNAL_KEY')
|
166
|
-
assert_redirected_to account_bundles_path(@bundle.account_id)
|
167
|
-
|
168
|
-
# search by EXTERNAL_KEY and fails
|
169
|
-
get :search, :q => query_builder('BUNDLE',dummy_uuid, 'EXTERNAL_KEY')
|
170
|
-
assert_redirected_to home_path
|
171
|
-
assert_equal "No bundle matches \"#{dummy_uuid}\"", flash[:error]
|
172
|
-
|
173
|
-
# search by BLANK only first
|
174
|
-
get :search, :q => query_builder('BUNDLE',@bundle.account_id, nil, '1')
|
175
|
-
assert_redirected_to account_bundles_path(@bundle.account_id)
|
176
|
-
|
177
|
-
# search by BLANK
|
178
|
-
get :search, :q => query_builder('BUNDLE',@bundle.account_id)
|
179
|
-
assert_redirected_to account_bundles_path(@bundle.account_id)
|
180
|
-
|
181
|
-
# search by BLANK and fails
|
182
|
-
get :search, :q => query_builder('BUNDLE',dummy_uuid)
|
183
|
-
assert_redirected_to home_path
|
184
|
-
assert_equal "No bundle matches \"#{dummy_uuid}\"", flash[:error]
|
185
|
-
end
|
186
|
-
|
187
|
-
test 'should understand credit search queries' do
|
188
|
-
dummy_uuid = SecureRandom.uuid.to_s
|
189
|
-
credit = create_credit
|
190
|
-
# search by ID
|
191
|
-
get :search, :q => query_builder('CREDIT',credit.invoice_item_id, 'ID')
|
192
|
-
assert_redirected_to account_invoice_path(credit.account_id, credit.invoice_id)
|
193
|
-
|
194
|
-
# search by ID and fails
|
195
|
-
get :search, :q => query_builder('CREDIT',dummy_uuid, 'ID')
|
196
|
-
assert_redirected_to home_path
|
197
|
-
assert_equal "No credit matches \"#{dummy_uuid}\"", flash[:error]
|
198
|
-
|
199
|
-
# search by EXTERNAL_KEY and fails
|
200
|
-
get :search, :q => query_builder('CREDIT',dummy_uuid, 'EXTERNAL_KEY')
|
201
|
-
assert_redirected_to home_path
|
202
|
-
assert_equal "\"CREDIT\": Search by \"EXTERNAL KEY\" is not supported.", flash[:error]
|
203
|
-
|
204
|
-
# search by BLANK only first
|
205
|
-
get :search, :q => query_builder('CREDIT',credit.invoice_item_id, nil, '1')
|
206
|
-
assert_redirected_to account_invoice_path(credit.account_id, credit.invoice_id)
|
207
|
-
|
208
|
-
# search by BLANK
|
209
|
-
get :search, :q => query_builder('CREDIT',credit.invoice_item_id)
|
210
|
-
assert_redirected_to account_invoice_path(credit.account_id, credit.invoice_id)
|
211
|
-
|
212
|
-
# search by BLANK and fails
|
213
|
-
get :search, :q => query_builder('CREDIT',dummy_uuid)
|
214
|
-
assert_redirected_to home_path
|
215
|
-
assert_equal "No credit matches \"#{dummy_uuid}\"", flash[:error]
|
216
|
-
end
|
217
|
-
|
218
|
-
test 'should understand custom field search queries' do
|
219
|
-
dummy_uuid = SecureRandom.uuid.to_s
|
220
|
-
custom_field = create_custom_field
|
221
|
-
# search by ID
|
222
|
-
get :search, :q => query_builder('CUSTOM_FIELD',custom_field[0].custom_field_id, 'ID')
|
223
|
-
assert_redirected_to custom_fields_path(:q => custom_field[0].custom_field_id, :fast => '0')
|
224
|
-
|
225
|
-
# search by ID and fails
|
226
|
-
get :search, :q => query_builder('CUSTOM_FIELD',dummy_uuid, 'ID')
|
227
|
-
assert_redirected_to home_path
|
228
|
-
assert_equal "No custom field matches \"#{dummy_uuid}\"", flash[:error]
|
229
|
-
|
230
|
-
# search by EXTERNAL_KEY and fails
|
231
|
-
get :search, :q => query_builder('CUSTOM_FIELD','test', 'EXTERNAL_KEY')
|
232
|
-
assert_redirected_to home_path
|
233
|
-
assert_equal "\"CUSTOM FIELD\": Search by \"EXTERNAL KEY\" is not supported.", flash[:error]
|
234
|
-
|
235
|
-
# search by BLANK only first
|
236
|
-
get :search, :q => query_builder('CUSTOM_FIELD','test', nil, '1')
|
237
|
-
assert_redirected_to custom_fields_path(:q => 'test', :fast => '1')
|
238
|
-
|
239
|
-
# search by BLANK
|
240
|
-
get :search, :q => query_builder('CUSTOM_FIELD','test')
|
241
|
-
assert_redirected_to custom_fields_path(:q => 'test', :fast => '0')
|
242
|
-
|
243
|
-
# search by BLANK and fails
|
244
|
-
get :search, :q => query_builder('CUSTOM_FIELD','test_uui')
|
245
|
-
assert_redirected_to home_path
|
246
|
-
assert_equal "No custom field matches \"test_uui\"", flash[:error]
|
247
|
-
end
|
248
|
-
|
249
|
-
test 'should understand invoice payment search queries' do
|
250
|
-
dummy_uuid = SecureRandom.uuid.to_s
|
251
|
-
# search by ID
|
252
|
-
get :search, :q => query_builder('INVOICE_PAYMENT', @payment.payment_id, 'ID')
|
253
|
-
assert_redirected_to account_payment_path(@payment.account_id, @payment.payment_id)
|
254
|
-
|
255
|
-
# search by ID and fails
|
256
|
-
get :search, :q => query_builder('INVOICE_PAYMENT',dummy_uuid, 'ID')
|
257
|
-
assert_redirected_to home_path
|
258
|
-
assert_equal "No invoice payment matches \"#{dummy_uuid}\"", flash[:error]
|
259
|
-
|
260
|
-
# search by EXTERNAL_KEY and fails
|
261
|
-
get :search, :q => query_builder('INVOICE_PAYMENT','test', 'EXTERNAL_KEY')
|
262
|
-
assert_redirected_to home_path
|
263
|
-
assert_equal "\"INVOICE PAYMENT\": Search by \"EXTERNAL KEY\" is not supported.", flash[:error]
|
264
|
-
|
265
|
-
# search by BLANK only first
|
266
|
-
get :search, :q => query_builder('INVOICE_PAYMENT',@payment.payment_id, nil, '1')
|
267
|
-
assert_redirected_to account_payment_path(@payment.account_id, @payment.payment_id)
|
268
|
-
|
269
|
-
# search by BLANK
|
270
|
-
get :search, :q => query_builder('INVOICE_PAYMENT',@payment.payment_id)
|
271
|
-
assert_redirected_to account_payment_path(@payment.account_id, @payment.payment_id)
|
272
|
-
|
273
|
-
# search by BLANK and fails
|
274
|
-
get :search, :q => query_builder('INVOICE_PAYMENT',dummy_uuid)
|
275
|
-
assert_redirected_to home_path
|
276
|
-
assert_equal "No invoice payment matches \"#{dummy_uuid}\"", flash[:error]
|
277
|
-
end
|
278
|
-
|
279
|
-
test 'should understand subscription search queries' do
|
280
|
-
dummy_uuid = SecureRandom.uuid.to_s
|
281
|
-
subscription = @bundle.subscriptions[0]
|
282
|
-
# search by ID
|
283
|
-
get :search, :q => query_builder('SUBSCRIPTION', subscription.subscription_id, 'ID')
|
284
|
-
assert_redirected_to account_bundles_path(subscription.account_id)
|
285
|
-
|
286
|
-
# search by ID and fails
|
287
|
-
get :search, :q => query_builder('SUBSCRIPTION',dummy_uuid, 'ID')
|
288
|
-
assert_redirected_to home_path
|
289
|
-
assert_equal "No subscription matches \"#{dummy_uuid}\"", flash[:error]
|
290
|
-
|
291
|
-
# search by EXTERNAL_KEY and fails
|
292
|
-
get :search, :q => query_builder('SUBSCRIPTION','test', 'EXTERNAL_KEY')
|
293
|
-
assert_redirected_to home_path
|
294
|
-
assert_equal "\"SUBSCRIPTION\": Search by \"EXTERNAL KEY\" is not supported.", flash[:error]
|
295
|
-
|
296
|
-
# search by BLANK only first
|
297
|
-
get :search, :q => query_builder('SUBSCRIPTION',subscription.subscription_id, nil, '1')
|
298
|
-
assert_redirected_to account_bundles_path(subscription.account_id)
|
299
|
-
|
300
|
-
# search by BLANK
|
301
|
-
get :search, :q => query_builder('SUBSCRIPTION',subscription.subscription_id)
|
302
|
-
assert_redirected_to account_bundles_path(subscription.account_id)
|
303
|
-
|
304
|
-
# search by BLANK and fails
|
305
|
-
get :search, :q => query_builder('SUBSCRIPTION',dummy_uuid)
|
306
|
-
assert_redirected_to home_path
|
307
|
-
assert_equal "No subscription matches \"#{dummy_uuid}\"", flash[:error]
|
308
|
-
end
|
309
|
-
|
310
|
-
test 'should understand tag search queries' do
|
311
|
-
dummy_uuid = SecureRandom.uuid.to_s
|
312
|
-
tag = create_tag
|
313
|
-
# search by ID
|
314
|
-
get :search, :q => query_builder('TAG', tag[0].tag_id, 'ID')
|
315
|
-
assert_redirected_to tags_path(:q => tag[0].tag_id, :fast => '0')
|
316
|
-
|
317
|
-
# search by ID and fails
|
318
|
-
get :search, :q => query_builder('TAG',dummy_uuid, 'ID')
|
319
|
-
assert_redirected_to home_path
|
320
|
-
assert_equal "No tag matches \"#{dummy_uuid}\"", flash[:error]
|
321
|
-
|
322
|
-
# search by EXTERNAL_KEY and fails
|
323
|
-
get :search, :q => query_builder('TAG','test', 'EXTERNAL_KEY')
|
324
|
-
assert_redirected_to home_path
|
325
|
-
assert_equal "\"TAG\": Search by \"EXTERNAL KEY\" is not supported.", flash[:error]
|
326
|
-
|
327
|
-
# search by BLANK only first
|
328
|
-
get :search, :q => query_builder('TAG','account', nil, '1')
|
329
|
-
assert_redirected_to tags_path(:q => 'account', :fast => '1')
|
330
|
-
|
331
|
-
# search by BLANK
|
332
|
-
get :search, :q => query_builder('TAG','account')
|
333
|
-
assert_redirected_to tags_path(:q => 'account', :fast => '0')
|
334
|
-
|
335
|
-
# search by BLANK and fails
|
336
|
-
get :search, :q => query_builder('TAG',dummy_uuid)
|
337
|
-
assert_redirected_to home_path
|
338
|
-
assert_equal "No tag matches \"#{dummy_uuid}\"", flash[:error]
|
339
|
-
end
|
340
|
-
|
341
|
-
test 'should understand tag definition search queries' do
|
342
|
-
dummy_uuid = SecureRandom.uuid.to_s
|
343
|
-
tag_definition = create_account_tag_definition
|
344
|
-
# search by ID
|
345
|
-
get :search, :q => query_builder('TAG_DEFINITION', tag_definition.id, 'ID')
|
346
|
-
assert_redirected_to tag_definitions_path(:q => tag_definition.id, :fast => '0')
|
347
|
-
|
348
|
-
# search by ID and fails
|
349
|
-
get :search, :q => query_builder('TAG_DEFINITION',dummy_uuid, 'ID')
|
350
|
-
assert_redirected_to home_path
|
351
|
-
assert_equal "No tag definition matches \"#{dummy_uuid}\"", flash[:error]
|
352
|
-
|
353
|
-
# search by EXTERNAL_KEY and fails
|
354
|
-
get :search, :q => query_builder('TAG_DEFINITION','test', 'EXTERNAL_KEY')
|
355
|
-
assert_redirected_to home_path
|
356
|
-
assert_equal "\"TAG DEFINITION\": Search by \"EXTERNAL KEY\" is not supported.", flash[:error]
|
357
|
-
|
358
|
-
# search by BLANK only first
|
359
|
-
get :search, :q => query_builder('TAG_DEFINITION','account', nil, '1')
|
360
|
-
assert_redirected_to tag_definitions_path(:q => 'account', :fast => '1')
|
361
|
-
|
362
|
-
# search by BLANK
|
363
|
-
get :search, :q => query_builder('TAG_DEFINITION','account')
|
364
|
-
assert_redirected_to tag_definitions_path(:q => 'account', :fast => '0')
|
365
|
-
|
366
|
-
# search by BLANK and fails
|
367
|
-
get :search, :q => query_builder('TAG_DEFINITION',dummy_uuid)
|
368
|
-
assert_redirected_to home_path
|
369
|
-
assert_equal "No tag definition matches \"#{dummy_uuid}\"", flash[:error]
|
370
|
-
end
|
371
|
-
|
372
|
-
private
|
373
|
-
|
374
|
-
def query_builder(object_type, search_for, search_by = nil, fast = nil)
|
375
|
-
"FIND:#{object_type} #{(search_by.nil? ? '' : "BY:#{search_by}")} FOR:#{search_for} #{(fast.nil? ? '' : "ONLY_FIRST:#{fast}")}"
|
376
|
-
end
|
377
|
-
|
378
|
-
def create_credit
|
379
|
-
credit = KillBillClient::Model::Credit.new(:invoice_id => nil, :account_id => @account.account_id, :amount => 2.22)
|
380
|
-
credit = credit.create(true, 'kaui search test', nil, nil, build_options(@tenant, USERNAME, PASSWORD))
|
381
|
-
credit.first
|
382
|
-
end
|
383
|
-
|
384
|
-
def create_custom_field
|
385
|
-
custom_field = Kaui::CustomField.new({ object_id: @account.account_id,
|
386
|
-
objectType: 'ACCOUNT',
|
387
|
-
name: 'test',
|
388
|
-
value: 'test' })
|
389
|
-
@account.add_custom_field(custom_field, 'kaui search test', nil, nil, build_options(@tenant, USERNAME, PASSWORD))
|
390
|
-
end
|
391
|
-
|
392
|
-
def create_account_tag_definition(name = 'account', description = 'i am an account')
|
393
|
-
|
394
|
-
tag_definition = Kaui::TagDefinition.new({is_control_tag: false,
|
395
|
-
name: name,
|
396
|
-
description: description,
|
397
|
-
applicable_object_types: ['ACCOUNT']})
|
398
|
-
|
399
|
-
tag_definition.create('kaui search test', nil, nil, build_options(@tenant, USERNAME, PASSWORD))
|
400
|
-
end
|
401
|
-
|
402
|
-
def create_tag
|
403
|
-
tag_definition = create_account_tag_definition
|
404
|
-
tags = [tag_definition.id]
|
405
|
-
Kaui::Tag.set_for_account(@account.account_id, tags, 'kaui search test', nil, nil, build_options(@tenant, USERNAME, PASSWORD ))
|
406
|
-
end
|
407
|
-
end
|