Passing the customer_id with the requests would do. Something like this :-
class DomainsControllerTest < ActionController::TestCase
test "should get index" do
get :index ,:customer_id=> 1
assert_response :success
assert_not_nil assigns(:domains)
end
end