bootstrap_form 2.7.0 → 4.0.0.alpha1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +14 -0
  3. data/.travis.yml +29 -0
  4. data/CHANGELOG.md +227 -0
  5. data/CONTRIBUTING.md +57 -0
  6. data/Dangerfile +54 -0
  7. data/Gemfile +21 -0
  8. data/{MIT-LICENSE → LICENSE.txt} +1 -1
  9. data/README.md +154 -87
  10. data/Rakefile +5 -15
  11. data/UPGRADE-4.0.md +79 -0
  12. data/bootstrap_form.gemspec +28 -0
  13. data/demo/README.md +17 -0
  14. data/demo/Rakefile +6 -0
  15. data/demo/app/controllers/application_controller.rb +2 -0
  16. data/demo/app/controllers/bootstrap_controller.rb +16 -0
  17. data/demo/app/helpers/bootstrap_helper.rb +23 -0
  18. data/{test/dummy → demo}/app/models/address.rb +0 -0
  19. data/demo/app/models/application_record.rb +3 -0
  20. data/{test/dummy → demo}/app/models/faux_user.rb +0 -0
  21. data/{test/dummy → demo}/app/models/super_user.rb +0 -0
  22. data/{test/dummy → demo}/app/models/user.rb +0 -0
  23. data/demo/app/views/bootstrap/form.html.erb +53 -0
  24. data/demo/app/views/layouts/application.html.erb +65 -0
  25. data/demo/bin/bundle +3 -0
  26. data/{test/dummy → demo}/bin/rails +1 -1
  27. data/{test/dummy → demo}/bin/rake +0 -0
  28. data/demo/bin/setup +36 -0
  29. data/demo/bin/update +31 -0
  30. data/demo/bin/yarn +11 -0
  31. data/{test/dummy → demo}/config.ru +2 -1
  32. data/demo/config/application.rb +24 -0
  33. data/demo/config/boot.rb +5 -0
  34. data/{test/dummy → demo}/config/database.yml +8 -12
  35. data/demo/config/environment.rb +5 -0
  36. data/demo/config/environments/development.rb +60 -0
  37. data/{test/dummy → demo}/config/environments/test.rb +15 -20
  38. data/demo/config/initializers/application_controller_renderer.rb +8 -0
  39. data/demo/config/initializers/assets.rb +14 -0
  40. data/{test/dummy → demo}/config/initializers/backtrace_silencers.rb +0 -0
  41. data/demo/config/initializers/cookies_serializer.rb +5 -0
  42. data/{test/dummy → demo}/config/initializers/filter_parameter_logging.rb +0 -0
  43. data/{test/dummy → demo}/config/initializers/inflections.rb +0 -0
  44. data/{test/dummy → demo}/config/initializers/mime_types.rb +0 -1
  45. data/{test/dummy → demo}/config/initializers/wrap_parameters.rb +2 -2
  46. data/{test/dummy → demo}/config/locales/en.yml +10 -0
  47. data/demo/config/puma.rb +56 -0
  48. data/{test/dummy → demo}/config/routes.rb +2 -0
  49. data/demo/config/spring.rb +6 -0
  50. data/demo/config/storage.yml +35 -0
  51. data/demo/db/schema.rb +24 -0
  52. data/{test/dummy/public/favicon.ico → demo/log/.keep} +0 -0
  53. data/demo/package.json +5 -0
  54. data/demo/public/favicon.ico +0 -0
  55. data/lib/bootstrap_form/form_builder.rb +221 -96
  56. data/lib/bootstrap_form/helper.rb +26 -16
  57. data/lib/bootstrap_form/helpers/bootstrap.rb +37 -24
  58. data/lib/bootstrap_form/version.rb +1 -1
  59. metadata +67 -252
  60. data/lib/bootstrap_form/helpers/nested_form.rb +0 -33
  61. data/test/bootstrap_checkbox_test.rb +0 -144
  62. data/test/bootstrap_fields_test.rb +0 -152
  63. data/test/bootstrap_form_group_test.rb +0 -289
  64. data/test/bootstrap_form_test.rb +0 -209
  65. data/test/bootstrap_other_components_test.rb +0 -86
  66. data/test/bootstrap_radio_button_test.rb +0 -124
  67. data/test/bootstrap_selects_test.rb +0 -160
  68. data/test/dummy/Gemfile +0 -45
  69. data/test/dummy/Gemfile.lock +0 -120
  70. data/test/dummy/README.rdoc +0 -28
  71. data/test/dummy/Rakefile +0 -10
  72. data/test/dummy/app/assets/javascripts/application.js +0 -16
  73. data/test/dummy/app/assets/stylesheets/application.css +0 -13
  74. data/test/dummy/app/controllers/application_controller.rb +0 -5
  75. data/test/dummy/app/helpers/application_helper.rb +0 -2
  76. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  77. data/test/dummy/bin/bundle +0 -3
  78. data/test/dummy/config/application.rb +0 -23
  79. data/test/dummy/config/boot.rb +0 -4
  80. data/test/dummy/config/environment.rb +0 -5
  81. data/test/dummy/config/environments/development.rb +0 -29
  82. data/test/dummy/config/environments/production.rb +0 -80
  83. data/test/dummy/config/initializers/secret_token.rb +0 -12
  84. data/test/dummy/config/initializers/session_store.rb +0 -3
  85. data/test/dummy/db/migrate/20130703191909_create_users.rb +0 -13
  86. data/test/dummy/db/migrate/20130703191937_create_addresses.rb +0 -13
  87. data/test/dummy/db/migrate/20130912171202_add_preferences_to_user.rb +0 -5
  88. data/test/dummy/db/migrate/20140327190145_add_terms_to_user.rb +0 -5
  89. data/test/dummy/db/migrate/20140922133133_add_type_to_users.rb +0 -5
  90. data/test/dummy/db/schema.rb +0 -39
  91. data/test/dummy/db/seeds.rb +0 -7
  92. data/test/dummy/db/test.sqlite3 +0 -0
  93. data/test/dummy/log/test.log +0 -38160
  94. data/test/dummy/public/404.html +0 -58
  95. data/test/dummy/public/422.html +0 -58
  96. data/test/dummy/public/500.html +0 -57
  97. data/test/dummy/public/robots.txt +0 -5
  98. data/test/dummy/test/fixtures/addresses.yml +0 -15
  99. data/test/dummy/test/fixtures/users.yml +0 -15
  100. data/test/dummy/test/models/address_test.rb +0 -7
  101. data/test/dummy/test/models/user_test.rb +0 -7
  102. data/test/dummy/test/test_helper.rb +0 -15
  103. data/test/special_form_class_models_test.rb +0 -43
  104. data/test/test_helper.rb +0 -86
@@ -1,58 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The page you were looking for doesn't exist (404)</title>
5
- <style>
6
- body {
7
- background-color: #EFEFEF;
8
- color: #2E2F30;
9
- text-align: center;
10
- font-family: arial, sans-serif;
11
- }
12
-
13
- div.dialog {
14
- width: 25em;
15
- margin: 4em auto 0 auto;
16
- border: 1px solid #CCC;
17
- border-right-color: #999;
18
- border-left-color: #999;
19
- border-bottom-color: #BBB;
20
- border-top: #B00100 solid 4px;
21
- border-top-left-radius: 9px;
22
- border-top-right-radius: 9px;
23
- background-color: white;
24
- padding: 7px 4em 0 4em;
25
- }
26
-
27
- h1 {
28
- font-size: 100%;
29
- color: #730E15;
30
- line-height: 1.5em;
31
- }
32
-
33
- body > p {
34
- width: 33em;
35
- margin: 0 auto 1em;
36
- padding: 1em 0;
37
- background-color: #F7F7F7;
38
- border: 1px solid #CCC;
39
- border-right-color: #999;
40
- border-bottom-color: #999;
41
- border-bottom-left-radius: 4px;
42
- border-bottom-right-radius: 4px;
43
- border-top-color: #DADADA;
44
- color: #666;
45
- box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
- }
47
- </style>
48
- </head>
49
-
50
- <body>
51
- <!-- This file lives in public/404.html -->
52
- <div class="dialog">
53
- <h1>The page you were looking for doesn't exist.</h1>
54
- <p>You may have mistyped the address or the page may have moved.</p>
55
- </div>
56
- <p>If you are the application owner check the logs for more information.</p>
57
- </body>
58
- </html>
@@ -1,58 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The change you wanted was rejected (422)</title>
5
- <style>
6
- body {
7
- background-color: #EFEFEF;
8
- color: #2E2F30;
9
- text-align: center;
10
- font-family: arial, sans-serif;
11
- }
12
-
13
- div.dialog {
14
- width: 25em;
15
- margin: 4em auto 0 auto;
16
- border: 1px solid #CCC;
17
- border-right-color: #999;
18
- border-left-color: #999;
19
- border-bottom-color: #BBB;
20
- border-top: #B00100 solid 4px;
21
- border-top-left-radius: 9px;
22
- border-top-right-radius: 9px;
23
- background-color: white;
24
- padding: 7px 4em 0 4em;
25
- }
26
-
27
- h1 {
28
- font-size: 100%;
29
- color: #730E15;
30
- line-height: 1.5em;
31
- }
32
-
33
- body > p {
34
- width: 33em;
35
- margin: 0 auto 1em;
36
- padding: 1em 0;
37
- background-color: #F7F7F7;
38
- border: 1px solid #CCC;
39
- border-right-color: #999;
40
- border-bottom-color: #999;
41
- border-bottom-left-radius: 4px;
42
- border-bottom-right-radius: 4px;
43
- border-top-color: #DADADA;
44
- color: #666;
45
- box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
- }
47
- </style>
48
- </head>
49
-
50
- <body>
51
- <!-- This file lives in public/422.html -->
52
- <div class="dialog">
53
- <h1>The change you wanted was rejected.</h1>
54
- <p>Maybe you tried to change something you didn't have access to.</p>
55
- </div>
56
- <p>If you are the application owner check the logs for more information.</p>
57
- </body>
58
- </html>
@@ -1,57 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>We're sorry, but something went wrong (500)</title>
5
- <style>
6
- body {
7
- background-color: #EFEFEF;
8
- color: #2E2F30;
9
- text-align: center;
10
- font-family: arial, sans-serif;
11
- }
12
-
13
- div.dialog {
14
- width: 25em;
15
- margin: 4em auto 0 auto;
16
- border: 1px solid #CCC;
17
- border-right-color: #999;
18
- border-left-color: #999;
19
- border-bottom-color: #BBB;
20
- border-top: #B00100 solid 4px;
21
- border-top-left-radius: 9px;
22
- border-top-right-radius: 9px;
23
- background-color: white;
24
- padding: 7px 4em 0 4em;
25
- }
26
-
27
- h1 {
28
- font-size: 100%;
29
- color: #730E15;
30
- line-height: 1.5em;
31
- }
32
-
33
- body > p {
34
- width: 33em;
35
- margin: 0 auto 1em;
36
- padding: 1em 0;
37
- background-color: #F7F7F7;
38
- border: 1px solid #CCC;
39
- border-right-color: #999;
40
- border-bottom-color: #999;
41
- border-bottom-left-radius: 4px;
42
- border-bottom-right-radius: 4px;
43
- border-top-color: #DADADA;
44
- color: #666;
45
- box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
- }
47
- </style>
48
- </head>
49
-
50
- <body>
51
- <!-- This file lives in public/500.html -->
52
- <div class="dialog">
53
- <h1>We're sorry, but something went wrong.</h1>
54
- </div>
55
- <p>If you are the application owner check the logs for more information.</p>
56
- </body>
57
- </html>
@@ -1,5 +0,0 @@
1
- # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
- #
3
- # To ban all spiders from the entire site uncomment the next two lines:
4
- # User-agent: *
5
- # Disallow: /
@@ -1,15 +0,0 @@
1
- # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
-
3
- one:
4
- user_id: 1
5
- street: MyString
6
- city: MyString
7
- state: MyString
8
- zip_code: MyString
9
-
10
- two:
11
- user_id: 1
12
- street: MyString
13
- city: MyString
14
- state: MyString
15
- zip_code: MyString
@@ -1,15 +0,0 @@
1
- # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
-
3
- one:
4
- email: MyString
5
- password: MyString
6
- comments: MyText
7
- status: MyString
8
- misc: MyString
9
-
10
- two:
11
- email: MyString
12
- password: MyString
13
- comments: MyText
14
- status: MyString
15
- misc: MyString
@@ -1,7 +0,0 @@
1
- require 'test_helper'
2
-
3
- class AddressTest < ActiveSupport::TestCase
4
- # test "the truth" do
5
- # assert true
6
- # end
7
- end
@@ -1,7 +0,0 @@
1
- require 'test_helper'
2
-
3
- class UserTest < ActiveSupport::TestCase
4
- # test "the truth" do
5
- # assert true
6
- # end
7
- end
@@ -1,15 +0,0 @@
1
- ENV["RAILS_ENV"] ||= "test"
2
- require File.expand_path('../../config/environment', __FILE__)
3
- require 'rails/test_help'
4
-
5
- class ActiveSupport::TestCase
6
- ActiveRecord::Migration.check_pending!
7
-
8
- # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
9
- #
10
- # Note: You'll currently still have to declare fixtures explicitly in integration tests
11
- # -- they do not yet inherit this setting
12
- fixtures :all
13
-
14
- # Add more helper methods to be used by all tests here...
15
- end
@@ -1,43 +0,0 @@
1
- require 'test_helper'
2
-
3
- class SpecialFormClassModelsTest < ActionView::TestCase
4
- include BootstrapForm::Helper
5
-
6
- test "Anonymous models are supported for form builder" do
7
- user_klass = Class.new(User)
8
- def user_klass.model_name
9
- ActiveModel::Name.new(User)
10
- end
11
-
12
- @user = user_klass.new(email: 'steve@example.com', password: 'secret', comments: 'my comment')
13
- @builder = BootstrapForm::FormBuilder.new(:user, @user, self, {})
14
- @horizontal_builder = BootstrapForm::FormBuilder.new(:user, @user, self, {layout: :horizontal, label_col: "col-sm-2", control_col: "col-sm-10"})
15
- I18n.backend.store_translations(:en, {activerecord: {help: {user: {password: "A good password should be at least six characters long"}}}})
16
-
17
- expected = %{<div class="form-group"><label class="control-label" for="user_misc">Misc</label><input class="form-control" id="user_misc" name="user[misc]" type="date" /></div>}
18
- assert_equivalent_xml expected, @builder.date_field(:misc)
19
- end
20
-
21
- test "Nil models are supported for form builder" do
22
- @user = nil
23
- @builder = BootstrapForm::FormBuilder.new(:user, @user, self, {})
24
- @horizontal_builder = BootstrapForm::FormBuilder.new(:user, @user, self, {layout: :horizontal, label_col: "col-sm-2", control_col: "col-sm-10"})
25
- I18n.backend.store_translations(:en, {activerecord: {help: {user: {password: "A good password should be at least six characters long"}}}})
26
-
27
- expected = %{<div class="form-group"><label class="control-label" for="user_misc">Misc</label><input class="form-control" id="user_misc" name="user[misc]" type="date" /></div>}
28
- assert_equivalent_xml expected, @builder.date_field(:misc)
29
- end
30
-
31
- test "Objects without model names are supported for form builder" do
32
- user_klass = FauxUser
33
-
34
- @user = user_klass.new(email: 'steve@example.com', password: 'secret', comments: 'my comment')
35
- @builder = BootstrapForm::FormBuilder.new(:user, @user, self, {})
36
- @horizontal_builder = BootstrapForm::FormBuilder.new(:user, @user, self, {layout: :horizontal, label_col: "col-sm-2", control_col: "col-sm-10"})
37
- I18n.backend.store_translations(:en, {activerecord: {help: {faux_user: {password: "A good password should be at least six characters long"}}}})
38
-
39
- expected = %{<div class="form-group"><label class="control-label" for="user_misc">Misc</label><input class="form-control" id="user_misc" name="user[misc]" type="date" /></div>}
40
- assert_equivalent_xml expected, @builder.date_field(:misc)
41
- end
42
-
43
- end
@@ -1,86 +0,0 @@
1
- require 'timecop'
2
- require 'diffy'
3
- require 'nokogiri'
4
- require 'equivalent-xml'
5
- require 'mocha/mini_test'
6
-
7
- # Configure Rails Environment
8
- ENV["RAILS_ENV"] = "test"
9
-
10
- require File.expand_path("../dummy/config/environment.rb", __FILE__)
11
- require "rails/test_help"
12
-
13
- Rails.backtrace_cleaner.remove_silencers!
14
-
15
- # Load support files
16
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
17
-
18
- def setup_test_fixture
19
- @user = User.new(email: 'steve@example.com', password: 'secret', comments: 'my comment')
20
- @builder = BootstrapForm::FormBuilder.new(:user, @user, self, {})
21
- @horizontal_builder = BootstrapForm::FormBuilder.new(:user, @user, self, { layout: :horizontal, label_col: "col-sm-2", control_col: "col-sm-10" })
22
- I18n.backend.store_translations(:en, {
23
- activerecord: {
24
- attributes: {
25
- user: {
26
- email: "Email"
27
- }
28
- },
29
- help: {
30
- user: {
31
- password: "A good password should be at least six characters long"
32
- }
33
- }
34
- }
35
- })
36
- end
37
-
38
- def sort_attributes doc
39
- doc.dup.traverse do |node|
40
- if node.is_a?(Nokogiri::XML::Element)
41
- attributes = node.attribute_nodes.sort_by(&:name)
42
- attributes.each do |attribute|
43
- node.delete(attribute.name)
44
- node[attribute.name] = attribute.value
45
- end
46
- end
47
- node
48
- end
49
- end
50
-
51
- class ActionView::TestCase
52
- def assert_equivalent_xml(expected, actual)
53
- expected_xml = Nokogiri::XML(expected)
54
- actual_xml = Nokogiri::XML(actual)
55
- ignored_attributes = %w(style data-disable-with)
56
- equivalent = EquivalentXml.equivalent?(expected_xml, actual_xml, {
57
- ignore_attr_values: ignored_attributes
58
- }) do |a, b, result|
59
- if result === false && b.is_a?(Nokogiri::XML::Element)
60
- if b.attr('name') == 'utf8'
61
- # Handle wrapped utf8 hidden field for Rails 4.2+
62
- result = EquivalentXml.equivalent?(a.child, b)
63
- end
64
- if b.delete('data-disable-with')
65
- # Remove data-disable-with for Rails 5+
66
- # Workaround because ignoring in EquivalentXml doesn't work
67
- result = EquivalentXml.equivalent?(a, b)
68
- end
69
- if a.attr('type') == 'datetime' && b.attr('type') == 'datetime-local'
70
- a.delete('type')
71
- b.delete('type')
72
- # Handle new datetime type for Rails 5+
73
- result = EquivalentXml.equivalent?(a, b)
74
- end
75
- end
76
- result
77
- end
78
- assert equivalent, lambda {
79
- # using a lambda because diffing is expensive
80
- Diffy::Diff.new(
81
- sort_attributes(expected_xml.root),
82
- sort_attributes(actual_xml.root)
83
- ).to_s(:color)
84
- }
85
- end
86
- end