diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index fa82218d..ebad847d 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -29,6 +29,7 @@ class BoardsController < ApplicationController def index @boards = @project.boards + render_404 if @boards.empty? # show the board if there is only one if @boards.size == 1 @board = @boards.first diff --git a/test/functional/boards_controller_test.rb b/test/functional/boards_controller_test.rb index 597a3df2..420cf0c1 100644 --- a/test/functional/boards_controller_test.rb +++ b/test/functional/boards_controller_test.rb @@ -96,4 +96,11 @@ class BoardsControllerTest < ActionController::TestCase assert_redirected_to '/projects/ecookbook/settings/boards' assert_nil Board.find_by_id(2) end + + def test_index_should_404_with_no_board + Project.find(1).boards.each(&:destroy) + + get :index, :project_id => 1 + assert_response 404 + end end