sinatra_more 0.3.28 → 0.3.29

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -731,6 +731,7 @@ See the wiki article for additional information: <http://wiki.github.com/nesquen
731
731
  * Nathan Esquenazi - Project creator and code maintainer
732
732
  * Arthur Chiu - Forming the idea and various code contributions
733
733
  * Rob Holland - Added couchrest ORM component to generator
734
+ * Bill Turner - Added several form builder and helper fixes
734
735
 
735
736
  == Known Issues
736
737
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.28
1
+ 0.3.29
@@ -92,7 +92,7 @@ class AbstractFormBuilder
92
92
  # Returns the object's models name
93
93
  # => user_assignment
94
94
  def object_name
95
- object.is_a?(Symbol) ? object : object.class.to_s.underscore
95
+ object.is_a?(Symbol) ? object : object.class.to_s.underscore.gsub('/', '-')
96
96
  end
97
97
 
98
98
  # Returns true if the value matches the value in the field
@@ -82,8 +82,8 @@ module SinatraMore
82
82
  # Constructs a text area input from the given options
83
83
  # text_area_tag :username, :class => 'long', :value => "Demo?"
84
84
  def text_area_tag(name, options={})
85
- options.reverse_merge!(:name => name, :value => '')
86
- content_tag(:textarea, options.delete(:value), options)
85
+ options.reverse_merge!(:name => name)
86
+ content_tag(:textarea, options.delete(:value).to_s, options)
87
87
  end
88
88
 
89
89
  # Constructs a password field input from the given options
data/sinatra_more.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sinatra_more}
8
- s.version = "0.3.28"
8
+ s.version = "0.3.29"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Nathan Esquenazi"]
@@ -59,4 +59,8 @@ class Errors < Array
59
59
  def full_messages
60
60
  ["This is a fake error", "This is a second fake error", "This is a third fake error"]
61
61
  end
62
+ end
63
+
64
+ module Outer
65
+ class UserAccount; end
62
66
  end
@@ -33,6 +33,12 @@ class TestFormBuilder < Test::Unit::TestCase
33
33
  assert_has_tag('form input', :type => 'text', :name => 'markup_user[username]') { actual_html }
34
34
  assert_has_tag('form input[type=hidden]', :name => '_method', :count => 0) { actual_html } # no method action field
35
35
  end
36
+
37
+ should "display correct form html for namespaced object" do
38
+ actual_html = form_for(Outer::UserAccount.new, '/register', :method => 'post') { |f| f.text_field :username }
39
+ assert_has_tag('form', :action => '/register', :method => 'post') { actual_html }
40
+ assert_has_tag('form input', :type => 'text', :name => 'outer-user_account[username]') { actual_html }
41
+ end
36
42
 
37
43
  should "display correct form html with method :put" do
38
44
  actual_html = form_for(@user, '/update', :method => 'put') { "Demo" }
@@ -301,10 +307,15 @@ class TestFormBuilder < Test::Unit::TestCase
301
307
  assert_has_tag('textarea.large', :id => 'user_about', :name => 'user[about]') { actual_html }
302
308
  end
303
309
 
304
- should "display correct text_area html and content" do
310
+ should "display correct text_area html and custom content" do
305
311
  actual_html = standard_builder.text_area(:about, :value => "Demo")
306
312
  assert_has_tag('textarea', :id => 'user_about', :content => 'Demo') { actual_html }
307
313
  end
314
+
315
+ should "display correct text_area html and default content" do
316
+ actual_html = standard_builder(MarkupUser.new).text_area(:about)
317
+ assert_has_tag('textarea', :id => 'markup_user_about', :content => '') { actual_html }
318
+ end
308
319
 
309
320
  should "display correct text_area in haml" do
310
321
  visit '/haml/form_for'
@@ -194,6 +194,12 @@ class TestFormHelpers < Test::Unit::TestCase
194
194
  actual_html = text_area_tag(:about, :value => "a test")
195
195
  assert_has_tag(:textarea, :content => "a test", :name => 'about') { actual_html }
196
196
  end
197
+
198
+ should "display text area in ruby with no content with closing tag" do
199
+ actual_html = text_area_tag(:about)
200
+ assert_has_tag(:textarea, :content => "", :name => 'about') { actual_html }
201
+ assert_equal '<textarea name="about"></textarea>', actual_html
202
+ end
197
203
 
198
204
  should "display text area in erb" do
199
205
  visit '/erb/form_tag'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sinatra_more
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.28
4
+ version: 0.3.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Esquenazi