dynamic_form 1.2.0 → 1.3.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b0a342fb584e366ee3435e4d9e017602b9a68e5eb5a55e68f98289cc2de10e72
4
- data.tar.gz: bfd5abc37fe514962445b6b2d7678296d9befab2dd130e2fc79572dfea773b7f
3
+ metadata.gz: 3c6f76e91a7079a1585a8ab1918ec37f0dfab8db54612e7deec087f3feb33412
4
+ data.tar.gz: f85d1bb5d5e64941f041604987eb4ecb42e3b3ed83d9922291333d7f718e7835
5
5
  SHA512:
6
- metadata.gz: 7bdc76650d236b6f8074e4d92284c76f5b15a095ff2aff008ffb2ac620b707580ba5f3d1fdda75a7a45503cdfdd25d73e5871975165ba0c8e89acf090f51761a
7
- data.tar.gz: 5e4935361a88e1e0290d681efe89206684101cc86788e431cdde2bb7ce4cea308a3120b43f107a8d907706a28f7b8a02f825a0b4ea19fcca228831d4907f3dec
6
+ metadata.gz: 88a83d0ea616952a497e5a4194cc959e01f48cc32ab7e75b23745dc94b3277e48f64c8ef43f5ad4cd9697a70176a6963c0d79aeb2d562eb43dc28737863e7a54
7
+ data.tar.gz: 4e33c1c7a8af8c2c416bf4928724515e94f677898894fc570d86e115cf29342f0b543c7d5b1efea5887613a7ec88318015dcab6c17fbaa4e3aaa4b8bfca5ccec
data/.gitignore CHANGED
@@ -1,2 +1,5 @@
1
1
  .bundle
2
- pkg
2
+ pkg
3
+ *emfile.lock
4
+ *.gem
5
+ *.swp
data/Gemfile CHANGED
@@ -1,4 +1,3 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gem 'rails', '3.0.0'
4
- gem 'mocha'
3
+ gemspec path: '.'
data/Gemfile.lock CHANGED
@@ -1,74 +1,247 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ dynamic_form (1.3.0)
5
+ actionview (> 5.2.0)
6
+ activemodel (> 5.2.0)
7
+
1
8
  GEM
2
9
  remote: http://rubygems.org/
3
10
  specs:
4
- abstract (1.0.0)
5
- actionmailer (3.0.0)
6
- actionpack (= 3.0.0)
7
- mail (~> 2.2.5)
8
- actionpack (3.0.0)
9
- activemodel (= 3.0.0)
10
- activesupport (= 3.0.0)
11
- builder (~> 2.1.2)
12
- erubis (~> 2.6.6)
13
- i18n (~> 0.4.1)
14
- rack (~> 1.2.1)
15
- rack-mount (~> 0.6.12)
16
- rack-test (~> 0.5.4)
17
- tzinfo (~> 0.3.23)
18
- activemodel (3.0.0)
19
- activesupport (= 3.0.0)
20
- builder (~> 2.1.2)
21
- i18n (~> 0.4.1)
22
- activerecord (3.0.0)
23
- activemodel (= 3.0.0)
24
- activesupport (= 3.0.0)
25
- arel (~> 1.0.0)
26
- tzinfo (~> 0.3.23)
27
- activeresource (3.0.0)
28
- activemodel (= 3.0.0)
29
- activesupport (= 3.0.0)
30
- activesupport (3.0.0)
31
- arel (1.0.1)
32
- activesupport (~> 3.0.0)
33
- builder (2.1.2)
34
- erubis (2.6.6)
35
- abstract (>= 1.0.0)
36
- i18n (0.4.1)
37
- mail (2.2.5)
38
- activesupport (>= 2.3.6)
39
- mime-types
40
- treetop (>= 1.4.5)
41
- mime-types (1.16)
42
- mocha (0.9.8)
43
- rake
44
- polyglot (0.3.1)
45
- rack (1.2.1)
46
- rack-mount (0.6.13)
47
- rack (>= 1.0.0)
48
- rack-test (0.5.4)
49
- rack (>= 1.0)
50
- rails (3.0.0)
51
- actionmailer (= 3.0.0)
52
- actionpack (= 3.0.0)
53
- activerecord (= 3.0.0)
54
- activeresource (= 3.0.0)
55
- activesupport (= 3.0.0)
56
- bundler (~> 1.0.0)
57
- railties (= 3.0.0)
58
- railties (3.0.0)
59
- actionpack (= 3.0.0)
60
- activesupport (= 3.0.0)
61
- rake (>= 0.8.4)
62
- thor (~> 0.14.0)
63
- rake (0.8.7)
64
- thor (0.14.0)
65
- treetop (1.4.8)
66
- polyglot (>= 0.3.1)
67
- tzinfo (0.3.23)
11
+ actioncable (7.1.1)
12
+ actionpack (= 7.1.1)
13
+ activesupport (= 7.1.1)
14
+ nio4r (~> 2.0)
15
+ websocket-driver (>= 0.6.1)
16
+ zeitwerk (~> 2.6)
17
+ actionmailbox (7.1.1)
18
+ actionpack (= 7.1.1)
19
+ activejob (= 7.1.1)
20
+ activerecord (= 7.1.1)
21
+ activestorage (= 7.1.1)
22
+ activesupport (= 7.1.1)
23
+ mail (>= 2.7.1)
24
+ net-imap
25
+ net-pop
26
+ net-smtp
27
+ actionmailer (7.1.1)
28
+ actionpack (= 7.1.1)
29
+ actionview (= 7.1.1)
30
+ activejob (= 7.1.1)
31
+ activesupport (= 7.1.1)
32
+ mail (~> 2.5, >= 2.5.4)
33
+ net-imap
34
+ net-pop
35
+ net-smtp
36
+ rails-dom-testing (~> 2.2)
37
+ actionpack (7.1.1)
38
+ actionview (= 7.1.1)
39
+ activesupport (= 7.1.1)
40
+ nokogiri (>= 1.8.5)
41
+ rack (>= 2.2.4)
42
+ rack-session (>= 1.0.1)
43
+ rack-test (>= 0.6.3)
44
+ rails-dom-testing (~> 2.2)
45
+ rails-html-sanitizer (~> 1.6)
46
+ actiontext (7.1.1)
47
+ actionpack (= 7.1.1)
48
+ activerecord (= 7.1.1)
49
+ activestorage (= 7.1.1)
50
+ activesupport (= 7.1.1)
51
+ globalid (>= 0.6.0)
52
+ nokogiri (>= 1.8.5)
53
+ actionview (7.1.1)
54
+ activesupport (= 7.1.1)
55
+ builder (~> 3.1)
56
+ erubi (~> 1.11)
57
+ rails-dom-testing (~> 2.2)
58
+ rails-html-sanitizer (~> 1.6)
59
+ activejob (7.1.1)
60
+ activesupport (= 7.1.1)
61
+ globalid (>= 0.3.6)
62
+ activemodel (7.1.1)
63
+ activesupport (= 7.1.1)
64
+ activerecord (7.1.1)
65
+ activemodel (= 7.1.1)
66
+ activesupport (= 7.1.1)
67
+ timeout (>= 0.4.0)
68
+ activestorage (7.1.1)
69
+ actionpack (= 7.1.1)
70
+ activejob (= 7.1.1)
71
+ activerecord (= 7.1.1)
72
+ activesupport (= 7.1.1)
73
+ marcel (~> 1.0)
74
+ activesupport (7.1.1)
75
+ base64
76
+ bigdecimal
77
+ concurrent-ruby (~> 1.0, >= 1.0.2)
78
+ connection_pool (>= 2.2.5)
79
+ drb
80
+ i18n (>= 1.6, < 2)
81
+ minitest (>= 5.1)
82
+ mutex_m
83
+ tzinfo (~> 2.0)
84
+ addressable (2.8.5)
85
+ public_suffix (>= 2.0.2, < 6.0)
86
+ base64 (0.1.1)
87
+ bigdecimal (3.1.4)
88
+ builder (3.2.4)
89
+ byebug (11.1.3)
90
+ capybara (3.39.2)
91
+ addressable
92
+ matrix
93
+ mini_mime (>= 0.1.3)
94
+ nokogiri (~> 1.8)
95
+ rack (>= 1.6.0)
96
+ rack-test (>= 0.6.3)
97
+ regexp_parser (>= 1.5, < 3.0)
98
+ xpath (~> 3.2)
99
+ concurrent-ruby (1.2.2)
100
+ connection_pool (2.4.1)
101
+ crass (1.0.6)
102
+ date (3.3.3)
103
+ drb (2.1.1)
104
+ ruby2_keywords
105
+ erubi (1.12.0)
106
+ globalid (1.2.1)
107
+ activesupport (>= 6.1)
108
+ i18n (1.14.1)
109
+ concurrent-ruby (~> 1.0)
110
+ io-console (0.6.0)
111
+ irb (1.8.3)
112
+ rdoc
113
+ reline (>= 0.3.8)
114
+ json (2.6.3)
115
+ loofah (2.21.4)
116
+ crass (~> 1.0.2)
117
+ nokogiri (>= 1.12.0)
118
+ mail (2.8.1)
119
+ mini_mime (>= 0.1.1)
120
+ net-imap
121
+ net-pop
122
+ net-smtp
123
+ marcel (1.0.2)
124
+ matrix (0.4.2)
125
+ mini_mime (1.1.5)
126
+ minitest (5.20.0)
127
+ mocha (2.1.0)
128
+ ruby2_keywords (>= 0.0.5)
129
+ mutex_m (0.1.2)
130
+ net-imap (0.4.3)
131
+ date
132
+ net-protocol
133
+ net-pop (0.1.2)
134
+ net-protocol
135
+ net-protocol (0.2.1)
136
+ timeout
137
+ net-smtp (0.4.0)
138
+ net-protocol
139
+ nio4r (2.5.9)
140
+ nokogiri (1.15.4-x86_64-linux)
141
+ racc (~> 1.4)
142
+ power_assert (2.0.3)
143
+ psych (5.1.1.1)
144
+ stringio
145
+ public_suffix (5.0.3)
146
+ racc (1.7.1)
147
+ rack (3.0.8)
148
+ rack-session (2.0.0)
149
+ rack (>= 3.0.0)
150
+ rack-test (2.1.0)
151
+ rack (>= 1.3)
152
+ rackup (2.1.0)
153
+ rack (>= 3)
154
+ webrick (~> 1.8)
155
+ rails (7.1.1)
156
+ actioncable (= 7.1.1)
157
+ actionmailbox (= 7.1.1)
158
+ actionmailer (= 7.1.1)
159
+ actionpack (= 7.1.1)
160
+ actiontext (= 7.1.1)
161
+ actionview (= 7.1.1)
162
+ activejob (= 7.1.1)
163
+ activemodel (= 7.1.1)
164
+ activerecord (= 7.1.1)
165
+ activestorage (= 7.1.1)
166
+ activesupport (= 7.1.1)
167
+ bundler (>= 1.15.0)
168
+ railties (= 7.1.1)
169
+ rails-dom-testing (2.2.0)
170
+ activesupport (>= 5.0.0)
171
+ minitest
172
+ nokogiri (>= 1.6)
173
+ rails-html-sanitizer (1.6.0)
174
+ loofah (~> 2.21)
175
+ nokogiri (~> 1.14)
176
+ railties (7.1.1)
177
+ actionpack (= 7.1.1)
178
+ activesupport (= 7.1.1)
179
+ irb
180
+ rackup (>= 1.0.0)
181
+ rake (>= 12.2)
182
+ thor (~> 1.0, >= 1.2.2)
183
+ zeitwerk (~> 2.6)
184
+ rake (13.1.0)
185
+ rdoc (6.5.0)
186
+ psych (>= 4.0.0)
187
+ regexp_parser (2.8.2)
188
+ reline (0.3.9)
189
+ io-console (~> 0.5)
190
+ rr (3.1.0)
191
+ ruby2_keywords (0.0.5)
192
+ stringio (3.0.8)
193
+ test-unit (3.6.1)
194
+ power_assert
195
+ test-unit-activesupport (1.1.1)
196
+ activesupport
197
+ test-unit
198
+ test-unit-capybara (1.1.1)
199
+ capybara (>= 2.1.0)
200
+ json
201
+ test-unit (>= 2.5.3)
202
+ test-unit-context (0.5.1)
203
+ test-unit (>= 2.4.0)
204
+ test-unit-full (0.0.5)
205
+ test-unit
206
+ test-unit-context
207
+ test-unit-notify
208
+ test-unit-rr
209
+ test-unit-runner-tap
210
+ test-unit-notify (1.0.4)
211
+ test-unit (>= 2.4.9)
212
+ test-unit-rails (7.0.2)
213
+ rails (>= 4.1.0)
214
+ test-unit (>= 3.1.7)
215
+ test-unit-activesupport (>= 1.0.8)
216
+ test-unit-capybara (>= 1.0.5)
217
+ test-unit-rr (>= 1.0.4)
218
+ test-unit-rr (1.0.5)
219
+ rr (>= 1.1.1)
220
+ test-unit (>= 2.5.2)
221
+ test-unit-runner-tap (1.1.2)
222
+ test-unit
223
+ thor (1.3.0)
224
+ timeout (0.4.0)
225
+ tzinfo (2.0.6)
226
+ concurrent-ruby (~> 1.0)
227
+ webrick (1.8.1)
228
+ websocket-driver (0.7.6)
229
+ websocket-extensions (>= 0.1.0)
230
+ websocket-extensions (0.1.5)
231
+ xpath (3.2.0)
232
+ nokogiri (~> 1.8)
233
+ zeitwerk (2.6.12)
68
234
 
69
235
  PLATFORMS
70
- ruby
236
+ x86_64-linux
71
237
 
72
238
  DEPENDENCIES
239
+ byebug
240
+ dynamic_form!
73
241
  mocha
74
- rails (= 3.0.0)
242
+ test-unit
243
+ test-unit-full
244
+ test-unit-rails
245
+
246
+ BUNDLED WITH
247
+ 2.4.21
data/Rakefile CHANGED
@@ -1,23 +1,6 @@
1
1
  require "rake"
2
2
  require 'rake/testtask'
3
3
 
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "dynamic_form"
8
- gem.summary = %Q{DynamicForm holds a few helper methods to help you deal with your Rails3 models}
9
- gem.description = %Q{DynamicForm holds a few helper methods to help you deal with your Rails3 models. It includes the stripped out methods from Rails 2; error_message_on and error_messages_for. It also brings in the functionality of the custom-err-messages plugin, which provides more flexibility over your model error messages.}
10
- gem.email = "joel@developwithstyle.com"
11
- gem.homepage = "http://codaset.com/joelmoss/dynamic-form"
12
- gem.authors = ["Joel Moss"]
13
- gem.add_development_dependency "mocha", ">= 0"
14
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
- end
16
- Jeweler::GemcutterTasks.new
17
- rescue LoadError
18
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
19
- end
20
-
21
4
  desc 'Default: run unit tests.'
22
5
  task :default => :test
23
6
 
data/dynamic_form.gemspec CHANGED
@@ -1,13 +1,9 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
- # -*- encoding: utf-8 -*-
5
-
6
1
  Gem::Specification.new do |s|
7
2
  s.name = %q{dynamic_form}
8
- s.version = "1.2.0"
3
+ s.version = "1.3.0"
9
4
 
10
5
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
+ s.required_ruby_version = ">= 2.7.0", "< 3.3"
11
7
  s.authors = ["Joel Moss"]
12
8
  s.date = %q{2010-09-05}
13
9
  s.description = %q{DynamicForm holds a few helper methods to help you deal with your Rails3 models. It includes the stripped out methods from Rails 2; error_message_on and error_messages_for. It also brings in the functionality of the custom-err-messages plugin, which provides more flexibility over your model error messages.}
@@ -45,16 +41,11 @@ Gem::Specification.new do |s|
45
41
  "test/test_helper.rb"
46
42
  ]
47
43
 
48
- if s.respond_to? :specification_version then
49
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
50
- s.specification_version = 3
51
-
52
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
53
- s.add_development_dependency(%q<mocha>, [">= 0"])
54
- else
55
- s.add_dependency(%q<mocha>, [">= 0"])
56
- end
57
- else
58
- s.add_dependency(%q<mocha>, [">= 0"])
59
- end
44
+ s.add_runtime_dependency 'actionview', '> 5.2.0'
45
+ s.add_runtime_dependency 'activemodel', '> 5.2.0'
46
+ s.add_development_dependency(%q<byebug>, [">= 0"])
47
+ s.add_development_dependency(%q<mocha>, [">= 0"])
48
+ s.add_development_dependency(%q<test-unit>, [">= 0"])
49
+ s.add_development_dependency(%q<test-unit-rails>, [">= 0"])
50
+ s.add_development_dependency(%q<test-unit-full>, [">= 0"])
60
51
  end
@@ -2,6 +2,7 @@ require 'action_view/helpers'
2
2
  require 'active_support/i18n'
3
3
  require 'active_support/core_ext/enumerable'
4
4
  require 'active_support/core_ext/object/blank'
5
+ class BrokenFeatureError < RuntimeError; end
5
6
 
6
7
  module ActionView
7
8
  module Helpers
@@ -16,6 +17,7 @@ module ActionView
16
17
  # input("post", "title")
17
18
  # # => <input id="post_title" name="post[title]" size="30" type="text" value="Hello World" />
18
19
  def input(record_name, method, options = {})
20
+ raise_broken_code_error
19
21
  InstanceTag.new(record_name, method, self).to_tag(options)
20
22
  end
21
23
 
@@ -79,6 +81,7 @@ module ActionView
79
81
 
80
82
  submit_value = options[:submit_value] || options[:action].gsub(/[^\w]/, '').capitalize
81
83
 
84
+ raise_broken_code_error
82
85
  contents = form_tag({:action => action}, :method =>(options[:method] || 'post'), :enctype => options[:multipart] ? 'multipart/form-data': nil)
83
86
  contents.safe_concat hidden_field(record_name, :id) if record.persisted?
84
87
  contents.safe_concat all_input_tags(record, record_name, options)
@@ -87,6 +90,10 @@ module ActionView
87
90
  contents.safe_concat('</form>')
88
91
  end
89
92
 
93
+ def convert_to_model(object)
94
+ object.respond_to?(:to_model) ? object.to_model : object
95
+ end
96
+
90
97
  # Returns a string containing the error message attached to the +method+ on the +object+ if one exists.
91
98
  # This error message is wrapped in a <tt>DIV</tt> tag by default or with <tt>:html_tag</tt> if specified,
92
99
  # which can be extended to include a <tt>:prepend_text</tt> and/or <tt>:append_text</tt> (to properly explain
@@ -241,6 +248,11 @@ module ActionView
241
248
 
242
249
  private
243
250
 
251
+ def raise_broken_code_error
252
+ raise BrokenFeatureError,
253
+ "This feature is currently broken, please open a pull request at https://github.com/payrollhero/dynamic_form to have it reviewed and released."
254
+ end
255
+
244
256
  def all_input_tags(record, record_name, options)
245
257
  input_block = options[:input_block] || default_input_block
246
258
  record.class.content_columns.collect{ |column| input_block.call(record_name, column) }.join("\n")
@@ -39,4 +39,4 @@ class DynamicFormI18nTest < Test::Unit::TestCase
39
39
  I18n.expects(:t).with(:'body', :locale => 'en', :scope => [:activerecord, :errors, :template]).returns 'There were problems with the following fields:'
40
40
  error_messages_for(:object => @object, :locale => 'en')
41
41
  end
42
- end
42
+ end
@@ -1,5 +1,6 @@
1
1
  require 'test_helper'
2
- require 'action_view/template/handlers/erb'
2
+ # warning: loading in progress, circular require considered harmful
3
+ #require 'action_view/template/handlers/erb'
3
4
 
4
5
  class DynamicFormTest < ActionView::TestCase
5
6
  tests ActionView::Helpers::DynamicForm
@@ -121,8 +122,6 @@ class DynamicFormTest < ActionView::TestCase
121
122
  super
122
123
  setup_post
123
124
  setup_user
124
-
125
- @response = ActionController::TestResponse.new
126
125
  end
127
126
 
128
127
  def url_for(options)
@@ -131,23 +130,28 @@ class DynamicFormTest < ActionView::TestCase
131
130
  end
132
131
 
133
132
  def test_generic_input_tag
133
+ assert_raise(BrokenFeatureError) do
134
134
  assert_dom_equal(
135
135
  %(<input id="post_title" name="post[title]" size="30" type="text" value="Hello World" />), input("post", "title")
136
136
  )
137
+ end
137
138
  end
138
139
 
139
140
  def test_text_area_with_errors
140
- assert_dom_equal(
141
- %(<div class="field_with_errors"><textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea></div>),
142
- text_area("post", "body")
141
+ expected_dom = %(
142
+ <div class="field_with_errors"><textarea id="post_body" name="post[body]">
143
+ Back to the hill and over it again!</textarea></div>
143
144
  )
145
+ assert_dom_equal(expected_dom, text_area("post", "body"))
144
146
  end
145
147
 
146
148
  def test_text_field_with_errors
147
- assert_dom_equal(
148
- %(<div class="field_with_errors"><input id="post_author_name" name="post[author_name]" size="30" type="text" value="" /></div>),
149
- text_field("post", "author_name")
149
+ expected_dom = %(
150
+ <div class="field_with_errors">
151
+ <input type="text" value="" id="post_author_name" name="post[author_name]" />
152
+ </div>
150
153
  )
154
+ assert_dom_equal(expected_dom, text_field("post", "author_name"))
151
155
  end
152
156
 
153
157
  def test_field_error_proc
@@ -157,7 +161,7 @@ class DynamicFormTest < ActionView::TestCase
157
161
  end
158
162
 
159
163
  assert_dom_equal(
160
- %(<div class="field_with_errors"><input id="post_author_name" name="post[author_name]" size="30" type="text" value="" /> <span class="error">can't be empty</span></div>),
164
+ %(<div class="field_with_errors"><input id="post_author_name" name="post[author_name]" type="text" value="" /> <span class="error">can't be empty</span></div>),
161
165
  text_field("post", "author_name")
162
166
  )
163
167
  ensure
@@ -165,6 +169,12 @@ class DynamicFormTest < ActionView::TestCase
165
169
  end
166
170
 
167
171
  def test_form_with_string
172
+ assert_raise(BrokenFeatureError) do
173
+ inner_test_form_with_string
174
+ end
175
+ end
176
+
177
+ def inner_test_form_with_string
168
178
  assert_dom_equal(
169
179
  %(<form accept-charset="UTF-8" action="create" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /></div><p><label for="post_title">Title</label><br /><input id="post_title" name="post[title]" size="30" type="text" value="Hello World" /></p>\n<p><label for="post_body">Body</label><br /><div class="field_with_errors"><textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea></div></p><input name="commit" type="submit" value="Create" /></form>),
170
180
  form("post")
@@ -185,6 +195,12 @@ class DynamicFormTest < ActionView::TestCase
185
195
  end
186
196
 
187
197
  def test_form_with_protect_against_forgery
198
+ assert_raise(BrokenFeatureError) do
199
+ inner_test_form_with_protect_against_forgery
200
+ end
201
+ end
202
+
203
+ def inner_test_form_with_protect_against_forgery
188
204
  @protect_against_forgery = true
189
205
  @request_forgery_protection_token = 'authenticity_token'
190
206
  @form_authenticity_token = '123'
@@ -195,6 +211,12 @@ class DynamicFormTest < ActionView::TestCase
195
211
  end
196
212
 
197
213
  def test_form_with_method_option
214
+ assert_raise(BrokenFeatureError) do
215
+ inner_test_form_with_method_option
216
+ end
217
+ end
218
+
219
+ def inner_test_form_with_method_option
198
220
  assert_dom_equal(
199
221
  %(<form accept-charset="UTF-8" action="create" method="get"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /></div><p><label for="post_title">Title</label><br /><input id="post_title" name="post[title]" size="30" type="text" value="Hello World" /></p>\n<p><label for="post_body">Body</label><br /><div class="field_with_errors"><textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea></div></p><input name="commit" type="submit" value="Create" /></form>),
200
222
  form("post", :method=>'get')
@@ -202,13 +224,21 @@ class DynamicFormTest < ActionView::TestCase
202
224
  end
203
225
 
204
226
  def test_form_with_action_option
227
+ assert_raise(BrokenFeatureError) do
205
228
  output_buffer << form("post", :action => "sign")
206
229
  assert_select "form[action=sign]" do |form|
207
230
  assert_select "input[type=submit][value=Sign]"
208
231
  end
232
+ end
209
233
  end
210
234
 
211
235
  def test_form_with_date
236
+ assert_raise(BrokenFeatureError) do
237
+ inner_test_form_with_date
238
+ end
239
+ end
240
+
241
+ def inner_test_form_with_date
212
242
  silence_warnings do
213
243
  def Post.content_columns() [ Column.new(:date, "written_on", "Written on") ] end
214
244
  end
@@ -220,6 +250,12 @@ class DynamicFormTest < ActionView::TestCase
220
250
  end
221
251
 
222
252
  def test_form_with_datetime
253
+ assert_raise(BrokenFeatureError) do
254
+ inner_test_form_with_datetime
255
+ end
256
+ end
257
+
258
+ def inner_test_form_with_datetime
223
259
  silence_warnings do
224
260
  def Post.content_columns() [ Column.new(:datetime, "written_on", "Written on") ] end
225
261
  end
@@ -232,10 +268,10 @@ class DynamicFormTest < ActionView::TestCase
232
268
  end
233
269
 
234
270
  def test_error_for_block
235
- assert_dom_equal %(<div class="errorExplanation" id="errorExplanation"><h2>1 error prohibited this post from being saved</h2><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li></ul></div>), error_messages_for("post")
236
- assert_equal %(<div class="errorDeathByClass" id="errorDeathById"><h1>1 error prohibited this post from being saved</h1><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li></ul></div>), error_messages_for("post", :class => "errorDeathByClass", :id => "errorDeathById", :header_tag => "h1")
237
- assert_equal %(<div id="errorDeathById"><h1>1 error prohibited this post from being saved</h1><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li></ul></div>), error_messages_for("post", :class => nil, :id => "errorDeathById", :header_tag => "h1")
238
- assert_equal %(<div class="errorDeathByClass"><h1>1 error prohibited this post from being saved</h1><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li></ul></div>), error_messages_for("post", :class => "errorDeathByClass", :id => nil, :header_tag => "h1")
271
+ assert_dom_equal %(<div id="errorExplanation" class="errorExplanation"><h2>1 error prohibited this post from being saved</h2><p>There were problems with the following fields:</p><ul><li>Author name can&#39;t be empty</li></ul></div>), error_messages_for("post")
272
+ assert_equal %(<div id="errorDeathById" class="errorDeathByClass"><h1>1 error prohibited this post from being saved</h1><p>There were problems with the following fields:</p><ul><li>Author name can&#39;t be empty</li></ul></div>), error_messages_for("post", :class => "errorDeathByClass", :id => "errorDeathById", :header_tag => "h1")
273
+ assert_equal %(<div id="errorDeathById"><h1>1 error prohibited this post from being saved</h1><p>There were problems with the following fields:</p><ul><li>Author name can&#39;t be empty</li></ul></div>), error_messages_for("post", :class => nil, :id => "errorDeathById", :header_tag => "h1")
274
+ assert_equal %(<div class="errorDeathByClass"><h1>1 error prohibited this post from being saved</h1><p>There were problems with the following fields:</p><ul><li>Author name can&#39;t be empty</li></ul></div>), error_messages_for("post", :class => "errorDeathByClass", :id => nil, :header_tag => "h1")
239
275
  end
240
276
 
241
277
  def test_error_messages_for_escapes_html
@@ -331,10 +367,12 @@ class DynamicFormTest < ActionView::TestCase
331
367
  end
332
368
 
333
369
  def test_form_with_string_multipart
370
+ assert_raise(BrokenFeatureError) do
334
371
  assert_dom_equal(
335
- %(<form accept-charset="UTF-8" action="create" enctype="multipart/form-data" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /></div><p><label for="post_title">Title</label><br /><input id="post_title" name="post[title]" size="30" type="text" value="Hello World" /></p>\n<p><label for="post_body">Body</label><br /><div class="field_with_errors"><textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea></div></p><input name="commit" type="submit" value="Create" /></form>),
372
+ %(<form accept-charset="UTF-8" action="create" enctype="multipart/form-data" method="post"><input name="utf8" type="hidden" value="&#x2713;" autocomplete="off" /><p><label for="post_title">Title</label><br /><input id="post_title" name="post[title]" size="30" type="text" value="Hello World" /></p>\n<p><label for="post_body">Body</label><br /><div class="field_with_errors"><textarea cols="40" id="post_body" name="post[body]" rows="20">Back to the hill and over it again!</textarea></div></p><input name="commit" type="submit" value="Create" /></form>),
336
373
  form("post", :multipart => true)
337
374
  )
375
+ end
338
376
  end
339
377
 
340
378
  def test_default_form_builder_with_dynamic_form_helpers
@@ -343,8 +381,9 @@ class DynamicFormTest < ActionView::TestCase
343
381
  concat f.error_messages
344
382
  end
345
383
 
346
- expected = %(<form accept-charset="UTF-8" class="post_new" method="post" action="" id="post_new">) +
347
- %(<div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /></div>) +
384
+ autocomplete = ActionView.version.to_s >= '6.1.0' ? ' autocomplete="off"' : ''
385
+ expected = %(<form class="new_post" id="new_post" action="" accept-charset="UTF-8" method="post">) +
386
+ %(<input name="utf8" type="hidden" value="&#x2713;"#{autocomplete} />) +
348
387
  %(<div class="formError">can't be empty</div>) +
349
388
  %(<div class="errorExplanation" id="errorExplanation"><h2>1 error prohibited this post from being saved</h2><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li></ul></div>) +
350
389
  %(</form>)
@@ -361,18 +400,19 @@ class DynamicFormTest < ActionView::TestCase
361
400
  concat f.error_messages
362
401
  end
363
402
 
364
- expected = %(<form accept-charset="UTF-8" class="post_new" method="post" action="" id="post_new">) +
365
- %(<div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="&#x2713;" /></div>) +
403
+ autocomplete = ActionView.version.to_s >= '6.1.0' ? ' autocomplete="off"' : ''
404
+ expected = %(<form accept-charset="UTF-8" class="new_post" method="post" action="" id="new_post">) +
405
+ %(<input name="utf8" type="hidden" value="&#x2713;"#{autocomplete} />) +
366
406
  %(<div class="formError">can't be empty</div>) +
367
407
  %(<div class="errorExplanation" id="errorExplanation"><h2>1 error prohibited this post from being saved</h2><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li></ul></div>) +
368
408
  %(</form>)
369
409
 
370
410
  assert_dom_equal expected, output_buffer
371
411
  end
372
-
412
+
373
413
  def test_error_messages_without_prefixed_attribute_name
374
414
  error = error_messages_for(@post)
375
415
  assert_dom_equal %(<div class="errorExplanation" id="errorExplanation"><h2>1 error prohibited this post from being saved</h2><p>There were problems with the following fields:</p><ul><li>Author name can't be empty</li></ul></div>),
376
416
  error
377
417
  end
378
- end
418
+ end
data/test/test_helper.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  require 'rubygems'
2
2
  require 'test/unit'
3
+ require 'test/unit/active_support'
4
+ require "test/unit/notify"
5
+ require 'mocha/test_unit'
3
6
  require 'active_support'
4
7
  require 'active_support/core_ext'
5
8
  require 'action_view'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamic_form
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Moss
@@ -10,6 +10,48 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2010-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: actionview
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">"
18
+ - !ruby/object:Gem::Version
19
+ version: 5.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">"
25
+ - !ruby/object:Gem::Version
26
+ version: 5.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: activemodel
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">"
32
+ - !ruby/object:Gem::Version
33
+ version: 5.2.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">"
39
+ - !ruby/object:Gem::Version
40
+ version: 5.2.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: byebug
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
13
55
  - !ruby/object:Gem::Dependency
14
56
  name: mocha
15
57
  requirement: !ruby/object:Gem::Requirement
@@ -24,6 +66,48 @@ dependencies:
24
66
  - - ">="
25
67
  - !ruby/object:Gem::Version
26
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: test-unit
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: test-unit-rails
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: test-unit-full
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
27
111
  description: DynamicForm holds a few helper methods to help you deal with your Rails3
28
112
  models. It includes the stripped out methods from Rails 2; error_message_on and
29
113
  error_messages_for. It also brings in the functionality of the custom-err-messages
@@ -63,16 +147,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
63
147
  requirements:
64
148
  - - ">="
65
149
  - !ruby/object:Gem::Version
66
- version: '0'
150
+ version: 2.7.0
151
+ - - "<"
152
+ - !ruby/object:Gem::Version
153
+ version: '3.3'
67
154
  required_rubygems_version: !ruby/object:Gem::Requirement
68
155
  requirements:
69
156
  - - ">="
70
157
  - !ruby/object:Gem::Version
71
158
  version: '0'
72
159
  requirements: []
73
- rubygems_version: 3.4.11
160
+ rubygems_version: 3.4.18
74
161
  signing_key:
75
- specification_version: 3
162
+ specification_version: 4
76
163
  summary: DynamicForm holds a few helper methods to help you deal with your Rails3
77
164
  models
78
165
  test_files: