From d8aa92f9d4911e28c95e9abb70e87ac282ef0601 Mon Sep 17 00:00:00 2001 From: Azul Date: Thu, 6 Feb 2014 19:03:40 +0100 Subject: make sure ticket get's cleared at end of tickets_by_admin test Also relax the requirement from tickets.count > 1 to > 0. There is only one ticket if there have not been any others in the database ahead of time. --- help/test/functional/tickets_controller_test.rb | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'help/test') diff --git a/help/test/functional/tickets_controller_test.rb b/help/test/functional/tickets_controller_test.rb index 2b30f66..2530ba1 100644 --- a/help/test/functional/tickets_controller_test.rb +++ b/help/test/functional/tickets_controller_test.rb @@ -158,19 +158,23 @@ class TicketsControllerTest < ActionController::TestCase end test "tickets by admin" do - other_user = find_record :user - ticket = FactoryGirl.create :ticket, :created_by => other_user.id + begin + other_user = find_record :user + ticket = FactoryGirl.create :ticket, :created_by => other_user.id - login :is_admin? => true + login :is_admin? => true - get :index, {:admin_status => "all", :open_status => "open"} - assert assigns(:all_tickets).count > 1 - - # if we close one ticket, the admin should have 1 less open ticket - assert_difference('assigns[:all_tickets].count', -1) do - assigns(:tickets).first.close - assigns(:tickets).first.save get :index, {:admin_status => "all", :open_status => "open"} + assert assigns(:all_tickets).count > 0 + + # if we close one ticket, the admin should have 1 less open ticket + assert_difference('assigns[:all_tickets].count', -1) do + assigns(:tickets).first.close + assigns(:tickets).first.save + get :index, {:admin_status => "all", :open_status => "open"} + end + ensure + ticket.reload.destroy if ticket end end -- cgit v1.2.3