From 8f8a99ce94818a5dbe372d8704ab396bff897489 Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Mon, 24 Nov 2014 12:20:53 -0500 Subject: [PATCH] 4533: Add integration test. --- .../api/test/integration/remote_reset_test.rb | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 services/api/test/integration/remote_reset_test.rb diff --git a/services/api/test/integration/remote_reset_test.rb b/services/api/test/integration/remote_reset_test.rb new file mode 100644 index 0000000000..81f341a75d --- /dev/null +++ b/services/api/test/integration/remote_reset_test.rb @@ -0,0 +1,38 @@ +require 'test_helper' + +class RemoteResetTest < ActionDispatch::IntegrationTest + self.use_transactional_fixtures = false + + test "roll back database change" do + active_auth = auth(:active) + admin_auth = auth(:admin) + + old_uuid = specimens(:owned_by_active_user).uuid + new_uuid = nil + authorize_with :admin + post '/database/reset', {}, admin_auth + assert_response :success + + delete '/arvados/v1/specimens/' + old_uuid, {}, active_auth + assert_response :success + post '/arvados/v1/specimens', {specimen: '{}'}, active_auth + assert_response :success + + new_uuid = json_response['uuid'] + get '/arvados/v1/specimens/'+new_uuid, {}, active_auth + assert_response :success + get '/arvados/v1/specimens/'+old_uuid, {}, active_auth + assert_response 404 + + # Reset to fixtures. + post '/database/reset', {}, admin_auth + assert_response :success + + # New speciment should disappear. Old specimen should reappear. + get '/arvados/v1/specimens/'+new_uuid, {}, active_auth + assert_response 404 + get '/arvados/v1/specimens/'+old_uuid, {}, active_auth + assert_response :success + assert_empty Specimen.where(uuid: new_uuid) + end +end -- 2.30.2