8784: Fix test for latest firefox.
[arvados.git] / services / api / test / functional / database_controller_test.rb
1 require 'test_helper'
2
3 class DatabaseControllerTest < ActionController::TestCase
4   include CurrentApiClient
5
6   test "reset fails with non-admin token" do
7     authorize_with :active
8     post :reset
9     assert_response 403
10   end
11
12   test "route not found when not in test mode" do
13     authorize_with :admin
14     env_was = Rails.env
15     begin
16       Rails.env = 'production'
17       Rails.application.reload_routes!
18       assert_raises ActionController::UrlGenerationError do
19         post :reset
20       end
21     ensure
22       Rails.env = env_was
23       Rails.application.reload_routes!
24     end
25   end
26
27   test "reset fails when a non-test-fixture user exists" do
28     act_as_system_user do
29       User.create!(uuid: 'abcde-tpzed-123451234512345', email: 'bar@example.net')
30     end
31     authorize_with :admin
32     post :reset
33     assert_response 403
34   end
35
36   test "reset succeeds with admin token" do
37     new_uuid = nil
38     act_as_system_user do
39       new_uuid = Specimen.create.uuid
40     end
41     assert_not_empty Specimen.where(uuid: new_uuid)
42     authorize_with :admin
43     post :reset
44     assert_response 200
45     assert_empty Specimen.where(uuid: new_uuid)
46   end
47 end