From 663b639372258981179c15d5d2536fde419d55ed Mon Sep 17 00:00:00 2001 From: Pierre-Alexandre Meyer Date: Sat, 24 Jun 2023 13:08:38 +0100 Subject: [PATCH] rails: 6.1 compatibility Signed-off-by: Pierre-Alexandre Meyer --- .github/workflows/ci.yml | 4 ++-- .github/workflows/rubocop.yml | 2 +- .rubocop.yml | 6 ++++++ Gemfile | 6 +++--- app/controllers/kaui/accounts_controller.rb | 2 +- app/controllers/kaui/admin_tenants_controller.rb | 4 ++-- app/controllers/kaui/audit_logs_controller.rb | 2 +- app/controllers/kaui/charges_controller.rb | 2 +- app/controllers/kaui/credits_controller.rb | 2 +- app/controllers/kaui/engine_controller_util.rb | 8 +++++--- app/controllers/kaui/home_controller.rb | 16 ++++++++-------- app/controllers/kaui/invoice_tags_controller.rb | 2 +- app/helpers/kaui/date_helper.rb | 2 +- app/helpers/kaui/plugin_helper.rb | 2 +- app/helpers/kaui/uuid_helper.rb | 4 ++-- app/models/kaui/account_email.rb | 6 +++--- app/models/kaui/admin.rb | 6 +++--- app/models/kaui/killbill_authenticatable.rb | 4 ++-- config/initializers/killbill_authenticatable.rb | 4 ++-- kaui.gemspec | 6 +++--- lib/kaui.rb | 9 --------- lib/kaui/version.rb | 2 +- test/dummy/config/application.rb | 2 +- .../kaui/account_emails_controller_test.rb | 6 +++--- .../kaui/account_tags_controller_test.rb | 2 +- test/functional/kaui/accounts_controller_test.rb | 14 +++++++------- .../kaui/admin_allowed_users_controller_test.rb | 12 ++++++------ .../kaui/admin_tenants_controller_test.rb | 8 ++++---- .../kaui/bundle_tags_controller_test.rb | 2 +- test/functional/kaui/bundles_controller_test.rb | 4 ++-- .../kaui/chargebacks_controller_test.rb | 4 ++-- test/functional/kaui/charges_controller_test.rb | 4 ++-- test/functional/kaui/credits_controller_test.rb | 4 ++-- .../kaui/custom_fields_controller_test.rb | 4 ++-- test/functional/kaui/home_controller_test.rb | 4 ++-- .../kaui/invoice_items_controller_test.rb | 6 +++--- test/functional/kaui/refunds_controller_test.rb | 4 ++-- .../kaui/role_definitions_controller_test.rb | 4 ++-- .../kaui/subscriptions_controller_test.rb | 2 +- .../kaui/transactions_controller_test.rb | 6 +++--- test/killbill_test_helper.rb | 6 +++--- 41 files changed, 99 insertions(+), 100 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f2f1f334..58bdd30c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ jobs: database-password: 'root' database-port: '3306' docker-compose-file: 'docker-compose.ci.mysql.yml' - - ruby-version: 'jruby-9.4.2.0' + - ruby-version: 'jruby-9.3.10.0' database-adapter: 'mariadb' database-user: 'root' database-password: 'root' @@ -36,7 +36,7 @@ jobs: database-password: 'postgres' database-port: '5432' docker-compose-file: 'docker-compose.ci.postgresql.yml' - - ruby-version: 'jruby-9.4.2.0' + - ruby-version: 'jruby-9.3.10.0' database-adapter: 'postgresql' database-user: 'postgres' database-password: 'postgres' diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml index 0cb5b3c2..7ad39cbe 100644 --- a/.github/workflows/rubocop.yml +++ b/.github/workflows/rubocop.yml @@ -10,7 +10,7 @@ jobs: - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: 3.2.2 + ruby-version: 2.6.10 - name: Install gems run: | bundle config path vendor/bundle diff --git a/.rubocop.yml b/.rubocop.yml index 2dfa4591..0d620c16 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -51,3 +51,9 @@ Style/Documentation: Style/EmptyElse: EnforcedStyle: empty + +Style/HashSyntax: + Enabled: false + +Style/ExplicitBlockArgument: + Enabled: false diff --git a/Gemfile b/Gemfile index 4c78d1cc..800efdb2 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ # frozen_string_literal: true source 'https://rubygems.org' -ruby '>= 3.1.0' +ruby '>= 2.6.0' gemspec @@ -18,7 +18,7 @@ group :development do gem 'simplecov' if defined?(JRUBY_VERSION) - git 'https://github.com/jruby/activerecord-jdbc-adapter', branch: 'master' do + git 'https://github.com/jruby/activerecord-jdbc-adapter', branch: 'v61.2' do gem 'activerecord-jdbc-adapter' # Add the drivers gem 'jdbc-mariadb' @@ -40,4 +40,4 @@ gem 'killbill-client', git: 'https://github.com/killbill/killbill-client-ruby.gi # gem 'killbill-client', '3.2.0' # gem 'kenui', :path => '../killbill-email-notifications-ui' -gem 'kenui', git: 'https://github.com/killbill/killbill-email-notifications-ui.git', branch: 'master' +# gem 'kenui', git: 'https://github.com/killbill/killbill-email-notifications-ui.git', branch: 'master' diff --git a/app/controllers/kaui/accounts_controller.rb b/app/controllers/kaui/accounts_controller.rb index d0583385..2964215d 100644 --- a/app/controllers/kaui/accounts_controller.rb +++ b/app/controllers/kaui/accounts_controller.rb @@ -202,7 +202,7 @@ def trigger_invoice render template: 'kaui/invoices/show' else # Redirect to fetch payments, etc. - redirect_to invoice_path(invoice.invoice_id, account_id:), notice: "Generated invoice #{invoice.invoice_number} for target date #{invoice.target_date}" + redirect_to invoice_path(invoice.invoice_id, account_id: account_id), notice: "Generated invoice #{invoice.invoice_number} for target date #{invoice.target_date}" end end diff --git a/app/controllers/kaui/admin_tenants_controller.rb b/app/controllers/kaui/admin_tenants_controller.rb index 4546f160..eb43e36e 100644 --- a/app/controllers/kaui/admin_tenants_controller.rb +++ b/app/controllers/kaui/admin_tenants_controller.rb @@ -448,10 +448,10 @@ def catalog_by_effective_date catalog << { version_date: data[:version_date], currencies: data[:currencies], - plans: } + plans: plans } end - { catalog: } + { catalog: catalog } end end diff --git a/app/controllers/kaui/audit_logs_controller.rb b/app/controllers/kaui/audit_logs_controller.rb index 69bf5d83..6ca4b7d8 100644 --- a/app/controllers/kaui/audit_logs_controller.rb +++ b/app/controllers/kaui/audit_logs_controller.rb @@ -104,7 +104,7 @@ def history error = e.message end - { audits: audit_logs_with_history, error: } + { audits: audit_logs_with_history, error: error } end end diff --git a/app/controllers/kaui/charges_controller.rb b/app/controllers/kaui/charges_controller.rb index d986fa3e..41573900 100644 --- a/app/controllers/kaui/charges_controller.rb +++ b/app/controllers/kaui/charges_controller.rb @@ -15,7 +15,7 @@ def new currency = params[:currency] || 'USD' end - @charge = Kaui::InvoiceItem.new(account_id: params.require(:account_id), invoice_id:, amount:, currency:) + @charge = Kaui::InvoiceItem.new(account_id: params.require(:account_id), invoice_id: invoice_id, amount: amount, currency: currency) end def create diff --git a/app/controllers/kaui/credits_controller.rb b/app/controllers/kaui/credits_controller.rb index 5786b125..53f77ba5 100644 --- a/app/controllers/kaui/credits_controller.rb +++ b/app/controllers/kaui/credits_controller.rb @@ -15,7 +15,7 @@ def new currency = params[:currency] || 'USD' end - @credit = Kaui::Credit.new(account_id: params.require(:account_id), invoice_id:, amount:, currency:) + @credit = Kaui::Credit.new(account_id: params.require(:account_id), invoice_id: invoice_id, amount: amount, currency: currency) end def create diff --git a/app/controllers/kaui/engine_controller_util.rb b/app/controllers/kaui/engine_controller_util.rb index eecc9eda..cc4f4503 100644 --- a/app/controllers/kaui/engine_controller_util.rb +++ b/app/controllers/kaui/engine_controller_util.rb @@ -53,15 +53,17 @@ def paginate(searcher, data_extractor, formatter) pages.each { |page| json[:data] << formatter.call(page) } respond_to do |format| - format.json { render json: } + format.json { render json: json } end end - def promise(&) + def promise # Evaluation starts immediately ::Concurrent::Promises.future do # https://github.com/rails/rails/issues/26847 - Rails.application.executor.wrap(&) + Rails.application.executor.wrap do + yield + end end end diff --git a/app/controllers/kaui/home_controller.rb b/app/controllers/kaui/home_controller.rb index 13499a01..7c54e9af 100644 --- a/app/controllers/kaui/home_controller.rb +++ b/app/controllers/kaui/home_controller.rb @@ -46,7 +46,7 @@ def account_search(search_query, search_by = nil, fast = 0, options = {}) elsif true?(fast) redirect_to account_path(account.account_id) and return else - redirect_to accounts_path(q: search_query, fast:) and return + redirect_to accounts_path(q: search_query, fast: fast) and return end end end @@ -73,7 +73,7 @@ def invoice_search(search_query, search_by = nil, fast = 0, options = {}) elsif true?(fast) redirect_to account_invoice_path(invoice.account_id, invoice.invoice_id) and return else - redirect_to account_invoices_path(account_id: invoice.account_id, q: search_query, fast:) and return + redirect_to account_invoices_path(account_id: invoice.account_id, q: search_query, fast: fast) and return end end end @@ -100,7 +100,7 @@ def payment_search(search_query, search_by = nil, fast = 0, options = {}) elsif true?(fast) redirect_to account_payment_path(payment.account_id, payment.payment_id) and return else - redirect_to account_payments_path(account_id: payment.account_id, q: search_query, fast:) and return + redirect_to account_payments_path(account_id: payment.account_id, q: search_query, fast: fast) and return end end end @@ -167,7 +167,7 @@ def custom_field_search(search_query, search_by = nil, fast = 0, options = {}) if custom_field.blank? search_error("No custom field matches \"#{search_query}\"") else - redirect_to custom_fields_path(q: search_query, fast:) + redirect_to custom_fields_path(q: search_query, fast: fast) end else unsupported_external_key_search('CUSTOM FIELD') @@ -206,7 +206,7 @@ def tag_search(search_query, search_by = nil, fast = 0, options = {}) if tag.blank? search_error("No tag matches \"#{search_query}\"") else - redirect_to tags_path(q: search_query, fast:) + redirect_to tags_path(q: search_query, fast: fast) end else unsupported_external_key_search('TAG') @@ -217,7 +217,7 @@ def tag_definition_search(search_query, search_by = nil, fast = 0, options = {}) if search_by == 'ID' begin Kaui::TagDefinition.find_by_id(search_query, 'NONE', options) - redirect_to tag_definitions_path(q: search_query, fast:) + redirect_to tag_definitions_path(q: search_query, fast: fast) rescue KillBillClient::API::NotFound => _e search_error("No tag definition matches \"#{search_query}\"") end @@ -228,12 +228,12 @@ def tag_definition_search(search_query, search_by = nil, fast = 0, options = {}) if tag_definition.blank? begin Kaui::TagDefinition.find_by_id(search_query, 'NONE', options) - redirect_to tag_definitions_path(q: search_query, fast:) and return + redirect_to tag_definitions_path(q: search_query, fast: fast) and return rescue KillBillClient::API::NotFound => _e search_error("No tag definition matches \"#{search_query}\"") end else - redirect_to tag_definitions_path(q: search_query, fast:) + redirect_to tag_definitions_path(q: search_query, fast: fast) end end end diff --git a/app/controllers/kaui/invoice_tags_controller.rb b/app/controllers/kaui/invoice_tags_controller.rb index 6088ab27..ac516c45 100644 --- a/app/controllers/kaui/invoice_tags_controller.rb +++ b/app/controllers/kaui/invoice_tags_controller.rb @@ -26,7 +26,7 @@ def update end Kaui::Tag.set_for_invoice(invoice_id, tags, current_user.kb_username, params[:reason], params[:comment], options_for_klient) - redirect_to kaui_engine.invoice_path(invoice_id, account_id:), notice: 'Invoice tags successfully set' + redirect_to kaui_engine.invoice_path(invoice_id, account_id: account_id), notice: 'Invoice tags successfully set' end end end diff --git a/app/helpers/kaui/date_helper.rb b/app/helpers/kaui/date_helper.rb index 4fc155f1..03880496 100644 --- a/app/helpers/kaui/date_helper.rb +++ b/app/helpers/kaui/date_helper.rb @@ -17,7 +17,7 @@ def format_date(date, timezone) # If not, convert into account timezone and return the date part only parsed_date = DateTime.parse(date.to_s).in_time_zone(timezone) - parsed_date.to_fs(:date_only) + parsed_date.to_s(:date_only) end def truncate_millis(date_s) diff --git a/app/helpers/kaui/plugin_helper.rb b/app/helpers/kaui/plugin_helper.rb index 856e7ec8..f3f9919c 100644 --- a/app/helpers/kaui/plugin_helper.rb +++ b/app/helpers/kaui/plugin_helper.rb @@ -21,7 +21,7 @@ def installed_plugins plugin_key = plugin.plugin_key installed_plugins << { # Unique identifier chosen by the user and used for kpm operations - plugin_key:, + plugin_key: plugin_key, # Notes: # * plugin.plugin_name comes from kpm and is arbitrary (see Utils.get_plugin_name_from_file_path in the kpm codebase for instance) # * plugin_name here is the plugin name as seen by Kill Bill and is typically defined in the Activator.java (this value is the one that matters for plugin configuration) diff --git a/app/helpers/kaui/uuid_helper.rb b/app/helpers/kaui/uuid_helper.rb index 8355c200..c3ed3986 100644 --- a/app/helpers/kaui/uuid_helper.rb +++ b/app/helpers/kaui/uuid_helper.rb @@ -12,10 +12,10 @@ def truncate_uuid(uuid) def object_id_popover(object_id, placement = 'right', title = nil) content_tag(:span, truncate_uuid(object_id), - id: "#{object_id}-popover", class: 'object-id-popover', title:, + id: "#{object_id}-popover", class: 'object-id-popover', title: title, data: { id: object_id, - placement: + placement: placement }) end end diff --git a/app/models/kaui/account_email.rb b/app/models/kaui/account_email.rb index ec8b64f6..bd520f86 100644 --- a/app/models/kaui/account_email.rb +++ b/app/models/kaui/account_email.rb @@ -3,17 +3,17 @@ module Kaui class AccountEmail < KillBillClient::Model::AccountEmailAttributes def self.find_all_sorted_by_account_id(account_id, audit = 'NONE', options = {}) - emails = Kaui::Account.new(account_id:).emails(audit, options) + emails = Kaui::Account.new(account_id: account_id).emails(audit, options) emails.map { |email| Kaui::AccountEmail.new(email.to_hash) }.sort end def create(user = nil, reason = nil, comment = nil, options = {}) - account = Kaui::Account.new(account_id:) + account = Kaui::Account.new(account_id: account_id) account.add_email(email, user, reason, comment, options) end def destroy(user = nil, reason = nil, comment = nil, options = {}) - account = Kaui::Account.new(account_id:) + account = Kaui::Account.new(account_id: account_id) account.remove_email(email, user, reason, comment, options) end diff --git a/app/models/kaui/admin.rb b/app/models/kaui/admin.rb index 1eae8ca1..ebeb3fb7 100644 --- a/app/models/kaui/admin.rb +++ b/app/models/kaui/admin.rb @@ -27,9 +27,9 @@ def fix_transaction_state(payment_id, transaction_id, transaction_status, user = { transactionStatus: transaction_status }.to_json, {}, { - user:, - reason:, - comment: + user: user, + reason: reason, + comment: comment }.merge(options) end diff --git a/app/models/kaui/killbill_authenticatable.rb b/app/models/kaui/killbill_authenticatable.rb index a429c936..babdfa43 100644 --- a/app/models/kaui/killbill_authenticatable.rb +++ b/app/models/kaui/killbill_authenticatable.rb @@ -31,8 +31,8 @@ module ClassMethods # Invoked by the KillbillAuthenticatable strategy to lookup the user # before attempting authentication def find_for_killbill_authentication(kb_username) - find_for_authentication(kb_username:) || - new(kb_username:) + find_for_authentication(kb_username: kb_username) || + new(kb_username: kb_username) rescue KillBillClient::API::Unauthorized => _e # Multi-Tenancy was enabled, but the tenant_id couldn't be retrieved because of bad credentials nil diff --git a/config/initializers/killbill_authenticatable.rb b/config/initializers/killbill_authenticatable.rb index 14a37944..c8ca097f 100644 --- a/config/initializers/killbill_authenticatable.rb +++ b/config/initializers/killbill_authenticatable.rb @@ -28,7 +28,7 @@ def authenticate! return false unless valid_password? user = params[:user] || {} - kb_authenticate!(user[:kb_username], { username: user[:kb_username], password: }) + kb_authenticate!(user[:kb_username], { username: user[:kb_username], password: password }) end end @@ -77,7 +77,7 @@ def token unless user.authenticated_with_killbill? scope = opts[:scope] auth.logout(scope) - throw(:warden, scope:, reason: 'Kill Bill session expired') + throw(:warden, scope: scope, reason: 'Kill Bill session expired') end end diff --git a/kaui.gemspec b/kaui.gemspec index d6c47153..1a4b4ded 100644 --- a/kaui.gemspec +++ b/kaui.gemspec @@ -10,7 +10,7 @@ Gem::Specification.new do |s| s.summary = 'Killbill Admin UI mountable engine' s.description = 'Rails UI plugin for Killbill administration.' - s.required_ruby_version = '>= 2.7.0' + s.required_ruby_version = '>= 2.6.0' s.license = 'Apache License (2.0)' @@ -38,12 +38,12 @@ Gem::Specification.new do |s| s.add_dependency 'jquery-ui-rails' s.add_dependency 'js-routes' s.add_dependency 'jwt' - s.add_dependency 'kenui' + s.add_dependency 'kenui', '~> 2.1.0' s.add_dependency 'killbill-client' s.add_dependency 'money-rails' s.add_dependency 'mustache-js-rails' s.add_dependency 'popper_js', '~> 2.11.5' - s.add_dependency 'rails', '~> 7.0' + s.add_dependency 'rails', '~> 6.1' s.add_dependency 'sass' s.add_dependency 'sassc-rails', '>= 2.1.0' s.add_dependency 'sass-rails' diff --git a/lib/kaui.rb b/lib/kaui.rb index c6735339..7d9d90df 100644 --- a/lib/kaui.rb +++ b/lib/kaui.rb @@ -202,12 +202,3 @@ def self.config } end end - -# ruby-1.8 compatibility -module Kernel - def define_singleton_method(*args, &) - class << self - self - end.send(:define_method, *args, &) - end -end diff --git a/lib/kaui/version.rb b/lib/kaui/version.rb index a4833671..c1d48baa 100644 --- a/lib/kaui/version.rb +++ b/lib/kaui/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Kaui - VERSION = '3.0.1' + VERSION = '2.2.0' end diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb index f8b8fda2..37c4fd6f 100644 --- a/test/dummy/config/application.rb +++ b/test/dummy/config/application.rb @@ -22,7 +22,7 @@ module Dummy class Application < Rails::Application # Initialize configuration defaults for originally generated Rails version. - config.load_defaults 7.0 + config.load_defaults 6.1 # Configuration for the application, engines, and railties goes here. # diff --git a/test/functional/kaui/account_emails_controller_test.rb b/test/functional/kaui/account_emails_controller_test.rb index 7d97e893..f7367691 100644 --- a/test/functional/kaui/account_emails_controller_test.rb +++ b/test/functional/kaui/account_emails_controller_test.rb @@ -21,7 +21,7 @@ class AccountEmailsControllerTest < Kaui::FunctionalTestHelper test 'should handle Kill Bill errors during creation' do account_id = SecureRandom.uuid.to_s post :create, - params: { account_id:, + params: { account_id: account_id, account_email: { email: 'toto@example.com' } } @@ -31,7 +31,7 @@ class AccountEmailsControllerTest < Kaui::FunctionalTestHelper test 'should handle Kill Bill errors during deletion' do account_id = 'invalid-id' - delete :destroy, params: { account_id:, id: 'toto@example.com' } + delete :destroy, params: { account_id: account_id, id: 'toto@example.com' } assert_redirected_to account_path(account_id) end @@ -45,7 +45,7 @@ class AccountEmailsControllerTest < Kaui::FunctionalTestHelper params: { account_id: @account.account_id, account_email: { - email: + email: email } } assert_redirected_to account_path(@account.account_id) diff --git a/test/functional/kaui/account_tags_controller_test.rb b/test/functional/kaui/account_tags_controller_test.rb index 99e3a1ca..6a5410c3 100644 --- a/test/functional/kaui/account_tags_controller_test.rb +++ b/test/functional/kaui/account_tags_controller_test.rb @@ -6,7 +6,7 @@ module Kaui class AccountTagsControllerTest < Kaui::FunctionalTestHelper test 'should handle Kill Bill errors when getting edit screen' do account_id = '1234' - get :edit, params: { account_id: } + get :edit, params: { account_id: account_id } assert_redirected_to account_path(account_id) end diff --git a/test/functional/kaui/accounts_controller_test.rb b/test/functional/kaui/accounts_controller_test.rb index 55f80760..541a0988 100644 --- a/test/functional/kaui/accounts_controller_test.rb +++ b/test/functional/kaui/accounts_controller_test.rb @@ -43,7 +43,7 @@ class AccountsControllerTest < Kaui::FunctionalTestHelper test 'should handle Kill Bill errors when showing account details' do account_id = SecureRandom.uuid.to_s - get :show, params: { account_id: } + get :show, params: { account_id: account_id } assert_redirected_to home_path assert_equal "Error while communicating with the Kill Bill server: Object id=#{account_id} type=ACCOUNT doesn't exist!", flash[:error] end @@ -98,10 +98,10 @@ class AccountsControllerTest < Kaui::FunctionalTestHelper assert_equal 'Required parameter missing: account', flash[:error] external_key = SecureRandom.uuid.to_s - post :create, params: { account: { external_key: } } + post :create, params: { account: { external_key: external_key } } assert_redirected_to account_path(assigns(:account).account_id) - post :create, params: { account: { external_key: } } + post :create, params: { account: { external_key: external_key } } assert_template :new assert_equal "Error while creating account: Account already exists for key #{external_key}", flash[:error] end @@ -156,7 +156,7 @@ class AccountsControllerTest < Kaui::FunctionalTestHelper test 'should handle Kill Bill errors when setting default payment method' do account_id = SecureRandom.uuid.to_s - put :set_default_payment_method, params: { account_id:, payment_method_id: @payment_method.payment_method_id } + put :set_default_payment_method, params: { account_id: account_id, payment_method_id: @payment_method.payment_method_id } assert_redirected_to home_path assert_equal "Error while communicating with the Kill Bill server: Object id=#{account_id} type=ACCOUNT doesn't exist!", flash[:error] end @@ -168,7 +168,7 @@ class AccountsControllerTest < Kaui::FunctionalTestHelper test 'should handle Kill Bill errors when paying all invoices' do account_id = SecureRandom.uuid.to_s - post :pay_all_invoices, params: { account_id: } + post :pay_all_invoices, params: { account_id: account_id } assert_redirected_to home_path assert_equal "Error while communicating with the Kill Bill server: Object id=#{account_id} type=ACCOUNT doesn't exist!", flash[:error] end @@ -226,10 +226,10 @@ class AccountsControllerTest < Kaui::FunctionalTestHelper assert_equal JSON[@response.body]['is_found'], false external_key = SecureRandom.uuid.to_s - post :create, params: { account: { external_key: } } + post :create, params: { account: { external_key: external_key } } assert_redirected_to account_path(redirected_account_id) - get :validate_external_key, params: { external_key: } + get :validate_external_key, params: { external_key: external_key } assert_response :success assert_equal JSON[@response.body]['is_found'], true end diff --git a/test/functional/kaui/admin_allowed_users_controller_test.rb b/test/functional/kaui/admin_allowed_users_controller_test.rb index 6aec6a4a..c0a46d97 100644 --- a/test/functional/kaui/admin_allowed_users_controller_test.rb +++ b/test/functional/kaui/admin_allowed_users_controller_test.rb @@ -88,7 +88,7 @@ class AdminAllowedUsersControllerTest < Kaui::FunctionalTestHelper assert response_path.include?(expected_response_path(id)), "#{response_path} is expected to contain #{expected_response_path(id)}" parameters = { - id:, + id: id, allowed_user: { description: 'An post-apocalyptic super hero' }, roles: 'one,two' } @@ -100,13 +100,13 @@ class AdminAllowedUsersControllerTest < Kaui::FunctionalTestHelper assert response_path.include?(expected_response_path(id)), "#{response_path} is expected to contain #{expected_response_path(id)}" # get the user to verify that the data was actually updated - get :edit, params: { id: } + get :edit, params: { id: id } description = extract_allowed_description assert_response :success assert_equal parameters[:allowed_user][:description], description # delete created user - delete :destroy, params: { id: } + delete :destroy, params: { id: id } assert_equal 'User was successfully deleted', flash[:notice] assert_response :redirect # validate redirect path @@ -126,14 +126,14 @@ class AdminAllowedUsersControllerTest < Kaui::FunctionalTestHelper # validate redirect path assert response_path.include?(expected_response_path(id)), "#{response_path} is expected to contain #{expected_response_path(id)}" - delete :destroy, params: { id: } + delete :destroy, params: { id: id } assert_equal 'User was successfully deleted', flash[:notice] assert_response :redirect # validate redirect path assert response_path.include?(expected_response_path), "#{response_path} is expected to contain #{expected_response_path}" # should respond with an error if tried to delete again - delete :destroy, params: { id: } + delete :destroy, params: { id: id } assert_equal "Error: Couldn't find Kaui::AllowedUser with 'id'=#{id}", flash[:error] assert_response :redirect # validate redirect path @@ -151,7 +151,7 @@ class AdminAllowedUsersControllerTest < Kaui::FunctionalTestHelper allowed_user[:id] = au.id - put :add_tenant, params: { allowed_user:, tenant_1: nil } + put :add_tenant, params: { allowed_user: allowed_user, tenant_1: nil } assert_equal 'Successfully set tenants for user', flash[:notice] assert_response :redirect # validate redirect path diff --git a/test/functional/kaui/admin_tenants_controller_test.rb b/test/functional/kaui/admin_tenants_controller_test.rb index 6aa59ac5..eeab8156 100644 --- a/test/functional/kaui/admin_tenants_controller_test.rb +++ b/test/functional/kaui/admin_tenants_controller_test.rb @@ -141,7 +141,7 @@ class AdminTenantsControllerTest < Kaui::FunctionalTestHelper assert_redirected_to admin_tenant_path(tenant.id) assert_equal I18n.translate('flashes.notices.catalog_uploaded_successfully'), flash[:notice] - get :new_plan_currency, params: { id: tenant.id, plan_id: } + get :new_plan_currency, params: { id: tenant.id, plan_id: plan_id } assert_response :success assert_equal extract_value_from_input_field('simple_plan_plan_id'), plan_id @@ -238,7 +238,7 @@ class AdminTenantsControllerTest < Kaui::FunctionalTestHelper assert_redirected_to admin_tenant_path(tenant.id) assert_equal I18n.translate('flashes.notices.catalog_uploaded_successfully'), flash[:notice] - post :display_catalog_xml, params: { effective_date:, id: tenant.id } + post :display_catalog_xml, params: { effective_date: effective_date, id: tenant.id } doc = nil assert_nothing_raised { doc = Nokogiri::XML(@response.body, &:strict) } @@ -261,7 +261,7 @@ class AdminTenantsControllerTest < Kaui::FunctionalTestHelper tenant = create_kaui_tenant post :upload_catalog, params: { id: tenant.id, catalog: fixture_file_upload("#{FIXTURES_PATH}/catalog-v1.xml") } - get :catalog_by_effective_date, params: { id: tenant.id, effective_date: } + get :catalog_by_effective_date, params: { id: tenant.id, effective_date: effective_date } assert_response :success result = nil @@ -325,7 +325,7 @@ class AdminTenantsControllerTest < Kaui::FunctionalTestHelper assert_redirected_to admin_tenant_path(tenant.id) assert_equal I18n.translate('flashes.notices.catalog_uploaded_successfully'), flash[:notice] - get :download_catalog_xml, params: { effective_date:, id: tenant.id } + get :download_catalog_xml, params: { effective_date: effective_date, id: tenant.id } assert_response :success assert_equal 'application/xml', @response.header['Content-Type'] assert_equal ActionDispatch::Http::ContentDisposition.format(disposition: 'attachment', filename: "catalog_#{effective_date}.xml"), @response.header['Content-Disposition'] diff --git a/test/functional/kaui/bundle_tags_controller_test.rb b/test/functional/kaui/bundle_tags_controller_test.rb index 063bfe73..be7efc86 100644 --- a/test/functional/kaui/bundle_tags_controller_test.rb +++ b/test/functional/kaui/bundle_tags_controller_test.rb @@ -10,7 +10,7 @@ class BundleTagsControllerTest < Kaui::FunctionalTestHelper assert_equal 'Required parameter missing: bundle_id', flash[:error] bundle_id = SecureRandom.uuid.to_s - get :edit, params: { account_id: @account.account_id, bundle_id: } + get :edit, params: { account_id: @account.account_id, bundle_id: bundle_id } assert_redirected_to account_path(@account.account_id) assert_equal "Error while communicating with the Kill Bill server: Object id=#{bundle_id} type=BUNDLE doesn't exist!", flash[:error] end diff --git a/test/functional/kaui/bundles_controller_test.rb b/test/functional/kaui/bundles_controller_test.rb index 98ede16d..74d04ba2 100644 --- a/test/functional/kaui/bundles_controller_test.rb +++ b/test/functional/kaui/bundles_controller_test.rb @@ -6,7 +6,7 @@ module Kaui class BundlesControllerTest < Kaui::FunctionalTestHelper test 'should be redirected if an invalid account id was specified in index screen' do account_id = SecureRandom.uuid.to_s - get :index, params: { account_id: } + get :index, params: { account_id: account_id } assert_redirected_to account_path(account_id) assert_equal "Error while communicating with the Kill Bill server: Object id=#{account_id} type=ACCOUNT doesn't exist!", flash[:error] end @@ -34,7 +34,7 @@ class BundlesControllerTest < Kaui::FunctionalTestHelper assert_equal 'Required parameter missing: new_account_key', flash[:error] new_account_key = SecureRandom.uuid.to_s - post :do_transfer, params: { id: @bundle.bundle_id, new_account_key: } + post :do_transfer, params: { id: @bundle.bundle_id, new_account_key: new_account_key } assert_redirected_to home_path assert_equal "Error while communicating with the Kill Bill server: Object id=#{new_account_key} type=ACCOUNT doesn't exist!", flash[:error] diff --git a/test/functional/kaui/chargebacks_controller_test.rb b/test/functional/kaui/chargebacks_controller_test.rb index 4f4b23cc..b69f73bc 100644 --- a/test/functional/kaui/chargebacks_controller_test.rb +++ b/test/functional/kaui/chargebacks_controller_test.rb @@ -6,7 +6,7 @@ module Kaui class ChargebacksControllerTest < Kaui::FunctionalTestHelper test 'should handle Kill Bill errors in new screen' do payment_id = SecureRandom.uuid.to_s - get :new, params: { account_id: @account.account_id, payment_id: } + get :new, params: { account_id: @account.account_id, payment_id: payment_id } assert_redirected_to account_path(@account.account_id) assert_equal "Error while communicating with the Kill Bill server: Object id=#{payment_id} type=PAYMENT doesn't exist!", flash[:error] end @@ -22,7 +22,7 @@ class ChargebacksControllerTest < Kaui::FunctionalTestHelper params: { account_id: @account.account_id, chargeback: { - payment_id:, + payment_id: payment_id, amount: @payment.paid_amount_to_money.to_f, currency: @payment.currency } diff --git a/test/functional/kaui/charges_controller_test.rb b/test/functional/kaui/charges_controller_test.rb index d283398b..ce6e53f3 100644 --- a/test/functional/kaui/charges_controller_test.rb +++ b/test/functional/kaui/charges_controller_test.rb @@ -6,7 +6,7 @@ module Kaui class ChargesControllerTest < Kaui::FunctionalTestHelper test 'should handle Kill Bill errors in new screen' do invoice_id = SecureRandom.uuid.to_s - get :new, params: { account_id: @account.account_id, invoice_id: } + get :new, params: { account_id: @account.account_id, invoice_id: invoice_id } assert_redirected_to account_path(@account.account_id) assert_equal "Error while communicating with the Kill Bill server: Object id=#{invoice_id} type=INVOICE doesn't exist!", flash[:error] end @@ -27,7 +27,7 @@ class ChargesControllerTest < Kaui::FunctionalTestHelper params: { account_id: @account.account_id, invoice_item: { - invoice_id:, + invoice_id: invoice_id, amount: 5.34, currency: 'USD', description: SecureRandom.uuid diff --git a/test/functional/kaui/credits_controller_test.rb b/test/functional/kaui/credits_controller_test.rb index 8be0f25a..5dd5575f 100644 --- a/test/functional/kaui/credits_controller_test.rb +++ b/test/functional/kaui/credits_controller_test.rb @@ -6,7 +6,7 @@ module Kaui class CreditsControllerTest < Kaui::FunctionalTestHelper test 'should handle Kill Bill errors in new screen' do invoice_id = SecureRandom.uuid.to_s - get :new, params: { account_id: @account.account_id, invoice_id: } + get :new, params: { account_id: @account.account_id, invoice_id: invoice_id } assert_redirected_to account_path(@account.account_id) assert_equal "Error while communicating with the Kill Bill server: Object id=#{invoice_id} type=INVOICE doesn't exist!", flash[:error] end @@ -27,7 +27,7 @@ class CreditsControllerTest < Kaui::FunctionalTestHelper params: { account_id: @account.account_id, credit: { - invoice_id:, + invoice_id: invoice_id, amount: 5.34 } } diff --git a/test/functional/kaui/custom_fields_controller_test.rb b/test/functional/kaui/custom_fields_controller_test.rb index 2e4f00aa..814949de 100644 --- a/test/functional/kaui/custom_fields_controller_test.rb +++ b/test/functional/kaui/custom_fields_controller_test.rb @@ -38,8 +38,8 @@ class CustomFieldsControllerTest < Kaui::FunctionalTestHelper post :create, params: { custom_field: { - object_id:, - object_type:, + object_id: object_id, + object_type: object_type, name: SecureRandom.uuid.to_s, value: SecureRandom.uuid.to_s } diff --git a/test/functional/kaui/home_controller_test.rb b/test/functional/kaui/home_controller_test.rb index 786278fc..e596d23f 100644 --- a/test/functional/kaui/home_controller_test.rb +++ b/test/functional/kaui/home_controller_test.rb @@ -393,8 +393,8 @@ def create_custom_field def create_account_tag_definition(name = 'account', description = 'i am an account') tag_definition = Kaui::TagDefinition.new({ is_control_tag: false, - name:, - description:, + name: name, + description: description, applicable_object_types: ['ACCOUNT'] }) tag_definition.create('kaui search test', nil, nil, build_options(@tenant, USERNAME, PASSWORD)) diff --git a/test/functional/kaui/invoice_items_controller_test.rb b/test/functional/kaui/invoice_items_controller_test.rb index f7183f2f..683dc3da 100644 --- a/test/functional/kaui/invoice_items_controller_test.rb +++ b/test/functional/kaui/invoice_items_controller_test.rb @@ -10,7 +10,7 @@ class InvoiceItemsControllerTest < Kaui::FunctionalTestHelper assert_equal 'Required parameter missing: invoice_id', flash[:error] invoice_id = SecureRandom.uuid.to_s - get :edit, params: { account_id: @account.account_id, id: @invoice_item.invoice_item_id, invoice_id: } + get :edit, params: { account_id: @account.account_id, id: @invoice_item.invoice_item_id, invoice_id: invoice_id } assert_redirected_to account_path(@account.account_id) assert_equal "Error while communicating with the Kill Bill server: Object id=#{invoice_id} type=INVOICE doesn't exist!", flash[:error] @@ -32,7 +32,7 @@ class InvoiceItemsControllerTest < Kaui::FunctionalTestHelper params: { id: @invoice_item.invoice_item_id, invoice_item: { account_id: @account.account_id, - invoice_id:, + invoice_id: invoice_id, invoice_item_id: @invoice_item.invoice_item_id, amount: 5.34, currency: :USD @@ -68,7 +68,7 @@ class InvoiceItemsControllerTest < Kaui::FunctionalTestHelper delete :destroy, params: { id: @cba.invoice_item_id, - invoice_id:, + invoice_id: invoice_id, account_id: @account.account_id } assert_redirected_to account_path(@account.account_id) diff --git a/test/functional/kaui/refunds_controller_test.rb b/test/functional/kaui/refunds_controller_test.rb index b2203051..3af95b29 100644 --- a/test/functional/kaui/refunds_controller_test.rb +++ b/test/functional/kaui/refunds_controller_test.rb @@ -6,12 +6,12 @@ module Kaui class RefundsControllerTest < Kaui::FunctionalTestHelper test 'should handle Kill Bill errors in new screen' do invoice_id = SecureRandom.uuid.to_s - get :new, params: { account_id: @account.account_id, invoice_id:, payment_id: @payment.payment_id } + get :new, params: { account_id: @account.account_id, invoice_id: invoice_id, payment_id: @payment.payment_id } assert_redirected_to account_path(@account.account_id) assert_equal "Error while communicating with the Kill Bill server: Object id=#{invoice_id} type=INVOICE doesn't exist!", flash[:error] payment_id = SecureRandom.uuid.to_s - get :new, params: { account_id: @account.account_id, invoice_id: @paid_invoice_item.invoice_id, payment_id: } + get :new, params: { account_id: @account.account_id, invoice_id: @paid_invoice_item.invoice_id, payment_id: payment_id } assert_redirected_to account_path(@account.account_id) assert_equal "Error while communicating with the Kill Bill server: Object id=#{payment_id} type=PAYMENT doesn't exist!", flash[:error] end diff --git a/test/functional/kaui/role_definitions_controller_test.rb b/test/functional/kaui/role_definitions_controller_test.rb index 23db5dfa..c39ea996 100644 --- a/test/functional/kaui/role_definitions_controller_test.rb +++ b/test/functional/kaui/role_definitions_controller_test.rb @@ -29,7 +29,7 @@ class RoleDefinitionsControllerTest < Kaui::FunctionalTestHelper role_definition['role'] = "test#{SecureRandom.base64(9).gsub(%r{[/+=]}, '')}" role_definition['permissions'] = 'account:delete_emails,account:add_emails' - post :create, params: { role_definition: } + post :create, params: { role_definition: role_definition } assert_equal 'Role was successfully created', flash[:notice] assert_response :redirect @@ -41,7 +41,7 @@ class RoleDefinitionsControllerTest < Kaui::FunctionalTestHelper role_definition['role'] = "test#{SecureRandom.base64(9).gsub(%r{[/+=]}, '')}" role_definition['permissions'] = 'account:delete_emails,account:add_emails' - post :create, params: { role_definition:, reason: SecureRandom.base64(4000), comment: SecureRandom.base64(4000) } + post :create, params: { role_definition: role_definition, reason: SecureRandom.base64(4000), comment: SecureRandom.base64(4000) } assert_match 'Error while creating role', flash[:error] assert_response :success end diff --git a/test/functional/kaui/subscriptions_controller_test.rb b/test/functional/kaui/subscriptions_controller_test.rb index 170d2caa..f56b787b 100644 --- a/test/functional/kaui/subscriptions_controller_test.rb +++ b/test/functional/kaui/subscriptions_controller_test.rb @@ -7,7 +7,7 @@ class SubscriptionsControllerTest < Kaui::FunctionalTestHelper OVERRIDE_CATALOG = 'test/fixtures/catalog-sample-for-cancel-subscription.xml' test 'should handle Kill Bill errors in new screen' do bundle_id = SecureRandom.uuid.to_s - get :new, params: { bundle_id:, account_id: @account.account_id, product_category: 'ADD_ON' } + get :new, params: { bundle_id: bundle_id, account_id: @account.account_id, product_category: 'ADD_ON' } assert_redirected_to account_path(@account.account_id) assert_equal "Error while communicating with the Kill Bill server: Object id=#{bundle_id} type=BUNDLE doesn't exist!", flash[:error] end diff --git a/test/functional/kaui/transactions_controller_test.rb b/test/functional/kaui/transactions_controller_test.rb index a2ccb700..58174b8c 100644 --- a/test/functional/kaui/transactions_controller_test.rb +++ b/test/functional/kaui/transactions_controller_test.rb @@ -49,7 +49,7 @@ class TransactionsControllerTest < Kaui::FunctionalTestHelper payment_external_key: SecureRandom.uuid, amount: 12, currency: 'USD', - transaction_type: + transaction_type: transaction_type } } @@ -64,10 +64,10 @@ class TransactionsControllerTest < Kaui::FunctionalTestHelper params: { account_id: @account.account_id, transaction: { - payment_id:, + payment_id: payment_id, amount: 12, currency: 'USD', - transaction_type: + transaction_type: transaction_type } } assert_redirected_to account_payment_path(@account.account_id, payment_id) diff --git a/test/killbill_test_helper.rb b/test/killbill_test_helper.rb index 66272ad9..60898e7c 100644 --- a/test/killbill_test_helper.rb +++ b/test/killbill_test_helper.rb @@ -163,7 +163,7 @@ def create_cba(invoice_id = nil, account = nil, tenant = nil, _auto_commit = fal tenant = create_tenant(user, reason, comment) if tenant.nil? account = create_account(tenant, username, password, user, reason, comment) if account.nil? - credit = KillBillClient::Model::Credit.new(invoice_id:, account_id: account.account_id, amount: 23.22) + credit = KillBillClient::Model::Credit.new(invoice_id: invoice_id, account_id: account.account_id, amount: 23.22) credit = credit.create(true, user, reason, comment, build_options(tenant, username, password)).first invoice = KillBillClient::Model::Invoice.find_by_id(credit.invoice_id, 'NONE', build_options(tenant, username, password)) @@ -212,8 +212,8 @@ def build_options(tenant = nil, username = USERNAME, password = PASSWORD) { api_key: tenant&.api_key, api_secret: tenant&.api_secret, - username:, - password: + username: username, + password: password } end