Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ jobs:
database-password: 'root'
database-port: '3306'
docker-compose-file: 'docker-compose.ci.mysql.yml'
- ruby-version: 'jruby-9.4.2.0'
database-adapter: 'mariadb'
- ruby-version: 'jruby-9.4.15.0'
database-adapter: 'mysql2'
database-user: 'root'
database-password: 'root'
database-port: '3306'
Expand All @@ -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.4.15.0'
database-adapter: 'postgresql'
database-user: 'postgres'
database-password: 'postgres'
Expand Down
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ruby '>= 3.1.0'

gemspec

gem 'rails', '~> 7.0.1'
gem 'rails', '~> 7.2.0'

# Lock i18n to 1.14.x for: https://github.com/ruby-i18n/i18n/issues/735
gem 'i18n', '~> 1.14.0'
Expand All @@ -26,7 +26,7 @@ group :development do
gem 'simplecov'

if defined?(JRUBY_VERSION)
gem 'activerecord-jdbc-adapter', '~> 70.0'
gem 'activerecord-jdbc-adapter', '~> 72.0'
# Add the drivers
gem 'jdbc-mariadb'
gem 'jdbc-postgres'
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Kill Bill compatibility
Dependencies
------------

Ruby 3.2.2+ or JRuby 9.4.2.0+ required.
Ruby 3.1.0+ or JRuby 9.4.15.0+ required.

Running Kaui locally
---------------------
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/kaui/exception_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def standardize_exception(exception)
I18n.t('errors.messages.error_communicating_killbill')
else
# Show detailed error in development/test, or when KAUI_SHOW_ERROR_DETAILS is set (for Docker)
show_details = Rails.env.development? || Rails.env.test? || ENV['KAUI_SHOW_ERROR_DETAILS'].present?
show_details = Rails.env.local? || ENV['KAUI_SHOW_ERROR_DETAILS'].present?
show_details ? exception.message : nil
end
end
Expand Down
6 changes: 5 additions & 1 deletion app/views/kaui/admin_allowed_users/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<%= form_for @allowed_user, :url => @allowed_user.persisted? ? admin_allowed_user_path(@allowed_user.id) : admin_allowed_users_path, :method => @allowed_user.persisted? ? :put : :post, :html => {:class => 'form-horizontal'} do |f| %>
<input type="hidden" id="killbillManaged" value="<%= @is_killbill_managed %>" />
<div class='form-group d-flex pb-3'>
<%= f.label ' ', :class => 'col-sm-3 control-label' %>
<%# Not associated with a real attribute - use label_tag instead of f.label, which under
Rails 7.2 raises NoMethodError (undefined method `humanize' for nil) for a blank name,
since ActiveModel::Translation#human_attribute_name only handles a blank *namespaced*
attribute (e.g. "foo."), not a plain blank string. %>
<%= label_tag nil, ' ', :class => 'col-sm-3 control-label' %>
<div class="col-sm-9">
<div class="checkbox">
<label for="external" class="d-flex align-items-center gap-2 control-label">
Expand Down
4 changes: 2 additions & 2 deletions kaui.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '>= 3.1.0'

s.license = 'Apache License (2.0)'

Expand All @@ -37,7 +37,7 @@ Gem::Specification.new do |s|
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', '~> 7.2'
s.add_dependency 'spinjs-rails'
s.add_dependency 'sprockets'
s.add_dependency 'sprockets-rails'
Expand Down
9 changes: 9 additions & 0 deletions test/dummy/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@
require "rails/test_unit/railtie"
require 'sprockets/railtie'

# Work around a sorbet-runtime/js-routes crash under JRuby 10 (Ruby 4.0 compat):
# js-routes' sig-decorated methods trigger a sorbet-runtime signature-validation
# NoMethodError at load time. Disabling runtime checks avoids building the
# crashing validation wrapper. See repo memory for details.
if defined?(JRUBY_VERSION)
require 'sorbet-runtime'
T::Configuration.default_checked_level = :never
end

# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
Expand Down
17 changes: 16 additions & 1 deletion test/dummy/config/database.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
development: &default
<% if defined?(JRUBY_VERSION) %>
<% adapter = java.lang.System.getProperty('kaui.db.adapter', ENV['DB_ADAPTER'] || 'mariadb') %>
<% if adapter == 'mysql2'
# arjdbc's mysql2 adapter doesn't auto-load the MariaDB JDBC driver the way the
# (now removed in arjdbc 72.x) 'mariadb' adapter used to; without this, connecting
# raises Java::JavaLang::ClassNotFoundException: org.mariadb.jdbc.Driver
# Note: must pass :require explicitly - the default :load method does not
# actually register the jar with JRuby's classloader.
require 'jdbc/mariadb'
Jdbc::MariaDB.load_driver(:require)
end %>
adapter: <%= adapter %>
encoding: <%= java.lang.System.getProperty('kaui.db.encoding', ENV['DB_ENCODING'] || 'utf8') %>
<% if adapter == 'sqlite3' %>
Expand All @@ -15,6 +24,9 @@ development: &default
port: <%= java.lang.System.getProperty('kaui.db.port', ENV['DB_PORT']) %>
pool: <%= java.lang.System.getProperty('kaui.db.pool', ENV['DB_POOL'] || '50') %>
timeout: <%= java.lang.System.getProperty('kaui.db.timeout', ENV['DB_TIMEOUT'] || '5000') %>
<% if adapter == 'mysql2' %>
driver: org.mariadb.jdbc.Driver
<% end %>
<% end %>
<% else %>
adapter: mysql2
Expand All @@ -35,9 +47,12 @@ test:
<% if defined?(JRUBY_VERSION) %>
<% adapter = java.lang.System.getProperty('kaui.db.adapter', ENV['DB_ADAPTER'] || 'mariadb') %>
adapter: <%= adapter %>
<% if adapter == 'mariadb' %>
<% if adapter == 'mariadb' || adapter == 'mysql2' %>
url: <%= java.lang.System.getProperty('kaui.db.url', ENV['DB_URL'] || 'jdbc:mariadb://localhost:3306/kaui?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC') %>
<% end %>
<% if adapter == 'mysql2' %>
driver: org.mariadb.jdbc.Driver
<% end %>
<% else %>
adapter: <%= ENV.fetch('DB_ADAPTER', 'mysql2') %>
<% end %>
Expand Down
12 changes: 7 additions & 5 deletions test/functional/kaui/accounts_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,9 @@ class AccountsControllerTest < Kaui::FunctionalTestHelper
post :trigger_invoice, params: parameters
assert_response :redirect
assert_match(/Generated invoice.*for target date.*/, flash[:notice])
a_tag = /<a.href="(?<href>.*?)">/.match(@response.body)
assert_redirected_to a_tag[:href]
# Rails 7.2 no longer includes a fallback HTML body in redirect responses;
# use the Location header directly instead of parsing @response.body.
assert_redirected_to @response.location
end

test 'should get next_invoice_date' do
Expand Down Expand Up @@ -290,10 +291,11 @@ class AccountsControllerTest < Kaui::FunctionalTestHelper
private

def redirected_account_id
fields = %r{<a.href="http:/.*/.*?/(?<id>.*?)">}.match(@response.body) if fields.nil?

return nil if fields.nil?
# Rails 7.2 no longer includes a fallback HTML body (with a link to the redirect
# target) in redirect responses, so parse the account id from the Location header instead.
return nil if @response.location.blank?

fields = %r{/accounts/(?<id>[^/?]+)}.match(@response.location)
fields.nil? ? nil : fields[:id]
end
end
Expand Down
9 changes: 7 additions & 2 deletions test/functional/kaui/admin_allowed_users_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ class AdminAllowedUsersControllerTest < Kaui::FunctionalTestHelper

# should respond with an error if tried to delete again
delete :destroy, params: { id: }
assert_equal "Error: Couldn't find Kaui::AllowedUser with 'id'=#{id}", flash[:error]
# Rails 7.2 quotes the id value in ActiveRecord::RecordNotFound's message
# (e.g. 'id'="60" instead of 'id'=60), since the id here is a String.
assert_equal "Error: Couldn't find Kaui::AllowedUser with 'id'=\"#{id}\"", flash[:error]
assert_response :redirect
# validate redirect path
assert response_path.include?('/kaui/home'), "#{response_path} is expected to contain '/kaui/home'"
Expand Down Expand Up @@ -228,8 +230,11 @@ def extract_allowed_description

def extract_allowed_id(response_body)
fields = %r{<form.*action="/.*/.*/(?<id>.*?)".accept-charset=.*method="post">}.match(response_body)
fields = %r{<a.href="http:/.*/.*/(?<id>.*?)">}.match(response_body) if fields.nil?
return fields[:id] if fields

# Rails 7.2 no longer includes a fallback HTML body in redirect responses,
# so fall back to parsing the id out of the Location header instead.
fields = %r{/(?<id>[^/?]+)\z}.match(response_path)
fields.nil? ? nil : fields[:id]
end
end
Expand Down
6 changes: 3 additions & 3 deletions test/functional/kaui/admin_tenants_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class AdminTenantsControllerTest < Kaui::FunctionalTestHelper
test 'should upload plugin config' do
tenant = create_kaui_tenant

stripe_yml = YAML.load_file(File.join(self.class.fixture_path, 'stripe.yml'))[:stripe]
stripe_yml = YAML.load_file(File.join(self.class.fixture_paths.first, 'stripe.yml'))[:stripe]
stripe_yml.stringify_keys!
stripe_yml.each { |k, v| stripe_yml[k] = v.to_s }
post :upload_plugin_config, params: { id: tenant.id, plugin_name: 'killbill-stripe', plugin_key: 'stripe', plugin_type: 'ruby', plugin_properties: stripe_yml }
Expand All @@ -166,7 +166,7 @@ class AdminTenantsControllerTest < Kaui::FunctionalTestHelper
tenant = create_kaui_tenant

# retrieve plan id from catalog xml
catalog_xml = File.read(File.join(self.class.fixture_path, 'catalog-v1.xml'))
catalog_xml = File.read(File.join(self.class.fixture_paths.first, 'catalog-v1.xml'))
doc = Nokogiri::XML(catalog_xml)
plan_id = doc.css('plan').first['name']

Expand Down Expand Up @@ -327,7 +327,7 @@ class AdminTenantsControllerTest < Kaui::FunctionalTestHelper
end

test 'should display overdue xml' do
overdue_xml = File.read(File.join(self.class.fixture_path, 'overdue-v1.xml'))
overdue_xml = File.read(File.join(self.class.fixture_paths.first, 'overdue-v1.xml'))
post :display_overdue_xml, params: { xml: overdue_xml }

assert_equal @response.body, overdue_xml
Expand Down
13 changes: 12 additions & 1 deletion test/functional/kaui/functional_test_helper_nosetup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,18 @@ class FunctionalTestHelperNoSetup < ActionController::TestCase

protected

self.fixture_path = Kaui::Engine.root.join('test', 'fixtures')
self.fixture_paths = [Kaui::Engine.root.join('test', 'fixtures')]

# ActionController::TestCase recycles the request env between successive calls in the
# same test (e.g. a multipart POST followed by a GET), but doesn't clear a stale multipart
# Content-Type header (see scrub_env! in Rails' action_controller/test_case.rb). Rack 3.x
# then raises Rack::Multipart::EmptyContentError when that later request's (now empty)
# body gets parsed as multipart. Clear it before every request; #process re-sets it as
# needed for whichever request is actually being made.
def process(*, **)
@request&.delete_header('CONTENT_TYPE')
super
end

#
# Rails helpers
Expand Down
Loading