[ARVADOS] updated: af3d57d7eeb458e598c9d3954942db7e1d28b780
git at public.curoverse.com
git at public.curoverse.com
Mon Dec 1 13:49:09 EST 2014
Summary of changes:
services/api/config/application.default.yml | 4 --
.../test/functional/database_controller_test.rb | 5 +-
.../api/test/integration/database_reset_test.rb | 59 ++++++++++++++++++++--
services/api/test/integration/remote_reset_test.rb | 57 ---------------------
4 files changed, 56 insertions(+), 69 deletions(-)
delete mode 100644 services/api/test/integration/remote_reset_test.rb
via af3d57d7eeb458e598c9d3954942db7e1d28b780 (commit)
via fc2824f30bd7e87e85b6329cbb44d3c7259c2676 (commit)
from 9d281577e42c6f8411cc3ee9954134b771499624 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit af3d57d7eeb458e598c9d3954942db7e1d28b780
Author: Tom Clegg <tom at curoverse.com>
Date: Mon Dec 1 13:28:12 2014 -0500
4533: Consolidate database-reset tests. Fix up ensure/reload_routes! blocks.
diff --git a/services/api/test/functional/database_controller_test.rb b/services/api/test/functional/database_controller_test.rb
index 56662ee..4bda0d0 100644
--- a/services/api/test/functional/database_controller_test.rb
+++ b/services/api/test/functional/database_controller_test.rb
@@ -12,11 +12,10 @@ class DatabaseControllerTest < ActionController::TestCase
test "route not found when not in test mode" do
authorize_with :admin
env_was = Rails.env
- Rails.application.reload_routes!
begin
+ Rails.env = 'production'
+ Rails.application.reload_routes!
assert_raises ActionController::RoutingError do
- Rails.env = 'production'
- Rails.application.reload_routes!
post :reset
end
ensure
diff --git a/services/api/test/integration/database_reset_test.rb b/services/api/test/integration/database_reset_test.rb
index 8c77c2d..58f2abf 100644
--- a/services/api/test/integration/database_reset_test.rb
+++ b/services/api/test/integration/database_reset_test.rb
@@ -1,11 +1,7 @@
require 'test_helper'
class DatabaseResetTest < ActionDispatch::IntegrationTest
- teardown do
- restore_configuration
- # We made configuration changes here that affect routing.
- Rails.application.reload_routes!
- end
+ self.use_transactional_fixtures = false
test "reset fails when Rails.env != 'test'" do
rails_env_was = Rails.env
@@ -16,6 +12,7 @@ class DatabaseResetTest < ActionDispatch::IntegrationTest
assert_response 404
ensure
Rails.env = rails_env_was
+ Rails.application.reload_routes!
end
end
@@ -23,4 +20,56 @@ class DatabaseResetTest < ActionDispatch::IntegrationTest
post '/database/reset', {}, auth(:active)
assert_response 403
end
+
+ test "database reset doesn't break basic CRUD operations" do
+ active_auth = auth(:active)
+ admin_auth = auth(:admin)
+
+ authorize_with :admin
+ post '/database/reset', {}, admin_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
+
+ put('/arvados/v1/specimens/'+new_uuid,
+ {specimen: '{"properties":{}}'}, active_auth)
+ assert_response :success
+
+ delete '/arvados/v1/specimens/'+new_uuid, {}, active_auth
+ assert_response :success
+
+ get '/arvados/v1/specimens/'+new_uuid, {}, active_auth
+ assert_response 404
+ end
+
+ test "roll back database change" do
+ active_auth = auth(:active)
+ admin_auth = auth(:admin)
+
+ old_uuid = specimens(:owned_by_active_user).uuid
+ 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']
+
+ # Reset to fixtures.
+ post '/database/reset', {}, admin_auth
+ assert_response :success
+
+ # New specimen 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
+ end
end
diff --git a/services/api/test/integration/remote_reset_test.rb b/services/api/test/integration/remote_reset_test.rb
deleted file mode 100644
index b3a7c63..0000000
--- a/services/api/test/integration/remote_reset_test.rb
+++ /dev/null
@@ -1,57 +0,0 @@
-require 'test_helper'
-
-class RemoteResetTest < ActionDispatch::IntegrationTest
- self.use_transactional_fixtures = false
-
- test "database reset doesn't break basic CRUD operations" do
- active_auth = auth(:active)
- admin_auth = auth(:admin)
-
- authorize_with :admin
- post '/database/reset', {}, admin_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
-
- put('/arvados/v1/specimens/'+new_uuid,
- {specimen: '{"properties":{}}'}, active_auth)
- assert_response :success
-
- delete '/arvados/v1/specimens/'+new_uuid, {}, active_auth
- assert_response :success
-
- get '/arvados/v1/specimens/'+new_uuid, {}, active_auth
- assert_response 404
- end
-
- test "roll back database change" do
- active_auth = auth(:active)
- admin_auth = auth(:admin)
-
- old_uuid = specimens(:owned_by_active_user).uuid
- 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']
-
- # Reset to fixtures.
- post '/database/reset', {}, admin_auth
- assert_response :success
-
- # New specimen 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
- end
-end
commit fc2824f30bd7e87e85b6329cbb44d3c7259c2676
Author: Tom Clegg <tom at curoverse.com>
Date: Mon Dec 1 12:52:05 2014 -0500
4533: Remove config flag from default section, too.
diff --git a/services/api/config/application.default.yml b/services/api/config/application.default.yml
index 8b3eb21..cc46d04 100644
--- a/services/api/config/application.default.yml
+++ b/services/api/config/application.default.yml
@@ -241,7 +241,3 @@ common:
# Default lifetime for ephemeral collections: 2 weeks.
default_trash_lifetime: 1209600
-
- # Allow resetting the database to fixtures via API call. This only
- # makes sense if RAILS_ENV=test. It requires an admin token.
- enable_remote_database_reset: false
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list