strong_form 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +7 -0
  2. data/AGPL-LICENSE +661 -0
  3. data/Rakefile +28 -0
  4. data/lib/strong_form.rb +5 -0
  5. data/lib/strong_form/finder.rb +16 -0
  6. data/lib/strong_form/form.rb +56 -0
  7. data/lib/strong_form/nested_form.rb +38 -0
  8. data/lib/strong_form/railtie.rb +31 -0
  9. data/lib/strong_form/record.rb +16 -0
  10. data/lib/strong_form/tag.rb +12 -0
  11. data/lib/strong_form/version.rb +3 -0
  12. data/lib/tasks/strong_form_tasks.rake +4 -0
  13. data/spec/dummy/README.rdoc +28 -0
  14. data/spec/dummy/Rakefile +6 -0
  15. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  16. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  17. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  18. data/spec/dummy/app/controllers/base_controller.rb +22 -0
  19. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  20. data/spec/dummy/app/models/address.rb +6 -0
  21. data/spec/dummy/app/models/tag.rb +3 -0
  22. data/spec/dummy/app/models/user.rb +7 -0
  23. data/spec/dummy/app/views/base/_address_fields.html.haml +10 -0
  24. data/spec/dummy/app/views/base/_tag_fields.html.haml +2 -0
  25. data/spec/dummy/app/views/base/_user_fields.html.haml +4 -0
  26. data/spec/dummy/app/views/base/basic_form.html.haml +2 -0
  27. data/spec/dummy/app/views/base/deep_fields_for.html.haml +8 -0
  28. data/spec/dummy/app/views/base/fields_for.html.haml +8 -0
  29. data/spec/dummy/app/views/base/nested_form_gem.html.haml +7 -0
  30. data/spec/dummy/app/views/layouts/application.html.haml +10 -0
  31. data/spec/dummy/bin/bundle +3 -0
  32. data/spec/dummy/bin/rails +4 -0
  33. data/spec/dummy/bin/rake +4 -0
  34. data/spec/dummy/bin/setup +29 -0
  35. data/spec/dummy/config.ru +4 -0
  36. data/spec/dummy/config/application.rb +27 -0
  37. data/spec/dummy/config/boot.rb +5 -0
  38. data/spec/dummy/config/database.yml +25 -0
  39. data/spec/dummy/config/environment.rb +5 -0
  40. data/spec/dummy/config/environments/development.rb +41 -0
  41. data/spec/dummy/config/environments/production.rb +79 -0
  42. data/spec/dummy/config/environments/test.rb +42 -0
  43. data/spec/dummy/config/initializers/assets.rb +11 -0
  44. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  45. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  46. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  47. data/spec/dummy/config/initializers/inflections.rb +16 -0
  48. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  49. data/spec/dummy/config/initializers/session_store.rb +3 -0
  50. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  51. data/spec/dummy/config/locales/en.yml +23 -0
  52. data/spec/dummy/config/routes.rb +57 -0
  53. data/spec/dummy/config/secrets.yml +22 -0
  54. data/spec/dummy/db/development.sqlite3 +0 -0
  55. data/spec/dummy/db/migrate/20150626095843_create_users.rb +12 -0
  56. data/spec/dummy/db/migrate/20150626104120_create_addresses.rb +13 -0
  57. data/spec/dummy/db/migrate/20150626132542_create_tags.rb +11 -0
  58. data/spec/dummy/db/schema.rb +44 -0
  59. data/spec/dummy/db/test.sqlite3 +0 -0
  60. data/spec/dummy/log/development.log +55 -0
  61. data/spec/dummy/log/test.log +13928 -0
  62. data/spec/dummy/public/404.html +67 -0
  63. data/spec/dummy/public/422.html +67 -0
  64. data/spec/dummy/public/500.html +66 -0
  65. data/spec/dummy/public/favicon.ico +0 -0
  66. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/2LhrvKfMxngd4BdL-T9u1PoK7r2yCrsF0F7Kfd3Ah_E.cache +0 -0
  67. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/51piSq8D_vSYzuo29rqbhXeezoY2DCrHKutZ4oxBHhg.cache +1 -0
  68. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/5G4z0ygg3o4YrC8hdVviqeaSPwFizCPEz9C_aP3xEf4.cache +0 -0
  69. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/6HZK27_4B_5JmRqd-_qY4A4hlMpkUhe5T2NBYDBhhtY.cache +0 -0
  70. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/7ujPiNFNHPEE5v8dU7pWT1mFTAIzzANjE_WnhuOn5aQ.cache +0 -0
  71. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/BzvE8UQ9KacHmD--VP941KFQNmtCCtrawpZ0I-RiJ_I.cache +0 -0
  72. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/D2r9R9v7HN8bhcRxAk9Fq198KPyRMlGc6pTeXk7akFY.cache +1 -0
  73. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/K_5SG-ud7IMx-4BeZy5hmsicHUiqJlF0tZQjyR3NNEU.cache +1 -0
  74. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/QEdR93qQ7nm2SXxevYI5Jq-kZ1bMKqprrz_1CIog8cY.cache +1 -0
  75. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/SJbwTdB2TakRdPR0nH-X3xfT67Q2hf09i_4vNn90Ntw.cache +1 -0
  76. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/_yOk6c3S7xX6EByWm0rTZ3-h6G5R-0Ge65s1mE62K6A.cache +0 -0
  77. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/e7M8G17FmxSeoA5Hsf5--bxNsxEVKc7QeyJ0xpag8Dk.cache +1 -0
  78. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/eFzh__t_QtfMtE7gJNX9lWmkNGR1gwr-qeBFKqaapzE.cache +0 -0
  79. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/eOkP0DI4t_W9XXjhMLYN1h9XQHVX47uYT5mxUaf5d8c.cache +1 -0
  80. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/fCdygUQVvilffWkcrZOOmWAmg7_SGBAllsGphcjPUgI.cache +0 -0
  81. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/h46aLbOd8j7U9bu77JY1Q_My7hoRoFram5quuS5mTNY.cache +1 -0
  82. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/mdlk4FrQ_MAYAufc3sZP3Womvzc2ygzcE3wI8h-HtG8.cache +1 -0
  83. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/nFFtnxQpd52C5Kw2pAiHS8UAeTmmHYy1bKqAvX9URXg.cache +0 -0
  84. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/o5l8KQJq6xdUXyLhmo54-Hq3b4IBPiejD7IVebnzsfg.cache +0 -0
  85. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/qzaJT3HFRBZRH91xzxTdWOj3bMvepjEc7g8K9lDSq2E.cache +0 -0
  86. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/ugAO4WRjF1KW12RW1b9zwLT8jfn5FBDPuO3cPg3ETKM.cache +0 -0
  87. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/xRuy4fW0E5CWWpAMIAzcxNKri0l5BRWXNdikJDAGbZc.cache +0 -0
  88. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/xm4K2DO5jy_tnB04EtEXjdEZC3rMAvHvZGHmpC4tFeQ.cache +1 -0
  89. data/spec/dummy/tmp/cache/assets/test/sprockets/v3.0/yy6a1dwFUwRlNVthC-5nAYk3ICpfyp79q5qfO0FHibQ.cache +1 -0
  90. data/spec/examples.txt +52 -0
  91. data/spec/features/strong_form_spec.rb +338 -0
  92. data/spec/models/user_spec.rb +46 -0
  93. data/spec/rails_helper.rb +53 -0
  94. data/spec/spec_helper.rb +92 -0
  95. metadata +317 -0
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/404.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The page you were looking for doesn't exist.</h1>
62
+ <p>You may have mistyped the address or the page may have moved.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/422.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The change you wanted was rejected.</h1>
62
+ <p>Maybe you tried to change something you didn't have access to.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/500.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>We're sorry, but something went wrong.</h1>
62
+ </div>
63
+ <p>If you are the application owner check the logs for more information.</p>
64
+ </div>
65
+ </body>
66
+ </html>
File without changes
@@ -0,0 +1 @@
1
+ I"�file:///Users/markus/svn/gem-strong-form/spec/dummy/app/assets/javascripts/application.js?type=application/javascript&id=3871d18d8934e89f8c7f092d13cf4005e87f9fa7286650c774ca1f639ca041d0:ET
@@ -0,0 +1 @@
1
+ I"�file:///Users/markus/svn/gem-strong-form/spec/dummy/app/assets/stylesheets/application.css?type=text/css&id=bd0f65dedf719ecb27c84784a1b8c94e9d6856fb3b2ccebbd0e270f3a20c9422:ET
@@ -0,0 +1 @@
1
+ I"�file:///Users/markus/svn/gem-strong-form/spec/dummy/app/assets/javascripts/application.js?type=application/javascript&pipeline=self&id=544fa04b5e64df08247cc09e148bdfcbf74834034d6b52e03cf61a8a938f5176:ET
@@ -0,0 +1 @@
1
+ "%Ѱč@�����6H�uZoX�Z�gbh0W��V
@@ -0,0 +1 @@
1
+ I"�file:///Users/markus/svn/gem-strong-form/spec/dummy/app/assets/javascripts/application.js?type=application/javascript&id=d492d8f0bb3bdfd371c01156b5f69bd4bea7479500b59487318e1428d2e2dde8:ET
@@ -0,0 +1 @@
1
+ I"�file:///Users/markus/svn/gem-strong-form/spec/dummy/app/assets/stylesheets/application.css?type=text/css&id=3d86d1eb4ddc15dbe6fbf799150a06de91a10873a3e6873e6b4b151b58fbe74d:ET
@@ -0,0 +1 @@
1
+ I"�file:///Users/markus/svn/gem-strong-form/spec/dummy/app/assets/stylesheets/application.css?type=text/css&pipeline=self&id=26ff20112fcbc73544df76613a167d759bf9cdb75bbc1290c0bc63ac507ef77b:ET
@@ -0,0 +1 @@
1
+ I"�file:///Users/markus/svn/gem-strong-form/spec/dummy/app/assets/stylesheets/application.css?type=text/css&pipeline=self&id=bb3aba1d0dce2016b29fd6688e025e55eb12ad3a7bf92222a0300d3fc1f94bab:ET
@@ -0,0 +1 @@
1
+ I"�file:///Users/markus/svn/gem-strong-form/spec/dummy/app/assets/javascripts/application.js?type=application/javascript&pipeline=self&id=68010392710123cd519e39ee26abfeba4d6e031eca6c8e2767c36f94a37c8d84:ET
@@ -0,0 +1 @@
1
+ "%��Rm�v�S3.��O�L���ڹc�ƕq�=_j�
@@ -0,0 +1 @@
1
+ "%�W\�yho9S���ƫ˥��)|�~���(���
data/spec/examples.txt ADDED
@@ -0,0 +1,52 @@
1
+ example_id | status | run_time |
2
+ ---------------------------------------------- | ------ | --------------- |
3
+ ./spec/features/strong_form_spec.rb[1:1:1:1] | passed | 0.00347 seconds |
4
+ ./spec/features/strong_form_spec.rb[1:1:1:2] | passed | 0.00362 seconds |
5
+ ./spec/features/strong_form_spec.rb[1:1:1:3] | passed | 0.00354 seconds |
6
+ ./spec/features/strong_form_spec.rb[1:1:1:4] | passed | 0.00366 seconds |
7
+ ./spec/features/strong_form_spec.rb[1:1:2:1] | passed | 0.00479 seconds |
8
+ ./spec/features/strong_form_spec.rb[1:1:2:2] | passed | 0.14378 seconds |
9
+ ./spec/features/strong_form_spec.rb[1:1:2:3] | passed | 0.00388 seconds |
10
+ ./spec/features/strong_form_spec.rb[1:1:2:4] | passed | 0.00408 seconds |
11
+ ./spec/features/strong_form_spec.rb[1:2:1:1:1] | passed | 0.00576 seconds |
12
+ ./spec/features/strong_form_spec.rb[1:2:1:1:2] | passed | 0.00599 seconds |
13
+ ./spec/features/strong_form_spec.rb[1:2:1:1:3] | passed | 0.00628 seconds |
14
+ ./spec/features/strong_form_spec.rb[1:2:1:1:4] | passed | 0.00593 seconds |
15
+ ./spec/features/strong_form_spec.rb[1:2:1:1:5] | passed | 0.00586 seconds |
16
+ ./spec/features/strong_form_spec.rb[1:2:1:1:6] | passed | 0.00583 seconds |
17
+ ./spec/features/strong_form_spec.rb[1:2:2:1:1] | passed | 0.00649 seconds |
18
+ ./spec/features/strong_form_spec.rb[1:2:2:1:2] | passed | 0.00675 seconds |
19
+ ./spec/features/strong_form_spec.rb[1:2:2:1:3] | passed | 0.00602 seconds |
20
+ ./spec/features/strong_form_spec.rb[1:2:2:1:4] | passed | 0.03 seconds |
21
+ ./spec/features/strong_form_spec.rb[1:2:2:2:1] | passed | 0.00754 seconds |
22
+ ./spec/features/strong_form_spec.rb[1:2:2:2:2] | passed | 0.00761 seconds |
23
+ ./spec/features/strong_form_spec.rb[1:2:3:1:1] | passed | 0.0061 seconds |
24
+ ./spec/features/strong_form_spec.rb[1:2:3:1:2] | passed | 0.00794 seconds |
25
+ ./spec/features/strong_form_spec.rb[1:2:3:1:3] | passed | 0.00648 seconds |
26
+ ./spec/features/strong_form_spec.rb[1:2:3:1:4] | passed | 0.00688 seconds |
27
+ ./spec/features/strong_form_spec.rb[1:2:3:2:1] | passed | 0.00628 seconds |
28
+ ./spec/features/strong_form_spec.rb[1:2:3:2:2] | passed | 0.00641 seconds |
29
+ ./spec/features/strong_form_spec.rb[1:3:1:1:1] | passed | 0.0104 seconds |
30
+ ./spec/features/strong_form_spec.rb[1:3:1:1:2] | passed | 0.01235 seconds |
31
+ ./spec/features/strong_form_spec.rb[1:3:2:1:1] | passed | 0.01065 seconds |
32
+ ./spec/features/strong_form_spec.rb[1:3:2:1:2] | passed | 0.00964 seconds |
33
+ ./spec/features/strong_form_spec.rb[1:4:1] | passed | 0.00881 seconds |
34
+ ./spec/features/strong_form_spec.rb[1:4:2:1:1] | passed | 0.00892 seconds |
35
+ ./spec/features/strong_form_spec.rb[1:4:2:1:2] | passed | 0.00898 seconds |
36
+ ./spec/features/strong_form_spec.rb[1:4:2:2:1] | passed | 0.00937 seconds |
37
+ ./spec/features/strong_form_spec.rb[1:4:3:1:1] | passed | 0.00824 seconds |
38
+ ./spec/features/strong_form_spec.rb[1:4:3:1:2] | passed | 0.01065 seconds |
39
+ ./spec/features/strong_form_spec.rb[1:4:3:2:1] | passed | 0.01426 seconds |
40
+ ./spec/features/strong_form_spec.rb[1:4:4:1:1] | passed | 0.00833 seconds |
41
+ ./spec/features/strong_form_spec.rb[1:4:4:1:2] | passed | 0.00957 seconds |
42
+ ./spec/features/strong_form_spec.rb[1:4:4:1:3] | passed | 0.00933 seconds |
43
+ ./spec/features/strong_form_spec.rb[1:4:4:1:4] | passed | 0.0092 seconds |
44
+ ./spec/features/strong_form_spec.rb[1:4:4:1:5] | passed | 0.00932 seconds |
45
+ ./spec/features/strong_form_spec.rb[1:4:4:1:6] | passed | 0.00863 seconds |
46
+ ./spec/features/strong_form_spec.rb[1:4:4:2:1] | passed | 0.00875 seconds |
47
+ ./spec/features/strong_form_spec.rb[1:4:5:1:1] | passed | 0.02441 seconds |
48
+ ./spec/models/user_spec.rb[1:1:1:1] | passed | 0.00069 seconds |
49
+ ./spec/models/user_spec.rb[1:1:2:1] | passed | 0.00037 seconds |
50
+ ./spec/models/user_spec.rb[1:1:2:2] | passed | 0.00035 seconds |
51
+ ./spec/models/user_spec.rb[1:1:2:3] | passed | 0.00074 seconds |
52
+ ./spec/models/user_spec.rb[1:1:2:4] | passed | 0.00139 seconds |
@@ -0,0 +1,338 @@
1
+ require 'rails_helper'
2
+
3
+ def all_user_attributes
4
+ %i(first_name last_name gender description)
5
+ end
6
+
7
+ def all_addresses_attributes
8
+ %i(street city country description)
9
+ end
10
+
11
+ def all_tags_attributes
12
+ %i(name description)
13
+ end
14
+
15
+ RSpec.describe 'strong form' do
16
+ describe 'basic form' do
17
+ subject { visit '/basic_form' }
18
+
19
+ context 'without permitted attributes' do
20
+ before(:each) { subject }
21
+
22
+ all_user_attributes.each do |attr|
23
+ it "should enable #{attr}" do
24
+ expect(page.find('[name="user[' + attr.to_s + ']"]')[:disabled])
25
+ .to be_falsy
26
+ end
27
+ end
28
+ end
29
+
30
+ context 'with permitted attributes' do
31
+ before(:each) do
32
+ new_user = User.new
33
+ allow(User).to receive(:new) do
34
+ new_user.permitted_attributes = [:last_name]
35
+ new_user
36
+ end
37
+ subject
38
+ end
39
+
40
+ (all_user_attributes - %i(last_name)).each do |attr|
41
+ it "should disable #{attr}" do
42
+ expect(page.find('[name="user[' + attr.to_s + ']"]')[:disabled])
43
+ .to be_truthy
44
+ end
45
+ end
46
+
47
+ it 'should enable last_name' do
48
+ expect(page.find('[name="user[last_name]"]')[:disabled])
49
+ .to be_falsy
50
+ end
51
+ end
52
+ end
53
+
54
+ describe 'nested form' do
55
+ subject { visit '/fields_for' }
56
+
57
+ context 'without permitted attributes' do
58
+ before(:each) { subject }
59
+
60
+ describe 'has_many association' do
61
+ all_addresses_attributes.each do |attr|
62
+ it "should enable address #{attr}" do
63
+ expect(page.find(
64
+ '[name="user[addresses_attributes][0][' + attr.to_s + ']"]'
65
+ )[:disabled])
66
+ .to be_falsy
67
+ end
68
+ end
69
+
70
+ all_tags_attributes.each do |attr|
71
+ it "should enable tag #{attr}" do
72
+ expect(page.find('[name="user[tag_attributes][' + attr.to_s + ']"]')[:disabled])
73
+ .to be_falsy
74
+ end
75
+ end
76
+ end
77
+ end
78
+
79
+ context 'with permitted attributes for addresses' do
80
+ before(:each) do
81
+ new_user = User.new
82
+ allow(User).to receive(:new) do
83
+ new_user.permitted_attributes = [
84
+ :last_name, addresses_attributes: [:city]
85
+ ]
86
+ new_user
87
+ end
88
+ subject
89
+ end
90
+
91
+ describe 'has_many association' do
92
+ (all_addresses_attributes - %i(city)).each do |attr|
93
+ it "should disable address #{attr}" do
94
+ expect(page.find(
95
+ '[name="user[addresses_attributes][0][' + attr.to_s + ']"]'
96
+ )[:disabled])
97
+ .to be_truthy
98
+ end
99
+ end
100
+
101
+ it 'should enable address city' do
102
+ expect(page.find(
103
+ '[name="user[addresses_attributes][0][city]"]'
104
+ )[:disabled])
105
+ .to be_falsy
106
+ end
107
+ end
108
+
109
+ describe 'has_one association' do
110
+ all_tags_attributes.each do |attr|
111
+ it "should disable tag #{attr}" do
112
+ expect(page.find('[name="user[tag_attributes][' + attr.to_s + ']"]')[:disabled])
113
+ .to be_truthy
114
+ end
115
+ end
116
+ end
117
+ end
118
+
119
+ context 'with permitted attributes for tag' do
120
+ before(:each) do
121
+ new_user = User.new
122
+ allow(User).to receive(:new) do
123
+ new_user.permitted_attributes = [
124
+ :last_name, tag_attributes: [:name]
125
+ ]
126
+ new_user
127
+ end
128
+ subject
129
+ end
130
+
131
+ describe 'has_many association' do
132
+ all_addresses_attributes.each do |attr|
133
+ it "should disable address #{attr}" do
134
+ expect(page.find(
135
+ '[name="user[addresses_attributes][0][' + attr.to_s + ']"]'
136
+ )[:disabled])
137
+ .to be_truthy
138
+ end
139
+ end
140
+ end
141
+
142
+ describe 'has_one association' do
143
+ (all_tags_attributes - %i(name)).each do |attr|
144
+ it "should disable tag #{attr}" do
145
+ expect(page.find('[name="user[tag_attributes][' + attr.to_s + ']"]')[:disabled])
146
+ .to be_truthy
147
+ end
148
+ end
149
+
150
+ it 'should enable tag name' do
151
+ expect(page.find('[name="user[tag_attributes][name]"]')[:disabled])
152
+ .to be_falsy
153
+ end
154
+ end
155
+ end
156
+ end
157
+
158
+ describe 'deeply nested form' do
159
+ subject { visit '/deep_fields_for' }
160
+
161
+ context 'without permitted attributes' do
162
+ before(:each) { subject }
163
+
164
+ describe 'deeply nested has_many association' do
165
+ all_tags_attributes.each do |attr|
166
+ it "should enable address tag #{attr}" do
167
+ expect(page.find(
168
+ '[name="user[addresses_attributes][0][tags_attributes][0][' + attr.to_s + ']"]'
169
+ )[:disabled])
170
+ .to be_falsy
171
+ end
172
+ end
173
+ end
174
+ end
175
+
176
+ context 'with permitted attributes deeply nested tag' do
177
+ before(:each) do
178
+ new_user = User.new
179
+ allow(User).to receive(:new) do
180
+ new_user.permitted_attributes = [
181
+ addresses_attributes: { tags_attributes: [:name] }
182
+ ]
183
+ new_user
184
+ end
185
+ subject
186
+ end
187
+
188
+ describe 'deeply nested has_many association' do
189
+ (all_tags_attributes - %i(name)).each do |attr|
190
+ it "should disable address tag #{attr}" do
191
+ expect(page.find(
192
+ '[name="user[addresses_attributes][0][tags_attributes][0][' + attr.to_s + ']"]'
193
+ )[:disabled])
194
+ .to be_truthy
195
+ end
196
+ end
197
+
198
+ it 'should enable address tag name' do
199
+ expect(page.find(
200
+ '[name="user[addresses_attributes][0][tags_attributes][0][name]"]'
201
+ )[:disabled])
202
+ .to be_falsy
203
+ end
204
+ end
205
+ end
206
+ end
207
+
208
+ describe 'nested form gem' do
209
+ subject { visit '/nested_form_gem' }
210
+
211
+ it 'should work' do
212
+ subject
213
+ end
214
+
215
+ context 'without permitted attributes' do
216
+ before(:each) { subject }
217
+
218
+ describe 'link to add' do
219
+ it 'should be displayed' do
220
+ expect(page)
221
+ .to have_selector('[data-blueprint-id="addresses_fields_blueprint"]')
222
+ end
223
+
224
+ it 'blueprint should not have disabled fields' do
225
+ expect(find('#addresses_fields_blueprint', visible: false)[:'data-blueprint'])
226
+ .not_to include('disabled')
227
+ end
228
+ end
229
+
230
+ describe 'link to remove' do
231
+ it 'should be displayed' do
232
+ expect(page)
233
+ .to have_selector('a.remove_nested_fields[data-association="addresses"]')
234
+ end
235
+ end
236
+ end
237
+
238
+ context 'with permitted attributes not including association' do
239
+ before(:each) do
240
+ new_user = User.new
241
+ allow(User).to receive(:new) do
242
+ new_user.permitted_attributes = []
243
+ new_user
244
+ end
245
+ subject
246
+ end
247
+
248
+ describe 'link to add' do
249
+ it 'should not be displayed' do
250
+ expect(page)
251
+ .not_to have_selector('[data-blueprint-id="addresses_fields_blueprint"]')
252
+ end
253
+
254
+ it 'should not add blueprint' do
255
+ expect(page.all('#addresses_fields_blueprint', visible: false).length)
256
+ .to eq(0)
257
+ end
258
+ end
259
+
260
+ describe 'link to remove' do
261
+ it 'should not be displayed' do
262
+ expect(page)
263
+ .not_to have_selector('a.remove_nested_fields[data-association="addresses"]')
264
+ end
265
+ end
266
+ end
267
+
268
+ context 'with permitted attributes including association' do
269
+ before(:each) do
270
+ new_user = User.new
271
+ allow(User).to receive(:new) do
272
+ new_user.permitted_attributes = [
273
+ addresses_attributes: %i(city _destroy)
274
+ ]
275
+ new_user
276
+ end
277
+ subject
278
+ end
279
+
280
+ describe 'link to add' do
281
+ it 'should be displayed' do
282
+ expect(page)
283
+ .to have_selector('[data-blueprint-id="addresses_fields_blueprint"]')
284
+ end
285
+
286
+ it 'should add blueprint' do
287
+ expect(page.all('#addresses_fields_blueprint', visible: false).length)
288
+ .to eq(1)
289
+ end
290
+
291
+ (all_addresses_attributes - %i(city)).each do |attr|
292
+ it "should disable address #{attr} in blueprint" do
293
+ blueprint =
294
+ page.find('#addresses_fields_blueprint', visible: false)[:'data-blueprint']
295
+ tag = blueprint.match(/<[^>]+name=[^>]*#{attr}.*?>/)[0]
296
+
297
+ expect(tag).to include('disabled')
298
+ end
299
+ end
300
+
301
+ it 'should enable address city in blueprint' do
302
+ blueprint =
303
+ page.find('#addresses_fields_blueprint', visible: false)[:'data-blueprint']
304
+ city_tag = blueprint.match(/<[^>]+name=[^>]*city.*?>/)[0]
305
+
306
+ expect(city_tag).not_to include('disabled')
307
+ end
308
+ end
309
+
310
+ describe 'link to remove' do
311
+ it 'should be displayed' do
312
+ expect(page)
313
+ .to have_selector('a.remove_nested_fields[data-association="addresses"]')
314
+ end
315
+ end
316
+ end
317
+
318
+ context 'with permitted attributes including association without _destroy' do
319
+ before(:each) do
320
+ new_user = User.new
321
+ allow(User).to receive(:new) do
322
+ new_user.permitted_attributes = [
323
+ addresses_attributes: %i(city)
324
+ ]
325
+ new_user
326
+ end
327
+ subject
328
+ end
329
+
330
+ describe 'link to remove' do
331
+ it 'should not be displayed' do
332
+ expect(page)
333
+ .not_to have_selector('a.remove_nested_fields[data-association="addresses"]')
334
+ end
335
+ end
336
+ end
337
+ end
338
+ end