From 2f479617bef47a26154986f1c010b2d7b631c41e Mon Sep 17 00:00:00 2001 From: Oleg Date: Mon, 8 Jan 2018 14:38:08 -0800 Subject: [PATCH 001/112] removing appraisal, tweaking gemspec and gemfiles --- .travis.yml | 32 +++++++------------------------- Appraisals | 28 ---------------------------- Gemfile | 21 +++++++++------------ Rakefile | 20 +++++--------------- bootstrap_form.gemspec | 24 ++++++++---------------- gemfiles/4.0.gemfile | 9 --------- gemfiles/4.1.gemfile | 9 --------- gemfiles/4.2.gemfile | 9 --------- gemfiles/5.0.gemfile | 10 ---------- gemfiles/5.1.gemfile | 9 --------- test/gemfiles/5.0.gemfile | 16 ++++++++++++++++ test/gemfiles/5.1.gemfile | 16 ++++++++++++++++ test/gemfiles/5.2.gemfile | 16 ++++++++++++++++ 13 files changed, 77 insertions(+), 142 deletions(-) delete mode 100644 Appraisals delete mode 100644 gemfiles/4.0.gemfile delete mode 100644 gemfiles/4.1.gemfile delete mode 100644 gemfiles/4.2.gemfile delete mode 100644 gemfiles/5.0.gemfile delete mode 100644 gemfiles/5.1.gemfile create mode 100644 test/gemfiles/5.0.gemfile create mode 100644 test/gemfiles/5.1.gemfile create mode 100644 test/gemfiles/5.2.gemfile diff --git a/.travis.yml b/.travis.yml index 42528216c..1c72f00eb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,28 +1,10 @@ -sudo: false language: ruby rvm: - - 1.9 - - 2.0 - - 2.1 - - 2.2 - - 2.3.1 + - 2.2.7 + - 2.3.5 + - 2.4.2 + - 2.5.0 gemfile: - - gemfiles/4.0.gemfile - - gemfiles/4.1.gemfile - - gemfiles/4.2.gemfile -matrix: - include: - - rvm: 2.2.2 - gemfile: gemfiles/5.0.gemfile - - rvm: 2.3.1 - gemfile: gemfiles/5.0.gemfile - # Run Danger only once - script: bundle exec danger - - rvm: 2.2.2 - gemfile: gemfiles/5.1.gemfile - - rvm: 2.3.1 - gemfile: gemfiles/5.1.gemfile -before_install: - - gem install bundler --conservative --version '~> 1.10' -before_script: - - bundle exec rake -f test/dummy/Rakefile db:create db:migrate RAILS_ENV=test + - test/gemfiles/5.0.gemfile + - test/gemfiles/5.1.gemfile + - test/gemfiles/5.2.gemfile diff --git a/Appraisals b/Appraisals deleted file mode 100644 index 0af3c431b..000000000 --- a/Appraisals +++ /dev/null @@ -1,28 +0,0 @@ -appraise "4.0" do - gem "rails", "~> 4.0.0" - # nokogiri 1.7+ is not compatible with Ruby < 2.1, so pin at older version. - gem "nokogiri", "~> 1.6.8", platforms: [:ruby_19, :ruby_20] -end - -appraise "4.1" do - gem "rails", "~> 4.1.0" - # nokogiri 1.7+ is not compatible with Ruby < 2.1, so pin at older version. - gem "nokogiri", "~> 1.6.8", platforms: [:ruby_19, :ruby_20] -end - -appraise "4.2" do - gem "rails", "~> 4.2.0" - # nokogiri 1.7+ is not compatible with Ruby < 2.1, so pin at older version. - gem "nokogiri", "~> 1.6.8", platforms: [:ruby_19, :ruby_20] -end - -appraise "5.0" do - gem "rails", "~> 5.0.0" - gem "minitest", "< 5.10.2" - gem "danger" -end - -appraise "5.1" do - gem "rails", "~> 5.1.0" - gem "minitest", "< 5.10.2" -end diff --git a/Gemfile b/Gemfile index a65ccd187..ec295692f 100644 --- a/Gemfile +++ b/Gemfile @@ -1,17 +1,14 @@ source "http://rubygems.org" -# Declare your gem's dependencies in bootstrap_form.gemspec. -# Bundler will treat runtime dependencies like base dependencies, and -# development dependencies will be added by default to the :development group. gemspec -# jquery-rails is used by the dummy application -gem "jquery-rails" +group :test do + gem "diffy" + gem "equivalent-xml" + gem "mime-types", "~> 2.6.2" + gem "mocha" + gem "nokogiri" -# Declare any dependencies that are still in development here instead of in -# your gemspec. These might include edge Rails or gems from your path or -# Git. Remember to move these dependencies to your gemspec before releasing -# your gem to rubygems.org. - -# To use debugger -# gem 'ruby-debug19', :require => 'ruby-debug' + gem "sqlite3" + gem "timecop", "~> 0.7.1" +end diff --git a/Rakefile b/Rakefile index 8a5484318..708c7b858 100644 --- a/Rakefile +++ b/Rakefile @@ -1,37 +1,27 @@ -#!/usr/bin/env rake begin require 'bundler/setup' rescue LoadError puts 'You must `gem install bundler` and `bundle install` to run rake tasks' end -begin - require 'rdoc/task' -rescue LoadError - require 'rdoc/rdoc' - require 'rake/rdoctask' - RDoc::Task = Rake::RDocTask -end + +require 'rdoc/task' RDoc::Task.new(:rdoc) do |rdoc| rdoc.rdoc_dir = 'rdoc' rdoc.title = 'BootstrapForm' rdoc.options << '--line-numbers' - rdoc.rdoc_files.include('README.rdoc') + rdoc.rdoc_files.include('README.md') rdoc.rdoc_files.include('lib/**/*.rb') end - - -Bundler::GemHelper.install_tasks +require 'bundler/gem_tasks' require 'rake/testtask' Rake::TestTask.new(:test) do |t| - t.libs << 'lib' t.libs << 'test' t.pattern = 'test/**/*_test.rb' t.verbose = false end - -task :default => :test +task default: :test diff --git a/bootstrap_form.gemspec b/bootstrap_form.gemspec index 02eefe81e..7e8cc25a4 100644 --- a/bootstrap_form.gemspec +++ b/bootstrap_form.gemspec @@ -1,8 +1,7 @@ -lib = File.expand_path("../lib", __FILE__) -$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) +$LOAD_PATH.unshift File.expand_path("../lib", __FILE__) + require "bootstrap_form/version" -# Describe your gem and declare its dependencies: Gem::Specification.new do |s| s.name = "bootstrap_form" s.version = BootstrapForm::VERSION @@ -15,18 +14,11 @@ Gem::Specification.new do |s| "easy to create beautiful-looking forms using Bootstrap 4" s.license = "MIT" - s.files = `git ls-files -z`.split("\x0").reject do |f| - f.match(%r{^(test|spec|features)/}) - end - s.bindir = "exe" + s.files = `git ls-files`.split("\n") + s.platform = Gem::Platform::RUBY + s.require_paths = ["lib"] + + s.required_ruby_version = ">= 2.2.2" - s.add_development_dependency "appraisal" - s.add_development_dependency "diffy" - s.add_development_dependency "equivalent-xml" - s.add_development_dependency "mime-types", "~> 2.6.2" - s.add_development_dependency "mocha" - s.add_development_dependency "nokogiri" - s.add_development_dependency "rails", ">= 4.0" - s.add_development_dependency "sqlite3" - s.add_development_dependency "timecop", "~> 0.7.1" + s.add_dependency "rails", ">= 5.0" end diff --git a/gemfiles/4.0.gemfile b/gemfiles/4.0.gemfile deleted file mode 100644 index 976d756ea..000000000 --- a/gemfiles/4.0.gemfile +++ /dev/null @@ -1,9 +0,0 @@ -# This file was generated by Appraisal - -source "http://rubygems.org" - -gem "jquery-rails" -gem "rails", "~> 4.0.0" -gem "nokogiri", "~> 1.6.8", platforms: [:ruby_19, :ruby_20] - -gemspec path: "../" diff --git a/gemfiles/4.1.gemfile b/gemfiles/4.1.gemfile deleted file mode 100644 index 5d937d0f7..000000000 --- a/gemfiles/4.1.gemfile +++ /dev/null @@ -1,9 +0,0 @@ -# This file was generated by Appraisal - -source "http://rubygems.org" - -gem "jquery-rails" -gem "rails", "~> 4.1.0" -gem "nokogiri", "~> 1.6.8", platforms: [:ruby_19, :ruby_20] - -gemspec path: "../" diff --git a/gemfiles/4.2.gemfile b/gemfiles/4.2.gemfile deleted file mode 100644 index a5995131c..000000000 --- a/gemfiles/4.2.gemfile +++ /dev/null @@ -1,9 +0,0 @@ -# This file was generated by Appraisal - -source "http://rubygems.org" - -gem "jquery-rails" -gem "rails", "~> 4.2.0" -gem "nokogiri", "~> 1.6.8", platforms: [:ruby_19, :ruby_20] - -gemspec path: "../" diff --git a/gemfiles/5.0.gemfile b/gemfiles/5.0.gemfile deleted file mode 100644 index b57e347dd..000000000 --- a/gemfiles/5.0.gemfile +++ /dev/null @@ -1,10 +0,0 @@ -# This file was generated by Appraisal - -source "http://rubygems.org" - -gem "jquery-rails" -gem "rails", "~> 5.0.0" -gem "minitest", "< 5.10.2" -gem "danger" - -gemspec path: "../" diff --git a/gemfiles/5.1.gemfile b/gemfiles/5.1.gemfile deleted file mode 100644 index 0d55c51c1..000000000 --- a/gemfiles/5.1.gemfile +++ /dev/null @@ -1,9 +0,0 @@ -# This file was generated by Appraisal - -source "http://rubygems.org" - -gem "jquery-rails" -gem "rails", "~> 5.1.0" -gem "minitest", "< 5.10.2" - -gemspec path: "../" diff --git a/test/gemfiles/5.0.gemfile b/test/gemfiles/5.0.gemfile new file mode 100644 index 000000000..7bbf2d906 --- /dev/null +++ b/test/gemfiles/5.0.gemfile @@ -0,0 +1,16 @@ +source "http://rubygems.org" + +gemspec path: "../" + +gem "rails", "~> 5.0.0" + +group :test do + gem "diffy" + gem "equivalent-xml" + gem "mime-types", "~> 2.6.2" + gem "mocha" + gem "nokogiri" + + gem "sqlite3" + gem "timecop", "~> 0.7.1" +end diff --git a/test/gemfiles/5.1.gemfile b/test/gemfiles/5.1.gemfile new file mode 100644 index 000000000..530f2ace2 --- /dev/null +++ b/test/gemfiles/5.1.gemfile @@ -0,0 +1,16 @@ +source "http://rubygems.org" + +gemspec path: "../" + +gem "rails", "~> 5.1.0" + +group :test do + gem "diffy" + gem "equivalent-xml" + gem "mime-types", "~> 2.6.2" + gem "mocha" + gem "nokogiri" + + gem "sqlite3" + gem "timecop", "~> 0.7.1" +end diff --git a/test/gemfiles/5.2.gemfile b/test/gemfiles/5.2.gemfile new file mode 100644 index 000000000..9e581b399 --- /dev/null +++ b/test/gemfiles/5.2.gemfile @@ -0,0 +1,16 @@ +source "http://rubygems.org" + +gemspec path: "../" + +gem "rails", "~> 5.2.0" + +group :test do + gem "diffy" + gem "equivalent-xml" + gem "mime-types", "~> 2.6.2" + gem "mocha" + gem "nokogiri" + + gem "sqlite3" + gem "timecop", "~> 0.7.1" +end From 10d877a1478e4071087a24cec11a2c7a0e7772ba Mon Sep 17 00:00:00 2001 From: Oleg Date: Mon, 8 Jan 2018 14:47:57 -0800 Subject: [PATCH 002/112] fixing gemspec path --- test/gemfiles/5.0.gemfile | 2 +- test/gemfiles/5.1.gemfile | 2 +- test/gemfiles/5.2.gemfile | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/gemfiles/5.0.gemfile b/test/gemfiles/5.0.gemfile index 7bbf2d906..e47ea8bca 100644 --- a/test/gemfiles/5.0.gemfile +++ b/test/gemfiles/5.0.gemfile @@ -1,6 +1,6 @@ source "http://rubygems.org" -gemspec path: "../" +gemspec path: "../../" gem "rails", "~> 5.0.0" diff --git a/test/gemfiles/5.1.gemfile b/test/gemfiles/5.1.gemfile index 530f2ace2..39843d8e1 100644 --- a/test/gemfiles/5.1.gemfile +++ b/test/gemfiles/5.1.gemfile @@ -1,6 +1,6 @@ source "http://rubygems.org" -gemspec path: "../" +gemspec path: "../../" gem "rails", "~> 5.1.0" diff --git a/test/gemfiles/5.2.gemfile b/test/gemfiles/5.2.gemfile index 9e581b399..992d393bc 100644 --- a/test/gemfiles/5.2.gemfile +++ b/test/gemfiles/5.2.gemfile @@ -1,6 +1,6 @@ source "http://rubygems.org" -gemspec path: "../" +gemspec path: "../../" gem "rails", "~> 5.2.0" From 88545a7cff8455a01132aafdc696bd55c643bd5a Mon Sep 17 00:00:00 2001 From: Oleg Date: Mon, 8 Jan 2018 14:55:01 -0800 Subject: [PATCH 003/112] removing few unused dependencies. linking to proper rails 5.2 --- Gemfile | 3 --- test/gemfiles/5.0.gemfile | 4 +--- test/gemfiles/5.1.gemfile | 3 --- test/gemfiles/5.2.gemfile | 5 +---- 4 files changed, 2 insertions(+), 13 deletions(-) diff --git a/Gemfile b/Gemfile index ec295692f..2575a695f 100644 --- a/Gemfile +++ b/Gemfile @@ -5,10 +5,7 @@ gemspec group :test do gem "diffy" gem "equivalent-xml" - gem "mime-types", "~> 2.6.2" gem "mocha" - gem "nokogiri" - gem "sqlite3" gem "timecop", "~> 0.7.1" end diff --git a/test/gemfiles/5.0.gemfile b/test/gemfiles/5.0.gemfile index e47ea8bca..4408d2821 100644 --- a/test/gemfiles/5.0.gemfile +++ b/test/gemfiles/5.0.gemfile @@ -7,10 +7,8 @@ gem "rails", "~> 5.0.0" group :test do gem "diffy" gem "equivalent-xml" - gem "mime-types", "~> 2.6.2" gem "mocha" - gem "nokogiri" - gem "sqlite3" gem "timecop", "~> 0.7.1" end + diff --git a/test/gemfiles/5.1.gemfile b/test/gemfiles/5.1.gemfile index 39843d8e1..d8f773078 100644 --- a/test/gemfiles/5.1.gemfile +++ b/test/gemfiles/5.1.gemfile @@ -7,10 +7,7 @@ gem "rails", "~> 5.1.0" group :test do gem "diffy" gem "equivalent-xml" - gem "mime-types", "~> 2.6.2" gem "mocha" - gem "nokogiri" - gem "sqlite3" gem "timecop", "~> 0.7.1" end diff --git a/test/gemfiles/5.2.gemfile b/test/gemfiles/5.2.gemfile index 992d393bc..c9b967421 100644 --- a/test/gemfiles/5.2.gemfile +++ b/test/gemfiles/5.2.gemfile @@ -2,15 +2,12 @@ source "http://rubygems.org" gemspec path: "../../" -gem "rails", "~> 5.2.0" +gem "rails", "~> 5.2.0.beta2" group :test do gem "diffy" gem "equivalent-xml" - gem "mime-types", "~> 2.6.2" gem "mocha" - gem "nokogiri" - gem "sqlite3" gem "timecop", "~> 0.7.1" end From ddeab7ed026fd9bc4cf9b0e8775c0622ceaa0a9c Mon Sep 17 00:00:00 2001 From: Oleg Date: Mon, 8 Jan 2018 15:08:03 -0800 Subject: [PATCH 004/112] making travis run with 2.5.0 --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 1c72f00eb..ff00c9863 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,3 +8,6 @@ gemfile: - test/gemfiles/5.0.gemfile - test/gemfiles/5.1.gemfile - test/gemfiles/5.2.gemfile +before_install: + - gem update --system + - gem update bundler From c1337755a182a1859571bc88550af9266592eb8d Mon Sep 17 00:00:00 2001 From: Oleg Date: Mon, 8 Jan 2018 15:15:44 -0800 Subject: [PATCH 005/112] cleaning up test helper. removing methods from global scope --- test/test_helper.rb | 73 ++++++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 34 deletions(-) diff --git a/test/test_helper.rb b/test/test_helper.rb index e38085c2c..f24b41149 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -4,55 +4,58 @@ require 'equivalent-xml' require 'mocha/mini_test' -# Configure Rails Environment ENV["RAILS_ENV"] = "test" -require File.expand_path("../dummy/config/environment.rb", __FILE__) +require_relative "./dummy/config/environment.rb" require "rails/test_help" Rails.backtrace_cleaner.remove_silencers! -# Load support files -Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f } +class ActionView::TestCase -def setup_test_fixture - @user = User.new(email: 'steve@example.com', password: 'secret', comments: 'my comment') - @builder = BootstrapForm::FormBuilder.new(:user, @user, self, {}) - @horizontal_builder = BootstrapForm::FormBuilder.new(:user, @user, self, { layout: :horizontal, label_col: "col-sm-2", control_col: "col-sm-10" }) - I18n.backend.store_translations(:en, { - activerecord: { - attributes: { - user: { - email: "Email" - } - }, - help: { - user: { - password: "A good password should be at least six characters long" + def setup_test_fixture + @user = User.new(email: 'steve@example.com', password: 'secret', comments: 'my comment') + @builder = BootstrapForm::FormBuilder.new(:user, @user, self, {}) + @horizontal_builder = BootstrapForm::FormBuilder.new(:user, @user, self, { + layout: :horizontal, + label_col: "col-sm-2", + control_col: "col-sm-10" + }) + + I18n.backend.store_translations(:en, { + activerecord: { + attributes: { + user: { + email: "Email" + } + }, + help: { + user: { + password: "A good password should be at least six characters long" + } } } - } - }) -end + }) + end -def sort_attributes doc - doc.dup.traverse do |node| - if node.is_a?(Nokogiri::XML::Element) - attributes = node.attribute_nodes.sort_by(&:name) - attributes.each do |attribute| - node.delete(attribute.name) - node[attribute.name] = attribute.value + def sort_attributes doc + doc.dup.traverse do |node| + if node.is_a?(Nokogiri::XML::Element) + attributes = node.attribute_nodes.sort_by(&:name) + attributes.each do |attribute| + node.delete(attribute.name) + node[attribute.name] = attribute.value + end end + node end - node end -end -class ActionView::TestCase def assert_equivalent_xml(expected, actual) - expected_xml = Nokogiri::XML(expected) - actual_xml = Nokogiri::XML(actual) - ignored_attributes = %w(style data-disable-with) + expected_xml = Nokogiri::XML(expected) + actual_xml = Nokogiri::XML(actual) + ignored_attributes = %w(style data-disable-with) + equivalent = EquivalentXml.equivalent?(expected_xml, actual_xml, { ignore_attr_values: ignored_attributes }) do |a, b, result| @@ -75,6 +78,7 @@ def assert_equivalent_xml(expected, actual) end result end + assert equivalent, lambda { # using a lambda because diffing is expensive Diffy::Diff.new( @@ -83,4 +87,5 @@ def assert_equivalent_xml(expected, actual) ).to_s(:color) } end + end From e0596146b827728604028fb3c63e91a9bebe93b4 Mon Sep 17 00:00:00 2001 From: Oleg Date: Mon, 8 Jan 2018 16:28:20 -0800 Subject: [PATCH 006/112] adding rails 5.2 dummy app. let's see if travis is still happy --- Gemfile | 3 + test/dummy/.gitignore | 16 --- test/dummy/.ruby-version | 1 + test/dummy/Gemfile | 45 ------- test/dummy/Gemfile.lock | 120 ------------------ test/dummy/README.md | 7 + test/dummy/README.rdoc | 28 ---- test/dummy/Rakefile | 8 +- test/dummy/app/assets/config/manifest.js | 3 + .../app/assets/javascripts/application.js | 10 +- test/dummy/app/assets/javascripts/cable.js | 13 ++ .../javascripts/channels}/.keep | 0 .../app/assets/stylesheets/application.css | 10 +- .../app/channels/application_cable/channel.rb | 4 + .../channels/application_cable/connection.rb | 4 + .../app/controllers/application_controller.rb | 3 - test/dummy/app/jobs/application_job.rb | 2 + test/dummy/app/mailers/application_mailer.rb | 4 + test/dummy/app/models/application_record.rb | 3 + .../app/views/layouts/application.html.erb | 18 +-- test/dummy/app/views/layouts/mailer.html.erb | 13 ++ test/dummy/app/views/layouts/mailer.text.erb | 1 + test/dummy/bin/bundle | 2 +- test/dummy/bin/rails | 2 +- test/dummy/bin/setup | 36 ++++++ test/dummy/bin/update | 31 +++++ test/dummy/bin/yarn | 11 ++ test/dummy/config.ru | 3 +- test/dummy/config/application.rb | 26 ++-- test/dummy/config/boot.rb | 3 +- test/dummy/config/cable.yml | 10 ++ test/dummy/config/database.yml | 18 +-- test/dummy/config/environment.rb | 4 +- test/dummy/config/environments/development.rb | 39 +++++- test/dummy/config/environments/production.rb | 80 ------------ test/dummy/config/environments/test.rb | 33 ++--- .../application_controller_renderer.rb | 8 ++ test/dummy/config/initializers/assets.rb | 14 ++ .../config/initializers/cookies_serializer.rb | 5 + .../config/initializers/generic_migration.rb | 6 - test/dummy/config/initializers/mime_types.rb | 1 - .../dummy/config/initializers/secret_token.rb | 12 -- .../config/initializers/session_store.rb | 3 - .../config/initializers/wrap_parameters.rb | 4 +- test/dummy/config/locales/en.yml | 10 ++ test/dummy/config/puma.rb | 56 ++++++++ test/dummy/config/spring.rb | 6 + test/dummy/config/storage.yml | 35 +++++ .../db/migrate/20130703191909_create_users.rb | 13 -- .../20130703191937_create_addresses.rb | 13 -- .../20130912171202_add_preferences_to_user.rb | 5 - .../20140327190145_add_terms_to_user.rb | 5 - .../20140922133133_add_type_to_users.rb | 5 - test/dummy/db/schema.rb | 50 +++----- test/dummy/db/seeds.rb | 7 - test/dummy/package.json | 5 + test/dummy/public/404.html | 39 +++--- test/dummy/public/422.html | 39 +++--- test/dummy/public/500.html | 37 ++++-- .../apple-touch-icon-precomposed.png} | 0 .../.keep => public/apple-touch-icon.png} | 0 test/dummy/public/robots.txt | 5 - .../dummy/{test/controllers => storage}/.keep | 0 test/dummy/test/fixtures/.keep | 0 test/dummy/test/fixtures/addresses.yml | 15 --- test/dummy/test/fixtures/users.yml | 15 --- test/dummy/test/helpers/.keep | 0 test/dummy/test/integration/.keep | 0 test/dummy/test/mailers/.keep | 0 test/dummy/test/models/.keep | 0 test/dummy/test/models/address_test.rb | 7 - test/dummy/test/models/user_test.rb | 7 - test/dummy/test/test_helper.rb | 15 --- test/dummy/vendor/assets/javascripts/.keep | 0 test/dummy/vendor/assets/stylesheets/.keep | 0 75 files changed, 475 insertions(+), 581 deletions(-) delete mode 100644 test/dummy/.gitignore create mode 100644 test/dummy/.ruby-version delete mode 100644 test/dummy/Gemfile delete mode 100644 test/dummy/Gemfile.lock create mode 100644 test/dummy/README.md delete mode 100644 test/dummy/README.rdoc create mode 100644 test/dummy/app/assets/config/manifest.js create mode 100644 test/dummy/app/assets/javascripts/cable.js rename test/dummy/app/{mailers => assets/javascripts/channels}/.keep (100%) create mode 100644 test/dummy/app/channels/application_cable/channel.rb create mode 100644 test/dummy/app/channels/application_cable/connection.rb create mode 100644 test/dummy/app/jobs/application_job.rb create mode 100644 test/dummy/app/mailers/application_mailer.rb create mode 100644 test/dummy/app/models/application_record.rb create mode 100644 test/dummy/app/views/layouts/mailer.html.erb create mode 100644 test/dummy/app/views/layouts/mailer.text.erb create mode 100755 test/dummy/bin/setup create mode 100755 test/dummy/bin/update create mode 100755 test/dummy/bin/yarn create mode 100644 test/dummy/config/cable.yml delete mode 100644 test/dummy/config/environments/production.rb create mode 100644 test/dummy/config/initializers/application_controller_renderer.rb create mode 100644 test/dummy/config/initializers/assets.rb create mode 100644 test/dummy/config/initializers/cookies_serializer.rb delete mode 100644 test/dummy/config/initializers/generic_migration.rb delete mode 100644 test/dummy/config/initializers/secret_token.rb delete mode 100644 test/dummy/config/initializers/session_store.rb create mode 100644 test/dummy/config/puma.rb create mode 100644 test/dummy/config/spring.rb create mode 100644 test/dummy/config/storage.yml delete mode 100644 test/dummy/db/migrate/20130703191909_create_users.rb delete mode 100644 test/dummy/db/migrate/20130703191937_create_addresses.rb delete mode 100644 test/dummy/db/migrate/20130912171202_add_preferences_to_user.rb delete mode 100644 test/dummy/db/migrate/20140327190145_add_terms_to_user.rb delete mode 100644 test/dummy/db/migrate/20140922133133_add_type_to_users.rb delete mode 100644 test/dummy/db/seeds.rb create mode 100644 test/dummy/package.json rename test/dummy/{app/models/.keep => public/apple-touch-icon-precomposed.png} (100%) rename test/dummy/{lib/tasks/.keep => public/apple-touch-icon.png} (100%) delete mode 100644 test/dummy/public/robots.txt rename test/dummy/{test/controllers => storage}/.keep (100%) delete mode 100644 test/dummy/test/fixtures/.keep delete mode 100644 test/dummy/test/fixtures/addresses.yml delete mode 100644 test/dummy/test/fixtures/users.yml delete mode 100644 test/dummy/test/helpers/.keep delete mode 100644 test/dummy/test/integration/.keep delete mode 100644 test/dummy/test/mailers/.keep delete mode 100644 test/dummy/test/models/.keep delete mode 100644 test/dummy/test/models/address_test.rb delete mode 100644 test/dummy/test/models/user_test.rb delete mode 100644 test/dummy/test/test_helper.rb delete mode 100644 test/dummy/vendor/assets/javascripts/.keep delete mode 100644 test/dummy/vendor/assets/stylesheets/.keep diff --git a/Gemfile b/Gemfile index 2575a695f..1bf379333 100644 --- a/Gemfile +++ b/Gemfile @@ -2,6 +2,9 @@ source "http://rubygems.org" gemspec +# Uncomment and change rails version for testing purposes +# gem "rails", "~> 5.2.0.beta2" + group :test do gem "diffy" gem "equivalent-xml" diff --git a/test/dummy/.gitignore b/test/dummy/.gitignore deleted file mode 100644 index 25a742dff..000000000 --- a/test/dummy/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -# See http://help.github.com/ignore-files/ for more about ignoring files. -# -# If you find yourself ignoring temporary files generated by your text editor -# or operating system, you probably want to add a global ignore instead: -# git config --global core.excludesfile '~/.gitignore_global' - -# Ignore bundler config. -/.bundle - -# Ignore the default SQLite database. -/db/*.sqlite3 -/db/*.sqlite3-journal - -# Ignore all logfiles and tempfiles. -/log/*.log -/tmp diff --git a/test/dummy/.ruby-version b/test/dummy/.ruby-version new file mode 100644 index 000000000..58073ef8d --- /dev/null +++ b/test/dummy/.ruby-version @@ -0,0 +1 @@ +2.4.1 \ No newline at end of file diff --git a/test/dummy/Gemfile b/test/dummy/Gemfile deleted file mode 100644 index 30d54d47a..000000000 --- a/test/dummy/Gemfile +++ /dev/null @@ -1,45 +0,0 @@ -source 'https://rubygems.org' - -# Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '4.0.0' - -# Use sqlite3 as the database for Active Record -gem 'sqlite3' - -# Use SCSS for stylesheets -gem 'sass-rails', '~> 4.0.0' - -# Use Uglifier as compressor for JavaScript assets -gem 'uglifier', '>= 1.3.0' - -# Use CoffeeScript for .js.coffee assets and views -gem 'coffee-rails', '~> 4.0.0' - -# See https://github.com/sstephenson/execjs#readme for more supported runtimes -# gem 'therubyracer', platforms: :ruby - -# Use jquery as the JavaScript library -gem 'jquery-rails' - -# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks -gem 'turbolinks' - -# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder -gem 'jbuilder', '~> 1.2' - -group :doc do - # bundle exec rake doc:rails generates the API under doc/api. - gem 'sdoc', require: false -end - -# Use ActiveModel has_secure_password -# gem 'bcrypt-ruby', '~> 3.0.0' - -# Use unicorn as the app server -# gem 'unicorn' - -# Use Capistrano for deployment -# gem 'capistrano', group: :development - -# Use debugger -# gem 'debugger', group: [:development, :test] diff --git a/test/dummy/Gemfile.lock b/test/dummy/Gemfile.lock deleted file mode 100644 index c362f1900..000000000 --- a/test/dummy/Gemfile.lock +++ /dev/null @@ -1,120 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - actionmailer (4.0.0) - actionpack (= 4.0.0) - mail (~> 2.5.3) - actionpack (4.0.0) - activesupport (= 4.0.0) - builder (~> 3.1.0) - erubis (~> 2.7.0) - rack (~> 1.5.2) - rack-test (~> 0.6.2) - activemodel (4.0.0) - activesupport (= 4.0.0) - builder (~> 3.1.0) - activerecord (4.0.0) - activemodel (= 4.0.0) - activerecord-deprecated_finders (~> 1.0.2) - activesupport (= 4.0.0) - arel (~> 4.0.0) - activerecord-deprecated_finders (1.0.3) - activesupport (4.0.0) - i18n (~> 0.6, >= 0.6.4) - minitest (~> 4.2) - multi_json (~> 1.3) - thread_safe (~> 0.1) - tzinfo (~> 0.3.37) - arel (4.0.0) - atomic (1.1.10) - builder (3.1.4) - coffee-rails (4.0.0) - coffee-script (>= 2.2.0) - railties (>= 4.0.0.beta, < 5.0) - coffee-script (2.2.0) - coffee-script-source - execjs - coffee-script-source (1.6.2) - erubis (2.7.0) - execjs (1.4.0) - multi_json (~> 1.0) - hike (1.2.3) - i18n (0.6.4) - jbuilder (1.4.2) - activesupport (>= 3.0.0) - multi_json (>= 1.2.0) - jquery-rails (3.0.1) - railties (>= 3.0, < 5.0) - thor (>= 0.14, < 2.0) - json (1.8.0) - mail (2.5.4) - mime-types (~> 1.16) - treetop (~> 1.4.8) - mime-types (1.23) - minitest (4.7.5) - multi_json (1.7.7) - polyglot (0.3.3) - rack (1.5.2) - rack-test (0.6.2) - rack (>= 1.0) - rails (4.0.0) - actionmailer (= 4.0.0) - actionpack (= 4.0.0) - activerecord (= 4.0.0) - activesupport (= 4.0.0) - bundler (>= 1.3.0, < 2.0) - railties (= 4.0.0) - sprockets-rails (~> 2.0.0) - railties (4.0.0) - actionpack (= 4.0.0) - activesupport (= 4.0.0) - rake (>= 0.8.7) - thor (>= 0.18.1, < 2.0) - rake (10.1.0) - rdoc (3.12.2) - json (~> 1.4) - sass (3.2.9) - sass-rails (4.0.0) - railties (>= 4.0.0.beta, < 5.0) - sass (>= 3.1.10) - sprockets-rails (~> 2.0.0) - sdoc (0.3.20) - json (>= 1.1.3) - rdoc (~> 3.10) - sprockets (2.10.0) - hike (~> 1.2) - multi_json (~> 1.0) - rack (~> 1.0) - tilt (~> 1.1, != 1.3.0) - sprockets-rails (2.0.0) - actionpack (>= 3.0) - activesupport (>= 3.0) - sprockets (~> 2.8) - sqlite3 (1.3.7) - thor (0.18.1) - thread_safe (0.1.0) - atomic - tilt (1.4.1) - treetop (1.4.14) - polyglot - polyglot (>= 0.3.1) - turbolinks (1.2.0) - coffee-rails - tzinfo (0.3.37) - uglifier (2.1.1) - execjs (>= 0.3.0) - multi_json (~> 1.0, >= 1.0.2) - -PLATFORMS - ruby - -DEPENDENCIES - coffee-rails (~> 4.0.0) - jbuilder (~> 1.2) - jquery-rails - rails (= 4.0.0) - sass-rails (~> 4.0.0) - sdoc - sqlite3 - turbolinks - uglifier (>= 1.3.0) diff --git a/test/dummy/README.md b/test/dummy/README.md new file mode 100644 index 000000000..7e010757f --- /dev/null +++ b/test/dummy/README.md @@ -0,0 +1,7 @@ +# TEST DUMMY APP (Rails 5.2) + +Following files were added or changed: + +- db/schema.rb +- config/application.rb +- config/routes.rb diff --git a/test/dummy/README.rdoc b/test/dummy/README.rdoc deleted file mode 100644 index dd4e97e22..000000000 --- a/test/dummy/README.rdoc +++ /dev/null @@ -1,28 +0,0 @@ -== README - -This README would normally document whatever steps are necessary to get the -application up and running. - -Things you may want to cover: - -* Ruby version - -* System dependencies - -* Configuration - -* Database creation - -* Database initialization - -* How to run the test suite - -* Services (job queues, cache servers, search engines, etc.) - -* Deployment instructions - -* ... - - -Please feel free to use a different markup language if you do not plan to run -rake doc:app. diff --git a/test/dummy/Rakefile b/test/dummy/Rakefile index 03926c32f..e85f91391 100644 --- a/test/dummy/Rakefile +++ b/test/dummy/Rakefile @@ -1,10 +1,6 @@ # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. -require File.expand_path('../config/application', __FILE__) +require_relative 'config/application' -Dummy::Application.load_tasks - -if Rake::Task.task_defined?(:'db:check_protected_environments') - Rake::Task[:'db:check_protected_environments'].clear -end +Rails.application.load_tasks diff --git a/test/dummy/app/assets/config/manifest.js b/test/dummy/app/assets/config/manifest.js new file mode 100644 index 000000000..b16e53d6d --- /dev/null +++ b/test/dummy/app/assets/config/manifest.js @@ -0,0 +1,3 @@ +//= link_tree ../images +//= link_directory ../javascripts .js +//= link_directory ../stylesheets .css diff --git a/test/dummy/app/assets/javascripts/application.js b/test/dummy/app/assets/javascripts/application.js index d6925fa43..e914de739 100644 --- a/test/dummy/app/assets/javascripts/application.js +++ b/test/dummy/app/assets/javascripts/application.js @@ -2,15 +2,13 @@ // listed below. // // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, -// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. +// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path. // // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the -// compiled file. +// compiled file. JavaScript code in this file should be added after the last require_* statement. // -// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details // about supported directives. // -//= require jquery -//= require jquery_ujs -//= require turbolinks +//= require activestorage //= require_tree . diff --git a/test/dummy/app/assets/javascripts/cable.js b/test/dummy/app/assets/javascripts/cable.js new file mode 100644 index 000000000..739aa5f02 --- /dev/null +++ b/test/dummy/app/assets/javascripts/cable.js @@ -0,0 +1,13 @@ +// Action Cable provides the framework to deal with WebSockets in Rails. +// You can generate new channels where WebSocket features live using the `rails generate channel` command. +// +//= require action_cable +//= require_self +//= require_tree ./channels + +(function() { + this.App || (this.App = {}); + + App.cable = ActionCable.createConsumer(); + +}).call(this); diff --git a/test/dummy/app/mailers/.keep b/test/dummy/app/assets/javascripts/channels/.keep similarity index 100% rename from test/dummy/app/mailers/.keep rename to test/dummy/app/assets/javascripts/channels/.keep diff --git a/test/dummy/app/assets/stylesheets/application.css b/test/dummy/app/assets/stylesheets/application.css index 3192ec897..0ebd7fe82 100644 --- a/test/dummy/app/assets/stylesheets/application.css +++ b/test/dummy/app/assets/stylesheets/application.css @@ -3,11 +3,13 @@ * listed below. * * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, - * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path. + * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path. * - * You're free to add application-wide styles to this file and they'll appear at the top of the - * compiled file, but it's generally better to create a new file per style scope. + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS + * files in this directory. Styles in this file should be added after the last require_* statement. + * It is generally better to create a new file per style scope. * - *= require_self *= require_tree . + *= require_self */ diff --git a/test/dummy/app/channels/application_cable/channel.rb b/test/dummy/app/channels/application_cable/channel.rb new file mode 100644 index 000000000..d67269728 --- /dev/null +++ b/test/dummy/app/channels/application_cable/channel.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Channel < ActionCable::Channel::Base + end +end diff --git a/test/dummy/app/channels/application_cable/connection.rb b/test/dummy/app/channels/application_cable/connection.rb new file mode 100644 index 000000000..0ff5442f4 --- /dev/null +++ b/test/dummy/app/channels/application_cable/connection.rb @@ -0,0 +1,4 @@ +module ApplicationCable + class Connection < ActionCable::Connection::Base + end +end diff --git a/test/dummy/app/controllers/application_controller.rb b/test/dummy/app/controllers/application_controller.rb index d83690e1b..09705d12a 100644 --- a/test/dummy/app/controllers/application_controller.rb +++ b/test/dummy/app/controllers/application_controller.rb @@ -1,5 +1,2 @@ class ApplicationController < ActionController::Base - # Prevent CSRF attacks by raising an exception. - # For APIs, you may want to use :null_session instead. - protect_from_forgery with: :exception end diff --git a/test/dummy/app/jobs/application_job.rb b/test/dummy/app/jobs/application_job.rb new file mode 100644 index 000000000..a009ace51 --- /dev/null +++ b/test/dummy/app/jobs/application_job.rb @@ -0,0 +1,2 @@ +class ApplicationJob < ActiveJob::Base +end diff --git a/test/dummy/app/mailers/application_mailer.rb b/test/dummy/app/mailers/application_mailer.rb new file mode 100644 index 000000000..286b2239d --- /dev/null +++ b/test/dummy/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: 'from@example.com' + layout 'mailer' +end diff --git a/test/dummy/app/models/application_record.rb b/test/dummy/app/models/application_record.rb new file mode 100644 index 000000000..10a4cba84 --- /dev/null +++ b/test/dummy/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + self.abstract_class = true +end diff --git a/test/dummy/app/views/layouts/application.html.erb b/test/dummy/app/views/layouts/application.html.erb index 670d1875b..a6eb0174b 100644 --- a/test/dummy/app/views/layouts/application.html.erb +++ b/test/dummy/app/views/layouts/application.html.erb @@ -1,14 +1,14 @@ - - Dummy - <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %> - <%= javascript_include_tag "application", "data-turbolinks-track" => true %> - <%= csrf_meta_tags %> - - + + Dummy + <%= csrf_meta_tags %> -<%= yield %> + <%= stylesheet_link_tag 'application', media: 'all' %> + <%= javascript_include_tag 'application' %> + - + + <%= yield %> + diff --git a/test/dummy/app/views/layouts/mailer.html.erb b/test/dummy/app/views/layouts/mailer.html.erb new file mode 100644 index 000000000..cbd34d2e9 --- /dev/null +++ b/test/dummy/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ + + + + + + + + + <%= yield %> + + diff --git a/test/dummy/app/views/layouts/mailer.text.erb b/test/dummy/app/views/layouts/mailer.text.erb new file mode 100644 index 000000000..37f0bddbd --- /dev/null +++ b/test/dummy/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/test/dummy/bin/bundle b/test/dummy/bin/bundle index 66e9889e8..f19acf5b5 100755 --- a/test/dummy/bin/bundle +++ b/test/dummy/bin/bundle @@ -1,3 +1,3 @@ #!/usr/bin/env ruby -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) load Gem.bin_path('bundler', 'bundle') diff --git a/test/dummy/bin/rails b/test/dummy/bin/rails index 728cd85aa..073966023 100755 --- a/test/dummy/bin/rails +++ b/test/dummy/bin/rails @@ -1,4 +1,4 @@ #!/usr/bin/env ruby -APP_PATH = File.expand_path('../../config/application', __FILE__) +APP_PATH = File.expand_path('../config/application', __dir__) require_relative '../config/boot' require 'rails/commands' diff --git a/test/dummy/bin/setup b/test/dummy/bin/setup new file mode 100755 index 000000000..94fd4d797 --- /dev/null +++ b/test/dummy/bin/setup @@ -0,0 +1,36 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + # puts "\n== Copying sample files ==" + # unless File.exist?('config/database.yml') + # cp 'config/database.yml.sample', 'config/database.yml' + # end + + puts "\n== Preparing database ==" + system! 'bin/rails db:setup' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/test/dummy/bin/update b/test/dummy/bin/update new file mode 100755 index 000000000..58bfaed51 --- /dev/null +++ b/test/dummy/bin/update @@ -0,0 +1,31 @@ +#!/usr/bin/env ruby +require 'fileutils' +include FileUtils + +# path to your application root. +APP_ROOT = File.expand_path('..', __dir__) + +def system!(*args) + system(*args) || abort("\n== Command #{args} failed ==") +end + +chdir APP_ROOT do + # This script is a way to update your development environment automatically. + # Add necessary update steps to this file. + + puts '== Installing dependencies ==' + system! 'gem install bundler --conservative' + system('bundle check') || system!('bundle install') + + # Install JavaScript dependencies if using Yarn + # system('bin/yarn') + + puts "\n== Updating database ==" + system! 'bin/rails db:migrate' + + puts "\n== Removing old logs and tempfiles ==" + system! 'bin/rails log:clear tmp:clear' + + puts "\n== Restarting application server ==" + system! 'bin/rails restart' +end diff --git a/test/dummy/bin/yarn b/test/dummy/bin/yarn new file mode 100755 index 000000000..ec3db7b27 --- /dev/null +++ b/test/dummy/bin/yarn @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +APP_ROOT = File.expand_path('..', __dir__) +Dir.chdir(APP_ROOT) do + begin + exec "yarnpkg #{ARGV.join(' ')}" + rescue Errno::ENOENT + $stderr.puts "Yarn executable was not detected in the system." + $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" + exit 1 + end +end diff --git a/test/dummy/config.ru b/test/dummy/config.ru index 5bc2a619e..f7ba0b527 100644 --- a/test/dummy/config.ru +++ b/test/dummy/config.ru @@ -1,4 +1,5 @@ # This file is used by Rack-based servers to start the application. -require ::File.expand_path('../config/environment', __FILE__) +require_relative 'config/environment' + run Rails.application diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb index 4cd6683f8..6fbb9acbb 100644 --- a/test/dummy/config/application.rb +++ b/test/dummy/config/application.rb @@ -1,23 +1,25 @@ -require File.expand_path('../boot', __FILE__) +require_relative 'boot' require 'rails/all' -# Require the gems listed in Gemfile, including any gems -# you've limited to :test, :development, or :production. -Bundler.require(:default, Rails.env) +Bundler.require(*Rails.groups) +require "bootstrap_form" module Dummy class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + + if config.respond_to?(:load_defaults) + config.load_defaults [Rails::VERSION::MAJOR, Rails::VERSION::MINOR].join(".") + end + + if config.respond_to?(:secret_key_base) + config.secret_key_base = "ignore" + end + # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. - - # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. - # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. - # config.time_zone = 'Central Time (US & Canada)' - - # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. - # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] - # config.i18n.default_locale = :de end end + diff --git a/test/dummy/config/boot.rb b/test/dummy/config/boot.rb index 5e5f0c1fa..c9aef85d4 100644 --- a/test/dummy/config/boot.rb +++ b/test/dummy/config/boot.rb @@ -1,4 +1,5 @@ # Set up gems listed in the Gemfile. -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__) require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) +$LOAD_PATH.unshift File.expand_path('../../../lib', __dir__) diff --git a/test/dummy/config/cable.yml b/test/dummy/config/cable.yml new file mode 100644 index 000000000..1cd0f8363 --- /dev/null +++ b/test/dummy/config/cable.yml @@ -0,0 +1,10 @@ +development: + adapter: async + +test: + adapter: async + +production: + adapter: redis + url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> + channel_prefix: dummy_production diff --git a/test/dummy/config/database.yml b/test/dummy/config/database.yml index 51a4dd459..0d02f2498 100644 --- a/test/dummy/config/database.yml +++ b/test/dummy/config/database.yml @@ -3,23 +3,23 @@ # # Ensure the SQLite 3 gem is defined in your Gemfile # gem 'sqlite3' -development: +# +default: &default adapter: sqlite3 - database: db/development.sqlite3 - pool: 5 + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> timeout: 5000 +development: + <<: *default + database: db/development.sqlite3 + # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: - adapter: sqlite3 + <<: *default database: db/test.sqlite3 - pool: 5 - timeout: 5000 production: - adapter: sqlite3 + <<: *default database: db/production.sqlite3 - pool: 5 - timeout: 5000 diff --git a/test/dummy/config/environment.rb b/test/dummy/config/environment.rb index 10e0cadcf..426333bb4 100644 --- a/test/dummy/config/environment.rb +++ b/test/dummy/config/environment.rb @@ -1,5 +1,5 @@ # Load the Rails application. -require File.expand_path('../application', __FILE__) +require_relative 'application' # Initialize the Rails application. -Dummy::Application.initialize! +Rails.application.initialize! diff --git a/test/dummy/config/environments/development.rb b/test/dummy/config/environments/development.rb index 9d26e1250..7b8374da8 100644 --- a/test/dummy/config/environments/development.rb +++ b/test/dummy/config/environments/development.rb @@ -1,4 +1,4 @@ -Dummy::Application.configure do +Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded on @@ -9,21 +9,50 @@ # Do not eager load code on boot. config.eager_load = false - # Show full error reports and disable caching. - config.consider_all_requests_local = true - config.action_controller.perform_caching = false + # Show full error reports. + config.consider_all_requests_local = true + + # Enable/disable caching. By default caching is disabled. + # Run rails dev:cache to toggle caching. + if Rails.root.join('tmp/caching-dev.txt').exist? + config.action_controller.perform_caching = true + + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{2.days.to_i}" + } + else + config.action_controller.perform_caching = false + + config.cache_store = :null_store + end + + # Store uploaded files on the local file system (see config/storage.yml for options) + config.active_storage.service = :local # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false + config.action_mailer.perform_caching = false + # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log - # Raise an error on page load if there are pending migrations + # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. config.assets.debug = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true + + # Use an evented file watcher to asynchronously detect changes in source code, + # routes, locales, etc. This feature depends on the listen gem. + # config.file_watcher = ActiveSupport::EventedFileUpdateChecker end diff --git a/test/dummy/config/environments/production.rb b/test/dummy/config/environments/production.rb deleted file mode 100644 index b690b1cf6..000000000 --- a/test/dummy/config/environments/production.rb +++ /dev/null @@ -1,80 +0,0 @@ -Dummy::Application.configure do - # Settings specified here will take precedence over those in config/application.rb. - - # Code is not reloaded between requests. - config.cache_classes = true - - # Eager load code on boot. This eager loads most of Rails and - # your application in memory, allowing both thread web servers - # and those relying on copy on write to perform better. - # Rake tasks automatically ignore this option for performance. - config.eager_load = true - - # Full error reports are disabled and caching is turned on. - config.consider_all_requests_local = false - config.action_controller.perform_caching = true - - # Enable Rack::Cache to put a simple HTTP cache in front of your application - # Add `rack-cache` to your Gemfile before enabling this. - # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. - # config.action_dispatch.rack_cache = true - - # Disable Rails's static asset server (Apache or nginx will already do this). - config.serve_static_assets = false - - # Compress JavaScripts and CSS. - config.assets.js_compressor = :uglifier - # config.assets.css_compressor = :sass - - # Do not fallback to assets pipeline if a precompiled asset is missed. - config.assets.compile = false - - # Generate digests for assets URLs. - config.assets.digest = true - - # Version of your assets, change this if you want to expire all your assets. - config.assets.version = '1.0' - - # Specifies the header that your server uses for sending files. - # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache - # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx - - # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. - # config.force_ssl = true - - # Set to :debug to see everything in the log. - config.log_level = :info - - # Prepend all log lines with the following tags. - # config.log_tags = [ :subdomain, :uuid ] - - # Use a different logger for distributed setups. - # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) - - # Use a different cache store in production. - # config.cache_store = :mem_cache_store - - # Enable serving of images, stylesheets, and JavaScripts from an asset server. - # config.action_controller.asset_host = "http://assets.example.com" - - # Precompile additional assets. - # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. - # config.assets.precompile += %w( search.js ) - - # Ignore bad email addresses and do not raise email delivery errors. - # Set this to true and configure the email server for immediate delivery to raise delivery errors. - # config.action_mailer.raise_delivery_errors = false - - # Enable locale fallbacks for I18n (makes lookups for any locale fall back to - # the I18n.default_locale when a translation can not be found). - config.i18n.fallbacks = true - - # Send deprecation notices to registered listeners. - config.active_support.deprecation = :notify - - # Disable automatic flushing of the log to improve performance. - # config.autoflush_log = false - - # Use default logging formatter so that PID and timestamp are not suppressed. - config.log_formatter = ::Logger::Formatter.new -end diff --git a/test/dummy/config/environments/test.rb b/test/dummy/config/environments/test.rb index aeb6b5550..288b92fbf 100644 --- a/test/dummy/config/environments/test.rb +++ b/test/dummy/config/environments/test.rb @@ -1,4 +1,4 @@ -Dummy::Application.configure do +Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # The test environment is used exclusively to run your application's @@ -12,23 +12,11 @@ # preloads Rails for running tests, you may have to set it to true. config.eager_load = false - version = Rails.version.to_f - - # Configure static asset server for tests with Cache-Control for performance. - if version < 4.2 - config.serve_static_assets = true - elsif version < 5 - config.serve_static_files = true - end - - if version < 5 - config.static_cache_control = "public, max-age=3600" - else - config.public_file_server.enabled = true - config.public_file_server.headers = { - "Cache-Control" => "public, max-age=3600" - } - end + # Configure public file server for tests with Cache-Control for performance. + config.public_file_server.enabled = true + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{1.hour.to_i}" + } # Show full error reports and disable caching. config.consider_all_requests_local = true @@ -40,6 +28,11 @@ # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false + # Store uploaded files on the local file system in a temporary directory + # config.active_storage.service = :test + + config.action_mailer.perform_caching = false + # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. @@ -48,6 +41,6 @@ # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr - # In Rails 5, the default value of this option will change from `:sorted` to `:random`. - config.active_support.test_order = :sorted + # Raises error for missing translations + # config.action_view.raise_on_missing_translations = true end diff --git a/test/dummy/config/initializers/application_controller_renderer.rb b/test/dummy/config/initializers/application_controller_renderer.rb new file mode 100644 index 000000000..89d2efab2 --- /dev/null +++ b/test/dummy/config/initializers/application_controller_renderer.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# ActiveSupport::Reloader.to_prepare do +# ApplicationController.renderer.defaults.merge!( +# http_host: 'example.org', +# https: false +# ) +# end diff --git a/test/dummy/config/initializers/assets.rb b/test/dummy/config/initializers/assets.rb new file mode 100644 index 000000000..4b828e80c --- /dev/null +++ b/test/dummy/config/initializers/assets.rb @@ -0,0 +1,14 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path. +# Rails.application.config.assets.paths << Emoji.images_path +# Add Yarn node_modules folder to the asset load path. +Rails.application.config.assets.paths << Rails.root.join('node_modules') + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in the app/assets +# folder are already added. +# Rails.application.config.assets.precompile += %w( admin.js admin.css ) diff --git a/test/dummy/config/initializers/cookies_serializer.rb b/test/dummy/config/initializers/cookies_serializer.rb new file mode 100644 index 000000000..5a6a32d37 --- /dev/null +++ b/test/dummy/config/initializers/cookies_serializer.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Specify a serializer for the signed and encrypted cookie jars. +# Valid options are :json, :marshal, and :hybrid. +Rails.application.config.action_dispatch.cookies_serializer = :json diff --git a/test/dummy/config/initializers/generic_migration.rb b/test/dummy/config/initializers/generic_migration.rb deleted file mode 100644 index 6634663f7..000000000 --- a/test/dummy/config/initializers/generic_migration.rb +++ /dev/null @@ -1,6 +0,0 @@ -version = Rails.version.to_f -if version < 5.0 - class GenericMigration < ActiveRecord::Migration; end -else - class GenericMigration < ActiveRecord::Migration[5.0]; end -end diff --git a/test/dummy/config/initializers/mime_types.rb b/test/dummy/config/initializers/mime_types.rb index 72aca7e44..dc1899682 100644 --- a/test/dummy/config/initializers/mime_types.rb +++ b/test/dummy/config/initializers/mime_types.rb @@ -2,4 +2,3 @@ # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf -# Mime::Type.register_alias "text/html", :iphone diff --git a/test/dummy/config/initializers/secret_token.rb b/test/dummy/config/initializers/secret_token.rb deleted file mode 100644 index 6681ab352..000000000 --- a/test/dummy/config/initializers/secret_token.rb +++ /dev/null @@ -1,12 +0,0 @@ -# Be sure to restart your server when you modify this file. - -# Your secret key is used for verifying the integrity of signed cookies. -# If you change this key, all old signed cookies will become invalid! - -# Make sure the secret is at least 30 characters and all random, -# no regular words or you'll be exposed to dictionary attacks. -# You can use `rake secret` to generate a secure secret key. - -# Make sure your secret_key_base is kept private -# if you're sharing your code publicly. -Dummy::Application.config.secret_key_base = 'bec72f1ad1c7af22ffaa254b55db3012b074c780aebcb898a763397a82e1ab4514361d1bccd30addb962d142c20e37d0502a9bd0526a76e36135dfd957b50f7d' diff --git a/test/dummy/config/initializers/session_store.rb b/test/dummy/config/initializers/session_store.rb deleted file mode 100644 index 155f7b028..000000000 --- a/test/dummy/config/initializers/session_store.rb +++ /dev/null @@ -1,3 +0,0 @@ -# Be sure to restart your server when you modify this file. - -Dummy::Application.config.session_store :cookie_store, key: '_dummy_session' diff --git a/test/dummy/config/initializers/wrap_parameters.rb b/test/dummy/config/initializers/wrap_parameters.rb index 33725e95f..bbfc3961b 100644 --- a/test/dummy/config/initializers/wrap_parameters.rb +++ b/test/dummy/config/initializers/wrap_parameters.rb @@ -5,10 +5,10 @@ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. ActiveSupport.on_load(:action_controller) do - wrap_parameters format: [:json] if respond_to?(:wrap_parameters) + wrap_parameters format: [:json] end # To enable root element in JSON for ActiveRecord objects. # ActiveSupport.on_load(:active_record) do -# self.include_root_in_json = true +# self.include_root_in_json = true # end diff --git a/test/dummy/config/locales/en.yml b/test/dummy/config/locales/en.yml index 065395716..decc5a857 100644 --- a/test/dummy/config/locales/en.yml +++ b/test/dummy/config/locales/en.yml @@ -16,6 +16,16 @@ # # This would use the information in config/locales/es.yml. # +# The following keys must be escaped otherwise they will not be retrieved by +# the default I18n backend: +# +# true, false, on, off, yes, no +# +# Instead, surround them with single quotes. +# +# en: +# 'true': 'foo' +# # To learn more, please read the Rails Internationalization guide # available at http://guides.rubyonrails.org/i18n.html. diff --git a/test/dummy/config/puma.rb b/test/dummy/config/puma.rb new file mode 100644 index 000000000..1e19380dc --- /dev/null +++ b/test/dummy/config/puma.rb @@ -0,0 +1,56 @@ +# Puma can serve each request in a thread from an internal thread pool. +# The `threads` method setting takes two numbers: a minimum and maximum. +# Any libraries that use thread pools should be configured to match +# the maximum value specified for Puma. Default is set to 5 threads for minimum +# and maximum; this matches the default thread size of Active Record. +# +threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +# +port ENV.fetch("PORT") { 3000 } + +# Specifies the `environment` that Puma will run in. +# +environment ENV.fetch("RAILS_ENV") { "development" } + +# Specifies the number of `workers` to boot in clustered mode. +# Workers are forked webserver processes. If using threads and workers together +# the concurrency of the application would be max `threads` * `workers`. +# Workers do not work on JRuby or Windows (both of which do not support +# processes). +# +# workers ENV.fetch("WEB_CONCURRENCY") { 2 } + +# Use the `preload_app!` method when specifying a `workers` number. +# This directive tells Puma to first boot the application and load code +# before forking the application. This takes advantage of Copy On Write +# process behavior so workers use less memory. If you use this option +# you need to make sure to reconnect any threads in the `on_worker_boot` +# block. +# +# preload_app! + +# If you are preloading your application and using Active Record, it's +# recommended that you close any connections to the database before workers +# are forked to prevent connection leakage. +# +# before_fork do +# ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord) +# end + +# The code in the `on_worker_boot` will be called if you are using +# clustered mode by specifying a number of `workers`. After each worker +# process is booted, this block will be run. If you are using the `preload_app!` +# option, you will want to use this block to reconnect to any threads +# or connections that may have been created at application boot, as Ruby +# cannot share connections between processes. +# +# on_worker_boot do +# ActiveRecord::Base.establish_connection if defined?(ActiveRecord) +# end +# + +# Allow puma to be restarted by `rails restart` command. +plugin :tmp_restart diff --git a/test/dummy/config/spring.rb b/test/dummy/config/spring.rb new file mode 100644 index 000000000..9fa7863f9 --- /dev/null +++ b/test/dummy/config/spring.rb @@ -0,0 +1,6 @@ +%w[ + .ruby-version + .rbenv-vars + tmp/restart.txt + tmp/caching-dev.txt +].each { |path| Spring.watch(path) } diff --git a/test/dummy/config/storage.yml b/test/dummy/config/storage.yml new file mode 100644 index 000000000..388b6e475 --- /dev/null +++ b/test/dummy/config/storage.yml @@ -0,0 +1,35 @@ +test: + service: Disk + root: <%= Rails.root.join("tmp/storage") %> + +local: + service: Disk + root: <%= Rails.root.join("storage") %> + +# Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) +# amazon: +# service: S3 +# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> +# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> +# region: us-east-1 +# bucket: your_own_bucket + +# Remember not to checkin your GCS keyfile to a repository +# google: +# service: GCS +# project: your_project +# keyfile: <%= Rails.root.join("path/to/gcs.keyfile") %> +# bucket: your_own_bucket + +# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key) +# microsoft: +# service: AzureStorage +# path: your_azure_storage_path +# storage_account_name: your_account_name +# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %> +# container: your_container_name + +# mirror: +# service: Mirror +# primary: local +# mirrors: [ amazon, google, microsoft ] diff --git a/test/dummy/db/migrate/20130703191909_create_users.rb b/test/dummy/db/migrate/20130703191909_create_users.rb deleted file mode 100644 index 94f264ea1..000000000 --- a/test/dummy/db/migrate/20130703191909_create_users.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreateUsers < GenericMigration - def change - create_table :users do |t| - t.string :email - t.string :password - t.text :comments - t.string :status - t.string :misc - - t.timestamps - end - end -end diff --git a/test/dummy/db/migrate/20130703191937_create_addresses.rb b/test/dummy/db/migrate/20130703191937_create_addresses.rb deleted file mode 100644 index 9613a6e37..000000000 --- a/test/dummy/db/migrate/20130703191937_create_addresses.rb +++ /dev/null @@ -1,13 +0,0 @@ -class CreateAddresses < GenericMigration - def change - create_table :addresses do |t| - t.integer :user_id - t.string :street - t.string :city - t.string :state - t.string :zip_code - - t.timestamps - end - end -end diff --git a/test/dummy/db/migrate/20130912171202_add_preferences_to_user.rb b/test/dummy/db/migrate/20130912171202_add_preferences_to_user.rb deleted file mode 100644 index 8d354faa3..000000000 --- a/test/dummy/db/migrate/20130912171202_add_preferences_to_user.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddPreferencesToUser < GenericMigration - def change - add_column :users, :preferences, :text - end -end diff --git a/test/dummy/db/migrate/20140327190145_add_terms_to_user.rb b/test/dummy/db/migrate/20140327190145_add_terms_to_user.rb deleted file mode 100644 index 2aa04a3ea..000000000 --- a/test/dummy/db/migrate/20140327190145_add_terms_to_user.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddTermsToUser < GenericMigration - def change - add_column :users, :terms, :boolean, default: false - end -end diff --git a/test/dummy/db/migrate/20140922133133_add_type_to_users.rb b/test/dummy/db/migrate/20140922133133_add_type_to_users.rb deleted file mode 100644 index fc2239cd8..000000000 --- a/test/dummy/db/migrate/20140922133133_add_type_to_users.rb +++ /dev/null @@ -1,5 +0,0 @@ -class AddTypeToUsers < GenericMigration - def change - add_column :users, :type, :string - end -end diff --git a/test/dummy/db/schema.rb b/test/dummy/db/schema.rb index a072ddbdb..4020137a6 100644 --- a/test/dummy/db/schema.rb +++ b/test/dummy/db/schema.rb @@ -1,38 +1,24 @@ -# This file is auto-generated from the current state of the database. Instead -# of editing this file, please use the migrations feature of Active Record to -# incrementally modify your database, and then regenerate this schema definition. -# -# Note that this schema.rb definition is the authoritative source for your -# database schema. If you need to create the application database on another -# system, you should be using db:schema:load, not running all the migrations -# from scratch. The latter is a flawed and unsustainable approach (the more migrations -# you'll amass, the slower it'll run and the greater likelihood for issues). -# -# It's strongly recommended that you check this file into your version control system. +ActiveRecord::Schema.define(version: 1) do -ActiveRecord::Schema.define(version: 20140922133133) do - - create_table "addresses", force: :cascade do |t| - t.integer "user_id" - t.string "street" - t.string "city" - t.string "state" - t.string "zip_code" - t.datetime "created_at" - t.datetime "updated_at" + create_table :addresses, force: :cascade do |t| + t.integer :user_id + t.string :street + t.string :city + t.string :state + t.string :zip_code + t.timestamps end - create_table "users", force: :cascade do |t| - t.string "email" - t.string "password" - t.text "comments" - t.string "status" - t.string "misc" - t.datetime "created_at" - t.datetime "updated_at" - t.text "preferences" - t.boolean "terms", default: false - t.string "type" + create_table :users, force: :cascade do |t| + t.string :email + t.string :password + t.text :comments + t.string :status + t.string :misc + t.text :preferences + t.boolean :terms, default: false + t.string :type + t.timestamps end end diff --git a/test/dummy/db/seeds.rb b/test/dummy/db/seeds.rb deleted file mode 100644 index 4edb1e857..000000000 --- a/test/dummy/db/seeds.rb +++ /dev/null @@ -1,7 +0,0 @@ -# This file should contain all the record creation needed to seed the database with its default values. -# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). -# -# Examples: -# -# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) -# Mayor.create(name: 'Emanuel', city: cities.first) diff --git a/test/dummy/package.json b/test/dummy/package.json new file mode 100644 index 000000000..caa2d7bb3 --- /dev/null +++ b/test/dummy/package.json @@ -0,0 +1,5 @@ +{ + "name": "dummy", + "private": true, + "dependencies": {} +} diff --git a/test/dummy/public/404.html b/test/dummy/public/404.html index a0daa0c15..2be3af26f 100644 --- a/test/dummy/public/404.html +++ b/test/dummy/public/404.html @@ -2,17 +2,23 @@ The page you were looking for doesn't exist (404) + - +
-

The page you were looking for doesn't exist.

-

You may have mistyped the address or the page may have moved.

+
+

The page you were looking for doesn't exist.

+

You may have mistyped the address or the page may have moved.

+
+

If you are the application owner check the logs for more information.

-

If you are the application owner check the logs for more information.

diff --git a/test/dummy/public/422.html b/test/dummy/public/422.html index fbb4b84d7..c08eac0d1 100644 --- a/test/dummy/public/422.html +++ b/test/dummy/public/422.html @@ -2,17 +2,23 @@ The change you wanted was rejected (422) + - +
-

The change you wanted was rejected.

-

Maybe you tried to change something you didn't have access to.

+
+

The change you wanted was rejected.

+

Maybe you tried to change something you didn't have access to.

+
+

If you are the application owner check the logs for more information.

-

If you are the application owner check the logs for more information.

diff --git a/test/dummy/public/500.html b/test/dummy/public/500.html index e9052d35b..78a030af2 100644 --- a/test/dummy/public/500.html +++ b/test/dummy/public/500.html @@ -2,17 +2,23 @@ We're sorry, but something went wrong (500) + - +
-

We're sorry, but something went wrong.

+
+

We're sorry, but something went wrong.

+
+

If you are the application owner check the logs for more information.

-

If you are the application owner check the logs for more information.

diff --git a/test/dummy/app/models/.keep b/test/dummy/public/apple-touch-icon-precomposed.png similarity index 100% rename from test/dummy/app/models/.keep rename to test/dummy/public/apple-touch-icon-precomposed.png diff --git a/test/dummy/lib/tasks/.keep b/test/dummy/public/apple-touch-icon.png similarity index 100% rename from test/dummy/lib/tasks/.keep rename to test/dummy/public/apple-touch-icon.png diff --git a/test/dummy/public/robots.txt b/test/dummy/public/robots.txt deleted file mode 100644 index 1a3a5e4dd..000000000 --- a/test/dummy/public/robots.txt +++ /dev/null @@ -1,5 +0,0 @@ -# See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file -# -# To ban all spiders from the entire site uncomment the next two lines: -# User-agent: * -# Disallow: / diff --git a/test/dummy/test/controllers/.keep b/test/dummy/storage/.keep similarity index 100% rename from test/dummy/test/controllers/.keep rename to test/dummy/storage/.keep diff --git a/test/dummy/test/fixtures/.keep b/test/dummy/test/fixtures/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/test/dummy/test/fixtures/addresses.yml b/test/dummy/test/fixtures/addresses.yml deleted file mode 100644 index ba3212270..000000000 --- a/test/dummy/test/fixtures/addresses.yml +++ /dev/null @@ -1,15 +0,0 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html - -one: - user_id: 1 - street: MyString - city: MyString - state: MyString - zip_code: MyString - -two: - user_id: 1 - street: MyString - city: MyString - state: MyString - zip_code: MyString diff --git a/test/dummy/test/fixtures/users.yml b/test/dummy/test/fixtures/users.yml deleted file mode 100644 index 719bdcb09..000000000 --- a/test/dummy/test/fixtures/users.yml +++ /dev/null @@ -1,15 +0,0 @@ -# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html - -one: - email: MyString - password: MyString - comments: MyText - status: MyString - misc: MyString - -two: - email: MyString - password: MyString - comments: MyText - status: MyString - misc: MyString diff --git a/test/dummy/test/helpers/.keep b/test/dummy/test/helpers/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/test/dummy/test/integration/.keep b/test/dummy/test/integration/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/test/dummy/test/mailers/.keep b/test/dummy/test/mailers/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/test/dummy/test/models/.keep b/test/dummy/test/models/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/test/dummy/test/models/address_test.rb b/test/dummy/test/models/address_test.rb deleted file mode 100644 index 44f9f9b48..000000000 --- a/test/dummy/test/models/address_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class AddressTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/dummy/test/models/user_test.rb b/test/dummy/test/models/user_test.rb deleted file mode 100644 index 82f61e010..000000000 --- a/test/dummy/test/models/user_test.rb +++ /dev/null @@ -1,7 +0,0 @@ -require 'test_helper' - -class UserTest < ActiveSupport::TestCase - # test "the truth" do - # assert true - # end -end diff --git a/test/dummy/test/test_helper.rb b/test/dummy/test/test_helper.rb deleted file mode 100644 index bc7e05d70..000000000 --- a/test/dummy/test/test_helper.rb +++ /dev/null @@ -1,15 +0,0 @@ -ENV["RAILS_ENV"] ||= "test" -require File.expand_path('../../config/environment', __FILE__) -require 'rails/test_help' - -class ActiveSupport::TestCase - ActiveRecord::Migration.check_pending! - - # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. - # - # Note: You'll currently still have to declare fixtures explicitly in integration tests - # -- they do not yet inherit this setting - fixtures :all - - # Add more helper methods to be used by all tests here... -end diff --git a/test/dummy/vendor/assets/javascripts/.keep b/test/dummy/vendor/assets/javascripts/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/test/dummy/vendor/assets/stylesheets/.keep b/test/dummy/vendor/assets/stylesheets/.keep deleted file mode 100644 index e69de29bb..000000000 From 1568244bd06c44ad4542d121a5d3139c131e8fa1 Mon Sep 17 00:00:00 2001 From: Oleg Date: Mon, 8 Jan 2018 18:06:12 -0800 Subject: [PATCH 007/112] adding a job for danger bot --- .travis.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ff00c9863..fcef12d24 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,4 +10,13 @@ gemfile: - test/gemfiles/5.2.gemfile before_install: - gem update --system - - gem update bundler + - gem update bundle + +# Running one job to execute DANGER bot +matrix: + include: + - rvm: 2.5.0 + gemfile: test/gemfiles/5.2.gemfile + script: + - gem install danger + - danger From 650d88b29a3bdc79255291a1cf1287b84941865d Mon Sep 17 00:00:00 2001 From: Oleg Date: Mon, 8 Jan 2018 18:45:32 -0800 Subject: [PATCH 008/112] trimming test/dummy adding simple bootstrap_form for the view --- Gemfile | 4 ++ test/dummy/README.md | 10 ++++ test/dummy/app/assets/config/manifest.js | 3 - test/dummy/app/assets/images/.keep | 0 .../app/assets/javascripts/application.js | 14 ----- test/dummy/app/assets/javascripts/cable.js | 13 ----- .../app/assets/javascripts/channels/.keep | 0 .../app/assets/stylesheets/application.css | 15 ----- .../app/channels/application_cable/channel.rb | 4 -- .../channels/application_cable/connection.rb | 4 -- .../app/controllers/bootstrap_controller.rb | 14 +++++ test/dummy/app/controllers/concerns/.keep | 0 test/dummy/app/helpers/application_helper.rb | 2 - test/dummy/app/jobs/application_job.rb | 2 - test/dummy/app/mailers/application_mailer.rb | 4 -- test/dummy/app/models/concerns/.keep | 0 test/dummy/app/views/bootstrap/form.html.erb | 13 +++++ .../app/views/layouts/application.html.erb | 56 ++++++++++++++++--- test/dummy/app/views/layouts/mailer.html.erb | 13 ----- test/dummy/app/views/layouts/mailer.text.erb | 1 - test/dummy/config/cable.yml | 10 ---- test/dummy/config/environments/development.rb | 4 +- test/dummy/config/environments/test.rb | 4 +- test/dummy/config/routes.rb | 2 + test/dummy/lib/assets/.keep | 0 test/dummy/storage/.keep | 0 26 files changed, 97 insertions(+), 95 deletions(-) delete mode 100644 test/dummy/app/assets/config/manifest.js delete mode 100644 test/dummy/app/assets/images/.keep delete mode 100644 test/dummy/app/assets/javascripts/application.js delete mode 100644 test/dummy/app/assets/javascripts/cable.js delete mode 100644 test/dummy/app/assets/javascripts/channels/.keep delete mode 100644 test/dummy/app/assets/stylesheets/application.css delete mode 100644 test/dummy/app/channels/application_cable/channel.rb delete mode 100644 test/dummy/app/channels/application_cable/connection.rb create mode 100644 test/dummy/app/controllers/bootstrap_controller.rb delete mode 100644 test/dummy/app/controllers/concerns/.keep delete mode 100644 test/dummy/app/helpers/application_helper.rb delete mode 100644 test/dummy/app/jobs/application_job.rb delete mode 100644 test/dummy/app/mailers/application_mailer.rb delete mode 100644 test/dummy/app/models/concerns/.keep create mode 100644 test/dummy/app/views/bootstrap/form.html.erb delete mode 100644 test/dummy/app/views/layouts/mailer.html.erb delete mode 100644 test/dummy/app/views/layouts/mailer.text.erb delete mode 100644 test/dummy/config/cable.yml delete mode 100644 test/dummy/lib/assets/.keep delete mode 100644 test/dummy/storage/.keep diff --git a/Gemfile b/Gemfile index 1bf379333..655be500f 100644 --- a/Gemfile +++ b/Gemfile @@ -5,6 +5,10 @@ gemspec # Uncomment and change rails version for testing purposes # gem "rails", "~> 5.2.0.beta2" +group :development do + gem "htmlbeautifier" +end + group :test do gem "diffy" gem "equivalent-xml" diff --git a/test/dummy/README.md b/test/dummy/README.md index 7e010757f..a5f4d59b5 100644 --- a/test/dummy/README.md +++ b/test/dummy/README.md @@ -5,3 +5,13 @@ Following files were added or changed: - db/schema.rb - config/application.rb - config/routes.rb +- 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 + +### Usage + +- rake db:schema:load +- rails s +- Navigate to http://localhost:3000 diff --git a/test/dummy/app/assets/config/manifest.js b/test/dummy/app/assets/config/manifest.js deleted file mode 100644 index b16e53d6d..000000000 --- a/test/dummy/app/assets/config/manifest.js +++ /dev/null @@ -1,3 +0,0 @@ -//= link_tree ../images -//= link_directory ../javascripts .js -//= link_directory ../stylesheets .css diff --git a/test/dummy/app/assets/images/.keep b/test/dummy/app/assets/images/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/test/dummy/app/assets/javascripts/application.js b/test/dummy/app/assets/javascripts/application.js deleted file mode 100644 index e914de739..000000000 --- a/test/dummy/app/assets/javascripts/application.js +++ /dev/null @@ -1,14 +0,0 @@ -// This is a manifest file that'll be compiled into application.js, which will include all the files -// listed below. -// -// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, -// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path. -// -// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the -// compiled file. JavaScript code in this file should be added after the last require_* statement. -// -// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details -// about supported directives. -// -//= require activestorage -//= require_tree . diff --git a/test/dummy/app/assets/javascripts/cable.js b/test/dummy/app/assets/javascripts/cable.js deleted file mode 100644 index 739aa5f02..000000000 --- a/test/dummy/app/assets/javascripts/cable.js +++ /dev/null @@ -1,13 +0,0 @@ -// Action Cable provides the framework to deal with WebSockets in Rails. -// You can generate new channels where WebSocket features live using the `rails generate channel` command. -// -//= require action_cable -//= require_self -//= require_tree ./channels - -(function() { - this.App || (this.App = {}); - - App.cable = ActionCable.createConsumer(); - -}).call(this); diff --git a/test/dummy/app/assets/javascripts/channels/.keep b/test/dummy/app/assets/javascripts/channels/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/test/dummy/app/assets/stylesheets/application.css b/test/dummy/app/assets/stylesheets/application.css deleted file mode 100644 index 0ebd7fe82..000000000 --- a/test/dummy/app/assets/stylesheets/application.css +++ /dev/null @@ -1,15 +0,0 @@ -/* - * This is a manifest file that'll be compiled into application.css, which will include all the files - * listed below. - * - * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, - * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path. - * - * You're free to add application-wide styles to this file and they'll appear at the bottom of the - * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS - * files in this directory. Styles in this file should be added after the last require_* statement. - * It is generally better to create a new file per style scope. - * - *= require_tree . - *= require_self - */ diff --git a/test/dummy/app/channels/application_cable/channel.rb b/test/dummy/app/channels/application_cable/channel.rb deleted file mode 100644 index d67269728..000000000 --- a/test/dummy/app/channels/application_cable/channel.rb +++ /dev/null @@ -1,4 +0,0 @@ -module ApplicationCable - class Channel < ActionCable::Channel::Base - end -end diff --git a/test/dummy/app/channels/application_cable/connection.rb b/test/dummy/app/channels/application_cable/connection.rb deleted file mode 100644 index 0ff5442f4..000000000 --- a/test/dummy/app/channels/application_cable/connection.rb +++ /dev/null @@ -1,4 +0,0 @@ -module ApplicationCable - class Connection < ActionCable::Connection::Base - end -end diff --git a/test/dummy/app/controllers/bootstrap_controller.rb b/test/dummy/app/controllers/bootstrap_controller.rb new file mode 100644 index 000000000..b726db3e7 --- /dev/null +++ b/test/dummy/app/controllers/bootstrap_controller.rb @@ -0,0 +1,14 @@ +class BootstrapController < ApplicationController + helper_method :codemirror_html + + def form + @user = User.new + end + +private + + def codemirror_html(html) + HtmlBeautifier.beautify(html.strip.gsub(">", ">\n").gsub("<", "\n<")) + end + +end \ No newline at end of file diff --git a/test/dummy/app/controllers/concerns/.keep b/test/dummy/app/controllers/concerns/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/test/dummy/app/helpers/application_helper.rb b/test/dummy/app/helpers/application_helper.rb deleted file mode 100644 index de6be7945..000000000 --- a/test/dummy/app/helpers/application_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module ApplicationHelper -end diff --git a/test/dummy/app/jobs/application_job.rb b/test/dummy/app/jobs/application_job.rb deleted file mode 100644 index a009ace51..000000000 --- a/test/dummy/app/jobs/application_job.rb +++ /dev/null @@ -1,2 +0,0 @@ -class ApplicationJob < ActiveJob::Base -end diff --git a/test/dummy/app/mailers/application_mailer.rb b/test/dummy/app/mailers/application_mailer.rb deleted file mode 100644 index 286b2239d..000000000 --- a/test/dummy/app/mailers/application_mailer.rb +++ /dev/null @@ -1,4 +0,0 @@ -class ApplicationMailer < ActionMailer::Base - default from: 'from@example.com' - layout 'mailer' -end diff --git a/test/dummy/app/models/concerns/.keep b/test/dummy/app/models/concerns/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/test/dummy/app/views/bootstrap/form.html.erb b/test/dummy/app/views/bootstrap/form.html.erb new file mode 100644 index 000000000..f5a003177 --- /dev/null +++ b/test/dummy/app/views/bootstrap/form.html.erb @@ -0,0 +1,13 @@ +

Simple

+
+ <% example = capture do %> + <%= bootstrap_form_for @user, url: "/" do |form| %> + <%= form.email_field :email, placeholder: "Enter Email", label: "Email address", help: "We'll never share your email with anyone else" %> + <%= form.password_field :password, placeholder: "Password" %> + <%= form.check_box :terms, label: "Check me out" %> + <%= form.submit %> + <% end %> + <% end %> + <%= example %> + +
diff --git a/test/dummy/app/views/layouts/application.html.erb b/test/dummy/app/views/layouts/application.html.erb index a6eb0174b..2f017f557 100644 --- a/test/dummy/app/views/layouts/application.html.erb +++ b/test/dummy/app/views/layouts/application.html.erb @@ -1,14 +1,54 @@ - - + + - Dummy - <%= csrf_meta_tags %> + + + + + + + + + - <%= stylesheet_link_tag 'application', media: 'all' %> - <%= javascript_include_tag 'application' %> + Hello, world! + <%= csrf_meta_tags %> - <%= yield %> +
+ <%= yield %> +
+ + + + + + + + + + + - + \ No newline at end of file diff --git a/test/dummy/app/views/layouts/mailer.html.erb b/test/dummy/app/views/layouts/mailer.html.erb deleted file mode 100644 index cbd34d2e9..000000000 --- a/test/dummy/app/views/layouts/mailer.html.erb +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - <%= yield %> - - diff --git a/test/dummy/app/views/layouts/mailer.text.erb b/test/dummy/app/views/layouts/mailer.text.erb deleted file mode 100644 index 37f0bddbd..000000000 --- a/test/dummy/app/views/layouts/mailer.text.erb +++ /dev/null @@ -1 +0,0 @@ -<%= yield %> diff --git a/test/dummy/config/cable.yml b/test/dummy/config/cable.yml deleted file mode 100644 index 1cd0f8363..000000000 --- a/test/dummy/config/cable.yml +++ /dev/null @@ -1,10 +0,0 @@ -development: - adapter: async - -test: - adapter: async - -production: - adapter: redis - url: <%= ENV.fetch("REDIS_URL") { "redis://localhost:6379/1" } %> - channel_prefix: dummy_production diff --git a/test/dummy/config/environments/development.rb b/test/dummy/config/environments/development.rb index 7b8374da8..8a9751305 100644 --- a/test/dummy/config/environments/development.rb +++ b/test/dummy/config/environments/development.rb @@ -28,7 +28,9 @@ end # Store uploaded files on the local file system (see config/storage.yml for options) - config.active_storage.service = :local + if config.respond_to?(:active_storage) + config.active_storage.service = :local + end # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false diff --git a/test/dummy/config/environments/test.rb b/test/dummy/config/environments/test.rb index 288b92fbf..41c1cacc3 100644 --- a/test/dummy/config/environments/test.rb +++ b/test/dummy/config/environments/test.rb @@ -29,7 +29,9 @@ config.action_controller.allow_forgery_protection = false # Store uploaded files on the local file system in a temporary directory - # config.active_storage.service = :test + if config.respond_to?(:active_storage) + config.active_storage.service = :test + end config.action_mailer.perform_caching = false diff --git a/test/dummy/config/routes.rb b/test/dummy/config/routes.rb index 4867764b3..7f9ec0db9 100644 --- a/test/dummy/config/routes.rb +++ b/test/dummy/config/routes.rb @@ -1,3 +1,5 @@ Dummy::Application.routes.draw do resources :users + + root to: "bootstrap#form" end diff --git a/test/dummy/lib/assets/.keep b/test/dummy/lib/assets/.keep deleted file mode 100644 index e69de29bb..000000000 diff --git a/test/dummy/storage/.keep b/test/dummy/storage/.keep deleted file mode 100644 index e69de29bb..000000000 From 9648ebf0433767615722dbe15b97d0d84a594600 Mon Sep 17 00:00:00 2001 From: Oleg Date: Mon, 8 Jan 2018 18:50:16 -0800 Subject: [PATCH 009/112] removing dummy/public --- test/dummy/config/application.rb | 1 - test/dummy/public/404.html | 67 ------------------- test/dummy/public/422.html | 67 ------------------- test/dummy/public/500.html | 66 ------------------ .../public/apple-touch-icon-precomposed.png | 0 test/dummy/public/apple-touch-icon.png | 0 test/dummy/public/favicon.ico | 0 7 files changed, 201 deletions(-) delete mode 100644 test/dummy/public/404.html delete mode 100644 test/dummy/public/422.html delete mode 100644 test/dummy/public/500.html delete mode 100644 test/dummy/public/apple-touch-icon-precomposed.png delete mode 100644 test/dummy/public/apple-touch-icon.png delete mode 100644 test/dummy/public/favicon.ico diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb index 6fbb9acbb..adc98cac0 100644 --- a/test/dummy/config/application.rb +++ b/test/dummy/config/application.rb @@ -22,4 +22,3 @@ class Application < Rails::Application # -- all .rb files in that directory are automatically loaded. end end - diff --git a/test/dummy/public/404.html b/test/dummy/public/404.html deleted file mode 100644 index 2be3af26f..000000000 --- a/test/dummy/public/404.html +++ /dev/null @@ -1,67 +0,0 @@ - - - - The page you were looking for doesn't exist (404) - - - - - - -
-
-

The page you were looking for doesn't exist.

-

You may have mistyped the address or the page may have moved.

-
-

If you are the application owner check the logs for more information.

-
- - diff --git a/test/dummy/public/422.html b/test/dummy/public/422.html deleted file mode 100644 index c08eac0d1..000000000 --- a/test/dummy/public/422.html +++ /dev/null @@ -1,67 +0,0 @@ - - - - The change you wanted was rejected (422) - - - - - - -
-
-

The change you wanted was rejected.

-

Maybe you tried to change something you didn't have access to.

-
-

If you are the application owner check the logs for more information.

-
- - diff --git a/test/dummy/public/500.html b/test/dummy/public/500.html deleted file mode 100644 index 78a030af2..000000000 --- a/test/dummy/public/500.html +++ /dev/null @@ -1,66 +0,0 @@ - - - - We're sorry, but something went wrong (500) - - - - - - -
-
-

We're sorry, but something went wrong.

-
-

If you are the application owner check the logs for more information.

-
- - diff --git a/test/dummy/public/apple-touch-icon-precomposed.png b/test/dummy/public/apple-touch-icon-precomposed.png deleted file mode 100644 index e69de29bb..000000000 diff --git a/test/dummy/public/apple-touch-icon.png b/test/dummy/public/apple-touch-icon.png deleted file mode 100644 index e69de29bb..000000000 diff --git a/test/dummy/public/favicon.ico b/test/dummy/public/favicon.ico deleted file mode 100644 index e69de29bb..000000000 From 9a0df05eb84417a7ac3b38dca89a184b7b561ad6 Mon Sep 17 00:00:00 2001 From: Oleg Date: Mon, 8 Jan 2018 19:04:51 -0800 Subject: [PATCH 010/112] adjusting CONTRIBUTING [skip ci] --- CONTRIBUTING.md | 70 ++++++++++++++++++++++---------------------- test/dummy/README.md | 4 +-- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f8c9dd656..ac8caafb2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,53 +1,53 @@ # Contributing -The release of Bootstrap 4 and Rails 5.1 have implications -for the future direction of `bootstrap_form`. -Don't worry. -We plan to move this gem forward to Bootstrap 4 -and to support Rails 5.1 and beyond. -If you're thinking of contributing to `bootstrap_form`, -please read [issue #361](https://github.com/bootstrap-ruby/rails-bootstrap-forms/issues/361). -Your comments are welcome. - -Thanks so much for considering contributing to bootstrap_form! -We love pull requests! +The release of Bootstrap 4 and Rails 5.1 have implications for the future +direction of `bootstrap_form`. Don't worry. We plan to move this gem forward to +Bootstrap 4 and to support Rails 5.1 and beyond. If you're thinking of +contributing to `bootstrap_form`, please read +[issue #361](https://github.com/bootstrap-ruby/rails-bootstrap-forms/issues/361). Here's a quick guide for contributing: -1. Make sure no one else is working on the same issue or feature. -Search the issues and pull requests for anything -that looks like the issue or feature you want to address. -If no one else is working on your issue or feature, -carry on with the following steps. +### 1. Check if issue or feature is available to work on -2. Fork the repo. +Make sure no one else is working on the same issue or feature. Search the issues +and pull requests for anything that looks like the issue or feature you want to +address. If no one else is working on your issue or feature, carry on with the +following steps. -2. Install the required dependencies. +### 2. Fork the repo -``` -bundle install -bundle exec appraisal install -``` +For the project. Optionally, create a branch you want to work on -3. Run the existing test suite: +### 3. Get it running locally -``` -$ bundle exec rake -f test/dummy/Rakefile db:create db:migrate RAILS_ENV=test -$ bundle exec appraisal rake test -``` +- Install the required dependencies with `bundle install` +- Run tests via: `bundle exec rake` -4. Add tests for your change. +### 4. Hack away -5. Add your changes and make your test(s) pass. Following the conventions you -see used in the source will increase the chance that your pull request is -accepted right away. +- Try to keep your changes small. Consider making several smaller pull requests. +- Don't forget to add necessary tests. +- Update the README if necessary. +- Add a line to the CHANGELOG for your bug fix or feature. -6. Update the README if necessary. +You may find using test/dummy application useful for development and debugging. -7. Add a line to the CHANGELOG for your bug fix or feature. +- `cd test/dummy` +- `rake db:schema:load` +- `rails s` +- Navigate to http://localhost:3000 -8. Push to your fork and submit a pull request. +### 5. Make a Pull Request -## Contributors +- If you never done it before read this: https://help.github.com/articles/about-pull-requests/ +- When PR is submitted check if TravisCI ran all tests successfully didn't raise any issues + +### 6. Done! + +Somebody will shortly review your pull request and if everything is good will be +merged into master brach. Eventually gem will be published with your changes. + +--- Thanks to all the great contributors over the years: https://github.com/bootstrap-ruby/rails-bootstrap-forms/graphs/contributors diff --git a/test/dummy/README.md b/test/dummy/README.md index a5f4d59b5..592c2fcc2 100644 --- a/test/dummy/README.md +++ b/test/dummy/README.md @@ -12,6 +12,6 @@ Following files were added or changed: ### Usage -- rake db:schema:load -- rails s +- `rake db:schema:load` +- `rails s` - Navigate to http://localhost:3000 From 1e2134bc4f4fe48d4d85c13c7f630f0359ba8396 Mon Sep 17 00:00:00 2001 From: Oleg Date: Mon, 8 Jan 2018 19:18:15 -0800 Subject: [PATCH 011/112] adding bleeding-edge job --- .travis.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index fcef12d24..524592bcf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,11 +12,19 @@ before_install: - gem update --system - gem update bundle -# Running one job to execute DANGER bot + matrix: include: + # Bleeding edge + - rvm: ruby-head + gemfile: test/gemfiles/5.2.gemfile + + # Running one job to execute DANGER bot - rvm: 2.5.0 gemfile: test/gemfiles/5.2.gemfile script: - gem install danger - danger + + allow_failures: + - rvm: ruby-head From 828e478acf85c8e1fc56935f656041290224c1e5 Mon Sep 17 00:00:00 2001 From: Oleg Date: Mon, 8 Jan 2018 19:52:06 -0800 Subject: [PATCH 012/112] reducing log noise due to missing favicon [skip ci] --- test/dummy/public/favicon.ico | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 test/dummy/public/favicon.ico diff --git a/test/dummy/public/favicon.ico b/test/dummy/public/favicon.ico new file mode 100644 index 000000000..e69de29bb From 5a5a3f41c9a483879e72a30c1777bfceccc53e09 Mon Sep 17 00:00:00 2001 From: Oleg Date: Mon, 8 Jan 2018 21:31:31 -0800 Subject: [PATCH 013/112] bumping travis ruby versions, putting back contrib text, standard load_path thing in gemspec --- .travis.yml | 7 +++---- CONTRIBUTING.md | 4 ++++ bootstrap_form.gemspec | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 524592bcf..91c1a19c1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,8 @@ language: ruby rvm: - - 2.2.7 - - 2.3.5 - - 2.4.2 + - 2.2.9 + - 2.3.6 + - 2.4.3 - 2.5.0 gemfile: - test/gemfiles/5.0.gemfile @@ -12,7 +12,6 @@ before_install: - gem update --system - gem update bundle - matrix: include: # Bleeding edge diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ac8caafb2..62a02439b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,6 +6,10 @@ Bootstrap 4 and to support Rails 5.1 and beyond. If you're thinking of contributing to `bootstrap_form`, please read [issue #361](https://github.com/bootstrap-ruby/rails-bootstrap-forms/issues/361). +Your comments are welcome. + +Thanks so much for considering a contribution to bootstrap_form. We love pull requests! + Here's a quick guide for contributing: ### 1. Check if issue or feature is available to work on diff --git a/bootstrap_form.gemspec b/bootstrap_form.gemspec index 7e8cc25a4..33fea5aac 100644 --- a/bootstrap_form.gemspec +++ b/bootstrap_form.gemspec @@ -1,4 +1,4 @@ -$LOAD_PATH.unshift File.expand_path("../lib", __FILE__) +$LOAD_PATH.push File.expand_path("lib", __dir__) require "bootstrap_form/version" From ee31b858b4290f00b7b06f1e428ebcf2b6b938c8 Mon Sep 17 00:00:00 2001 From: Oleg Date: Mon, 8 Jan 2018 22:21:59 -0800 Subject: [PATCH 014/112] small tweaks to travis.yml and gemspec --- .travis.yml | 2 +- bootstrap_form.gemspec | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 91c1a19c1..36d6d7d81 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ gemfile: - test/gemfiles/5.2.gemfile before_install: - gem update --system - - gem update bundle + - gem install bundler --no-document matrix: include: diff --git a/bootstrap_form.gemspec b/bootstrap_form.gemspec index 33fea5aac..5a0a9699a 100644 --- a/bootstrap_form.gemspec +++ b/bootstrap_form.gemspec @@ -1,4 +1,5 @@ -$LOAD_PATH.push File.expand_path("lib", __dir__) +lib = File.expand_path('../lib', __FILE__) +$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "bootstrap_form/version" @@ -14,8 +15,11 @@ Gem::Specification.new do |s| "easy to create beautiful-looking forms using Bootstrap 4" s.license = "MIT" - s.files = `git ls-files`.split("\n") - s.platform = Gem::Platform::RUBY + s.files = `git ls-files -z`.split("\x0").reject do |f| + f.match(%r{^(test)/}) + end + + s.bindir = "exe" s.require_paths = ["lib"] s.required_ruby_version = ">= 2.2.2" From 857664377ce64587fec3cebab16e9a0453d58ab9 Mon Sep 17 00:00:00 2001 From: Oleg Date: Tue, 9 Jan 2018 13:02:25 -0800 Subject: [PATCH 015/112] removing ruby-version from dummy --- .gitignore | 2 +- test/dummy/.ruby-version | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 test/dummy/.ruby-version diff --git a/.gitignore b/.gitignore index ca20e21f3..8540dd815 100644 --- a/.gitignore +++ b/.gitignore @@ -7,5 +7,5 @@ test/dummy/tmp/ *.gem .rbenv-gemsets *.swp -gemfiles/*.lock Gemfile.lock +.ruby-version diff --git a/test/dummy/.ruby-version b/test/dummy/.ruby-version deleted file mode 100644 index 58073ef8d..000000000 --- a/test/dummy/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -2.4.1 \ No newline at end of file From 1be02fa6b67089ab4660598ed6e5a03b42dee28c Mon Sep 17 00:00:00 2001 From: r-sierra Date: Thu, 11 Jan 2018 04:30:14 +1300 Subject: [PATCH 016/112] Additional Form Group Attributes in select example (#352) * Additional Form Group Attributes in select example Show how to set additional Form Group Attributes like wrapper class * Update README.md Missing "}" --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1ffd77618..6dcd8dd4b 100644 --- a/README.md +++ b/README.md @@ -269,7 +269,7 @@ You still can use `wrapper_class` option to set only a css class. This is just a Our select helper accepts the same arguments as the [default Rails helper](http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#method-i-select). Here's an example of how you pass both options and html_options hashes: ```erb -<%= f.select :product, [["Apple", 1], ["Grape", 2]], { label: "Choose your favorite fruit:" }, { class: "selectpicker" } %> +<%= f.select :product, [["Apple", 1], ["Grape", 2]], { label: "Choose your favorite fruit:" }, { class: "selectpicker", wrapper: { class: 'has-warning', data: { foo: 'bar' } } } %> ``` ### Checkboxes and Radios From de4bebc5fed3089a3b2c0d3058140a8a4540b60b Mon Sep 17 00:00:00 2001 From: Larry Reid Date: Thu, 11 Jan 2018 09:34:10 -0800 Subject: [PATCH 017/112] Pin Minitest to work around crash on test failure. Minitest 5.11 is broken for environments, like Rails, that use custom reporters. Pin to 5.10.3 in the meantime. --- Gemfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Gemfile b/Gemfile index 655be500f..1112f4f7b 100644 --- a/Gemfile +++ b/Gemfile @@ -16,3 +16,5 @@ group :test do gem "sqlite3" gem "timecop", "~> 0.7.1" end + +gem "minitest", "~> 5.10.3" From 225ad70cc22d2a0f88a93aaaddf49a36e4cb6b57 Mon Sep 17 00:00:00 2001 From: John Yeates Date: Sat, 2 Sep 2017 14:29:30 +0100 Subject: [PATCH 018/112] Support HTML in help translations. In keeping with convention, the presence of HTML in a translation is signalled by appending '_html' to the key name. It will then not be escaped. --- CHANGELOG.md | 2 +- README.md | 10 ++++++++++ lib/bootstrap_form/form_builder.rb | 5 +++++ test/bootstrap_form_test.rb | 13 +++++++++++++ 4 files changed, 29 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 923ceef97..e6f5f2a66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,9 +5,9 @@ Bugfixes: Features: - Your contribution here! + - Allow HTML in help translations by using the '_html' suffix on the key - [@unikitty37](https://github.com/unikitty37) * [#325](https://github.com/bootstrap-ruby/rails-bootstrap-forms/pull/325): Support :prepend and :append for the `select` helper - [@donv](https://github.com/donv). - ## [2.7.0][] (2017-04-21) Features: diff --git a/README.md b/README.md index 6dcd8dd4b..a6102cc70 100644 --- a/README.md +++ b/README.md @@ -198,6 +198,16 @@ en: password: "A good password should be at least six characters long" ``` +Help translations containing HTML should follow the convention of appending `_html` to the name: + +```yml +en: + activerecord: + help: + user: + password_html: "A good password should be at least six characters long" +``` + If your model name has multiple words (like `SuperUser`), the key on the translation file should be underscored (`super_user`). diff --git a/lib/bootstrap_form/form_builder.rb b/lib/bootstrap_form/form_builder.rb index 423360e6e..74871db44 100644 --- a/lib/bootstrap_form/form_builder.rb +++ b/lib/bootstrap_form/form_builder.rb @@ -452,6 +452,11 @@ def get_help_text_by_i18n_key(name) warn "I18n key '#{downcased_scope}.#{name}' is deprecated, use '#{underscored_scope}.#{name}' instead" text end + help_text ||= I18n.t("#{name}_html", scope: underscored_scope, default: '').html_safe.presence + help_text ||= if text = I18n.t("#{name}_html", scope: downcased_scope, default: '').html_safe.presence + warn "I18n key '#{downcased_scope}.#{name}' is deprecated, use '#{underscored_scope}.#{name}' instead" + text + end help_text end end diff --git a/test/bootstrap_form_test.rb b/test/bootstrap_form_test.rb index 7e0d69683..f73963df1 100644 --- a/test/bootstrap_form_test.rb +++ b/test/bootstrap_form_test.rb @@ -197,6 +197,19 @@ def setup assert_equivalent_xml expected, output end + test "help translations do not escape HTML when _html is appended to the name" do + I18n.backend.store_translations(:en, {activerecord: {help: {user: {email_html: "This is useful help"}}}}) + + output = bootstrap_form_for(@user) do |f| + f.text_field(:email) + end + + expected = %{
This is useful help
} + assert_equivalent_xml expected, output + + I18n.backend.store_translations(:en, {activerecord: {help: {user: {email_html: nil}}}}) + end + test "allows the form object to be nil" do builder = BootstrapForm::FormBuilder.new :other_model, nil, self, {} expected = %{
} From 037623df053f5ce70c3f32550d02bb96abc3dfd6 Mon Sep 17 00:00:00 2001 From: John Yeates Date: Sun, 3 Sep 2017 10:00:13 +0100 Subject: [PATCH 019/112] Fix: utf8 input should be wrapped in a div. --- test/bootstrap_form_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/bootstrap_form_test.rb b/test/bootstrap_form_test.rb index f73963df1..555d1ccc8 100644 --- a/test/bootstrap_form_test.rb +++ b/test/bootstrap_form_test.rb @@ -204,7 +204,7 @@ def setup f.text_field(:email) end - expected = %{
This is useful help
} + expected = %{
This is useful help
} assert_equivalent_xml expected, output I18n.backend.store_translations(:en, {activerecord: {help: {user: {email_html: nil}}}}) From bc993987e8a4f4b5e647c4a1b06b72ca02bc94a4 Mon Sep 17 00:00:00 2001 From: John Yeates Date: Wed, 10 Jan 2018 09:27:42 +0000 Subject: [PATCH 020/112] Bootstrap 4 compatibility fix for HTML translation form test. --- test/bootstrap_form_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/bootstrap_form_test.rb b/test/bootstrap_form_test.rb index 555d1ccc8..ff286ecc3 100644 --- a/test/bootstrap_form_test.rb +++ b/test/bootstrap_form_test.rb @@ -204,7 +204,7 @@ def setup f.text_field(:email) end - expected = %{
This is useful help
} + expected = %{
This is useful help
} assert_equivalent_xml expected, output I18n.backend.store_translations(:en, {activerecord: {help: {user: {email_html: nil}}}}) From 796bd76b87a7b73825e728cd3df9fdc46af227c3 Mon Sep 17 00:00:00 2001 From: "H. Gregor Molter" Date: Sat, 13 Jan 2018 04:58:12 +0100 Subject: [PATCH 021/112] Change form validation to support Bootstrap 4.0.0.beta (replaces #345) (#370) * New PR to replace PR #345 * Removed has_danger and form-control-label * Removed 'is-valid' * Removed wrong line from Changelog * Update html help test with latest v4 help markup --- CHANGELOG.md | 4 + README.md | 17 ++++- lib/bootstrap_form/form_builder.rb | 98 ++++++++++++++++--------- test/bootstrap_checkbox_test.rb | 42 ++++++++--- test/bootstrap_fields_test.rb | 42 +++++------ test/bootstrap_form_group_test.rb | 58 +++++++-------- test/bootstrap_form_test.rb | 28 +++---- test/bootstrap_other_components_test.rb | 12 +-- test/bootstrap_radio_button_test.rb | 42 ++++++++--- test/bootstrap_selects_test.rb | 46 ++++++------ test/special_form_class_models_test.rb | 6 +- 11 files changed, 237 insertions(+), 158 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6f5f2a66..2cfad8460 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,13 @@ Bugfixes: - Your contribution here! + - form-control-danger is replaced with is-invalid for bootstrap 4.0.0.beta3 + - form-control-feedback is replaced with invalid-feedback for bootstrap 4.0.0.beta3 + - help texts are rendered with tag instead of tag, i.e. like in bootstrap 4.0.0.beta3 Features: - Your contribution here! + - new `custom: true` option for radio buttons and check boxes according to bootstrap 4.0.0.beta3 - Allow HTML in help translations by using the '_html' suffix on the key - [@unikitty37](https://github.com/unikitty37) * [#325](https://github.com/bootstrap-ruby/rails-bootstrap-forms/pull/325): Support :prepend and :append for the `select` helper - [@donv](https://github.com/donv). diff --git a/README.md b/README.md index a6102cc70..f6a623606 100644 --- a/README.md +++ b/README.md @@ -477,6 +477,19 @@ The `layout` can be overridden per field: <% end %> ``` +### Custom Form Element Styles + +The `custom` option can be used to replace the browser default styles for check boxes and radio buttons with dedicated Bootstrap styled form elements. Here's an example: + +```erb +<%= bootstrap_form_for(@user) do |f| %> + <%= f.email_field :email %> + <%= f.password_field :password %> + <%= f.check_box :remember_me, custom: true %> + <%= f.submit "Log In" %> +<% end %> +``` + ## Validation & Errors ### Inline Errors @@ -488,8 +501,8 @@ div (field_with_errors), but this behavior is suppressed. Here's an example: ```html
- - + + can't be blank
``` diff --git a/lib/bootstrap_form/form_builder.rb b/lib/bootstrap_form/form_builder.rb index 74871db44..d69d88775 100644 --- a/lib/bootstrap_form/form_builder.rb +++ b/lib/bootstrap_form/form_builder.rb @@ -114,12 +114,23 @@ def time_zone_select_with_bootstrap(method, priority_zones = nil, options = {}, def check_box_with_bootstrap(name, options = {}, checked_value = "1", unchecked_value = "0", &block) options = options.symbolize_keys! - check_box_options = options.except(:label, :label_class, :help, :inline) - check_box_options[:class] = ["form-check-input", check_box_options[:class]].compact.join(' ') + check_box_options = options.except(:label, :label_class, :help, :inline, :custom) + if options[:custom] + validation = nil + validation = "is-invalid" if has_error?(name) + check_box_options[:class] = ["custom-control-input", validation, check_box_options[:class]].compact.join(' ') + else + check_box_options[:class] = ["form-check-input", check_box_options[:class]].compact.join(' ') + end - html = check_box_without_bootstrap(name, check_box_options, checked_value, unchecked_value) + checkbox_html = check_box_without_bootstrap(name, check_box_options, checked_value, unchecked_value) label_content = block_given? ? capture(&block) : options[:label] - html.concat(" ").concat(label_content || (object && object.class.human_attribute_name(name)) || name.to_s.humanize) + label_description = label_content || (object && object.class.human_attribute_name(name)) || name.to_s.humanize + if options[:custom] + html = label_description + else + html = checkbox_html.concat(" ").concat(label_description) + end label_name = name # label's `for` attribute needs to match checkbox tag's id, @@ -130,15 +141,23 @@ def check_box_with_bootstrap(name, options = {}, checked_value = "1", unchecked_ "#{name}_#{checked_value.to_s.gsub(/\s/, "_").gsub(/[^-\w]/, "").downcase}" end - disabled_class = " disabled" if options[:disabled] - label_class = options[:label_class] + label_class = options[:label_class] - if options[:inline] - label_class = " #{label_class}" if label_class - label(label_name, html, class: "form-check-inline#{disabled_class}#{label_class}") - else - content_tag(:div, class: "form-check#{disabled_class}") do - label(label_name, html, class: ["form-check-label", label_class].compact.join(" ")) + if options[:custom] + div_class = ["custom-control", "custom-checkbox"] + div_class.append("custom-control-inline") if options[:inline] + content_tag(:div, class: div_class.compact.join(" ")) do + checkbox_html.concat(label(label_name, html, class: ["custom-control-label", label_class].compact.join(" "))) + end + else + disabled_class = " disabled" if options[:disabled] + if options[:inline] + label_class = " #{label_class}" if label_class + label(label_name, html, class: "form-check-inline#{disabled_class}#{label_class}") + else + content_tag(:div, class: "form-check#{disabled_class}") do + label(label_name, html, class: ["form-check-label", label_class].compact.join(" ")) + end end end end @@ -147,19 +166,33 @@ def check_box_with_bootstrap(name, options = {}, checked_value = "1", unchecked_ def radio_button_with_bootstrap(name, value, *args) options = args.extract_options!.symbolize_keys! - args << options.except(:label, :label_class, :help, :inline) - - html = radio_button_without_bootstrap(name, value, *args) + " " + options[:label] + radio_options = options.except(:label, :label_class, :help, :inline, :custom) + radio_options[:class] = ["custom-control-input", options[:class]].compact.join(' ') if options[:custom] + args << radio_options + radio_html = radio_button_without_bootstrap(name, value, *args) + if options[:custom] + html = options[:label] + else + html = radio_html.concat(" ").concat(options[:label]) + end disabled_class = " disabled" if options[:disabled] label_class = options[:label_class] - if options[:inline] - label_class = " #{label_class}" if label_class - label(name, html, class: "radio-inline#{disabled_class}#{label_class}", value: value) - else - content_tag(:div, class: "radio#{disabled_class}") do - label(name, html, value: value, class: label_class) + if options[:custom] + div_class = ["custom-control", "custom-radio"] + div_class.append("custom-control-inline") if options[:inline] + content_tag(:div, class: div_class.compact.join(" ")) do + radio_html.concat(label(name, html, value: value, class: ["custom-control-label", label_class].compact.join(" "))) + end + else + if options[:inline] + label_class = " #{label_class}" if label_class + label(name, html, class: "radio-inline#{disabled_class}#{label_class}", value: value) + else + content_tag(:div, class: "radio#{disabled_class}") do + label(name, html, value: value, class: label_class) + end end end end @@ -200,7 +233,6 @@ def form_group(*args, &block) options[:class] = ["form-group", options[:class]].compact.join(' ') options[:class] << " row" if get_group_layout(options[:layout]) == :horizontal - options[:class] << " #{error_class}" if has_error?(name) options[:class] << " #{feedback_class}" if options[:icon] content_tag(:div, options.except(:id, :label, :help, :icon, :label_col, :control_col, :layout)) do @@ -225,7 +257,7 @@ def form_group(*args, &block) def fields_for_with_bootstrap(record_name, record_object = nil, fields_options = {}, &block) fields_options, record_object = record_object, nil if record_object.is_a?(Hash) && record_object.extractable_options? fields_options[:layout] ||= options[:layout] - fields_options[:label_col] = fields_options[:label_col].present? ? "#{fields_options[:label_col]} #{label_class}" : options[:label_col] + fields_options[:label_col] = fields_options[:label_col].present? ? "#{fields_options[:label_col]}" : options[:label_col] fields_options[:control_col] ||= options[:control_col] fields_options[:inline_errors] ||= options[:inline_errors] fields_options[:label_errors] ||= options[:label_errors] @@ -264,14 +296,6 @@ def control_class "form-control" end - def label_class - "form-control-label" - end - - def error_class - "has-danger" - end - def feedback_class "has-feedback" end @@ -315,7 +339,7 @@ def form_group_builder(method, options, html_options = nil) css_options = html_options || options control_classes = css_options.delete(:control_class) { control_class } css_options[:class] = [control_classes, css_options[:class]].compact.join(" ") - css_options[:class] << " form-control-danger" if has_error?(method) + css_options[:class] << " is-invalid" if has_error?(method) options = convert_form_tag_options(method, options) if acts_like_form_tag @@ -373,7 +397,7 @@ def convert_form_tag_options(method, options = {}) def generate_label(id, name, options, custom_label_col, group_layout) options[:for] = id if acts_like_form_tag - classes = [options[:class], label_class] + classes = [options[:class]] classes << (custom_label_col || label_col) if get_group_layout(group_layout) == :horizontal unless options.delete(:skip_required) classes << "required" if required_attribute?(object, name) @@ -394,18 +418,20 @@ def generate_label(id, name, options, custom_label_col, group_layout) def generate_help(name, help_text) if has_error?(name) && inline_errors help_text = get_error_messages(name) - help_klass = 'form-control-feedback' + help_klass = 'invalid-feedback' + help_tag = :div end return if help_text == false help_klass ||= 'form-text text-muted' help_text ||= get_help_text_by_i18n_key(name) + help_tag ||= :small - content_tag(:span, help_text, class: help_klass) if help_text.present? + content_tag(help_tag, help_text, class: help_klass) if help_text.present? end def generate_icon(icon) - content_tag(:span, "", class: "glyphicon glyphicon-#{icon} form-control-feedback") + content_tag(:span, "", class: "glyphicon glyphicon-#{icon} invalid-feedback") end def get_error_messages(name) diff --git a/test/bootstrap_checkbox_test.rb b/test/bootstrap_checkbox_test.rb index da2df251c..78f192831 100644 --- a/test/bootstrap_checkbox_test.rb +++ b/test/bootstrap_checkbox_test.rb @@ -54,28 +54,28 @@ def setup test 'collection_check_boxes renders the form_group correctly' do collection = [Address.new(id: 1, street: 'Foobar')] - expected = %{
With a help!
} + expected = %{
With a help!
} assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, :id, :street, label: 'This is a checkbox collection', help: 'With a help!') end test 'collection_check_boxes renders multiple checkboxes correctly' do collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')] - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, :id, :street) end test 'collection_check_boxes renders inline checkboxes correctly' do collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')] - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, :id, :street, inline: true) end test 'collection_check_boxes renders with checked option correctly' do collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')] - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, :id, :street, checked: 1) assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, :id, :street, checked: collection.first) @@ -83,7 +83,7 @@ def setup test 'collection_check_boxes renders with multiple checked options correctly' do collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')] - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, :id, :street, checked: [1, 2]) assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, :id, :street, checked: collection) @@ -91,42 +91,42 @@ def setup test 'collection_check_boxes sanitizes values when generating label `for`' do collection = [Address.new(id: 1, street: 'Foo St')] - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, :street, :street) end test 'collection_check_boxes renders multiple checkboxes with labels defined by Proc :text_method correctly' do collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')] - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, :id, Proc.new { |a| a.street.reverse }) end test 'collection_check_boxes renders multiple checkboxes with values defined by Proc :value_method correctly' do collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')] - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, Proc.new { |a| "address_#{a.id}" }, :street) end test 'collection_check_boxes renders multiple checkboxes with labels defined by lambda :text_method correctly' do collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')] - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, :id, lambda { |a| a.street.reverse }) end test 'collection_check_boxes renders multiple checkboxes with values defined by lambda :value_method correctly' do collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')] - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, lambda { |a| "address_#{a.id}" }, :street) end test 'collection_check_boxes renders with checked option correctly with Proc :value_method' do collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')] - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, Proc.new { |a| "address_#{a.id}" }, :street, checked: "address_1") assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, Proc.new { |a| "address_#{a.id}" }, :street, checked: collection.first) @@ -134,11 +134,29 @@ def setup test 'collection_check_boxes renders with multiple checked options correctly with lambda :value_method' do collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')] - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, lambda { |a| "address_#{a.id}" }, :street, checked: ["address_1", "address_2"]) assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, lambda { |a| "address_#{a.id}" }, :street, checked: collection) end + test "check_box is wrapped correctly with custom option set" do + expected = %{
} + assert_equivalent_xml expected, @builder.check_box(:terms, {label: 'I agree to the terms', custom: true}) + end + + test "check_box is wrapped correctly with custom and inline options set" do + expected = %{
} + assert_equivalent_xml expected, @builder.check_box(:terms, {label: 'I agree to the terms', inline: true, custom: true}) + end + test "check_box is wrapped correctly with custom and disabled options set" do + expected = %{
} + assert_equivalent_xml expected, @builder.check_box(:terms, {label: 'I agree to the terms', disabled: true, custom: true}) + end + + test "check_box is wrapped correctly with custom, inline and disabled options set" do + expected = %{
} + assert_equivalent_xml expected, @builder.check_box(:terms, {label: 'I agree to the terms', inline: true, disabled: true, custom: true}) + end end diff --git a/test/bootstrap_fields_test.rb b/test/bootstrap_fields_test.rb index b7d9445c9..021c8a0e5 100644 --- a/test/bootstrap_fields_test.rb +++ b/test/bootstrap_fields_test.rb @@ -8,32 +8,32 @@ def setup end test "color fields are wrapped correctly" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.color_field(:misc) end test "date fields are wrapped correctly" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.date_field(:misc) end test "date time fields are wrapped correctly" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.datetime_field(:misc) end test "date time local fields are wrapped correctly" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.datetime_local_field(:misc) end test "email fields are wrapped correctly" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.email_field(:misc) end test "file fields are wrapped correctly" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.file_field(:misc) end @@ -43,58 +43,58 @@ def setup end test "month local fields are wrapped correctly" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.month_field(:misc) end test "number fields are wrapped correctly" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.number_field(:misc) end test "password fields are wrapped correctly" do - expected = %{
A good password should be at least six characters long
} + expected = %{
A good password should be at least six characters long
} assert_equivalent_xml expected, @builder.password_field(:password) end test "phone/telephone fields are wrapped correctly" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.phone_field(:misc) assert_equivalent_xml expected, @builder.telephone_field(:misc) end test "range fields are wrapped correctly" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.range_field(:misc) end test "search fields are wrapped correctly" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.search_field(:misc) end test "text areas are wrapped correctly" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.text_area(:comments) end test "text fields are wrapped correctly" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.text_field(:email) end test "time fields are wrapped correctly" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.time_field(:misc) end test "url fields are wrapped correctly" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.url_field(:misc) end test "week fields are wrapped correctly" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.week_field(:misc) end @@ -107,7 +107,7 @@ def setup end end - expected = %{
} + expected = %{
} assert_equivalent_xml expected, output end @@ -120,7 +120,7 @@ def setup end end - expected = %{
} + expected = %{
} assert_equivalent_xml expected, output end @@ -133,7 +133,7 @@ def setup end end - expected = %{
} + expected = %{
} assert_equivalent_xml expected, output end @@ -146,7 +146,7 @@ def setup end end - expected = %{
} + expected = %{
} assert_equivalent_xml expected, output end end diff --git a/test/bootstrap_form_group_test.rb b/test/bootstrap_form_group_test.rb index 5b2ac0acb..b41407e54 100644 --- a/test/bootstrap_form_group_test.rb +++ b/test/bootstrap_form_group_test.rb @@ -8,32 +8,32 @@ def setup end test "changing the label text via the label option parameter" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.text_field(:email, label: 'Email Address') end test "changing the label text via the html_options label hash" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.text_field(:email, label: {text: 'Email Address'}) end test "hiding a label" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.text_field(:email, hide_label: true) end test "adding a custom label class via the label_class parameter" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.text_field(:email, label_class: 'btn') end test "adding a custom label class via the html_options label hash" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.text_field(:email, label: {class: 'btn'}) end test "adding a custom label and changing the label text via the html_options label hash" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.text_field(:email, label: {class: 'btn', text: "Email Address"}) end @@ -43,22 +43,22 @@ def setup end test "preventing a label from having the required class" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.text_field(:email, skip_required: true) end test "adding prepend text" do - expected = %{
@
} + expected = %{
@
} assert_equivalent_xml expected, @builder.text_field(:email, prepend: '@') end test "adding append text" do - expected = %{
.00
} + expected = %{
.00
} assert_equivalent_xml expected, @builder.text_field(:email, append: '.00') end test "append and prepend button" do - prefix = %{
} + prefix = %{
} field = %{} button_prepend = %{} button_append = %{} @@ -73,22 +73,22 @@ def setup end test "adding both prepend and append text" do - expected = %{
$
.00
} + expected = %{
$
.00
} assert_equivalent_xml expected, @builder.text_field(:email, prepend: '$', append: '.00') end test "help messages for default forms" do - expected = %{
This is required
} + expected = %{
This is required
} assert_equivalent_xml expected, @builder.text_field(:email, help: 'This is required') end test "help messages for horizontal forms" do - expected = %{
This is required
} + expected = %{
This is required
} assert_equivalent_xml expected, @horizontal_builder.text_field(:email, help: "This is required") end test "help messages to look up I18n automatically" do - expected = %{
A good password should be at least six characters long
} + expected = %{
A good password should be at least six characters long
} assert_equivalent_xml expected, @builder.text_field(:password) end @@ -111,7 +111,7 @@ def setup end test "help messages to ignore translation when user disables help" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.text_field(:password, help: false) end @@ -120,7 +120,7 @@ def setup %{

Bar

}.html_safe end - expected = %{

Bar

} + expected = %{

Bar

} assert_equivalent_xml expected, output end @@ -138,7 +138,7 @@ def setup %{

Bar

}.html_safe end - expected = %{

Bar

} + expected = %{

Bar

} assert_equivalent_xml expected, output end @@ -165,7 +165,7 @@ def setup %{

Bar

}.html_safe end - expected = %{

Bar

} + expected = %{

Bar

} assert_equivalent_xml expected, output end @@ -177,12 +177,12 @@ def setup %{

Bar

}.html_safe end - expected = %{

Bar

} + expected = %{

Bar

can't be blank, is too short (minimum is 5 characters)
} assert_equivalent_xml expected, output end test "adds class to wrapped form_group by a field" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.search_field(:misc, wrapper_class: 'none-margin') end @@ -190,7 +190,7 @@ def setup @user.email = nil @user.valid? - expected = %{
} + expected = %{
can't be blank, is too short (minimum is 5 characters)
} assert_equivalent_xml expected, @builder.email_field(:email, wrapper_class: 'none-margin') end @@ -202,7 +202,7 @@ def setup f.text_field(:email, help: 'This is required', wrapper_class: 'none-margin') end - expected = %{
} + expected = %{
can't be blank, is too short (minimum is 5 characters)
} assert_equivalent_xml expected, output end @@ -225,7 +225,7 @@ def setup end test "adding an icon to a field" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.email_field(:misc, icon: 'ok') end @@ -237,17 +237,17 @@ def setup output = output + @horizontal_builder.text_field(:email) - expected = %{
Hallo
} + expected = %{
Hallo
} assert_equivalent_xml expected, output end test "adds data-attributes (or any other options) to wrapper" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.search_field(:misc, wrapper: { data: { foo: 'bar' } }) end test "passing options to a form control get passed through" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.text_field(:email, autofocus: true) end @@ -256,12 +256,12 @@ def setup nil end - expected = %{
} + expected = %{
} assert_equivalent_xml expected, output end test "custom form group layout option" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, bootstrap_form_for(@user, layout: :horizontal) { |f| f.email_field :email, layout: :inline } end @@ -284,7 +284,7 @@ def setup end test ":input_group_class should apply to input-group" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.email_field(:email, append: @builder.primary('Subscribe'), input_group_class: 'input-group-lg') end end diff --git a/test/bootstrap_form_test.rb b/test/bootstrap_form_test.rb index ff286ecc3..cf4fb5c60 100644 --- a/test/bootstrap_form_test.rb +++ b/test/bootstrap_form_test.rb @@ -18,12 +18,12 @@ def setup end test "horizontal-style forms" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, bootstrap_form_for(@user, layout: :horizontal) { |f| f.email_field :email } end test "existing styles aren't clobbered when specifying a form style" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, bootstrap_form_for(@user, layout: :horizontal, html: { class: "my-style" }) { |f| f.email_field :email } end @@ -33,12 +33,12 @@ def setup end test "bootstrap_form_tag acts like a form tag" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, bootstrap_form_tag(url: '/users') { |f| f.text_field :email, label: "Your Email" } end test "bootstrap_form_tag does not clobber custom options" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, bootstrap_form_tag(url: '/users') { |f| f.text_field :email, name: 'NAME', id: "ID" } end @@ -56,7 +56,7 @@ def setup @user.email = nil @user.valid? - expected = %{
} + expected = %{
} assert_equivalent_xml expected, bootstrap_form_for(@user, label_errors: true) { |f| f.text_field :email } end @@ -64,7 +64,7 @@ def setup @user.email = nil @user.valid? - expected = %{
can't be blank, is too short (minimum is 5 characters)
} + expected = %{
can't be blank, is too short (minimum is 5 characters)
} assert_equivalent_xml expected, bootstrap_form_for(@user, label_errors: true, inline_errors: true) { |f| f.text_field :email } end @@ -74,7 +74,7 @@ def setup @user.email = nil @user.valid? - expected = %{
can't be blank, is too short (minimum is 5 characters)
} + expected = %{
can't be blank, is too short (minimum is 5 characters)
} assert_equivalent_xml expected, bootstrap_form_for(@user, label_errors: true, inline_errors: true) { |f| f.text_field :email } I18n.backend.store_translations(:en, {activerecord: {attributes: {user: {email: nil}}}}) @@ -147,7 +147,7 @@ def setup end test "custom label width for horizontal forms" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, bootstrap_form_for(@user, layout: :horizontal) { |f| f.email_field :email, label_col: 'col-sm-1' } end @@ -157,7 +157,7 @@ def setup end test "custom input width for horizontal forms" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, bootstrap_form_for(@user, layout: :horizontal) { |f| f.email_field :email, control_col: 'col-sm-5' } end @@ -169,7 +169,7 @@ def setup f.text_field(:email, help: 'This is required') end - expected = %{
} + expected = %{
can't be blank, is too short (minimum is 5 characters)
} assert_equivalent_xml expected, output end @@ -181,7 +181,7 @@ def setup f.text_field(:email, help: 'This is required') end - expected = %{
} + expected = %{
can't be blank, is too short (minimum is 5 characters)
} assert_equivalent_xml expected, output end @@ -193,7 +193,7 @@ def setup f.text_field(:email, help: 'This is required') end - expected = %{
This is required
} + expected = %{
This is required
} assert_equivalent_xml expected, output end @@ -204,7 +204,7 @@ def setup f.text_field(:email) end - expected = %{
This is useful help
} + expected = %{
This is useful help
} assert_equivalent_xml expected, output I18n.backend.store_translations(:en, {activerecord: {help: {user: {email_html: nil}}}}) @@ -212,7 +212,7 @@ def setup test "allows the form object to be nil" do builder = BootstrapForm::FormBuilder.new :other_model, nil, self, {} - expected = %{
} + expected = %{
} assert_equivalent_xml expected, builder.text_field(:email) end diff --git a/test/bootstrap_other_components_test.rb b/test/bootstrap_other_components_test.rb index 0933c56f2..ea92ae609 100644 --- a/test/bootstrap_other_components_test.rb +++ b/test/bootstrap_other_components_test.rb @@ -10,7 +10,7 @@ def setup test "static control" do output = @horizontal_builder.static_control :email - expected = %{

steve@example.com

} + expected = %{

steve@example.com

} assert_equivalent_xml expected, output end @@ -19,7 +19,7 @@ def setup "this is a test" end - expected = %{

this is a test

} + expected = %{

this is a test

} assert_equivalent_xml expected, output end @@ -28,7 +28,7 @@ def setup "Custom Control" end - expected = %{

Custom Control

} + expected = %{

Custom Control

} assert_equivalent_xml expected, output end @@ -37,7 +37,7 @@ def setup "this is a test" end - expected = %{
this is a test
} + expected = %{
this is a test
} assert_equivalent_xml expected, output end @@ -46,7 +46,7 @@ def setup "this is a test" end - expected = %{
this is a test
} + expected = %{
this is a test
} assert_equivalent_xml expected, output end @@ -55,7 +55,7 @@ def setup "Custom Control" end - expected = %{
Custom Control
} + expected = %{
Custom Control
} assert_equivalent_xml expected, output end diff --git a/test/bootstrap_radio_button_test.rb b/test/bootstrap_radio_button_test.rb index 2ba720da1..cd4ca68b1 100644 --- a/test/bootstrap_radio_button_test.rb +++ b/test/bootstrap_radio_button_test.rb @@ -39,86 +39,104 @@ def setup test 'collection_radio_buttons renders the form_group correctly' do collection = [Address.new(id: 1, street: 'Foobar')] - expected = %{
With a help!
} + expected = %{
With a help!
} assert_equivalent_xml expected, @builder.collection_radio_buttons(:misc, collection, :id, :street, label: 'This is a radio button collection', help: 'With a help!') end test 'collection_radio_buttons renders multiple radios correctly' do collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')] - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.collection_radio_buttons(:misc, collection, :id, :street) end test 'collection_radio_buttons renders inline radios correctly' do collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')] - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.collection_radio_buttons(:misc, collection, :id, :street, inline: true) end test 'collection_radio_buttons renders with checked option correctly' do collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')] - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.collection_radio_buttons(:misc, collection, :id, :street, checked: 1) end test 'collection_radio_buttons renders label defined by Proc correctly' do collection = [Address.new(id: 1, street: 'Foobar')] - expected = %{
With a help!
} + expected = %{
With a help!
} assert_equivalent_xml expected, @builder.collection_radio_buttons(:misc, collection, :id, Proc.new { |a| a.street.reverse }, label: 'This is a radio button collection', help: 'With a help!') end test 'collection_radio_buttons renders value defined by Proc correctly' do collection = [Address.new(id: 1, street: 'Foobar')] - expected = %{
With a help!
} + expected = %{
With a help!
} assert_equivalent_xml expected, @builder.collection_radio_buttons(:misc, collection, Proc.new { |a| "address_#{a.id}" }, :street, label: 'This is a radio button collection', help: 'With a help!') end test 'collection_radio_buttons renders multiple radios with label defined by Proc correctly' do collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')] - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.collection_radio_buttons(:misc, collection, :id, Proc.new { |a| a.street.reverse }) end test 'collection_radio_buttons renders multiple radios with value defined by Proc correctly' do collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')] - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.collection_radio_buttons(:misc, collection, Proc.new { |a| "address_#{a.id}" }, :street) end test 'collection_radio_buttons renders label defined by lambda correctly' do collection = [Address.new(id: 1, street: 'Foobar')] - expected = %{
With a help!
} + expected = %{
With a help!
} assert_equivalent_xml expected, @builder.collection_radio_buttons(:misc, collection, :id, lambda { |a| a.street.reverse }, label: 'This is a radio button collection', help: 'With a help!') end test 'collection_radio_buttons renders value defined by lambda correctly' do collection = [Address.new(id: 1, street: 'Foobar')] - expected = %{
With a help!
} + expected = %{
With a help!
} assert_equivalent_xml expected, @builder.collection_radio_buttons(:misc, collection, lambda { |a| "address_#{a.id}" }, :street, label: 'This is a radio button collection', help: 'With a help!') end test 'collection_radio_buttons renders multiple radios with label defined by lambda correctly' do collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')] - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.collection_radio_buttons(:misc, collection, :id, lambda { |a| a.street.reverse }) end test 'collection_radio_buttons renders multiple radios with value defined by lambda correctly' do collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')] - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.collection_radio_buttons(:misc, collection, lambda { |a| "address_#{a.id}" }, :street) end + test "radio_button is wrapped correctly with custom option set" do + expected = %{
} + assert_equivalent_xml expected, @builder.radio_button(:misc, '1', {label: 'This is a radio button', custom: true}) + end + + test "radio_button is wrapped correctly with custom and inline options set" do + expected = %{
} + assert_equivalent_xml expected, @builder.radio_button(:misc, '1', {label: 'This is a radio button', inline: true, custom: true}) + end + + test "radio_button is wrapped correctly with custom and disabled options set" do + expected = %{
} + assert_equivalent_xml expected, @builder.radio_button(:misc, '1', {label: 'This is a radio button', disabled: true, custom: true}) + end + test "radio_button is wrapped correctly with custom, inline and disabled options set" do + expected = %{
} + assert_equivalent_xml expected, @builder.radio_button(:misc, '1', {label: 'This is a radio button', inline: true, disabled: true, custom: true}) + end end diff --git a/test/bootstrap_selects_test.rb b/test/bootstrap_selects_test.rb index 929130a82..a701a289b 100644 --- a/test/bootstrap_selects_test.rb +++ b/test/bootstrap_selects_test.rb @@ -8,34 +8,34 @@ def setup end test "time zone selects are wrapped correctly" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.time_zone_select(:misc) end test "selects are wrapped correctly" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.select(:status, [['activated', 1], ['blocked', 2]]) end test "bootstrap_specific options are handled correctly" do - expected = %{
Help!
} + expected = %{
Help!
} assert_equivalent_xml expected, @builder.select(:status, [['activated', 1], ['blocked', 2]], label: "My Status Label", help: "Help!" ) end test "selects with options are wrapped correctly" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.select(:status, [['activated', 1], ['blocked', 2]], prompt: "Please Select") end test "selects with both options and html_options are wrapped correctly" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.select(:status, [['activated', 1], ['blocked', 2]], { prompt: "Please Select" }, class: "my-select") end test 'selects with addons are wrapped correctly' do expected = <<-HTML.strip_heredoc
- +
Before
} + expected = %{
} select = @builder.select(:status) do content_tag(:option) { 'Option 1' } + content_tag(:option) { 'Option 2' } @@ -61,99 +61,99 @@ def setup end test "selects render labels properly" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.select(:status, [['activated', 1], ['blocked', 2]], label: "User Status") end test "collection_selects are wrapped correctly" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.collection_select(:status, [], :id, :name) end test "collection_selects with options are wrapped correctly" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.collection_select(:status, [], :id, :name, prompt: "Please Select") end test "collection_selects with options and html_options are wrapped correctly" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.collection_select(:status, [], :id, :name, { prompt: "Please Select" }, class: "my-select") end test "grouped_collection_selects are wrapped correctly" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.grouped_collection_select(:status, [], :last, :first, :to_s, :to_s) end test "grouped_collection_selects with options are wrapped correctly" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.grouped_collection_select(:status, [], :last, :first, :to_s, :to_s, prompt: "Please Select") end test "grouped_collection_selects with options and html_options are wrapped correctly" do - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.grouped_collection_select(:status, [], :last, :first, :to_s, :to_s, { prompt: "Please Select" }, class: "my-select") end test "date selects are wrapped correctly" do Timecop.freeze(Time.utc(2012, 2, 3)) do - expected = %{
\n\n\n
} + expected = %{
\n\n\n
} assert_equivalent_xml expected, @builder.date_select(:misc) end end test "date selects with options are wrapped correctly" do Timecop.freeze(Time.utc(2012, 2, 3)) do - expected = %{
\n\n\n
} + expected = %{
\n\n\n
} assert_equivalent_xml expected, @builder.date_select(:misc, include_blank: true) end end test "date selects with options and html_options are wrapped correctly" do Timecop.freeze(Time.utc(2012, 2, 3)) do - expected = %{
\n\n\n
} + expected = %{
\n\n\n
} assert_equivalent_xml expected, @builder.date_select(:misc, { include_blank: true }, class: "my-date-select") end end test "time selects are wrapped correctly" do Timecop.freeze(Time.utc(2012, 2, 3, 12, 0, 0)) do - expected = %{
\n\n\n\n : \n
} + expected = %{
\n\n\n\n : \n
} assert_equivalent_xml expected, @builder.time_select(:misc) end end test "time selects with options are wrapped correctly" do Timecop.freeze(Time.utc(2012, 2, 3, 12, 0, 0)) do - expected = %{
\n\n\n\n : \n
} + expected = %{
\n\n\n\n : \n
} assert_equivalent_xml expected, @builder.time_select(:misc, include_blank: true) end end test "time selects with options and html_options are wrapped correctly" do Timecop.freeze(Time.utc(2012, 2, 3, 12, 0, 0)) do - expected = %{
\n\n\n\n : \n
} + expected = %{
\n\n\n\n : \n
} assert_equivalent_xml expected, @builder.time_select(:misc, { include_blank: true }, class: "my-time-select") end end test "datetime selects are wrapped correctly" do Timecop.freeze(Time.utc(2012, 2, 3, 12, 0, 0)) do - expected = %{
\n\n\n — \n : \n
} + expected = %{
\n\n\n — \n : \n
} assert_equivalent_xml expected, @builder.datetime_select(:misc) end end test "datetime selects with options are wrapped correctly" do Timecop.freeze(Time.utc(2012, 2, 3, 12, 0, 0)) do - expected = %{
\n\n\n — \n : \n
} + expected = %{
\n\n\n — \n : \n
} assert_equivalent_xml expected, @builder.datetime_select(:misc, include_blank: true) end end test "datetime selects with options and html_options are wrapped correctly" do Timecop.freeze(Time.utc(2012, 2, 3, 12, 0, 0)) do - expected = %{
\n\n\n — \n : \n
} + expected = %{
\n\n\n — \n : \n
} assert_equivalent_xml expected, @builder.datetime_select(:misc, { include_blank: true }, class: "my-datetime-select") end end diff --git a/test/special_form_class_models_test.rb b/test/special_form_class_models_test.rb index cc88f836a..5c3e428e0 100644 --- a/test/special_form_class_models_test.rb +++ b/test/special_form_class_models_test.rb @@ -14,7 +14,7 @@ def user_klass.model_name @horizontal_builder = BootstrapForm::FormBuilder.new(:user, @user, self, {layout: :horizontal, label_col: "col-sm-2", control_col: "col-sm-10"}) I18n.backend.store_translations(:en, {activerecord: {help: {user: {password: "A good password should be at least six characters long"}}}}) - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.date_field(:misc) end @@ -24,7 +24,7 @@ def user_klass.model_name @horizontal_builder = BootstrapForm::FormBuilder.new(:user, @user, self, {layout: :horizontal, label_col: "col-sm-2", control_col: "col-sm-10"}) I18n.backend.store_translations(:en, {activerecord: {help: {user: {password: "A good password should be at least six characters long"}}}}) - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.date_field(:misc) end @@ -36,7 +36,7 @@ def user_klass.model_name @horizontal_builder = BootstrapForm::FormBuilder.new(:user, @user, self, {layout: :horizontal, label_col: "col-sm-2", control_col: "col-sm-10"}) I18n.backend.store_translations(:en, {activerecord: {help: {faux_user: {password: "A good password should be at least six characters long"}}}}) - expected = %{
} + expected = %{
} assert_equivalent_xml expected, @builder.date_field(:misc) end From 00d391d1a4e76d863bad054a65945ce93a38bf76 Mon Sep 17 00:00:00 2001 From: Oleg Date: Fri, 12 Jan 2018 23:10:52 -0800 Subject: [PATCH 022/112] putting minitest dependency in the right place --- Gemfile | 5 +++-- test/gemfiles/5.0.gemfile | 2 +- test/gemfiles/5.1.gemfile | 1 + test/gemfiles/5.2.gemfile | 3 +++ 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 1112f4f7b..28b5c1a0e 100644 --- a/Gemfile +++ b/Gemfile @@ -10,11 +10,12 @@ group :development do end group :test do + # can relax version requirement for Rails 5.2.beta3+ + gem "minitest", "~> 5.10.3" + gem "diffy" gem "equivalent-xml" gem "mocha" gem "sqlite3" gem "timecop", "~> 0.7.1" end - -gem "minitest", "~> 5.10.3" diff --git a/test/gemfiles/5.0.gemfile b/test/gemfiles/5.0.gemfile index 4408d2821..99678fadb 100644 --- a/test/gemfiles/5.0.gemfile +++ b/test/gemfiles/5.0.gemfile @@ -5,10 +5,10 @@ gemspec path: "../../" gem "rails", "~> 5.0.0" group :test do + gem "minitest", "~> 5.10.3" gem "diffy" gem "equivalent-xml" gem "mocha" gem "sqlite3" gem "timecop", "~> 0.7.1" end - diff --git a/test/gemfiles/5.1.gemfile b/test/gemfiles/5.1.gemfile index d8f773078..0ef34fe8b 100644 --- a/test/gemfiles/5.1.gemfile +++ b/test/gemfiles/5.1.gemfile @@ -5,6 +5,7 @@ gemspec path: "../../" gem "rails", "~> 5.1.0" group :test do + gem "minitest", "~> 5.10.3" gem "diffy" gem "equivalent-xml" gem "mocha" diff --git a/test/gemfiles/5.2.gemfile b/test/gemfiles/5.2.gemfile index c9b967421..a93e39912 100644 --- a/test/gemfiles/5.2.gemfile +++ b/test/gemfiles/5.2.gemfile @@ -5,6 +5,9 @@ gemspec path: "../../" gem "rails", "~> 5.2.0.beta2" group :test do + # can relax version requirement for Rails 5.2.beta3+ + gem "minitest", "~> 5.10.3" + gem "diffy" gem "equivalent-xml" gem "mocha" From 737b09ea934ff8ea0e157da90f8f059dfe25c3b8 Mon Sep 17 00:00:00 2001 From: Oleg Date: Sat, 13 Jan 2018 09:07:36 -0800 Subject: [PATCH 023/112] [v4] Formatting tests to use heredoc for html blobs (#368) * formatting bootstrap_checkbox_test.rb * formatting for bootstrao_fields_test. why assertion was not picking up hidden field wrapper? * done with form_group_test * formatted form_test * formatting other_components_test * heredoc for radio_button_test * heredoc for form_class_models_test * heredoc for selects_test * formatting new tests --- test/bootstrap_checkbox_test.rb | 337 +++++++++++++++++++++--- test/bootstrap_fields_test.rb | 168 ++++++++++-- test/bootstrap_form_group_test.rb | 307 ++++++++++++++++++--- test/bootstrap_form_test.rb | 299 +++++++++++++++++---- test/bootstrap_other_components_test.rb | 54 +++- test/bootstrap_radio_button_test.rb | 252 ++++++++++++++++-- test/bootstrap_selects_test.rb | 336 +++++++++++++++++++++-- test/special_form_class_models_test.rb | 23 +- 8 files changed, 1571 insertions(+), 205 deletions(-) diff --git a/test/bootstrap_checkbox_test.rb b/test/bootstrap_checkbox_test.rb index 78f192831..0993a6ca5 100644 --- a/test/bootstrap_checkbox_test.rb +++ b/test/bootstrap_checkbox_test.rb @@ -1,81 +1,204 @@ -require 'test_helper' +require_relative "./test_helper" class BootstrapCheckboxTest < ActionView::TestCase include BootstrapForm::Helper - def setup - setup_test_fixture - end + setup :setup_test_fixture test "check_box is wrapped correctly" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ +
+ HTML assert_equivalent_xml expected, @builder.check_box(:terms, label: 'I agree to the terms') end test "disabled check_box has proper wrapper classes" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ +
+ HTML assert_equivalent_xml expected, @builder.check_box(:terms, label: 'I agree to the terms', disabled: true) end test "check_box label allows html" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ +
+ HTML assert_equivalent_xml expected, @builder.check_box(:terms, label: %{I agree to the terms}.html_safe) end test "check_box accepts a block to define the label" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ +
+ HTML assert_equivalent_xml expected, @builder.check_box(:terms) { "I agree to the terms" } end test "check_box accepts a custom label class" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ +
+ HTML assert_equivalent_xml expected, @builder.check_box(:terms, label_class: 'btn') end test "check_box responds to checked_value and unchecked_value arguments" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ +
+ HTML assert_equivalent_xml expected, @builder.check_box(:terms, {label: 'I agree to the terms'}, 'yes', 'no') end test "inline checkboxes" do - expected = %{} + expected = <<-HTML.strip_heredoc + + HTML assert_equivalent_xml expected, @builder.check_box(:terms, label: 'I agree to the terms', inline: true) end test "disabled inline check_box" do - expected = %{} + expected = <<-HTML.strip_heredoc + + HTML assert_equivalent_xml expected, @builder.check_box(:terms, label: 'I agree to the terms', inline: true, disabled: true) end test "inline checkboxes with custom label class" do - expected = %{} + expected = <<-HTML.strip_heredoc + + HTML assert_equivalent_xml expected, @builder.check_box(:terms, inline: true, label_class: 'btn') end test 'collection_check_boxes renders the form_group correctly' do collection = [Address.new(id: 1, street: 'Foobar')] - expected = %{
With a help!
} + expected = <<-HTML.strip_heredoc + +
+ +
+ +
+ With a help! +
+ HTML assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, :id, :street, label: 'This is a checkbox collection', help: 'With a help!') end test 'collection_check_boxes renders multiple checkboxes correctly' do collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')] - expected = %{
} + expected = <<-HTML.strip_heredoc + +
+ +
+ +
+
+ +
+
+ HTML assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, :id, :street) end test 'collection_check_boxes renders inline checkboxes correctly' do collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')] - expected = %{
} + expected = <<-HTML.strip_heredoc + +
+ + + +
+ HTML assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, :id, :street, inline: true) end test 'collection_check_boxes renders with checked option correctly' do collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')] - expected = %{
} + expected = <<-HTML.strip_heredoc + +
+ +
+ +
+
+ +
+
+ HTML assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, :id, :street, checked: 1) assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, :id, :street, checked: collection.first) @@ -83,7 +206,24 @@ def setup test 'collection_check_boxes renders with multiple checked options correctly' do collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')] - expected = %{
} + expected = <<-HTML.strip_heredoc + +
+ +
+ +
+
+ +
+
+ HTML assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, :id, :street, checked: [1, 2]) assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, :id, :street, checked: collection) @@ -91,42 +231,136 @@ def setup test 'collection_check_boxes sanitizes values when generating label `for`' do collection = [Address.new(id: 1, street: 'Foo St')] - expected = %{
} - + expected = <<-HTML.strip_heredoc + +
+ +
+ +
+
+ HTML assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, :street, :street) end test 'collection_check_boxes renders multiple checkboxes with labels defined by Proc :text_method correctly' do collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')] - expected = %{
} + expected = <<-HTML.strip_heredoc + +
+ +
+ +
+
+ +
+
+ HTML assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, :id, Proc.new { |a| a.street.reverse }) end test 'collection_check_boxes renders multiple checkboxes with values defined by Proc :value_method correctly' do collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')] - expected = %{
} - + expected = <<-HTML.strip_heredoc + +
+ +
+ +
+
+ +
+
+ HTML assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, Proc.new { |a| "address_#{a.id}" }, :street) end test 'collection_check_boxes renders multiple checkboxes with labels defined by lambda :text_method correctly' do collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')] - expected = %{
} + expected = <<-HTML.strip_heredoc + +
+ +
+ +
+
+ +
+
+ HTML assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, :id, lambda { |a| a.street.reverse }) end test 'collection_check_boxes renders multiple checkboxes with values defined by lambda :value_method correctly' do collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')] - expected = %{
} + expected = <<-HTML.strip_heredoc + +
+ +
+ +
+
+ +
+
+ HTML assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, lambda { |a| "address_#{a.id}" }, :street) end test 'collection_check_boxes renders with checked option correctly with Proc :value_method' do collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')] - expected = %{
} + expected = <<-HTML.strip_heredoc + +
+ +
+ +
+
+ +
+
+ HTML assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, Proc.new { |a| "address_#{a.id}" }, :street, checked: "address_1") assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, Proc.new { |a| "address_#{a.id}" }, :street, checked: collection.first) @@ -134,29 +368,70 @@ def setup test 'collection_check_boxes renders with multiple checked options correctly with lambda :value_method' do collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')] - expected = %{
} + expected = <<-HTML.strip_heredoc + +
+ +
+ +
+
+ +
+
+ HTML assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, lambda { |a| "address_#{a.id}" }, :street, checked: ["address_1", "address_2"]) assert_equivalent_xml expected, @builder.collection_check_boxes(:misc, collection, lambda { |a| "address_#{a.id}" }, :street, checked: collection) end test "check_box is wrapped correctly with custom option set" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + + +
+ HTML assert_equivalent_xml expected, @builder.check_box(:terms, {label: 'I agree to the terms', custom: true}) end test "check_box is wrapped correctly with custom and inline options set" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + + +
+ HTML assert_equivalent_xml expected, @builder.check_box(:terms, {label: 'I agree to the terms', inline: true, custom: true}) end test "check_box is wrapped correctly with custom and disabled options set" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + + +
+ HTML assert_equivalent_xml expected, @builder.check_box(:terms, {label: 'I agree to the terms', disabled: true, custom: true}) end test "check_box is wrapped correctly with custom, inline and disabled options set" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + + +
+ HTML assert_equivalent_xml expected, @builder.check_box(:terms, {label: 'I agree to the terms', inline: true, disabled: true, custom: true}) end end diff --git a/test/bootstrap_fields_test.rb b/test/bootstrap_fields_test.rb index 021c8a0e5..dcba190b9 100644 --- a/test/bootstrap_fields_test.rb +++ b/test/bootstrap_fields_test.rb @@ -1,39 +1,67 @@ -require 'test_helper' +require_relative "./test_helper" class BootstrapFieldsTest < ActionView::TestCase include BootstrapForm::Helper - def setup - setup_test_fixture - end + setup :setup_test_fixture test "color fields are wrapped correctly" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.color_field(:misc) end test "date fields are wrapped correctly" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.date_field(:misc) end test "date time fields are wrapped correctly" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.datetime_field(:misc) end test "date time local fields are wrapped correctly" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.datetime_local_field(:misc) end test "email fields are wrapped correctly" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.email_field(:misc) end test "file fields are wrapped correctly" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.file_field(:misc) end @@ -43,58 +71,114 @@ def setup end test "month local fields are wrapped correctly" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.month_field(:misc) end test "number fields are wrapped correctly" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.number_field(:misc) end test "password fields are wrapped correctly" do - expected = %{
A good password should be at least six characters long
} + expected = <<-HTML.strip_heredoc +
+ + + A good password should be at least six characters long +
+ HTML assert_equivalent_xml expected, @builder.password_field(:password) end test "phone/telephone fields are wrapped correctly" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.phone_field(:misc) assert_equivalent_xml expected, @builder.telephone_field(:misc) end test "range fields are wrapped correctly" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.range_field(:misc) end test "search fields are wrapped correctly" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.search_field(:misc) end test "text areas are wrapped correctly" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.text_area(:comments) end test "text fields are wrapped correctly" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.text_field(:email) end test "time fields are wrapped correctly" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.time_field(:misc) end test "url fields are wrapped correctly" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.url_field(:misc) end test "week fields are wrapped correctly" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.week_field(:misc) end @@ -107,7 +191,15 @@ def setup end end - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ +
+ + +
+
+ HTML assert_equivalent_xml expected, output end @@ -120,7 +212,15 @@ def setup end end - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ +
+ + +
+
+ HTML assert_equivalent_xml expected, output end @@ -133,7 +233,17 @@ def setup end end - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ +
+ +
+ +
+
+
+ HTML assert_equivalent_xml expected, output end @@ -146,7 +256,15 @@ def setup end end - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ +
+ + +
+
+ HTML assert_equivalent_xml expected, output end end diff --git a/test/bootstrap_form_group_test.rb b/test/bootstrap_form_group_test.rb index b41407e54..d0332578c 100644 --- a/test/bootstrap_form_group_test.rb +++ b/test/bootstrap_form_group_test.rb @@ -1,59 +1,116 @@ -require 'test_helper' +require_relative "./test_helper" class BootstrapFormGroupTest < ActionView::TestCase include BootstrapForm::Helper - def setup - setup_test_fixture - end + setup :setup_test_fixture test "changing the label text via the label option parameter" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.text_field(:email, label: 'Email Address') end test "changing the label text via the html_options label hash" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.text_field(:email, label: {text: 'Email Address'}) end test "hiding a label" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.text_field(:email, hide_label: true) end test "adding a custom label class via the label_class parameter" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.text_field(:email, label_class: 'btn') end test "adding a custom label class via the html_options label hash" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.text_field(:email, label: {class: 'btn'}) end test "adding a custom label and changing the label text via the html_options label hash" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.text_field(:email, label: {class: 'btn', text: "Email Address"}) end test "skipping a label" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ +
+ HTML assert_equivalent_xml expected, @builder.text_field(:email, skip_label: true) end test "preventing a label from having the required class" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.text_field(:email, skip_required: true) end test "adding prepend text" do - expected = %{
@
} + expected = <<-HTML.strip_heredoc +
+ +
+
+ @ +
+ +
+
+ HTML assert_equivalent_xml expected, @builder.text_field(:email, prepend: '@') end test "adding append text" do - expected = %{
.00
} + expected = <<-HTML.strip_heredoc +
+ +
+ +
+ .00 +
+
+
+ HTML assert_equivalent_xml expected, @builder.text_field(:email, append: '.00') end @@ -73,22 +130,55 @@ def setup end test "adding both prepend and append text" do - expected = %{
$
.00
} + expected = <<-HTML.strip_heredoc +
+ +
+
+ $
+
+ +
+ .00 +
+
+
+ HTML assert_equivalent_xml expected, @builder.text_field(:email, prepend: '$', append: '.00') end test "help messages for default forms" do - expected = %{
This is required
} + expected = <<-HTML.strip_heredoc +
+ + + This is required +
+ HTML assert_equivalent_xml expected, @builder.text_field(:email, help: 'This is required') end test "help messages for horizontal forms" do - expected = %{
This is required
} + expected = <<-HTML.strip_heredoc +
+ +
+ + This is required +
+
+ HTML assert_equivalent_xml expected, @horizontal_builder.text_field(:email, help: "This is required") end test "help messages to look up I18n automatically" do - expected = %{
A good password should be at least six characters long
} + expected = <<-HTML.strip_heredoc +
+ + + A good password should be at least six characters long +
+ HTML assert_equivalent_xml expected, @builder.text_field(:password) end @@ -111,7 +201,12 @@ def setup end test "help messages to ignore translation when user disables help" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.text_field(:password, help: false) end @@ -120,7 +215,14 @@ def setup %{

Bar

}.html_safe end - expected = %{

Bar

} + expected = <<-HTML.strip_heredoc +
+ +
+

Bar

+
+
+ HTML assert_equivalent_xml expected, output end @@ -129,7 +231,13 @@ def setup %{

Bar

}.html_safe end - expected = %{

Bar

} + expected = <<-HTML.strip_heredoc +
+
+

Bar

+
+
+ HTML assert_equivalent_xml expected, output end @@ -138,7 +246,14 @@ def setup %{

Bar

}.html_safe end - expected = %{

Bar

} + expected = <<-HTML.strip_heredoc +
+ +
+

Bar

+
+
+ HTML assert_equivalent_xml expected, output end @@ -147,7 +262,13 @@ def setup %{

Bar

}.html_safe end - expected = %{

Bar

} + expected = <<-HTML.strip_heredoc +
+
+

Bar

+
+
+ HTML assert_equivalent_xml expected, output end @@ -156,7 +277,13 @@ def setup %{

Bar

}.html_safe end - expected = %{

Bar

} + expected = <<-HTML.strip_heredoc +
+
+

Bar

+
+
+ HTML assert_equivalent_xml expected, output end @@ -165,7 +292,14 @@ def setup %{

Bar

}.html_safe end - expected = %{

Bar

} + expected = <<-HTML.strip_heredoc +
+ +
+

Bar

+
+
+ HTML assert_equivalent_xml expected, output end @@ -177,12 +311,22 @@ def setup %{

Bar

}.html_safe end - expected = %{

Bar

can't be blank, is too short (minimum is 5 characters)
} + expected = <<-HTML.strip_heredoc +
+

Bar

+
can't be blank, is too short (minimum is 5 characters)
+
+ HTML assert_equivalent_xml expected, output end test "adds class to wrapped form_group by a field" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.search_field(:misc, wrapper_class: 'none-margin') end @@ -190,7 +334,17 @@ def setup @user.email = nil @user.valid? - expected = %{
can't be blank, is too short (minimum is 5 characters)
} + expected = <<-HTML.strip_heredoc +
+
+ +
+
+ +
+
can't be blank, is too short (minimum is 5 characters)
+
+ HTML assert_equivalent_xml expected, @builder.email_field(:email, wrapper_class: 'none-margin') end @@ -202,7 +356,16 @@ def setup f.text_field(:email, help: 'This is required', wrapper_class: 'none-margin') end - expected = %{
can't be blank, is too short (minimum is 5 characters)
} + expected = <<-HTML.strip_heredoc +
+ +
+ + +
can't be blank, is too short (minimum is 5 characters)
+
+
+ HTML assert_equivalent_xml expected, output end @@ -211,7 +374,13 @@ def setup @horizontal_builder.submit end - expected = %{
} + expected = <<-HTML.strip_heredoc +
+
+ +
+
+ HTML assert_equivalent_xml expected, output end @@ -220,12 +389,24 @@ def setup @horizontal_builder.submit end - expected = %{
} + expected = <<-HTML.strip_heredoc +
+
+ +
+
+ HTML assert_equivalent_xml expected, output end test "adding an icon to a field" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + + +
+ HTML assert_equivalent_xml expected, @builder.email_field(:misc, icon: 'ok') end @@ -237,17 +418,37 @@ def setup output = output + @horizontal_builder.text_field(:email) - expected = %{
Hallo
} + expected = <<-HTML.strip_heredoc +
+
Hallo
+
+
+ +
+ +
+
+ HTML assert_equivalent_xml expected, output end test "adds data-attributes (or any other options) to wrapper" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.search_field(:misc, wrapper: { data: { foo: 'bar' } }) end test "passing options to a form control get passed through" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.text_field(:email, autofocus: true) end @@ -256,12 +457,24 @@ def setup nil end - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ +
+ HTML assert_equivalent_xml expected, output end test "custom form group layout option" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ +
+ + +
+
+ HTML assert_equivalent_xml expected, bootstrap_form_for(@user, layout: :horizontal) { |f| f.email_field :email, layout: :inline } end @@ -271,7 +484,13 @@ def setup %{

Bar

}.html_safe end - expected = %{

Bar

} + expected = <<-HTML.strip_heredoc +
+
+

Bar

+
+
+ HTML assert_equivalent_xml expected, output end @@ -284,7 +503,17 @@ def setup end test ":input_group_class should apply to input-group" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ +
+ +
+ +
+
+
+ HTML assert_equivalent_xml expected, @builder.email_field(:email, append: @builder.primary('Subscribe'), input_group_class: 'input-group-lg') end end diff --git a/test/bootstrap_form_test.rb b/test/bootstrap_form_test.rb index cf4fb5c60..b96850b2a 100644 --- a/test/bootstrap_form_test.rb +++ b/test/bootstrap_form_test.rb @@ -1,47 +1,94 @@ -require 'test_helper' +require_relative "./test_helper" class BootstrapFormTest < ActionView::TestCase include BootstrapForm::Helper - def setup - setup_test_fixture - end + setup :setup_test_fixture test "default-style forms" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ +
+ HTML assert_equivalent_xml expected, bootstrap_form_for(@user) { |f| nil } end test "inline-style forms" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ +
+ HTML assert_equivalent_xml expected, bootstrap_form_for(@user, layout: :inline) { |f| nil } end test "horizontal-style forms" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ +
+ +
+ +
+
+
+ HTML assert_equivalent_xml expected, bootstrap_form_for(@user, layout: :horizontal) { |f| f.email_field :email } end test "existing styles aren't clobbered when specifying a form style" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ +
+ +
+ +
+
+
+ HTML assert_equivalent_xml expected, 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 - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ +
+ HTML assert_equivalent_xml expected, bootstrap_form_for(@user, html: { role: 'not-a-form'}) {|f| nil} end test "bootstrap_form_tag acts like a form tag" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ +
+ + +
+
+ HTML assert_equivalent_xml expected, bootstrap_form_tag(url: '/users') { |f| f.text_field :email, label: "Your Email" } end test "bootstrap_form_tag does not clobber custom options" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ +
+ + +
+
+ HTML assert_equivalent_xml expected, bootstrap_form_tag(url: '/users') { |f| f.text_field :email, name: 'NAME', id: "ID" } end + # TODO: difference in rendering between 5.0 and 5.1? test "bootstrap_form_tag allows an empty name for checkboxes" do checkbox = if ::Rails::VERSION::STRING >= '5.1' %{
} @@ -56,7 +103,15 @@ def setup @user.email = nil @user.valid? - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ +
+ + +
+
+ HTML assert_equivalent_xml expected, bootstrap_form_for(@user, label_errors: true) { |f| f.text_field :email } end @@ -64,33 +119,72 @@ def setup @user.email = nil @user.valid? - expected = %{
can't be blank, is too short (minimum is 5 characters)
} + expected = <<-HTML.strip_heredoc +
+ +
+ + +
can't be blank, is too short (minimum is 5 characters) +
+ + HTML assert_equivalent_xml expected, bootstrap_form_for(@user, label_errors: true, inline_errors: true) { |f| f.text_field :email } end test "label error messages use humanized attribute names" do - I18n.backend.store_translations(:en, {activerecord: {attributes: {user: {email: 'Your e-mail address'}}}}) - - @user.email = nil - @user.valid? - - expected = %{
can't be blank, is too short (minimum is 5 characters)
} - assert_equivalent_xml expected, bootstrap_form_for(@user, label_errors: true, inline_errors: true) { |f| f.text_field :email } - - I18n.backend.store_translations(:en, {activerecord: {attributes: {user: {email: nil}}}}) + begin + I18n.backend.store_translations(:en, {activerecord: {attributes: {user: {email: 'Your e-mail address'}}}}) + + @user.email = nil + @user.valid? + + expected = <<-HTML.strip_heredoc +
+ +
+ + +
can't be blank, is too short (minimum is 5 characters)
+
+
+ HTML + assert_equivalent_xml expected, bootstrap_form_for(@user, label_errors: true, inline_errors: true) { |f| f.text_field :email } + + ensure + I18n.backend.store_translations(:en, {activerecord: {attributes: {user: {email: nil}}}}) + end end test "alert message is wrapped correctly" do @user.email = nil @user.valid? - expected = %{

Please fix the following errors:

  • Email can't be blank
  • Email is too short (minimum is 5 characters)
  • Terms must be accepted
} + expected = <<-HTML.strip_heredoc +
+

Please fix the following errors:

+
    +
  • Email can't be blank
  • +
  • Email is too short (minimum is 5 characters)
  • +
  • Terms must be accepted
  • +
+
+ HTML assert_equivalent_xml expected, @builder.alert_message('Please fix the following errors:') end test "changing the class name for the alert message" do @user.email = nil @user.valid? - expected = %{

Please fix the following errors:

  • Email can't be blank
  • Email is too short (minimum is 5 characters)
  • Terms must be accepted
} + expected = <<-HTML.strip_heredoc +
+

Please fix the following errors:

+
    +
  • Email can't be blank
  • +
  • Email is too short (minimum is 5 characters)
  • +
  • Terms must be accepted
  • +
+
+ HTML assert_equivalent_xml expected, @builder.alert_message('Please fix the following errors:', class: 'my-css-class') end @@ -102,7 +196,19 @@ def setup f.alert_message('Please fix the following errors:') end - expected = %{

Please fix the following errors:

  • Email can't be blank
  • Email is too short (minimum is 5 characters)
  • Terms must be accepted
} + expected = <<-HTML.strip_heredoc +
+ +
+

Please fix the following errors:

+
    +
  • Email can't be blank
  • +
  • Email is too short (minimum is 5 characters)
  • +
  • Terms must be accepted
  • +
+
+
+ HTML assert_equivalent_xml expected, output end @@ -114,7 +220,14 @@ def setup f.alert_message('Please fix the following errors:', error_summary: false) end - expected = %{

Please fix the following errors:

} + expected = <<-HTML.strip_heredoc +
+ +
+

Please fix the following errors:

+
+
+ HTML assert_equivalent_xml expected, output end @@ -126,7 +239,19 @@ def setup f.alert_message('Please fix the following errors:', error_summary: true) end - expected = %{

Please fix the following errors:

  • Email can't be blank
  • Email is too short (minimum is 5 characters)
  • Terms must be accepted
} + expected = <<-HTML.strip_heredoc +
+ +
+

Please fix the following errors:

+
    +
  • Email can't be blank
  • +
  • Email is too short (minimum is 5 characters)
  • +
  • Terms must be accepted
  • +
+
+
+ HTML assert_equivalent_xml expected, output end @@ -134,7 +259,13 @@ def setup @user.email = nil @user.valid? - expected = %{
  • Email can't be blank
  • Email is too short (minimum is 5 characters)
  • Terms must be accepted
} + expected = <<-HTML.strip_heredoc +
    +
  • Email can't be blank
  • +
  • Email is too short (minimum is 5 characters)
  • +
  • Terms must be accepted
  • +
+ HTML assert_equivalent_xml expected, @builder.error_summary end @@ -142,22 +273,53 @@ def setup @user.email = nil @user.valid? - expected = %{
Email can't be blank, Email is too short (minimum is 5 characters)
} + expected = <<-HTML.strip_heredoc +
Email can't be blank, Email is too short (minimum is 5 characters)
+ HTML assert_equivalent_xml expected, @builder.errors_on(:email) end test "custom label width for horizontal forms" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ +
+ +
+ +
+
+
+ HTML assert_equivalent_xml expected, 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 - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ +
+
+ +
+
+
+ HTML assert_equivalent_xml expected, bootstrap_form_for(@user, layout: :horizontal, label_col: 'col-md-2', control_col: 'col-md-10') { |f| f.form_group { f.submit } } end test "custom input width for horizontal forms" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ +
+ +
+ +
+
+
+ HTML assert_equivalent_xml expected, bootstrap_form_for(@user, layout: :horizontal) { |f| f.email_field :email, control_col: 'col-sm-5' } end @@ -169,7 +331,16 @@ def setup f.text_field(:email, help: 'This is required') end - expected = %{
can't be blank, is too short (minimum is 5 characters)
} + expected = <<-HTML.strip_heredoc +
+ +
+ + +
can't be blank, is too short (minimum is 5 characters)
+
+
+ HTML assert_equivalent_xml expected, output end @@ -181,7 +352,20 @@ def setup f.text_field(:email, help: 'This is required') end - expected = %{
can't be blank, is too short (minimum is 5 characters)
} + expected = <<-HTML.strip_heredoc +
+ +
+
+ +
+
+ +
+
can't be blank, is too short (minimum is 5 characters) +
+ + HTML assert_equivalent_xml expected, output end @@ -193,26 +377,51 @@ def setup f.text_field(:email, help: 'This is required') end - expected = %{
This is required
} + expected = <<-HTML.strip_heredoc +
+ +
+ + + This is required +
+
+ HTML assert_equivalent_xml expected, output end test "help translations do not escape HTML when _html is appended to the name" do - I18n.backend.store_translations(:en, {activerecord: {help: {user: {email_html: "This is useful help"}}}}) - - output = bootstrap_form_for(@user) do |f| - f.text_field(:email) + begin + I18n.backend.store_translations(:en, {activerecord: {help: {user: {email_html: "This is useful help"}}}}) + + output = bootstrap_form_for(@user) do |f| + f.text_field(:email) + end + + expected = <<-HTML.strip_heredoc +
+ +
+ + + This is useful help +
+
+ HTML + assert_equivalent_xml expected, output + ensure + I18n.backend.store_translations(:en, {activerecord: {help: {user: {email_html: nil}}}}) end - - expected = %{
This is useful help
} - assert_equivalent_xml expected, output - - I18n.backend.store_translations(:en, {activerecord: {help: {user: {email_html: nil}}}}) end test "allows the form object to be nil" do builder = BootstrapForm::FormBuilder.new :other_model, nil, self, {} - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, builder.text_field(:email) end diff --git a/test/bootstrap_other_components_test.rb b/test/bootstrap_other_components_test.rb index ea92ae609..f8e1d840a 100644 --- a/test/bootstrap_other_components_test.rb +++ b/test/bootstrap_other_components_test.rb @@ -1,16 +1,21 @@ -require 'test_helper' +require_relative "./test_helper" class BootstrapOtherComponentsTest < ActionView::TestCase include BootstrapForm::Helper - def setup - setup_test_fixture - end + setup :setup_test_fixture test "static control" do output = @horizontal_builder.static_control :email - expected = %{

steve@example.com

} + expected = <<-HTML.strip_heredoc +
+ +
+

steve@example.com

+
+
+ HTML assert_equivalent_xml expected, output end @@ -19,7 +24,14 @@ def setup "this is a test" end - expected = %{

this is a test

} + expected = <<-HTML.strip_heredoc +
+ +
+

this is a test

+
+
+ HTML assert_equivalent_xml expected, output end @@ -28,7 +40,14 @@ def setup "Custom Control" end - expected = %{

Custom Control

} + expected = <<-HTML.strip_heredoc +
+ +
+

Custom Control

+
+
+ HTML assert_equivalent_xml expected, output end @@ -37,7 +56,12 @@ def setup "this is a test" end - expected = %{
this is a test
} + expected = <<-HTML.strip_heredoc +
+ +
this is a test
+
+ HTML assert_equivalent_xml expected, output end @@ -46,7 +70,12 @@ def setup "this is a test" end - expected = %{
this is a test
} + expected = <<-HTML.strip_heredoc +
+ +
this is a test
+
+ HTML assert_equivalent_xml expected, output end @@ -55,7 +84,12 @@ def setup "Custom Control" end - expected = %{
Custom Control
} + expected = <<-HTML.strip_heredoc +
+ +
Custom Control
+
+ HTML assert_equivalent_xml expected, output end diff --git a/test/bootstrap_radio_button_test.rb b/test/bootstrap_radio_button_test.rb index cd4ca68b1..1def08c20 100644 --- a/test/bootstrap_radio_button_test.rb +++ b/test/bootstrap_radio_button_test.rb @@ -1,142 +1,342 @@ -require 'test_helper' +require_relative "./test_helper" class BootstrapRadioButtonTest < ActionView::TestCase include BootstrapForm::Helper - def setup - setup_test_fixture - end + setup :setup_test_fixture test "radio_button is wrapped correctly" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ +
+ HTML assert_equivalent_xml expected, @builder.radio_button(:misc, '1', label: 'This is a radio button') end test "radio_button disabled label is set correctly" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ +
+ HTML assert_equivalent_xml expected, @builder.radio_button(:misc, '1', label: 'This is a radio button', disabled: true) end test "radio_button label class is set correctly" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ +
+ HTML assert_equivalent_xml expected, @builder.radio_button(:misc, '1', label: 'This is a radio button', label_class: 'btn') end test "radio_button inline label is set correctly" do - expected = %{} + expected = <<-HTML.strip_heredoc + + HTML assert_equivalent_xml expected, @builder.radio_button(:misc, '1', label: 'This is a radio button', inline: true) end test "radio_button disabled inline label is set correctly" do - expected = %{} + expected = <<-HTML.strip_heredoc + + HTML assert_equivalent_xml expected, @builder.radio_button(:misc, '1', label: 'This is a radio button', inline: true, disabled: true) end test "radio_button inline label class is set correctly" do - expected = %{} + expected = <<-HTML.strip_heredoc + + HTML assert_equivalent_xml expected, @builder.radio_button(:misc, '1', label: 'This is a radio button', inline: true, label_class: 'btn') end test 'collection_radio_buttons renders the form_group correctly' do collection = [Address.new(id: 1, street: 'Foobar')] - expected = %{
With a help!
} + expected = <<-HTML.strip_heredoc +
+ +
+ +
+ With a help! +
+ HTML assert_equivalent_xml expected, @builder.collection_radio_buttons(:misc, collection, :id, :street, label: 'This is a radio button collection', help: 'With a help!') end test 'collection_radio_buttons renders multiple radios correctly' do collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')] - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ +
+ +
+
+ +
+
+ HTML assert_equivalent_xml expected, @builder.collection_radio_buttons(:misc, collection, :id, :street) end test 'collection_radio_buttons renders inline radios correctly' do collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')] - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + + +
+ HTML assert_equivalent_xml expected, @builder.collection_radio_buttons(:misc, collection, :id, :street, inline: true) end test 'collection_radio_buttons renders with checked option correctly' do collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')] - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ +
+ +
+
+ +
+
+ HTML assert_equivalent_xml expected, @builder.collection_radio_buttons(:misc, collection, :id, :street, checked: 1) end test 'collection_radio_buttons renders label defined by Proc correctly' do collection = [Address.new(id: 1, street: 'Foobar')] - expected = %{
With a help!
} + expected = <<-HTML.strip_heredoc +
+ +
+ +
+ With a help! +
+ HTML assert_equivalent_xml expected, @builder.collection_radio_buttons(:misc, collection, :id, Proc.new { |a| a.street.reverse }, label: 'This is a radio button collection', help: 'With a help!') end test 'collection_radio_buttons renders value defined by Proc correctly' do collection = [Address.new(id: 1, street: 'Foobar')] - expected = %{
With a help!
} + expected = <<-HTML.strip_heredoc +
+ +
+ +
+ With a help! +
+ HTML assert_equivalent_xml expected, @builder.collection_radio_buttons(:misc, collection, Proc.new { |a| "address_#{a.id}" }, :street, label: 'This is a radio button collection', help: 'With a help!') end test 'collection_radio_buttons renders multiple radios with label defined by Proc correctly' do collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')] - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ +
+ +
+
+ +
+
+ HTML assert_equivalent_xml expected, @builder.collection_radio_buttons(:misc, collection, :id, Proc.new { |a| a.street.reverse }) end test 'collection_radio_buttons renders multiple radios with value defined by Proc correctly' do collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')] - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ +
+ +
+
+ +
+
+ HTML assert_equivalent_xml expected, @builder.collection_radio_buttons(:misc, collection, Proc.new { |a| "address_#{a.id}" }, :street) end test 'collection_radio_buttons renders label defined by lambda correctly' do collection = [Address.new(id: 1, street: 'Foobar')] - expected = %{
With a help!
} + expected = <<-HTML.strip_heredoc +
+ +
+ +
+ With a help! +
+ HTML assert_equivalent_xml expected, @builder.collection_radio_buttons(:misc, collection, :id, lambda { |a| a.street.reverse }, label: 'This is a radio button collection', help: 'With a help!') end test 'collection_radio_buttons renders value defined by lambda correctly' do collection = [Address.new(id: 1, street: 'Foobar')] - expected = %{
With a help!
} + expected = <<-HTML.strip_heredoc +
+ +
+ +
+ With a help! +
+ HTML assert_equivalent_xml expected, @builder.collection_radio_buttons(:misc, collection, lambda { |a| "address_#{a.id}" }, :street, label: 'This is a radio button collection', help: 'With a help!') end test 'collection_radio_buttons renders multiple radios with label defined by lambda correctly' do collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')] - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ +
+ +
+
+ +
+
+ HTML assert_equivalent_xml expected, @builder.collection_radio_buttons(:misc, collection, :id, lambda { |a| a.street.reverse }) end test 'collection_radio_buttons renders multiple radios with value defined by lambda correctly' do collection = [Address.new(id: 1, street: 'Foo'), Address.new(id: 2, street: 'Bar')] - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ +
+ +
+
+ +
+
+ HTML assert_equivalent_xml expected, @builder.collection_radio_buttons(:misc, collection, lambda { |a| "address_#{a.id}" }, :street) end test "radio_button is wrapped correctly with custom option set" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.radio_button(:misc, '1', {label: 'This is a radio button', custom: true}) end test "radio_button is wrapped correctly with custom and inline options set" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.radio_button(:misc, '1', {label: 'This is a radio button', inline: true, custom: true}) end test "radio_button is wrapped correctly with custom and disabled options set" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.radio_button(:misc, '1', {label: 'This is a radio button', disabled: true, custom: true}) end test "radio_button is wrapped correctly with custom, inline and disabled options set" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.radio_button(:misc, '1', {label: 'This is a radio button', inline: true, disabled: true, custom: true}) end + end diff --git a/test/bootstrap_selects_test.rb b/test/bootstrap_selects_test.rb index a701a289b..5dd9dc2b0 100644 --- a/test/bootstrap_selects_test.rb +++ b/test/bootstrap_selects_test.rb @@ -1,34 +1,83 @@ -require 'test_helper' +require_relative "./test_helper" class BootstrapSelectsTest < ActionView::TestCase include BootstrapForm::Helper - def setup - setup_test_fixture + setup :setup_test_fixture + + # Helper to generate options + def options_range(start: 1, stop: 31, selected: nil, months: false) + (start..stop).map do |n| + attr = (n == selected) ? 'selected="selected"' : "" + label = months ? Date::MONTHNAMES[n] : n + "" + end.join("\n") end test "time zone selects are wrapped correctly" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.time_zone_select(:misc) end test "selects are wrapped correctly" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.select(:status, [['activated', 1], ['blocked', 2]]) end test "bootstrap_specific options are handled correctly" do - expected = %{
Help!
} + expected = <<-HTML.strip_heredoc +
+ + + Help! +
+ HTML assert_equivalent_xml expected, @builder.select(:status, [['activated', 1], ['blocked', 2]], label: "My Status Label", help: "Help!" ) end test "selects with options are wrapped correctly" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.select(:status, [['activated', 1], ['blocked', 2]], prompt: "Please Select") end test "selects with both options and html_options are wrapped correctly" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.select(:status, [['activated', 1], ['blocked', 2]], { prompt: "Please Select" }, class: "my-select") end @@ -51,7 +100,15 @@ def setup if Gem::Version.new(Rails::VERSION::STRING) >= Gem::Version.new("4.1.0") test "selects with block use block as content" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML select = @builder.select(:status) do content_tag(:option) { 'Option 1' } + content_tag(:option) { 'Option 2' } @@ -61,99 +118,328 @@ def setup end test "selects render labels properly" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.select(:status, [['activated', 1], ['blocked', 2]], label: "User Status") end test "collection_selects are wrapped correctly" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.collection_select(:status, [], :id, :name) end test "collection_selects with options are wrapped correctly" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.collection_select(:status, [], :id, :name, prompt: "Please Select") end test "collection_selects with options and html_options are wrapped correctly" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.collection_select(:status, [], :id, :name, { prompt: "Please Select" }, class: "my-select") end test "grouped_collection_selects are wrapped correctly" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.grouped_collection_select(:status, [], :last, :first, :to_s, :to_s) end test "grouped_collection_selects with options are wrapped correctly" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.grouped_collection_select(:status, [], :last, :first, :to_s, :to_s, prompt: "Please Select") end test "grouped_collection_selects with options and html_options are wrapped correctly" do - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.grouped_collection_select(:status, [], :last, :first, :to_s, :to_s, { prompt: "Please Select" }, class: "my-select") end test "date selects are wrapped correctly" do Timecop.freeze(Time.utc(2012, 2, 3)) do - expected = %{
\n\n\n
} + expected = <<-HTML.strip_heredoc +
+ +
+ + + +
+
+ HTML assert_equivalent_xml expected, @builder.date_select(:misc) end end test "date selects with options are wrapped correctly" do Timecop.freeze(Time.utc(2012, 2, 3)) do - expected = %{
\n\n\n
} + expected = <<-HTML.strip_heredoc +
+ +
+ + + +
+
+ HTML + assert_equivalent_xml expected, @builder.date_select(:misc, include_blank: true) end end test "date selects with options and html_options are wrapped correctly" do Timecop.freeze(Time.utc(2012, 2, 3)) do - expected = %{
\n\n\n
} + expected = <<-HTML.strip_heredoc +
+ +
+ + + +
+
+ HTML assert_equivalent_xml expected, @builder.date_select(:misc, { include_blank: true }, class: "my-date-select") end end test "time selects are wrapped correctly" do Timecop.freeze(Time.utc(2012, 2, 3, 12, 0, 0)) do - expected = %{
\n\n\n\n : \n
} + expected = <<-HTML.strip_heredoc +
+ +
+ + + + + : + +
+
+ HTML assert_equivalent_xml expected, @builder.time_select(:misc) end end test "time selects with options are wrapped correctly" do Timecop.freeze(Time.utc(2012, 2, 3, 12, 0, 0)) do - expected = %{
\n\n\n\n : \n
} + expected = <<-HTML.strip_heredoc +
+ +
+ + + + + : + +
+
+ HTML assert_equivalent_xml expected, @builder.time_select(:misc, include_blank: true) end end test "time selects with options and html_options are wrapped correctly" do Timecop.freeze(Time.utc(2012, 2, 3, 12, 0, 0)) do - expected = %{
\n\n\n\n : \n
} + expected = <<-HTML.strip_heredoc +
+ +
+ + + + + : + +
+
+ HTML assert_equivalent_xml expected, @builder.time_select(:misc, { include_blank: true }, class: "my-time-select") end end test "datetime selects are wrapped correctly" do Timecop.freeze(Time.utc(2012, 2, 3, 12, 0, 0)) do - expected = %{
\n\n\n — \n : \n
} + expected = <<-HTML.strip_heredoc +
+ +
+ + + + — + + : + +
+
+ HTML assert_equivalent_xml expected, @builder.datetime_select(:misc) end end test "datetime selects with options are wrapped correctly" do Timecop.freeze(Time.utc(2012, 2, 3, 12, 0, 0)) do - expected = %{
\n\n\n — \n : \n
} + expected = <<-HTML.strip_heredoc +
+ +
+ + + + — + + : + +
+
+ HTML assert_equivalent_xml expected, @builder.datetime_select(:misc, include_blank: true) end end test "datetime selects with options and html_options are wrapped correctly" do Timecop.freeze(Time.utc(2012, 2, 3, 12, 0, 0)) do - expected = %{
\n\n\n — \n : \n
} + expected = <<-HTML.strip_heredoc +
+ +
+ + + + — + + : + +
+
+ HTML assert_equivalent_xml expected, @builder.datetime_select(:misc, { include_blank: true }, class: "my-datetime-select") end end diff --git a/test/special_form_class_models_test.rb b/test/special_form_class_models_test.rb index 5c3e428e0..d53017d8d 100644 --- a/test/special_form_class_models_test.rb +++ b/test/special_form_class_models_test.rb @@ -1,4 +1,4 @@ -require 'test_helper' +require_relative "./test_helper" class SpecialFormClassModelsTest < ActionView::TestCase include BootstrapForm::Helper @@ -14,7 +14,12 @@ def user_klass.model_name @horizontal_builder = BootstrapForm::FormBuilder.new(:user, @user, self, {layout: :horizontal, label_col: "col-sm-2", control_col: "col-sm-10"}) I18n.backend.store_translations(:en, {activerecord: {help: {user: {password: "A good password should be at least six characters long"}}}}) - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.date_field(:misc) end @@ -24,7 +29,12 @@ def user_klass.model_name @horizontal_builder = BootstrapForm::FormBuilder.new(:user, @user, self, {layout: :horizontal, label_col: "col-sm-2", control_col: "col-sm-10"}) I18n.backend.store_translations(:en, {activerecord: {help: {user: {password: "A good password should be at least six characters long"}}}}) - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.date_field(:misc) end @@ -36,7 +46,12 @@ def user_klass.model_name @horizontal_builder = BootstrapForm::FormBuilder.new(:user, @user, self, {layout: :horizontal, label_col: "col-sm-2", control_col: "col-sm-10"}) I18n.backend.store_translations(:en, {activerecord: {help: {faux_user: {password: "A good password should be at least six characters long"}}}}) - expected = %{
} + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML assert_equivalent_xml expected, @builder.date_field(:misc) end From 2e223cb2184a9d0e37b021970447913a17eff321 Mon Sep 17 00:00:00 2001 From: Oleg Date: Sat, 13 Jan 2018 13:36:31 -0800 Subject: [PATCH 024/112] fleshing out test/dummy form --- test/bootstrap_selects_test.rb | 2 - .../app/controllers/bootstrap_controller.rb | 16 +++--- test/dummy/app/helpers/bootstrap_helper.rb | 23 +++++++++ test/dummy/app/views/bootstrap/form.html.erb | 50 ++++++++++++++----- .../app/views/layouts/application.html.erb | 15 ++++-- 5 files changed, 80 insertions(+), 26 deletions(-) create mode 100644 test/dummy/app/helpers/bootstrap_helper.rb diff --git a/test/bootstrap_selects_test.rb b/test/bootstrap_selects_test.rb index 5dd9dc2b0..ab813561f 100644 --- a/test/bootstrap_selects_test.rb +++ b/test/bootstrap_selects_test.rb @@ -57,9 +57,7 @@ def options_range(start: 1, stop: 31, selected: nil, months: false)
diff --git a/test/dummy/app/controllers/bootstrap_controller.rb b/test/dummy/app/controllers/bootstrap_controller.rb index b726db3e7..371da3291 100644 --- a/test/dummy/app/controllers/bootstrap_controller.rb +++ b/test/dummy/app/controllers/bootstrap_controller.rb @@ -1,14 +1,16 @@ class BootstrapController < ApplicationController - helper_method :codemirror_html def form - @user = User.new - end + @collection = [ + Address.new(id: 1, street: 'Foo'), + Address.new(id: 2, street: 'Bar') + ] -private + @user = User.new - def codemirror_html(html) - HtmlBeautifier.beautify(html.strip.gsub(">", ">\n").gsub("<", "\n<")) + @user_with_error = User.new + @user_with_error.errors.add(:email) + @user_with_error.errors.add(:misc) end -end \ No newline at end of file +end diff --git a/test/dummy/app/helpers/bootstrap_helper.rb b/test/dummy/app/helpers/bootstrap_helper.rb new file mode 100644 index 000000000..4b7a67ca0 --- /dev/null +++ b/test/dummy/app/helpers/bootstrap_helper.rb @@ -0,0 +1,23 @@ +module BootstrapHelper + + def form_with_source(&block) + form_html = capture(&block) + + content_tag(:div, class: "example") do + codemirror = content_tag(:div, class: "code", style: "display: none") do + content_tag(:textarea, class: "codemirror") do + HtmlBeautifier.beautify(form_html.strip.gsub(">", ">\n").gsub("<", "\n<")) + end + end + + toggle = content_tag(:button, class: "toggle btn btn-sm btn-info") do + "Show Source Code" + end + + concat(form_html) + concat(toggle) + concat(codemirror) + end + end + +end diff --git a/test/dummy/app/views/bootstrap/form.html.erb b/test/dummy/app/views/bootstrap/form.html.erb index f5a003177..426011058 100644 --- a/test/dummy/app/views/bootstrap/form.html.erb +++ b/test/dummy/app/views/bootstrap/form.html.erb @@ -1,13 +1,39 @@ -

Simple

-
- <% example = capture do %> - <%= bootstrap_form_for @user, url: "/" do |form| %> - <%= form.email_field :email, placeholder: "Enter Email", label: "Email address", help: "We'll never share your email with anyone else" %> - <%= form.password_field :password, placeholder: "Password" %> - <%= form.check_box :terms, label: "Check me out" %> - <%= form.submit %> - <% end %> +

Horizontal Form

+ +<%= form_with_source do %> + <%= bootstrap_form_for @user, layout: :horizontal do |form| %> + <%= form.email_field :email, placeholder: "Enter Email", label: "Email address", help: "We'll never share your email with anyone else" %> + <%= form.password_field :password, placeholder: "Password" %> + <%= form.select :status, [['activated', 1], ['blocked', 2]], prompt: "Please Select" %> + <%= form.text_area :misc %> + <%= form.check_box :terms, label: "Agree to Terms" %> + <%= form.collection_check_boxes :misc, @collection, :id, :street %> + <%= form.collection_radio_buttons :misc, @collection, :id, :street %> + + <%= form.submit %> <% end %> - <%= example %> - -
+<% end %> + + +

With Validation Error

+<%= form_with_source do %> + <%= bootstrap_form_for @user_with_error, layout: :horizontal do |form| %> + <%= form.alert_message "This is an alert" %> + <%= form.error_summary %> + <%= form.email_field :email, placeholder: "Enter Email", label: "Email address", help: "We'll never share your email with anyone else" %> + <%= form.collection_check_boxes :misc, @collection, :id, :street %> + <%= form.submit %> + <% end %> +<% end %> + +

Simple

+ +<%= form_with_source do %> + <%= bootstrap_form_for @user, url: "/" do |form| %> + <%= form.email_field :email, placeholder: "Enter Email", label: "Email address", help: "We'll never share your email with anyone else" %> + <%= form.password_field :password, placeholder: "Password" %> + <%= form.check_box :terms, label: "Agree to Terms" %> + <%= form.collection_check_boxes :misc, @collection, :id, :street %> + <%= form.submit %> + <% end %> +<% end %> diff --git a/test/dummy/app/views/layouts/application.html.erb b/test/dummy/app/views/layouts/application.html.erb index 2f017f557..7fb2e18a3 100644 --- a/test/dummy/app/views/layouts/application.html.erb +++ b/test/dummy/app/views/layouts/application.html.erb @@ -15,10 +15,12 @@ border: .2rem solid #f7f7f9; margin-bottom: 3em; } + form { + margin-bottom: 1.5em; + } .CodeMirror { border: 1px solid #eee; height: auto; - margin-top: 1.5em; } @@ -41,14 +43,17 @@ - \ No newline at end of file + From fc53de6d7eef6561b1246cb0f12336684a6db1bc Mon Sep 17 00:00:00 2001 From: Oleg Date: Mon, 15 Jan 2018 22:44:06 -0800 Subject: [PATCH 025/112] moving test/dummy to demo. adding more examples --- .gitignore | 6 ++--- CONTRIBUTING.md | 4 ++-- {test/dummy => demo}/README.md | 22 +++++++++---------- {test/dummy => demo}/Rakefile | 0 .../app/controllers/application_controller.rb | 0 .../app/controllers/bootstrap_controller.rb | 0 .../app/helpers/bootstrap_helper.rb | 0 {test/dummy => demo}/app/models/address.rb | 0 .../app/models/application_record.rb | 0 {test/dummy => demo}/app/models/faux_user.rb | 0 {test/dummy => demo}/app/models/super_user.rb | 0 {test/dummy => demo}/app/models/user.rb | 0 .../app/views/bootstrap/form.html.erb | 16 +++++++++++++- .../app/views/layouts/application.html.erb | 4 ++++ {test/dummy => demo}/bin/bundle | 0 {test/dummy => demo}/bin/rails | 0 {test/dummy => demo}/bin/rake | 0 {test/dummy => demo}/bin/setup | 0 {test/dummy => demo}/bin/update | 0 {test/dummy => demo}/bin/yarn | 0 {test/dummy => demo}/config.ru | 0 {test/dummy => demo}/config/application.rb | 0 demo/config/boot.rb | 5 +++++ {test/dummy => demo}/config/database.yml | 4 ---- {test/dummy => demo}/config/environment.rb | 0 .../config/environments/development.rb | 0 .../config/environments/test.rb | 0 .../application_controller_renderer.rb | 0 .../config/initializers/assets.rb | 0 .../initializers/backtrace_silencers.rb | 0 .../config/initializers/cookies_serializer.rb | 0 .../initializers/filter_parameter_logging.rb | 0 .../config/initializers/inflections.rb | 0 .../config/initializers/mime_types.rb | 0 .../config/initializers/wrap_parameters.rb | 0 {test/dummy => demo}/config/locales/en.yml | 0 {test/dummy => demo}/config/puma.rb | 0 {test/dummy => demo}/config/routes.rb | 0 {test/dummy => demo}/config/spring.rb | 0 {test/dummy => demo}/config/storage.yml | 0 {test/dummy => demo}/db/schema.rb | 0 {test/dummy => demo}/log/.keep | 0 {test/dummy => demo}/package.json | 0 {test/dummy => demo}/public/favicon.ico | 0 test/dummy/config/boot.rb | 5 ----- test/test_helper.rb | 2 +- 46 files changed, 41 insertions(+), 27 deletions(-) rename {test/dummy => demo}/README.md (55%) rename {test/dummy => demo}/Rakefile (100%) rename {test/dummy => demo}/app/controllers/application_controller.rb (100%) rename {test/dummy => demo}/app/controllers/bootstrap_controller.rb (100%) rename {test/dummy => demo}/app/helpers/bootstrap_helper.rb (100%) rename {test/dummy => demo}/app/models/address.rb (100%) rename {test/dummy => demo}/app/models/application_record.rb (100%) rename {test/dummy => demo}/app/models/faux_user.rb (100%) rename {test/dummy => demo}/app/models/super_user.rb (100%) rename {test/dummy => demo}/app/models/user.rb (100%) rename {test/dummy => demo}/app/views/bootstrap/form.html.erb (73%) rename {test/dummy => demo}/app/views/layouts/application.html.erb (95%) rename {test/dummy => demo}/bin/bundle (100%) rename {test/dummy => demo}/bin/rails (100%) rename {test/dummy => demo}/bin/rake (100%) rename {test/dummy => demo}/bin/setup (100%) rename {test/dummy => demo}/bin/update (100%) rename {test/dummy => demo}/bin/yarn (100%) rename {test/dummy => demo}/config.ru (100%) rename {test/dummy => demo}/config/application.rb (100%) create mode 100644 demo/config/boot.rb rename {test/dummy => demo}/config/database.yml (89%) rename {test/dummy => demo}/config/environment.rb (100%) rename {test/dummy => demo}/config/environments/development.rb (100%) rename {test/dummy => demo}/config/environments/test.rb (100%) rename {test/dummy => demo}/config/initializers/application_controller_renderer.rb (100%) rename {test/dummy => demo}/config/initializers/assets.rb (100%) rename {test/dummy => demo}/config/initializers/backtrace_silencers.rb (100%) rename {test/dummy => demo}/config/initializers/cookies_serializer.rb (100%) rename {test/dummy => demo}/config/initializers/filter_parameter_logging.rb (100%) rename {test/dummy => demo}/config/initializers/inflections.rb (100%) rename {test/dummy => demo}/config/initializers/mime_types.rb (100%) rename {test/dummy => demo}/config/initializers/wrap_parameters.rb (100%) rename {test/dummy => demo}/config/locales/en.yml (100%) rename {test/dummy => demo}/config/puma.rb (100%) rename {test/dummy => demo}/config/routes.rb (100%) rename {test/dummy => demo}/config/spring.rb (100%) rename {test/dummy => demo}/config/storage.yml (100%) rename {test/dummy => demo}/db/schema.rb (100%) rename {test/dummy => demo}/log/.keep (100%) rename {test/dummy => demo}/package.json (100%) rename {test/dummy => demo}/public/favicon.ico (100%) delete mode 100644 test/dummy/config/boot.rb diff --git a/.gitignore b/.gitignore index 8540dd815..5a7af378b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,9 @@ .bundle/ log/*.log pkg/ -test/dummy/db/*.sqlite3 -test/dummy/log/*.log -test/dummy/tmp/ +demo/db/*.sqlite3 +demo/log/*.log +demo/tmp/ *.gem .rbenv-gemsets *.swp diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 62a02439b..14d348181 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -35,9 +35,9 @@ For the project. Optionally, create a branch you want to work on - Update the README if necessary. - Add a line to the CHANGELOG for your bug fix or feature. -You may find using test/dummy application useful for development and debugging. +You may find using demo application useful for development and debugging. -- `cd test/dummy` +- `cd demo` - `rake db:schema:load` - `rails s` - Navigate to http://localhost:3000 diff --git a/test/dummy/README.md b/demo/README.md similarity index 55% rename from test/dummy/README.md rename to demo/README.md index 592c2fcc2..8b2dc3ad8 100644 --- a/test/dummy/README.md +++ b/demo/README.md @@ -1,17 +1,17 @@ -# TEST DUMMY APP (Rails 5.2) - -Following files were added or changed: - -- db/schema.rb -- config/application.rb -- config/routes.rb -- 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 +# DEMO APP (Rails 5.2) ### Usage - `rake db:schema:load` - `rails s` - Navigate to http://localhost:3000 + +### Following files were added or changed: + +- db/schema.rb +- config/{application, routes, boot}.rb +- config/environments/{development, test}.rb +- 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 \ No newline at end of file diff --git a/test/dummy/Rakefile b/demo/Rakefile similarity index 100% rename from test/dummy/Rakefile rename to demo/Rakefile diff --git a/test/dummy/app/controllers/application_controller.rb b/demo/app/controllers/application_controller.rb similarity index 100% rename from test/dummy/app/controllers/application_controller.rb rename to demo/app/controllers/application_controller.rb diff --git a/test/dummy/app/controllers/bootstrap_controller.rb b/demo/app/controllers/bootstrap_controller.rb similarity index 100% rename from test/dummy/app/controllers/bootstrap_controller.rb rename to demo/app/controllers/bootstrap_controller.rb diff --git a/test/dummy/app/helpers/bootstrap_helper.rb b/demo/app/helpers/bootstrap_helper.rb similarity index 100% rename from test/dummy/app/helpers/bootstrap_helper.rb rename to demo/app/helpers/bootstrap_helper.rb diff --git a/test/dummy/app/models/address.rb b/demo/app/models/address.rb similarity index 100% rename from test/dummy/app/models/address.rb rename to demo/app/models/address.rb diff --git a/test/dummy/app/models/application_record.rb b/demo/app/models/application_record.rb similarity index 100% rename from test/dummy/app/models/application_record.rb rename to demo/app/models/application_record.rb diff --git a/test/dummy/app/models/faux_user.rb b/demo/app/models/faux_user.rb similarity index 100% rename from test/dummy/app/models/faux_user.rb rename to demo/app/models/faux_user.rb diff --git a/test/dummy/app/models/super_user.rb b/demo/app/models/super_user.rb similarity index 100% rename from test/dummy/app/models/super_user.rb rename to demo/app/models/super_user.rb diff --git a/test/dummy/app/models/user.rb b/demo/app/models/user.rb similarity index 100% rename from test/dummy/app/models/user.rb rename to demo/app/models/user.rb diff --git a/test/dummy/app/views/bootstrap/form.html.erb b/demo/app/views/bootstrap/form.html.erb similarity index 73% rename from test/dummy/app/views/bootstrap/form.html.erb rename to demo/app/views/bootstrap/form.html.erb index 426011058..039af7631 100644 --- a/test/dummy/app/views/bootstrap/form.html.erb +++ b/demo/app/views/bootstrap/form.html.erb @@ -9,13 +9,15 @@ <%= form.check_box :terms, label: "Agree to Terms" %> <%= form.collection_check_boxes :misc, @collection, :id, :street %> <%= form.collection_radio_buttons :misc, @collection, :id, :street %> + <%= form.file_field :misc %> + <%= form.datetime_select :misc, include_blank: true %> <%= form.submit %> <% end %> <% end %> -

With Validation Error

+ <%= form_with_source do %> <%= bootstrap_form_for @user_with_error, layout: :horizontal do |form| %> <%= form.alert_message "This is an alert" %> @@ -26,6 +28,18 @@ <% end %> <% end %> +

Inline Form

+ +<%= form_with_source do %> + <%= bootstrap_form_for @user, layout: :inline do |form| %> + <%= form.email_field :email, placeholder: "Enter Email", label: "Email address", help: "We'll never share your email with anyone else" %> + <%= form.password_field :password, placeholder: "Password" %> + <%= form.check_box :terms, label: "Agree to Terms" %> + <%= form.collection_check_boxes :misc, @collection, :id, :street %> + <%= form.submit %> + <% end %> +<% end %> +

Simple

<%= form_with_source do %> diff --git a/test/dummy/app/views/layouts/application.html.erb b/demo/app/views/layouts/application.html.erb similarity index 95% rename from test/dummy/app/views/layouts/application.html.erb rename to demo/app/views/layouts/application.html.erb index 7fb2e18a3..e9a6f97c7 100644 --- a/test/dummy/app/views/layouts/application.html.erb +++ b/demo/app/views/layouts/application.html.erb @@ -22,6 +22,10 @@ border: 1px solid #eee; height: auto; } + .rails-bootstrap-forms-datetime-select select { + display: inline-block; + width: auto; + } Hello, world! diff --git a/test/dummy/bin/bundle b/demo/bin/bundle similarity index 100% rename from test/dummy/bin/bundle rename to demo/bin/bundle diff --git a/test/dummy/bin/rails b/demo/bin/rails similarity index 100% rename from test/dummy/bin/rails rename to demo/bin/rails diff --git a/test/dummy/bin/rake b/demo/bin/rake similarity index 100% rename from test/dummy/bin/rake rename to demo/bin/rake diff --git a/test/dummy/bin/setup b/demo/bin/setup similarity index 100% rename from test/dummy/bin/setup rename to demo/bin/setup diff --git a/test/dummy/bin/update b/demo/bin/update similarity index 100% rename from test/dummy/bin/update rename to demo/bin/update diff --git a/test/dummy/bin/yarn b/demo/bin/yarn similarity index 100% rename from test/dummy/bin/yarn rename to demo/bin/yarn diff --git a/test/dummy/config.ru b/demo/config.ru similarity index 100% rename from test/dummy/config.ru rename to demo/config.ru diff --git a/test/dummy/config/application.rb b/demo/config/application.rb similarity index 100% rename from test/dummy/config/application.rb rename to demo/config/application.rb diff --git a/demo/config/boot.rb b/demo/config/boot.rb new file mode 100644 index 000000000..e334ad375 --- /dev/null +++ b/demo/config/boot.rb @@ -0,0 +1,5 @@ +# Set up gems listed in the Gemfile. +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __dir__) + +require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) +$LOAD_PATH.unshift File.expand_path('../../lib', __dir__) diff --git a/test/dummy/config/database.yml b/demo/config/database.yml similarity index 89% rename from test/dummy/config/database.yml rename to demo/config/database.yml index 0d02f2498..1af1a8e91 100644 --- a/test/dummy/config/database.yml +++ b/demo/config/database.yml @@ -19,7 +19,3 @@ development: test: <<: *default database: db/test.sqlite3 - -production: - <<: *default - database: db/production.sqlite3 diff --git a/test/dummy/config/environment.rb b/demo/config/environment.rb similarity index 100% rename from test/dummy/config/environment.rb rename to demo/config/environment.rb diff --git a/test/dummy/config/environments/development.rb b/demo/config/environments/development.rb similarity index 100% rename from test/dummy/config/environments/development.rb rename to demo/config/environments/development.rb diff --git a/test/dummy/config/environments/test.rb b/demo/config/environments/test.rb similarity index 100% rename from test/dummy/config/environments/test.rb rename to demo/config/environments/test.rb diff --git a/test/dummy/config/initializers/application_controller_renderer.rb b/demo/config/initializers/application_controller_renderer.rb similarity index 100% rename from test/dummy/config/initializers/application_controller_renderer.rb rename to demo/config/initializers/application_controller_renderer.rb diff --git a/test/dummy/config/initializers/assets.rb b/demo/config/initializers/assets.rb similarity index 100% rename from test/dummy/config/initializers/assets.rb rename to demo/config/initializers/assets.rb diff --git a/test/dummy/config/initializers/backtrace_silencers.rb b/demo/config/initializers/backtrace_silencers.rb similarity index 100% rename from test/dummy/config/initializers/backtrace_silencers.rb rename to demo/config/initializers/backtrace_silencers.rb diff --git a/test/dummy/config/initializers/cookies_serializer.rb b/demo/config/initializers/cookies_serializer.rb similarity index 100% rename from test/dummy/config/initializers/cookies_serializer.rb rename to demo/config/initializers/cookies_serializer.rb diff --git a/test/dummy/config/initializers/filter_parameter_logging.rb b/demo/config/initializers/filter_parameter_logging.rb similarity index 100% rename from test/dummy/config/initializers/filter_parameter_logging.rb rename to demo/config/initializers/filter_parameter_logging.rb diff --git a/test/dummy/config/initializers/inflections.rb b/demo/config/initializers/inflections.rb similarity index 100% rename from test/dummy/config/initializers/inflections.rb rename to demo/config/initializers/inflections.rb diff --git a/test/dummy/config/initializers/mime_types.rb b/demo/config/initializers/mime_types.rb similarity index 100% rename from test/dummy/config/initializers/mime_types.rb rename to demo/config/initializers/mime_types.rb diff --git a/test/dummy/config/initializers/wrap_parameters.rb b/demo/config/initializers/wrap_parameters.rb similarity index 100% rename from test/dummy/config/initializers/wrap_parameters.rb rename to demo/config/initializers/wrap_parameters.rb diff --git a/test/dummy/config/locales/en.yml b/demo/config/locales/en.yml similarity index 100% rename from test/dummy/config/locales/en.yml rename to demo/config/locales/en.yml diff --git a/test/dummy/config/puma.rb b/demo/config/puma.rb similarity index 100% rename from test/dummy/config/puma.rb rename to demo/config/puma.rb diff --git a/test/dummy/config/routes.rb b/demo/config/routes.rb similarity index 100% rename from test/dummy/config/routes.rb rename to demo/config/routes.rb diff --git a/test/dummy/config/spring.rb b/demo/config/spring.rb similarity index 100% rename from test/dummy/config/spring.rb rename to demo/config/spring.rb diff --git a/test/dummy/config/storage.yml b/demo/config/storage.yml similarity index 100% rename from test/dummy/config/storage.yml rename to demo/config/storage.yml diff --git a/test/dummy/db/schema.rb b/demo/db/schema.rb similarity index 100% rename from test/dummy/db/schema.rb rename to demo/db/schema.rb diff --git a/test/dummy/log/.keep b/demo/log/.keep similarity index 100% rename from test/dummy/log/.keep rename to demo/log/.keep diff --git a/test/dummy/package.json b/demo/package.json similarity index 100% rename from test/dummy/package.json rename to demo/package.json diff --git a/test/dummy/public/favicon.ico b/demo/public/favicon.ico similarity index 100% rename from test/dummy/public/favicon.ico rename to demo/public/favicon.ico diff --git a/test/dummy/config/boot.rb b/test/dummy/config/boot.rb deleted file mode 100644 index c9aef85d4..000000000 --- a/test/dummy/config/boot.rb +++ /dev/null @@ -1,5 +0,0 @@ -# Set up gems listed in the Gemfile. -ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__) - -require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) -$LOAD_PATH.unshift File.expand_path('../../../lib', __dir__) diff --git a/test/test_helper.rb b/test/test_helper.rb index f24b41149..1dcfbc0e8 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -6,7 +6,7 @@ ENV["RAILS_ENV"] = "test" -require_relative "./dummy/config/environment.rb" +require_relative "../demo/config/environment.rb" require "rails/test_help" Rails.backtrace_cleaner.remove_silencers! From c5f6d0db5b86d622f8b1ecbdfde72558d87a6544 Mon Sep 17 00:00:00 2001 From: Oleg Date: Sat, 13 Jan 2018 16:24:54 -0800 Subject: [PATCH 026/112] removing deprecated methods completely --- CHANGELOG.md | 3 ++- lib/bootstrap_form/form_builder.rb | 14 ++------------ 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2cfad8460..9dc6d96fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,8 @@ Bugfixes: - Your contribution here! - form-control-danger is replaced with is-invalid for bootstrap 4.0.0.beta3 - form-control-feedback is replaced with invalid-feedback for bootstrap 4.0.0.beta3 - - help texts are rendered with tag instead of tag, i.e. like in bootstrap 4.0.0.beta3 + - help texts are rendered with tag instead of tag, i.e. like in bootstrap 4.0.0.beta3 + - completely removing deprecated methods: `check_boxes_collection` and `radio_buttons_collection` Features: - Your contribution here! diff --git a/lib/bootstrap_form/form_builder.rb b/lib/bootstrap_form/form_builder.rb index d69d88775..75232db7f 100644 --- a/lib/bootstrap_form/form_builder.rb +++ b/lib/bootstrap_form/form_builder.rb @@ -149,7 +149,7 @@ def check_box_with_bootstrap(name, options = {}, checked_value = "1", unchecked_ content_tag(:div, class: div_class.compact.join(" ")) do checkbox_html.concat(label(label_name, html, class: ["custom-control-label", label_class].compact.join(" "))) end - else + else disabled_class = " disabled" if options[:disabled] if options[:inline] label_class = " #{label_class}" if label_class @@ -185,7 +185,7 @@ def radio_button_with_bootstrap(name, value, *args) content_tag(:div, class: div_class.compact.join(" ")) do radio_html.concat(label(name, html, value: value, class: ["custom-control-label", label_class].compact.join(" "))) end - else + else if options[:inline] label_class = " #{label_class}" if label_class label(name, html, class: "radio-inline#{disabled_class}#{label_class}", value: value) @@ -217,16 +217,6 @@ def collection_radio_buttons_with_bootstrap(*args) bootstrap_method_alias :collection_radio_buttons - def check_boxes_collection(*args) - warn "'BootstrapForm#check_boxes_collection' is deprecated, use 'BootstrapForm#collection_check_boxes' instead" - collection_check_boxes(*args) - end - - def radio_buttons_collection(*args) - warn "'BootstrapForm#radio_buttons_collection' is deprecated, use 'BootstrapForm#collection_radio_buttons' instead" - collection_radio_buttons(*args) - end - def form_group(*args, &block) options = args.extract_options! name = args.first From 1222b430f9a1dc70cefb6d0f634178bf05441b6c Mon Sep 17 00:00:00 2001 From: Oleg Date: Mon, 15 Jan 2018 23:44:50 -0800 Subject: [PATCH 027/112] removing old rails checks --- lib/bootstrap_form/form_builder.rb | 25 +++++++------------------ test/bootstrap_selects_test.rb | 30 ++++++++++++++---------------- 2 files changed, 21 insertions(+), 34 deletions(-) diff --git a/lib/bootstrap_form/form_builder.rb b/lib/bootstrap_form/form_builder.rb index d69d88775..c1c82f1e0 100644 --- a/lib/bootstrap_form/form_builder.rb +++ b/lib/bootstrap_form/form_builder.rb @@ -68,20 +68,10 @@ def file_field_with_bootstrap(name, options = {}) bootstrap_method_alias :file_field - if Gem::Version.new(Rails::VERSION::STRING) >= Gem::Version.new("4.1.0") - def select_with_bootstrap(method, choices = nil, options = {}, html_options = {}, &block) - form_group_builder(method, options, html_options) do - prepend_and_append_input(options) do - select_without_bootstrap(method, choices, options, html_options, &block) - end - end - end - else - def select_with_bootstrap(method, choices, options = {}, html_options = {}) - form_group_builder(method, options, html_options) do - prepend_and_append_input(options) do - select_without_bootstrap(method, choices, options, html_options) - end + def select_with_bootstrap(method, choices = nil, options = {}, html_options = {}, &block) + form_group_builder(method, options, html_options) do + prepend_and_append_input(options) do + select_without_bootstrap(method, choices, options, html_options, &block) end end end @@ -149,7 +139,7 @@ def check_box_with_bootstrap(name, options = {}, checked_value = "1", unchecked_ content_tag(:div, class: div_class.compact.join(" ")) do checkbox_html.concat(label(label_name, html, class: ["custom-control-label", label_class].compact.join(" "))) end - else + else disabled_class = " disabled" if options[:disabled] if options[:inline] label_class = " #{label_class}" if label_class @@ -185,7 +175,7 @@ def radio_button_with_bootstrap(name, value, *args) content_tag(:div, class: div_class.compact.join(" ")) do radio_html.concat(label(name, html, value: value, class: ["custom-control-label", label_class].compact.join(" "))) end - else + else if options[:inline] label_class = " #{label_class}" if label_class label(name, html, class: "radio-inline#{disabled_class}#{label_class}", value: value) @@ -465,8 +455,7 @@ def get_help_text_by_i18n_key(name) if object if object.class.respond_to?(:model_name) - # ActiveModel::Naming 3.X.X does not support .name; it is supported as of 4.X.X - partial_scope = object.class.model_name.respond_to?(:name) ? object.class.model_name.name : object.class.model_name + partial_scope = object.class.model_name.name else partial_scope = object.class.name end diff --git a/test/bootstrap_selects_test.rb b/test/bootstrap_selects_test.rb index 5dd9dc2b0..d41e4ffe3 100644 --- a/test/bootstrap_selects_test.rb +++ b/test/bootstrap_selects_test.rb @@ -98,23 +98,21 @@ def options_range(start: 1, stop: 31, selected: nil, months: false) assert_equivalent_xml expected, @builder.select(:status, [['activated', 1], ['blocked', 2]], prepend: 'Before', append: 'After') end - if Gem::Version.new(Rails::VERSION::STRING) >= Gem::Version.new("4.1.0") - test "selects with block use block as content" do - expected = <<-HTML.strip_heredoc -
- - -
- HTML - select = @builder.select(:status) do - content_tag(:option) { 'Option 1' } + - content_tag(:option) { 'Option 2' } - end - assert_equivalent_xml expected, select + test "selects with block use block as content" do + expected = <<-HTML.strip_heredoc +
+ + +
+ HTML + select = @builder.select(:status) do + content_tag(:option) { 'Option 1' } + + content_tag(:option) { 'Option 2' } end + assert_equivalent_xml expected, select end test "selects render labels properly" do From 6082396faef5615f1c32f484fa5cab0e80784369 Mon Sep 17 00:00:00 2001 From: Larry Reid Date: Wed, 17 Jan 2018 08:17:34 -0800 Subject: [PATCH 028/112] Don't add class="" to label if no classes specified. (#383) * Don't add class="" to label if no classes specified. * Resolve conflicts. --- lib/bootstrap_form/form_builder.rb | 3 +- test/bootstrap_fields_test.rb | 38 ++++++++++----------- test/bootstrap_form_group_test.rb | 14 ++++---- test/bootstrap_form_test.rb | 6 ++-- test/bootstrap_radio_button_test.rb | 24 +++++++------- test/bootstrap_selects_test.rb | 46 +++++++++++++------------- test/special_form_class_models_test.rb | 6 ++-- 7 files changed, 69 insertions(+), 68 deletions(-) diff --git a/lib/bootstrap_form/form_builder.rb b/lib/bootstrap_form/form_builder.rb index c1c82f1e0..767dc2785 100644 --- a/lib/bootstrap_form/form_builder.rb +++ b/lib/bootstrap_form/form_builder.rb @@ -393,7 +393,8 @@ def generate_label(id, name, options, custom_label_col, group_layout) classes << "required" if required_attribute?(object, name) end - options[:class] = classes.compact.join(" ") + options[:class] = classes.compact.join(" ").strip + options.delete(:class) if options[:class].empty? if label_errors && has_error?(name) error_messages = get_error_messages(name) diff --git a/test/bootstrap_fields_test.rb b/test/bootstrap_fields_test.rb index dcba190b9..be28a3599 100644 --- a/test/bootstrap_fields_test.rb +++ b/test/bootstrap_fields_test.rb @@ -8,7 +8,7 @@ class BootstrapFieldsTest < ActionView::TestCase test "color fields are wrapped correctly" do expected = <<-HTML.strip_heredoc
- +
HTML @@ -18,7 +18,7 @@ class BootstrapFieldsTest < ActionView::TestCase test "date fields are wrapped correctly" do expected = <<-HTML.strip_heredoc
- +
HTML @@ -28,7 +28,7 @@ class BootstrapFieldsTest < ActionView::TestCase test "date time fields are wrapped correctly" do expected = <<-HTML.strip_heredoc
- +
HTML @@ -38,7 +38,7 @@ class BootstrapFieldsTest < ActionView::TestCase test "date time local fields are wrapped correctly" do expected = <<-HTML.strip_heredoc
- +
HTML @@ -48,7 +48,7 @@ class BootstrapFieldsTest < ActionView::TestCase test "email fields are wrapped correctly" do expected = <<-HTML.strip_heredoc
- +
HTML @@ -58,7 +58,7 @@ class BootstrapFieldsTest < ActionView::TestCase test "file fields are wrapped correctly" do expected = <<-HTML.strip_heredoc
- +
HTML @@ -73,7 +73,7 @@ class BootstrapFieldsTest < ActionView::TestCase test "month local fields are wrapped correctly" do expected = <<-HTML.strip_heredoc
- +
HTML @@ -83,7 +83,7 @@ class BootstrapFieldsTest < ActionView::TestCase test "number fields are wrapped correctly" do expected = <<-HTML.strip_heredoc
- +
HTML @@ -93,7 +93,7 @@ class BootstrapFieldsTest < ActionView::TestCase test "password fields are wrapped correctly" do expected = <<-HTML.strip_heredoc
- + A good password should be at least six characters long
@@ -104,7 +104,7 @@ class BootstrapFieldsTest < ActionView::TestCase test "phone/telephone fields are wrapped correctly" do expected = <<-HTML.strip_heredoc
- +
HTML @@ -115,7 +115,7 @@ class BootstrapFieldsTest < ActionView::TestCase test "range fields are wrapped correctly" do expected = <<-HTML.strip_heredoc
- +
HTML @@ -125,7 +125,7 @@ class BootstrapFieldsTest < ActionView::TestCase test "search fields are wrapped correctly" do expected = <<-HTML.strip_heredoc
- +
HTML @@ -135,7 +135,7 @@ class BootstrapFieldsTest < ActionView::TestCase test "text areas are wrapped correctly" do expected = <<-HTML.strip_heredoc
- +
HTML @@ -155,7 +155,7 @@ class BootstrapFieldsTest < ActionView::TestCase test "time fields are wrapped correctly" do expected = <<-HTML.strip_heredoc
- +
HTML @@ -165,7 +165,7 @@ class BootstrapFieldsTest < ActionView::TestCase test "url fields are wrapped correctly" do expected = <<-HTML.strip_heredoc
- +
HTML @@ -175,7 +175,7 @@ class BootstrapFieldsTest < ActionView::TestCase test "week fields are wrapped correctly" do expected = <<-HTML.strip_heredoc
- +
HTML @@ -195,7 +195,7 @@ class BootstrapFieldsTest < ActionView::TestCase
- +
@@ -216,7 +216,7 @@ class BootstrapFieldsTest < ActionView::TestCase
- +
@@ -260,7 +260,7 @@ class BootstrapFieldsTest < ActionView::TestCase
- +
diff --git a/test/bootstrap_form_group_test.rb b/test/bootstrap_form_group_test.rb index d0332578c..80e7600aa 100644 --- a/test/bootstrap_form_group_test.rb +++ b/test/bootstrap_form_group_test.rb @@ -77,7 +77,7 @@ class BootstrapFormGroupTest < ActionView::TestCase test "preventing a label from having the required class" do expected = <<-HTML.strip_heredoc
- +
HTML @@ -174,7 +174,7 @@ class BootstrapFormGroupTest < ActionView::TestCase test "help messages to look up I18n automatically" do expected = <<-HTML.strip_heredoc
- + A good password should be at least six characters long
@@ -203,7 +203,7 @@ class BootstrapFormGroupTest < ActionView::TestCase test "help messages to ignore translation when user disables help" do expected = <<-HTML.strip_heredoc
- +
HTML @@ -323,7 +323,7 @@ class BootstrapFormGroupTest < ActionView::TestCase test "adds class to wrapped form_group by a field" do expected = <<-HTML.strip_heredoc
- +
HTML @@ -402,7 +402,7 @@ class BootstrapFormGroupTest < ActionView::TestCase test "adding an icon to a field" do expected = <<-HTML.strip_heredoc
- +
@@ -435,7 +435,7 @@ class BootstrapFormGroupTest < ActionView::TestCase test "adds data-attributes (or any other options) to wrapper" do expected = <<-HTML.strip_heredoc
- +
HTML @@ -459,7 +459,7 @@ class BootstrapFormGroupTest < ActionView::TestCase expected = <<-HTML.strip_heredoc
- +
HTML assert_equivalent_xml expected, output diff --git a/test/bootstrap_form_test.rb b/test/bootstrap_form_test.rb index b96850b2a..4a47d98dc 100644 --- a/test/bootstrap_form_test.rb +++ b/test/bootstrap_form_test.rb @@ -67,7 +67,7 @@ class BootstrapFormTest < ActionView::TestCase
- +
@@ -80,7 +80,7 @@ class BootstrapFormTest < ActionView::TestCase
- +
@@ -418,7 +418,7 @@ class BootstrapFormTest < ActionView::TestCase builder = BootstrapForm::FormBuilder.new :other_model, nil, self, {} expected = <<-HTML.strip_heredoc
- +
HTML diff --git a/test/bootstrap_radio_button_test.rb b/test/bootstrap_radio_button_test.rb index 1def08c20..c19cdd47f 100644 --- a/test/bootstrap_radio_button_test.rb +++ b/test/bootstrap_radio_button_test.rb @@ -75,7 +75,7 @@ class BootstrapRadioButtonTest < ActionView::TestCase collection = [Address.new(id: 1, street: 'Foobar')] expected = <<-HTML.strip_heredoc
- +