Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support uploading files #32

Merged
merged 1 commit into from
Oct 31, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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