monkey_forms 0.0.18 → 0.0.19

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,8 +1,3 @@
1
- NOTE! If you use the cookie serialization feature, you
2
- need to use this version of deep_merge for now.
3
- https://github.com/joevandyk/deep_merge
4
-
5
-
6
1
  MonkeyForms::Form is an ActiveModel-compliant interface
7
2
  between your controllers and models (or whatever you are
8
3
  saving the data to).
@@ -1,3 +1,3 @@
1
1
  module MonkeyForms
2
- VERSION = "0.0.18"
2
+ VERSION = "0.0.19"
3
3
  end
data/lib/monkey_forms.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  $: << File.expand_path('monkey_forms/vendor/grouped_validations/lib', File.dirname(__FILE__))
2
2
  $: << File.expand_path('monkey_forms/vendor/deep_merge/lib', File.dirname(__FILE__))
3
+
4
+ # Warning: This code is atrocious.
3
5
  module MonkeyForms
4
6
  require 'monkey_forms/serializers'
5
7
  require 'active_model'
@@ -69,7 +71,13 @@ module MonkeyForms
69
71
  self.class.attributes.each do |a|
70
72
  @attributes[a] ||= ""
71
73
  if self.class.strip_attributes?
72
- @attributes[a].strip! if @attributes[a].class == String
74
+ if @attributes[a].class == String
75
+ @attributes[a].strip!
76
+ #elsif @attributes[a].class == Array
77
+ #@attributes[a].each do |v|
78
+ #v.strip! if v.class == String
79
+ #end
80
+ end
73
81
  end
74
82
  end
75
83
  end
@@ -5,7 +5,7 @@ class OrderForm
5
5
  attr_reader :an_attribute
6
6
 
7
7
  # Declares a few attributes on the form.
8
- form_attributes :name, :email, :city, :state, :line_items
8
+ form_attributes :name, :email, :city, :state, :line_items, :upload
9
9
  custom_attributes :user_id
10
10
  form_name :cart
11
11
 
@@ -23,6 +23,10 @@ class SampleSinatra < Sinatra::Base
23
23
  haml :form
24
24
  end
25
25
 
26
+ post "/upload" do
27
+ @form.upload[:tempfile].read.size.to_s
28
+ end
29
+
26
30
  post "/haml_form" do
27
31
  # We could probably do something with the form object here, maybe
28
32
  # Tells the form to serialize itself.
@@ -14,7 +14,7 @@
14
14
  As you click from page to page, note that your form
15
15
  values are saved. They are saved in a cookie!
16
16
 
17
- %form{:action => '/haml_form', :method => 'post'}
17
+ %form{:action => '/haml_form', :method => 'post', :enctype => 'multipart/form-data'}
18
18
  - @form.class.attributes.each do |name|
19
19
  %input{:type => 'text', :id => "form_#{name}", :name => "form[#{name}]", :value => @form.send(name)}
20
20
  %label{:for => "form_#{name}"}= name
@@ -1,5 +1,4 @@
1
1
  require 'minitest/autorun'
2
- require 'minitest/pride'
3
2
  require 'rack/test'
4
3
 
5
4
  require 'sinatra/sample_sinatra'
@@ -24,6 +23,12 @@ class TestMonkeyForms < MiniTest::Unit::TestCase
24
23
  assert_equal "Joe <joe@tanga.com>", last_response.body
25
24
  end
26
25
 
26
+ def test_file_upload
27
+ file = Rack::Test::UploadedFile.new(__FILE__)
28
+ post "https://test.domain.com/upload", :form => { :upload => file }
29
+ assert_equal File.read(__FILE__).size.to_s, last_response.body
30
+ end
31
+
27
32
  def test_form_post_with_bad_cookie
28
33
  post "https://test.domain.com/form", :form => { :name => "Joe" }
29
34
  set_cookie "order_cookie=bad_value; path=/; domain=test.domain.com; secure"
@@ -71,7 +76,7 @@ class TestMonkeyForms < MiniTest::Unit::TestCase
71
76
  assert_equal "Joe", o.name
72
77
  assert_equal "joe@tanga.com", o.email
73
78
  assert_equal "", o.city
74
- assert_equal 5, o.attributes.size
79
+ assert_equal 6, o.attributes.size
75
80
  assert_equal "Joe", o.attributes[:name]
76
81
  assert_equal "Joe", o.attributes["name"]
77
82
  end
@@ -131,6 +136,10 @@ class TestMonkeyForms < MiniTest::Unit::TestCase
131
136
  assert_equal "Joe <joe@tanga.com>", o.person
132
137
  end
133
138
 
139
+ def test_that_values_in_arrays_are_stripped
140
+ skip "FIX ME!"
141
+ end
142
+
134
143
  def test_array
135
144
  submit_form(:line_items => [ {:id => "previous"}])
136
145
  attributes = submit_form(:line_items => [ {:id => "new"}])
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monkey_forms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.18
4
+ version: 0.0.19
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-14 00:00:00.000000000Z
12
+ date: 2011-09-26 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel
16
- requirement: &70272335220300 !ruby/object:Gem::Requirement
16
+ requirement: &70253403801120 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70272335220300
24
+ version_requirements: *70253403801120
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: minitest
27
- requirement: &70272335219740 !ruby/object:Gem::Requirement
27
+ requirement: &70253403800640 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70272335219740
35
+ version_requirements: *70253403800640
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &70272335219240 !ruby/object:Gem::Requirement
38
+ requirement: &70253403800200 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70272335219240
46
+ version_requirements: *70253403800200
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: sinatra
49
- requirement: &70272335218620 !ruby/object:Gem::Requirement
49
+ requirement: &70253403799740 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70272335218620
57
+ version_requirements: *70253403799740
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rack-test
60
- requirement: &70272335217960 !ruby/object:Gem::Requirement
60
+ requirement: &70253403799160 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70272335217960
68
+ version_requirements: *70253403799160
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: shotgun
71
- requirement: &70272335217120 !ruby/object:Gem::Requirement
71
+ requirement: &70253403798560 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70272335217120
79
+ version_requirements: *70253403798560
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: haml
82
- requirement: &70272335216360 !ruby/object:Gem::Requirement
82
+ requirement: &70253403798100 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70272335216360
90
+ version_requirements: *70253403798100
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: msgpack
93
- requirement: &70272335215640 !ruby/object:Gem::Requirement
93
+ requirement: &70253403797580 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,7 +98,7 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70272335215640
101
+ version_requirements: *70253403797580
102
102
  description: Helps make complex forms
103
103
  email:
104
104
  - joe@tanga.com
@@ -164,7 +164,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
164
164
  version: '0'
165
165
  segments:
166
166
  - 0
167
- hash: 1638740973580231578
167
+ hash: -3949275010352210581
168
168
  required_rubygems_version: !ruby/object:Gem::Requirement
169
169
  none: false
170
170
  requirements:
@@ -173,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
173
  version: '0'
174
174
  segments:
175
175
  - 0
176
- hash: 1638740973580231578
176
+ hash: -3949275010352210581
177
177
  requirements: []
178
178
  rubyforge_project: monkey_forms
179
179
  rubygems_version: 1.8.10