Skip to content

Commit

Permalink
Remove support for Rails 5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
donv committed May 20, 2023
1 parent 7863f23 commit fc0fee3
Show file tree
Hide file tree
Showing 20 changed files with 107 additions and 109 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,10 @@ jobs:
fail-fast: false
matrix:
ruby-version: [ '3.2', '3.1', '3.0' ]
gemfile: [ '7.0', '6.1', '6.0', '5.2', 'edge' ]
gemfile: [ '7.0', '6.1', '6.0', 'edge' ]
exclude:
- { ruby-version: '3.2', gemfile: "6.0" }
- { ruby-version: '3.1', gemfile: "6.0" }
- { ruby-version: '3.2', gemfile: "5.2" }
- { ruby-version: '3.1', gemfile: "5.2" }
- { ruby-version: '3.0', gemfile: "5.2" }
env:
BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
steps:
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ eval File.read(gems), binding, gems # rubocop: disable Security/Eval
require "#{__dir__}/lib/bootstrap_form/version"

gem "rails", BootstrapForm::REQUIRED_RAILS_VERSION
gem "sprockets-rails", require: "sprockets/railtie"
2 changes: 1 addition & 1 deletion RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Follow these steps to release a new version of bootstrap_form to rubygems.org.
2. **Ensure the demo tests are passing by running**

cd demo
bundle install
bundle update
bundle exec rake test:all

3. Determine which would be the correct next version number according to [semver](http://semver.org/).
Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ end
desc 'Run RuboCop checks'
RuboCop::RakeTask.new(:rubocop)

task default: %i[test rubocop]
task default: %i[test rubocop:autocorrect]
2 changes: 1 addition & 1 deletion demo/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ gem "cssbundling-rails"
gem "htmlbeautifier"
gem "jbuilder"
gem "jsbundling-rails"
gem "puma", "~> 5.0"
gem "puma"
gem "sprockets-rails", require: "sprockets/railtie"
gem "sqlite3", "~> 1.4"
gem "tzinfo-data", platforms: %i[mingw mswin x64_mingw jruby]
Expand Down
10 changes: 5 additions & 5 deletions demo/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ PATH
remote: ..
specs:
bootstrap_form (5.2.0)
actionpack (>= 5.2)
activemodel (>= 5.2)
actionpack (>= 6.0)
activemodel (>= 6.0)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -148,7 +148,7 @@ GEM
nokogiri (1.15.1-x86_64-linux)
racc (~> 1.4)
public_suffix (5.0.1)
puma (5.6.5)
puma (6.2.2)
nio4r (~> 2.0)
racc (1.6.2)
rack (2.2.7)
Expand Down Expand Up @@ -182,7 +182,7 @@ GEM
zeitwerk (~> 2.5)
rake (13.0.6)
regexp_parser (2.8.0)
reline (0.3.3)
reline (0.3.4)
io-console (~> 0.5)
rexml (3.2.5)
rubyzip (2.3.2)
Expand Down Expand Up @@ -236,7 +236,7 @@ DEPENDENCIES
htmlbeautifier
jbuilder
jsbundling-rails
puma (~> 5.0)
puma
rails (~> 7.0.0)
selenium-webdriver
sprockets-rails
Expand Down
4 changes: 2 additions & 2 deletions demo/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# DEMO APP (Rails 5.2)
# DEMO APP (Rails 7.0)

### Usage

Expand All @@ -14,4 +14,4 @@
- app/models/{address,user,super_user,faux_user}.rb
- app/controllers/bootstrap_controller.rb
- app/views/layouts/application.html.erb
- app/views/bootstrap/form.html.erb
- app/views/bootstrap/form.html.erb
2 changes: 1 addition & 1 deletion demo/test/application_system_test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
include Capybara::Screenshot::Diff
Capybara::Screenshot.enabled = ENV['CI'].blank?
Capybara::Screenshot.enabled = ENV["CI"].blank?
driven_by :selenium, using: :headless_chrome, screen_size: [960, 720] do |capabilities|
capabilities.add_argument "force-device-scale-factor=1"
end
Expand Down
2 changes: 1 addition & 1 deletion demo/test/system/bootstrap_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class BootstrapTest < ApplicationSystemTestCase
HEADERS = ["Generated HTML", "This generates", "Which outputs", "will be rendered as"].join("|").freeze
REGEXP =
/(?:!\[[^\]]*\]\([^)]+\)\s*)?```erb\n(.*?)\n```\s*((?:#{HEADERS}).*?$)?\s*(```html\n(?:.*?)\n```\s*)?/mi
.freeze

test "readme examples" do
screenshot_group :readme

Expand Down
4 changes: 0 additions & 4 deletions gemfiles/5.2.gemfile

This file was deleted.

2 changes: 0 additions & 2 deletions gemfiles/7.0.gemfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
gems = "#{__dir__}/common.gemfile"
eval File.read(gems), binding, gems # rubocop: disable Security/Eval

# 7.0.0 has an issue with Ruby 3.1.
# And a test case has an issue with 7.0.1
gem "rails", "~> 7.0.2"
gem "sprockets-rails", require: "sprockets/railtie"
2 changes: 1 addition & 1 deletion lib/bootstrap_form/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module BootstrapForm
VERSION = "5.2.0".freeze
REQUIRED_RAILS_VERSION = ">= 5.2".freeze
REQUIRED_RAILS_VERSION = ">= 6.0".freeze
end
28 changes: 14 additions & 14 deletions test/bootstrap_checkbox_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class BootstrapCheckboxTest < ActionView::TestCase
</div>
HTML
assert_equivalent_html expected, @builder.check_box(:terms, label: "I agree to the terms", inline: true,
disabled: true)
disabled: true)
end

test "inline checkboxes with custom label class" do
Expand Down Expand Up @@ -182,7 +182,7 @@ class BootstrapCheckboxTest < ActionView::TestCase
HTML

assert_equivalent_html expected, @builder.collection_check_boxes(:misc, collection, :id, :street,
label: "This is a checkbox collection", help: "With a help!")
label: "This is a checkbox collection", help: "With a help!")
end

test "collection_check_boxes renders multiple checkboxes correctly" do
Expand Down Expand Up @@ -256,7 +256,7 @@ class BootstrapCheckboxTest < ActionView::TestCase
HTML

assert_equivalent_html expected, @builder.collection_check_boxes(:misc, collection, :id, :street,
inline: true)
inline: true)
end

test "collection_check_boxes renders with checked option correctly" do
Expand All @@ -281,9 +281,9 @@ class BootstrapCheckboxTest < ActionView::TestCase
HTML

assert_equivalent_html expected, @builder.collection_check_boxes(:misc, collection, :id, :street,
checked: 1)
checked: 1)
assert_equivalent_html expected, @builder.collection_check_boxes(:misc, collection, :id, :street,
checked: collection.first)
checked: collection.first)
end

test "collection_check_boxes renders with multiple checked options correctly" do
Expand All @@ -304,9 +304,9 @@ class BootstrapCheckboxTest < ActionView::TestCase
HTML

assert_equivalent_html expected, @builder.collection_check_boxes(:misc, collection, :id, :street,
checked: [1, 2])
checked: [1, 2])
assert_equivalent_html expected, @builder.collection_check_boxes(:misc, collection, :id, :street,
checked: collection)
checked: collection)
end

test "collection_check_boxes sanitizes values when generating label `for`" do
Expand Down Expand Up @@ -371,7 +371,7 @@ class BootstrapCheckboxTest < ActionView::TestCase
</div>
HTML
assert_equivalent_html expected, @builder.collection_check_boxes(:misc, collection, proc { |a| "address_#{a.id}" },
:street)
:street)
end

test "collection_check_boxes renders multiple checkboxes with labels defined by lambda :text_method correctly" do
Expand Down Expand Up @@ -420,7 +420,7 @@ class BootstrapCheckboxTest < ActionView::TestCase
HTML

assert_equivalent_html expected, @builder.collection_check_boxes(:misc, collection, ->(a) { "address_#{a.id}" },
:street)
:street)
end

test "collection_check_boxes renders with checked option correctly with Proc :value_method" do
Expand All @@ -445,9 +445,9 @@ class BootstrapCheckboxTest < ActionView::TestCase
HTML

assert_equivalent_html expected, @builder.collection_check_boxes(:misc, collection, proc { |a| "address_#{a.id}" },
:street, checked: "address_1")
:street, checked: "address_1")
assert_equivalent_html expected, @builder.collection_check_boxes(:misc, collection, proc { |a| "address_#{a.id}" },
:street, checked: collection.first)
:street, checked: collection.first)
end

test "collection_check_boxes renders with multiple checked options correctly with lambda :value_method" do
Expand All @@ -472,9 +472,9 @@ class BootstrapCheckboxTest < ActionView::TestCase
HTML

assert_equivalent_html expected, @builder.collection_check_boxes(:misc, collection, ->(a) { "address_#{a.id}" },
:street, checked: %w[address_1 address_2])
:street, checked: %w[address_1 address_2])
assert_equivalent_html expected, @builder.collection_check_boxes(:misc, collection, ->(a) { "address_#{a.id}" },
:street, checked: collection)
:street, checked: collection)
end

test "collection_check_boxes renders with include_hidden options correctly" do
Expand Down Expand Up @@ -620,7 +620,7 @@ class BootstrapCheckboxTest < ActionView::TestCase
</div>
HTML
assert_equivalent_html expected, @builder.check_box(:terms, label: "I agree to the terms", inline: true,
wrapper_class: "custom-class")
wrapper_class: "custom-class")
end

test "a required checkbox" do
Expand Down
6 changes: 3 additions & 3 deletions test/bootstrap_fields_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ class BootstrapFieldsTest < ActionView::TestCase
assert_equivalent_html expected, @builder.text_area(:comments)
end

test "text areas are wrapped correctly form_with Rails 5.2+" do
test "text areas are wrapped correctly using form_with" do
expected = <<~HTML
<div class="mb-3">
<label class="form-label" for="user_comments">Comments</label>
Expand Down Expand Up @@ -222,7 +222,7 @@ class BootstrapFieldsTest < ActionView::TestCase
</div>
HTML
assert_equivalent_html expected,
@horizontal_builder.text_field(:email, wrapper_class: "bogus-1", wrapper: { class: "bogus-2" })
@horizontal_builder.text_field(:email, wrapper_class: "bogus-1", wrapper: { class: "bogus-2" })
end

test "text fields are wrapped correctly when horizontal and wrapper class specified" do
Expand All @@ -247,7 +247,7 @@ class BootstrapFieldsTest < ActionView::TestCase
</div>
HTML
assert_equivalent_html expected,
@horizontal_builder.text_field(:email, wrapper: { class: "bogus-2" }, wrapper_class: "bogus-1")
@horizontal_builder.text_field(:email, wrapper: { class: "bogus-2" }, wrapper_class: "bogus-1")
end

test "field 'id' attribute is used to specify label 'for' attribute" do
Expand Down
2 changes: 1 addition & 1 deletion test/bootstrap_form_group_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,6 @@ class BootstrapFormGroupTest < ActionView::TestCase
</div>
HTML
assert_equivalent_html expected, @builder.email_field(:email, append: @builder.primary("Subscribe"),
input_group_class: "input-group-lg")
input_group_class: "input-group-lg")
end
end
16 changes: 8 additions & 8 deletions test/bootstrap_form_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ class BootstrapFormTest < ActionView::TestCase
</form>
HTML
assert_equivalent_html expected,
bootstrap_form_for(@user, layout: :horizontal, html: { class: "my-style" }) { |f| f.email_field :email }
bootstrap_form_for(@user, layout: :horizontal, html: { class: "my-style" }) { |f| f.email_field :email }
end

test "given role attribute should not be covered by default role attribute" do
Expand Down Expand Up @@ -368,7 +368,7 @@ class BootstrapFormTest < ActionView::TestCase
</form>
HTML
assert_equivalent_html expected,
bootstrap_form_tag(url: "/users") { |f| f.text_field :email, label: "Your Email" }
bootstrap_form_tag(url: "/users") { |f| f.text_field :email, label: "Your Email" }
end

test "bootstrap_form_for does not clobber custom options" do
Expand Down Expand Up @@ -608,7 +608,7 @@ class BootstrapFormTest < ActionView::TestCase
</form>
HTML
assert_equivalent_html expected,
bootstrap_form_for(@user, layout: :horizontal) { |f| f.email_field :email, label_col: "col-sm-1" }
bootstrap_form_for(@user, layout: :horizontal) { |f| f.email_field :email, label_col: "col-sm-1" }
end

test "offset for form group without label respects label width for horizontal forms" do
Expand All @@ -623,8 +623,8 @@ class BootstrapFormTest < ActionView::TestCase
</form>
HTML
assert_equivalent_html expected,
bootstrap_form_for(@user, layout: :horizontal, label_col: "col-md-2",
control_col: "col-md-10") { |f| f.form_group { f.submit } }
bootstrap_form_for(@user, layout: :horizontal, label_col: "col-md-2",
control_col: "col-md-10") { |f| f.form_group { f.submit } }
end

test "offset for form group without label respects multiple label widths for horizontal forms" do
Expand All @@ -639,8 +639,8 @@ class BootstrapFormTest < ActionView::TestCase
</form>
HTML
assert_equivalent_html expected,
bootstrap_form_for(@user, layout: :horizontal, label_col: "col-sm-4 col-md-2",
control_col: "col-sm-8 col-md-10") { |f| f.form_group { f.submit } }
bootstrap_form_for(@user, layout: :horizontal, label_col: "col-sm-4 col-md-2",
control_col: "col-sm-8 col-md-10") { |f| f.form_group { f.submit } }
end

test "custom input width for horizontal forms" do
Expand All @@ -656,7 +656,7 @@ class BootstrapFormTest < ActionView::TestCase
</form>
HTML
assert_equivalent_html expected,
bootstrap_form_for(@user, layout: :horizontal) { |f| f.email_field :email, control_col: "col-sm-5" }
bootstrap_form_for(@user, layout: :horizontal) { |f| f.email_field :email, control_col: "col-sm-5" }
end

test "additional input col class" do
Expand Down
14 changes: 7 additions & 7 deletions test/bootstrap_other_components_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -136,18 +136,18 @@ class BootstrapOtherComponentsTest < ActionView::TestCase
<button class="btn btn-secondary" extra="extra arg" name="button" type="submit"><span>I'm HTML!</span> in a button!</button>
HTML
assert_equivalent_html expected,
@builder.button(
"<span>I'm HTML!</span> in a button!".html_safe,
extra: "extra arg"
)
@builder.button(
"<span>I'm HTML!</span> in a button!".html_safe,
extra: "extra arg"
)
end

test "regular button can have extra css classes" do
expected = <<~HTML
<button class="btn btn-secondary test-button" name="button" type="submit"><span>I'm HTML!</span> in a button!</button>
HTML
assert_equivalent_html expected,
@builder.button("<span>I'm HTML!</span> in a button!".html_safe, extra_class: "test-button")
@builder.button("<span>I'm HTML!</span> in a button!".html_safe, extra_class: "test-button")
end

test "submit button defaults to rails action name" do
Expand Down Expand Up @@ -183,8 +183,8 @@ class BootstrapOtherComponentsTest < ActionView::TestCase
test "primary button can render as HTML button" do
expected = %q(<button class="btn btn-primary" name="button" type="submit"><span>I'm HTML!</span> Submit Form</button>)
assert_equivalent_html expected,
@builder.primary("<span>I'm HTML!</span> Submit Form".html_safe,
render_as_button: true)
@builder.primary("<span>I'm HTML!</span> Submit Form".html_safe,
render_as_button: true)
end

test "primary button with content block renders as HTML button" do
Expand Down
Loading

0 comments on commit fc0fee3

Please sign in to comment.