Skip to content

Commit

Permalink
Improving the Feed creation form.
Browse files Browse the repository at this point in the history
  • Loading branch information
futurechimp committed Jun 4, 2011
1 parent b717285 commit a994208
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
1 change: 1 addition & 0 deletions admin/controllers/feeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
end

get :new do
@wires = Wire.all
@feed = Feed.new
render 'feeds/new'
end
Expand Down
24 changes: 17 additions & 7 deletions admin/views/feeds/_form.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<div class="group">
<%= f.label :default_moderation_status %><%= f.error_message_on :default_moderation_status %>
<%= f.label :default_moderation_status %>
<%= f.error_message_on :default_moderation_status %>
<%= f.text_field :default_moderation_status, :class => :text_field %>
<span class="description">Ex: a simple text</span>
</div>
Expand All @@ -8,15 +9,24 @@
<%= f.text_field :url, :class => :text_field %>
<span class="description">Ex: a simple text</span>
</div>

<div class="group">
<%= f.label :_id %><%= f.error_message_on :_id %>
<%= f.text_field :_id, :class => :text_field %>
<span class="description">Ex: a simple text</span>
<%= f.label :wire %><%= f.error_message_on :wire %>
<%= f.select :wire_id, :collection => @wires, :fields => [:name, :id] %>
<span class="description">Please choose a wire.</span>
</div>

<% if @feed and @feed.image_url %>
<div class="group">
<strong>Current default image:</strong> <br />
<%= image_tag @feed.image_url("small") if @feed.image_url %>
</div>
<% end %>

<div class="group">
<%= f.label :_type %><%= f.error_message_on :_type %>
<%= f.text_field :_type, :class => :text_field %>
<span class="description">Ex: a simple text</span>
<%= label_tag :image %><%= f.error_message_on :image %>
<%= file_field_tag :image %>
<span class="description">Please upload a default image</span>
</div>

<div class="group navform wat-cf">
Expand Down
5 changes: 4 additions & 1 deletion admin/views/feeds/new.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
<div class="content">
<h2 class="title"><%= pat(:new) %> <% mt(:feed) %></h2>
<div class="inner">
<% form_for :feed, url(:feeds, :create), :class => :form do |f| %>
<% form_for :feed, url(:feeds, :create), :class => :form,
:multipart => :true do |f| %>
<%= partial "feeds/form", :locals => { :f => f } %>
<% end %>
</div>
</div>
Expand Down
5 changes: 5 additions & 0 deletions test/app/controllers/admin/feeds_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,18 @@ class Admin::FeedsControllerTest < Test::Unit::TestCase

context "on GET to new" do
setup do
@wire = Factory.make_wire
get '/admin/feeds/new'
end

should "work" do
assert last_response.ok?
assert_match /New/, last_response.body
end

should "insert the @wire name into the body" do
assert last_response.body.include?(@wire.name)
end
end

context "on GET to edit" do
Expand Down

0 comments on commit a994208

Please sign in to comment.