From 8d6550c39f67a2a29e76c73ebe424f5dab8fb87c Mon Sep 17 00:00:00 2001 From: Larry Reid Date: Tue, 20 Jan 2026 02:27:57 +0000 Subject: [PATCH 1/3] Don't raise exception when no model --- lib/bootstrap_form/form_group_builder.rb | 2 +- test/bootstrap_form_group_test.rb | 10 ++++++++++ test/test_helper.rb | 6 +++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/bootstrap_form/form_group_builder.rb b/lib/bootstrap_form/form_group_builder.rb index 620433da..94ec6dab 100644 --- a/lib/bootstrap_form/form_group_builder.rb +++ b/lib/bootstrap_form/form_group_builder.rb @@ -107,7 +107,7 @@ def form_group_css_options(method, html_options, options) end def form_group_placeholder(options, method) - form_group_label_text(options[:label]) || object.class.human_attribute_name(method) + form_group_label_text(options[:label]) || (object && object.class.human_attribute_name(method)) || method.to_s.humanize # rubocop:disable Style/SafeNavigation end end end diff --git a/test/bootstrap_form_group_test.rb b/test/bootstrap_form_group_test.rb index 5f15035e..acc9d102 100644 --- a/test/bootstrap_form_group_test.rb +++ b/test/bootstrap_form_group_test.rb @@ -118,6 +118,16 @@ class BootstrapFormGroupTest < ActionView::TestCase assert_equivalent_html expected, @builder.text_field(:email, label_as_placeholder: true) end + test "label as placeholder with form_with" do + expected = <<~HTML +
+ + +
+ HTML + assert_equivalent_html expected, form_with_builder.text_field(:email, label_as_placeholder: true, required: true) + end + test "adding prepend text" do expected = <<~HTML
diff --git a/test/test_helper.rb b/test/test_helper.rb index 83fee89e..da0547aa 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -41,10 +41,10 @@ def setup_test_fixture end # Originally only used in one test file but placed here in case it's needed in others in the future. + # This simulartes `form_with` without a model, which tests aspects that wouldn't otherwise + # be tested. def form_with_builder - builder = nil - bootstrap_form_with(model: @user) { |f| builder = f } - builder + BootstrapForm::FormBuilder.new(:user, false, self, {}) end def sort_attributes(doc) From 69c5d37d81e17ef2f325825d9726a89e80da0777 Mon Sep 17 00:00:00 2001 From: Larry Reid Date: Fri, 23 Jan 2026 00:04:44 +0000 Subject: [PATCH 2/3] Install minitest-mock; Hold minitest to 5 up to Rails 8.0 --- gemfiles/7.2.gemfile | 1 + gemfiles/8.0.gemfile | 1 + gemfiles/common.gemfile | 1 + 3 files changed, 3 insertions(+) diff --git a/gemfiles/7.2.gemfile b/gemfiles/7.2.gemfile index db3479f2..e57d13d4 100644 --- a/gemfiles/7.2.gemfile +++ b/gemfiles/7.2.gemfile @@ -3,6 +3,7 @@ eval File.read(gems), binding, gems # rubocop: disable Security/Eval gem "bigdecimal" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0") gem "drb" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0") +gem "minitest", "~> 5.0" gem "mutex_m" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0") gem "rails", "~> 7.2.0" gem "sprockets-rails", require: "sprockets/railtie" diff --git a/gemfiles/8.0.gemfile b/gemfiles/8.0.gemfile index 9e8686ae..32cf900d 100644 --- a/gemfiles/8.0.gemfile +++ b/gemfiles/8.0.gemfile @@ -3,6 +3,7 @@ eval File.read(gems), binding, gems # rubocop: disable Security/Eval gem "bigdecimal" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0") gem "drb" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0") +gem "minitest", "~> 5.0" gem "mutex_m" if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("3.4.0") gem "propshaft" gem "rails", "~> 8.0.1" diff --git a/gemfiles/common.gemfile b/gemfiles/common.gemfile index 40bcf014..9a18ca6b 100644 --- a/gemfiles/common.gemfile +++ b/gemfiles/common.gemfile @@ -9,6 +9,7 @@ group :test do gem "chunky_png", "~> 1.4" gem "diffy" gem "equivalent-xml" + gem "minitest-mock" gem "mocha" gem "selenium-webdriver" end From d9a2d289ecbe5300c5013b368741362931c7bc40 Mon Sep 17 00:00:00 2001 From: Larry Reid Date: Fri, 23 Jan 2026 01:56:17 +0000 Subject: [PATCH 3/3] Exclude Ruby 3.2 with edge --- .github/workflows/ruby.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index dafe1fad..602cffbe 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -34,6 +34,9 @@ jobs: matrix: ruby-version: [ '3.4', '3.3', '3.2', 'ruby-head' ] gemfile: [ '8.1', '8.0', '7.2', 'edge' ] + exclude: + - ruby-version: 3.2 + - gemfiles: 'edge' env: BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile steps: