Commit f7d88514c1c4752ca8fa9d655f59e752a5fd78d8
1 parent
b1cad3f0
Exists in
staging
and in
31 other branches
refactoring test to set admin user by another way
Showing
1 changed file
with
2 additions
and
17 deletions
Show diff stats
test/api/environment_test.rb
| @@ -2,11 +2,6 @@ require_relative 'test_helper' | @@ -2,11 +2,6 @@ require_relative 'test_helper' | ||
| 2 | 2 | ||
| 3 | class EnvironmentTest < ActiveSupport::TestCase | 3 | class EnvironmentTest < ActiveSupport::TestCase |
| 4 | 4 | ||
| 5 | - def setup | ||
| 6 | - @person = create_user('testing').person | ||
| 7 | - end | ||
| 8 | - attr_reader :person | ||
| 9 | - | ||
| 10 | should 'return the default environment' do | 5 | should 'return the default environment' do |
| 11 | environment = Environment.default | 6 | environment = Environment.default |
| 12 | get "/api/v1/environment/default" | 7 | get "/api/v1/environment/default" |
| @@ -22,20 +17,10 @@ class EnvironmentTest < ActiveSupport::TestCase | @@ -22,20 +17,10 @@ class EnvironmentTest < ActiveSupport::TestCase | ||
| 22 | assert_nil json['settings'] | 17 | assert_nil json['settings'] |
| 23 | end | 18 | end |
| 24 | 19 | ||
| 25 | - def login_admin | ||
| 26 | - # Create and activate the admin user | ||
| 27 | - admin_user = new_admin_user(Environment.default, true) | ||
| 28 | - params = {:login => "adminuser", :password => "adminuser"} | ||
| 29 | - post "/api/v1/login?#{params.to_query}" | ||
| 30 | - json = JSON.parse(last_response.body) | ||
| 31 | - private_token = json['user']["private_token"] | ||
| 32 | - assert_equal admin_user.private_token, private_token | ||
| 33 | - @params = {:private_token => private_token} | ||
| 34 | - end | ||
| 35 | - | ||
| 36 | should 'return the default environment settings for admin' do | 20 | should 'return the default environment settings for admin' do |
| 37 | - login_admin | 21 | + login_api |
| 38 | environment = Environment.default | 22 | environment = Environment.default |
| 23 | + environment.add_admin(person) | ||
| 39 | get "/api/v1/environment/default?#{params.to_query}" | 24 | get "/api/v1/environment/default?#{params.to_query}" |
| 40 | json = JSON.parse(last_response.body) | 25 | json = JSON.parse(last_response.body) |
| 41 | assert_equal environment.id, json['id'] | 26 | assert_equal environment.id, json['id'] |