Skip to content

Commit

Permalink
Merge pull request #1821 from heartcombo/ca/rails-71
Browse files Browse the repository at this point in the history
Rails 7.1
  • Loading branch information
carlosantoniodasilva committed Oct 11, 2023
2 parents 921ce9c + 1c27ae6 commit bf1013a
Show file tree
Hide file tree
Showing 14 changed files with 119 additions and 66 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ jobs:
gemfile:
- Gemfile
- gemfiles/Gemfile-rails-main
- gemfiles/Gemfile-rails-7-0
- gemfiles/Gemfile-rails-6-1
- gemfiles/Gemfile-rails-6-0
- gemfiles/Gemfile-rails-5-2
Expand All @@ -27,6 +28,10 @@ jobs:
ruby: '2.6'
- gemfile: gemfiles/Gemfile-rails-main
ruby: '2.5'
- gemfile: gemfiles/Gemfile-rails-7-0
ruby: '2.6'
- gemfile: gemfiles/Gemfile-rails-7-0
ruby: '2.5'
- gemfile: gemfiles/Gemfile-rails-6-0
ruby: '3.2'
- gemfile: gemfiles/Gemfile-rails-6-0
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Unreleased

* Add support for Rails 7.1. (no meaningful changes required.)
* Add `SimpleForm.deprecator` to integrate with new application deprecators in Rails 7.1.
* Remove test files from the gem package. [@orien](https://github.com/orien)
* Speed up input mapping lookup by avoiding rescuing exceptions. [@meanphil](https://github.com/meanphil) [@kriom](https://github.com/kriom) [@egeek](https://github.com/egeek)

Expand Down
6 changes: 3 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source 'https://rubygems.org'
gemspec

gem 'country_select'
gem 'activemodel', '~> 7.0.0'
gem 'actionpack', '~> 7.0.0'
gem 'railties', '~> 7.0.0'
gem 'activemodel', '~> 7.1.0'
gem 'actionpack', '~> 7.1.0'
gem 'railties', '~> 7.1.0'
gem 'rake'
121 changes: 77 additions & 44 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,78 +8,111 @@ PATH
GEM
remote: https://rubygems.org/
specs:
actionpack (7.0.4.2)
actionview (= 7.0.4.2)
activesupport (= 7.0.4.2)
rack (~> 2.0, >= 2.2.0)
actionpack (7.1.0)
actionview (= 7.1.0)
activesupport (= 7.1.0)
nokogiri (>= 1.8.5)
rack (>= 2.2.4)
rack-session (>= 1.0.1)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actionview (7.0.4.2)
activesupport (= 7.0.4.2)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
actionview (7.1.0)
activesupport (= 7.1.0)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.1, >= 1.2.0)
activemodel (7.0.4.2)
activesupport (= 7.0.4.2)
activesupport (7.0.4.2)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
activemodel (7.1.0)
activesupport (= 7.1.0)
activesupport (7.1.0)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
base64 (0.1.1)
bigdecimal (3.1.4)
builder (3.2.4)
concurrent-ruby (1.2.0)
countries (5.3.1)
concurrent-ruby (1.2.2)
connection_pool (2.4.1)
countries (5.7.0)
unaccent (~> 0.3)
country_select (8.0.1)
country_select (8.0.3)
countries (~> 5.0)
crass (1.0.6)
drb (2.1.1)
ruby2_keywords
erubi (1.12.0)
i18n (1.12.0)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
loofah (2.19.1)
io-console (0.6.0)
irb (1.8.1)
rdoc
reline (>= 0.3.8)
loofah (2.21.4)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
method_source (1.0.0)
mini_portile2 (2.8.1)
minitest (5.17.0)
nokogiri (1.14.0)
mini_portile2 (~> 2.8.0)
nokogiri (>= 1.12.0)
mini_portile2 (2.8.4)
minitest (5.20.0)
mutex_m (0.1.2)
nokogiri (1.15.4)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
racc (1.6.2)
rack (2.2.6.2)
rack-test (2.0.2)
psych (5.1.0)
stringio
racc (1.7.1)
rack (3.0.8)
rack-session (2.0.0)
rack (>= 3.0.0)
rack-test (2.1.0)
rack (>= 1.3)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
rackup (2.1.0)
rack (>= 3)
webrick (~> 1.8)
rails-dom-testing (2.2.0)
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
rails-html-sanitizer (1.5.0)
loofah (~> 2.19, >= 2.19.1)
railties (7.0.4.2)
actionpack (= 7.0.4.2)
activesupport (= 7.0.4.2)
method_source
rails-html-sanitizer (1.6.0)
loofah (~> 2.21)
nokogiri (~> 1.14)
railties (7.1.0)
actionpack (= 7.1.0)
activesupport (= 7.1.0)
irb
rackup (>= 1.0.0)
rake (>= 12.2)
thor (~> 1.0)
zeitwerk (~> 2.5)
thor (~> 1.0, >= 1.2.2)
zeitwerk (~> 2.6)
rake (13.0.6)
thor (1.2.1)
rdoc (6.5.0)
psych (>= 4.0.0)
reline (0.3.9)
io-console (~> 0.5)
ruby2_keywords (0.0.5)
stringio (3.0.8)
thor (1.2.2)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unaccent (0.4.0)
zeitwerk (2.6.6)
webrick (1.8.1)
zeitwerk (2.6.12)

PLATFORMS
ruby

DEPENDENCIES
actionpack (~> 7.0.0)
activemodel (~> 7.0.0)
actionpack (~> 7.1.0)
activemodel (~> 7.1.0)
country_select
railties (~> 7.0.0)
railties (~> 7.1.0)
rake
simple_form!

BUNDLED WITH
2.4.5
2.4.20
9 changes: 9 additions & 0 deletions gemfiles/Gemfile-rails-7-0
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
source 'https://rubygems.org'

gemspec path: '..'

gem 'country_select'
gem 'activemodel', '~> 7.0.0'
gem 'actionpack', '~> 7.0.0'
gem 'railties', '~> 7.0.0'
gem 'rake'
12 changes: 8 additions & 4 deletions lib/simple_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ def self.configured? #:nodoc:
@@configured
end

def self.deprecator
@deprecator ||= ActiveSupport::Deprecation.new("5.3", "SimpleForm")
end

## CONFIGURATION OPTIONS

# Method used to tidy up errors.
Expand Down Expand Up @@ -264,21 +268,21 @@ def self.additional_classes_for(component)
## SETUP

def self.default_input_size=(*)
ActiveSupport::Deprecation.warn "[SIMPLE_FORM] SimpleForm.default_input_size= is deprecated and has no effect", caller
SimpleForm.deprecator.warn "[SIMPLE_FORM] SimpleForm.default_input_size= is deprecated and has no effect", caller
end

def self.form_class=(value)
ActiveSupport::Deprecation.warn "[SIMPLE_FORM] SimpleForm.form_class= is deprecated and will be removed in 4.x. Use SimpleForm.default_form_class= instead", caller
SimpleForm.deprecator.warn "[SIMPLE_FORM] SimpleForm.form_class= is deprecated and will be removed in 4.x. Use SimpleForm.default_form_class= instead", caller
@@form_class = value
end

def self.file_methods=(file_methods)
ActiveSupport::Deprecation.warn(FILE_METHODS_DEPRECATION_WARN, caller)
SimpleForm.deprecator.warn(FILE_METHODS_DEPRECATION_WARN, caller)
@@file_methods = file_methods
end

def self.file_methods
ActiveSupport::Deprecation.warn(FILE_METHODS_DEPRECATION_WARN, caller)
SimpleForm.deprecator.warn(FILE_METHODS_DEPRECATION_WARN, caller)
@@file_methods
end

Expand Down
2 changes: 1 addition & 1 deletion lib/simple_form/components/label_input.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def deprecated_component(namespace, wrapper_options)
method = method(namespace)

if method.arity.zero?
ActiveSupport::Deprecation.warn(SimpleForm::CUSTOM_INPUT_DEPRECATION_WARN % { name: namespace })
SimpleForm.deprecator.warn(SimpleForm::CUSTOM_INPUT_DEPRECATION_WARN % { name: namespace })

method.call
else
Expand Down
4 changes: 4 additions & 0 deletions lib/simple_form/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,9 @@ class Railtie < Rails::Railtie
' Use `rails generate simple_form:install` to generate the Simple Form configuration.'
end
end

initializer "simple_form.deprecator" do |app|
app.deprecators[:simple_form] = SimpleForm.deprecator if app.respond_to?(:deprecators)
end
end
end
2 changes: 1 addition & 1 deletion lib/simple_form/wrappers/leaf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def render(input)
method = input.method(@namespace)

if method.arity.zero?
ActiveSupport::Deprecation.warn(SimpleForm::CUSTOM_INPUT_DEPRECATION_WARN % { name: @namespace })
SimpleForm.deprecator.warn(SimpleForm::CUSTOM_INPUT_DEPRECATION_WARN % { name: @namespace })

method.call
else
Expand Down
2 changes: 1 addition & 1 deletion test/action_view_extensions/form_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class FormHelperTest < ActionView::TestCase

# Remove this test when SimpleForm.form_class is removed in 4.x
test 'SimpleForm allows overriding default form class, but not form class' do
ActiveSupport::Deprecation.silence do
SimpleForm.deprecator.silence do
swap SimpleForm, form_class: "fixed_class", default_form_class: "my_custom_class" do
with_concat_form_for :user, html: { class: "override_class" }
assert_no_select 'form.my_custom_class'
Expand Down
6 changes: 3 additions & 3 deletions test/form_builder/association_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def with_association_for(object, *args)
end

test 'builder preloads collection association' do
value = @user.tags = MiniTest::Mock.new
value = @user.tags = Minitest::Mock.new
value.expect(:to_a, value)

with_association_for @user, :tags
Expand All @@ -61,7 +61,7 @@ def with_association_for(object, *args)
end

test 'builder does not preload collection association if preload is false' do
value = @user.tags = MiniTest::Mock.new
value = @user.tags = Minitest::Mock.new
value.expect(:to_a, nil)

with_association_for @user, :tags, preload: false
Expand All @@ -76,7 +76,7 @@ def with_association_for(object, *args)
end

test 'builder does not preload non-collection association' do
value = @user.company = MiniTest::Mock.new
value = @user.company = Minitest::Mock.new
value.expect(:to_a, nil)

with_association_for @user, :company
Expand Down
4 changes: 2 additions & 2 deletions test/form_builder/general_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def with_custom_form_for(object, *args, &block)
# COMMON OPTIONS
# Remove this test when SimpleForm.form_class is removed in 4.x
test 'builder adds chosen form class' do
ActiveSupport::Deprecation.silence do
SimpleForm.deprecator.silence do
swap SimpleForm, form_class: :my_custom_class do
with_form_for @user, :name
assert_select 'form.my_custom_class'
Expand All @@ -306,7 +306,7 @@ def with_custom_form_for(object, *args, &block)

# Remove this test when SimpleForm.form_class is removed in 4.x
test 'builder adds chosen form class and default form class' do
ActiveSupport::Deprecation.silence do
SimpleForm.deprecator.silence do
swap SimpleForm, form_class: "my_custom_class", default_form_class: "my_default_class" do
with_form_for @user, :name
assert_select 'form.my_custom_class.my_default_class'
Expand Down
4 changes: 2 additions & 2 deletions test/inputs/discovery_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ def discovery(value = false)
assert_select 'form input[type=file]#user_avatar.file-upload'
end
end

test 'inputs method without wrapper_options are deprecated' do
discovery do
assert_deprecated do
assert_deprecated('input method now accepts a `wrapper_options` argument.', SimpleForm.deprecator) do
with_form_for @user, :name, as: :deprecated
end

Expand Down
6 changes: 1 addition & 5 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ def self.env

require 'country_select'

if defined?(HTMLSelector::NO_STRIP)
HTMLSelector::NO_STRIP << "label"
else
ActionDispatch::Assertions::NO_STRIP << "label"
end
Rails::Dom::Testing::Assertions::SelectorAssertions::HTMLSelector::NO_STRIP << "label"

if ActiveSupport::TestCase.respond_to?(:test_order=)
ActiveSupport::TestCase.test_order = :random
Expand Down

0 comments on commit bf1013a

Please sign in to comment.