Skip to content

Commit

Permalink
Displaying topics list on home page.
Browse files Browse the repository at this point in the history
  • Loading branch information
futurechimp committed Jun 9, 2011
1 parent 513308c commit 6455804
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
1 change: 1 addition & 0 deletions app/controllers/home.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

get :index, :map => "/" do
@feed_items = FeedItem.order_by([:date_published, :desc]).limit(60)
@wires = Wire.all
erb :"home/index"
end

Expand Down
10 changes: 5 additions & 5 deletions app/views/home/index.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
<li id="just-head"><a href="#">Just Head</a></li>
</ul>
<div id="topics" class="list">
<% unless @wires.empty? %>
<h2>Topics</h2>
<ul>
<li><a href="#">Blah</a></li>
<li><a href="#">Foo</a></li>
<li><a href="#" class="on">Bar</a></li>
<li><a href="#">More Blah</a></li>
<li><a href="#">Potato</a></li>
<% @wires.each do |wire| %>
<li><%= wire.name %></li>
<% end %>
</ul>
<% end %>
</div>
<div id="tags">
<h2>Bar:Tags</h2>
Expand Down
22 changes: 22 additions & 0 deletions test/app/controllers/home_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class HomeControllerTest < Test::Unit::TestCase

setup do
FeedItem.destroy_all
Wire.destroy_all
end

context "with no FeedItems" do
Expand Down Expand Up @@ -40,7 +41,28 @@ class HomeControllerTest < Test::Unit::TestCase
assert_match(/#{feed_item.title}/, last_response.body)
end
end
end

context "with Wires" do
setup do
@wire = Wire.make
@wire.save
get '/'
end

should "output the @wire#name" do
assert_match(/#{@wire.name}/, last_response.body)
end
end

context "with no Wires" do
setup do
get '/'
end

should "not output the Topics list" do
assert_no_match(/<h2>Topics<\/h2>/, last_response.body)
end
end
end
end

0 comments on commit 6455804

Please sign in to comment.