Skip to content

Commit

Permalink
Merge pull request #32 from bongole/master
Browse files Browse the repository at this point in the history
Support uploading files
  • Loading branch information
fredwu committed Oct 31, 2012
2 parents 73f55cf + df3181d commit f03ffc8
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions api_taster.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions app/assets/javascripts/api_taster/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
//
//= require jquery
//= require jquery_ujs
//= require jquery.remotipart
//= require bootstrap
//= require_tree .
6 changes: 5 additions & 1 deletion app/views/api_taster/routes/_param_form_element.html.erb
Original file line number Diff line number Diff line change
@@ -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>
1 change: 1 addition & 0 deletions lib/api_taster.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require 'jquery-rails'
require 'bootstrap-sass'
require 'remotipart'
require 'active_support/dependencies'
require 'api_taster/engine'
require 'api_taster/route'
Expand Down
2 changes: 1 addition & 1 deletion lib/api_taster/form_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions spec/form_builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module ApiTaster
let(:builder) do
FormBuilder.new({
:hello => 'world',
:content => :file,
:user => {
:name => 'Fred',
:comment => {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f03ffc8

Please sign in to comment.