From 2413eb633426f76b18435c4fef4b9ee8015bcee8 Mon Sep 17 00:00:00 2001 From: Nick Muerdter Date: Sun, 5 Feb 2017 06:56:32 -0700 Subject: [PATCH] Fix some parallel test issues around admin accounts. - Ensure we don't delete all the admin accounts for tests that run in parallel, since that may impact other tests. - Ensure at least 1 admin account exists prior to some admin routing tests, so the admin doesn't redirect to the screen allowing for admin creation. --- test/apis/v1/admins/test_create.rb | 9 ++++----- test/proxy/routing/test_admin.rb | 1 + 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/apis/v1/admins/test_create.rb b/test/apis/v1/admins/test_create.rb index 66c4b7c56..cdfa3fd1a 100644 --- a/test/apis/v1/admins/test_create.rb +++ b/test/apis/v1/admins/test_create.rb @@ -8,11 +8,10 @@ class Test::Apis::V1::Admins::TestCreate < Minitest::Test def setup super setup_server - Admin.delete_all end def test_downcases_username - attributes = FactoryGirl.build(:admin, :username => "HELLO@example.com").serializable_hash + attributes = FactoryGirl.build(:admin, :username => "HELLO-#{unique_test_id}@example.com").serializable_hash response = Typhoeus.post("https://127.0.0.1:9081/api-umbrella/v1/admins.json", http_options.deep_merge(admin_token).deep_merge({ :headers => { "Content-Type" => "application/x-www-form-urlencoded" }, :body => { :admin => attributes }, @@ -20,11 +19,11 @@ def test_downcases_username assert_response_code(201, response) data = MultiJson.load(response.body) - assert_equal("HELLO@example.com", attributes["username"]) - assert_equal("hello@example.com", data["admin"]["username"]) + assert_equal("HELLO-#{unique_test_id}@example.com", attributes["username"]) + assert_equal("hello-#{unique_test_id.downcase}@example.com", data["admin"]["username"]) admin = Admin.find(data["admin"]["id"]) - assert_equal("hello@example.com", admin.username) + assert_equal("hello-#{unique_test_id.downcase}@example.com", admin.username) end def test_required_validations diff --git a/test/proxy/routing/test_admin.rb b/test/proxy/routing/test_admin.rb index d549e3b83..efde0a5ee 100644 --- a/test/proxy/routing/test_admin.rb +++ b/test/proxy/routing/test_admin.rb @@ -7,6 +7,7 @@ class Test::Proxy::Routing::TestAdmin < Minitest::Test def setup super setup_server + FactoryGirl.create(:admin) end def test_https_redirect