Permalink
Browse files

handling empty lists

  • Loading branch information...
lauramoore committed Apr 8, 2011
1 parent 13cbec7 commit d8afcb579f559131877b729b21d37e9a2bd40b6b
@@ -1,10 +1,10 @@
class BoardController < ApplicationController
def show
- @backlog = Story.order("column_ord").find_by_state("B")
- @priority = Story.order("column_ord").find_by_state("P")
- @active = Story.order("column_ord").find_by_state("A")
- @delegated = Story.order("column_ord").find_by_state("D")
- @complete = Story.order("column_ord").find_by_state("C")
+ @backlog = Story.order("column_ord").find_all_by_state("B")
+ @priority = Story.order("column_ord").find_all_by_state("P")
+ @active = Story.order("column_ord").find_all_by_state("A")
+ @delegated = Story.order("column_ord").find_all_by_state("D")
+ @complete = Story.order("column_ord").find_all_by_state("C")
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @stories }
@@ -11,35 +11,35 @@ a<%= link_to 'New Story', new_story_path %>
<td>
<div class="backlog">
<ul id="B" class="sortcol">
-<%= render(@backlog) %>
+<%= if @backlog then render(@backlog) end%>
</ul>
</div>
</td>
<td>
<div class="priority">
<ul id="P" class="sortcol">
-<%= render(@priority) %>
+<%= if @priority then render(@priority) end%>
</ul>
</div>
</td>
<td>
<div class="active">
<ul id="A" class="sortcol">
-<%= render(@active) %>
+<%= if @active then render(@active) end %>
</ul>
</div>
</td>
<td>
<div class="delegated">
<ul id="D" class="sortcol">
-<%= render(@delegated) %>
+<%= if @delegated then render(@delegated) end%>
</ul>
</div>
</td>
<td>
<div class="complete">
<ul id="C" class="sortcol">
-<%= render(@complete) %>
+<%= if @complete then render(@complete) end %>
</ul>
</div>
</td>
@@ -6,6 +6,7 @@ backlog:
need_by: 2011-03-12
delegatee:
column_ord:
+ state: B
priority:
task: MyString
@@ -15,13 +16,13 @@ priority:
column_ord: 2
state: P
-active:
+another_backlog:
task: MyString
notes: MyText
need_by: 2011-03-12
delegatee: MyString
column_ord:
- state: A
+ state: B
delegated:
task: MyString
@@ -5,10 +5,10 @@ class BoardControllerTest < ActionController::TestCase
get :show
assert_response :success
assert_select '.backlog', 1, 'board shows backlog section' do
- assert_select 'li', 1
+ assert_select 'li', assigns[:backlog].size
end
assert_select '.active', 1, 'board shows active section' do
- assert_select 'li', 1
+ assert_select 'li', 0
end
assert_select '.priority', 1, 'board shows priority section' do
assert_select 'li', 1
View
@@ -10,4 +10,8 @@ class StoryTest < ActiveSupport::TestCase
story = Story.new()
assert_equal story.state, 'B'
end
+
+ test "can find more than one story" do
+ assert_equal Story.order("column_ord").find_all_by_state("B").size, 2
+ end
end

0 comments on commit d8afcb5

Please sign in to comment.