diff --git a/.travis.yml b/.travis.yml index 92b868b7d..2a7f37ecd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -43,6 +43,18 @@ jobs: gemfile: gemfiles/rails_6.0.gemfile - rvm: 2.4.10 gemfile: gemfiles/rails_edge.gemfile + - rvm: 2.7.1 + gemfile: gemfiles/rails_5.0.gemfile + - rvm: 2.7.1 + gemfile: gemfiles/rails_5.1.gemfile + - rvm: 2.7.1 + gemfile: gemfiles/rails_5.2.gemfile + - rvm: ruby-head + gemfile: gemfiles/rails_5.0.gemfile + - rvm: ruby-head + gemfile: gemfiles/rails_5.1.gemfile + - rvm: ruby-head + gemfile: gemfiles/rails_5.2.gemfile fast_finish: true script: bundle exec rake test:all diff --git a/lib/client_side_validations/action_view/form_helper.rb b/lib/client_side_validations/action_view/form_helper.rb index 6fb1ae377..5c2eb10fb 100644 --- a/lib/client_side_validations/action_view/form_helper.rb +++ b/lib/client_side_validations/action_view/form_helper.rb @@ -98,10 +98,10 @@ def construct_validators def add_validator(validator_hash, validation_hash, name, attr) if validation_hash.key?(attr) validator_hash[name] = validation_hash[attr] - elsif attr.to_s.ends_with?('_id') + elsif attr.to_s.end_with?('_id') association_name = attr.to_s.gsub(/_id\Z/, '').to_sym add_validator_with_association validator_hash, validation_hash, name, association_name - elsif attr.to_s.ends_with?('_ids') + elsif attr.to_s.end_with?('_ids') association_name = attr.to_s.gsub(/_ids\Z/, '').pluralize.to_sym add_validator_with_association validator_hash, validation_hash, name, association_name end diff --git a/lib/client_side_validations/active_model.rb b/lib/client_side_validations/active_model.rb index d77338fc6..3cbf54320 100644 --- a/lib/client_side_validations/active_model.rb +++ b/lib/client_side_validations/active_model.rb @@ -91,7 +91,7 @@ def check_new_record(validator) end def will_save_change?(options) - options.is_a?(Symbol) && (options.to_s.ends_with?('changed?') || options.to_s.starts_with?('will_save_change_to')) + options.is_a?(Symbol) && (options.to_s.end_with?('changed?') || options.to_s.start_with?('will_save_change_to')) end def check_conditionals(attr, validator, force)