Permalink
Browse files

Support uploading files

  • Loading branch information...
1 parent 73f55cf commit df3181d7b2afceec13e6a18ea794a1026cdd191c @bongole bongole committed Oct 31, 2012
View
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
s.add_dependency 'sass-rails'
s.add_dependency 'bootstrap-sass', '~> 2.1'
s.add_dependency 'redcarpet'
+ s.add_dependency 'remotipart', '~> 1.0'
s.add_development_dependency 'rake'
s.add_development_dependency 'simplecov'
@@ -12,5 +12,6 @@
//
//= require jquery
//= require jquery_ujs
+//= require jquery.remotipart
//= require bootstrap
//= require_tree .
@@ -1,6 +1,10 @@
<div class="control-group">
<label class="control-label" for="<%= label %>"><%= defined?(label_text) ? label_text : label %></label>
<div class="controls">
- <input type="text" name="<%= label %>" value="<%= value %>"></input>
+ <% if value === :file %>
+ <input type="file" name="<%= label %>" ></input>
+ <% else %>
+ <input type="text" name="<%= label %>" value="<%= value.to_s %>"></input>
+ <% end %>
</div>
</div>
View
@@ -1,5 +1,6 @@
require 'jquery-rails'
require 'bootstrap-sass'
+require 'remotipart'
require 'active_support/dependencies'
require 'api_taster/engine'
require 'api_taster/route'
@@ -52,7 +52,7 @@ def add_element_to_buffer(parent_labels, label, value)
:locals => {
:label => "#{print_labels(parent_labels)}#{label}",
:label_text => label,
- :value => value.to_s
+ :value => value
}
)
end
@@ -12,6 +12,7 @@ module ApiTaster
let(:builder) do
FormBuilder.new({
:hello => 'world',
+ :content => :file,
:user => {
:name => 'Fred',
:comment => {
@@ -43,6 +44,10 @@ module ApiTaster
builder.html.should match('value="world"')
end
+ it "does files" do
+ builder.html.should match('<input type="file" name="content" ></input>')
+ end
+
it "does numbers" do
builder.html.should match('value="1"')
end

0 comments on commit df3181d

Please sign in to comment.