Skip to content

Commit

Permalink
Fix some parallel test issues around admin accounts.
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
GUI committed Feb 5, 2017
1 parent e94ccbf commit 2413eb6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
9 changes: 4 additions & 5 deletions test/apis/v1/admins/test_create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,22 @@ 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 => "[email protected]").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 },
}))
assert_response_code(201, response)

data = MultiJson.load(response.body)
assert_equal("[email protected]", attributes["username"])
assert_equal("[email protected]", 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("[email protected]", admin.username)
assert_equal("hello-#{unique_test_id.downcase}@example.com", admin.username)
end

def test_required_validations
Expand Down
1 change: 1 addition & 0 deletions test/proxy/routing/test_admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class Test::Proxy::Routing::TestAdmin < Minitest::Test
def setup
super
setup_server
FactoryGirl.create(:admin)
end

def test_https_redirect
Expand Down

0 comments on commit 2413eb6

Please sign in to comment.