forme 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -170,6 +170,12 @@ describe "Sequel forme_set plugin" do
170
170
  end
171
171
  end
172
172
 
173
+ it "#forme_set should not add validations for inputs with no options" do
174
+ @f.input(:artist, :options=>nil)
175
+ @ab.forme_set('artist_id'=>'1')
176
+ @ab.valid?.must_equal true
177
+ end
178
+
173
179
  it "#forme_set should not require associated values for many_to_one association with select boxes" do
174
180
  @f.input(:artist)
175
181
  @ab.forme_set({})
@@ -42,7 +42,7 @@ module FormeErbSpecs
42
42
  end
43
43
 
44
44
  it "#form should correctly handle subform with :grid option without block" do
45
- sin_get('/grid-noblock-multiple').sub(/ 3\z/, '3').sub(%r{<input name="_csrf" type="hidden" value="([^"]+)"/>}, '<input name="_csrf" type="hidden" value="csrf"/>').must_equal '0 <form action="/baz" class="forme artist" method="post"><input name="_csrf" type="hidden" value="csrf"/> 1 <input id="artist_albums_attributes_0_id" name="artist[albums_attributes][0][id]" type="hidden" value="1"/><table><caption>Foo</caption><thead><tr><th>Name</th><th>Copies</th></tr></thead><tbody><tr><td class="string"><input id="artist_albums_attributes_0_name" maxlength="255" name="artist[albums_attributes][0][name]" type="text" value="N"/></td><td class="integer"><input id="artist_albums_attributes_0_copies_sold" name="artist[albums_attributes][0][copies_sold]" type="number" value="2"/></td></tr></tbody></table> 2 <input type="submit" value="Sub"/></form>3'
45
+ sin_get('/grid-noblock-multiple').sub(/ 3\z/, '3').sub(%r{<input name="_csrf" type="hidden" value="([^"]+)"/>}, '<input name="_csrf" type="hidden" value="csrf"/>').must_equal '0 <form action="/baz" class="forme artist" method="post"><input name="_csrf" type="hidden" value="csrf"/> 1 <input id="artist_albums_attributes_0_id" name="artist[albums_attributes][0][id]" type="hidden" value="1"/><table><caption>Foo</caption><thead><tr><th>Name</th><th>Copies</th></tr></thead><tbody><tr><td class="string"><input id="artist_albums_attributes_0_name" maxlength="255" name="artist[albums_attributes][0][name]" type="text" value="N"/></td><td class="integer"><input id="artist_albums_attributes_0_copies_sold" inputmode="numeric" name="artist[albums_attributes][0][copies_sold]" pattern="-?[0-9]*" type="text" value="2"/></td></tr></tbody></table> 2 <input type="submit" value="Sub"/></form>3'
46
46
  end
47
47
 
48
48
  it "#form should accept two hashes instead of requiring obj as first argument" do
@@ -31,6 +31,24 @@ class FormeSinatraTest < Sinatra::Base
31
31
  end
32
32
 
33
33
  instance_exec(self, &ERB_BLOCK)
34
+
35
+ get 'no-session' do
36
+ session = env.delete('rack.session')
37
+ body = erb <<END
38
+ <% form(:method=>'POST') do %>
39
+ <% end %>
40
+ END
41
+ env['rack.session'] = session
42
+ body
43
+ end
44
+
45
+ get 'no-out_buf' do
46
+ erb(<<END, :outvar=>'@_foo')
47
+ <% form(:method=>'POST') do |f| %>
48
+ <%= f.input(:text) %>
49
+ <% end %>
50
+ END
51
+ end
34
52
  end
35
53
 
36
54
  describe "Forme Sinatra ERB integration" do
@@ -41,5 +59,13 @@ describe "Forme Sinatra ERB integration" do
41
59
  end
42
60
 
43
61
  include FormeErbSpecs
62
+
63
+ it "should handle missing rack.session when using Rack::Csrf" do
64
+ sin_get('/no-session').must_equal '<form method="POST"></form>'
65
+ end
66
+
67
+ it "should handle non-standard outvar, but without emitting into template" do
68
+ sin_get('/no-out_buf').must_equal '<input type="text"/>'
69
+ end
44
70
  end
45
71
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forme
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-25 00:00:00.000000000 Z
11
+ date: 2022-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest