From 1115838e2acecd82fc2a13c55a631a8cfa42520e Mon Sep 17 00:00:00 2001 From: Azul Date: Tue, 21 Mar 2017 10:42:17 +0100 Subject: test: admin user api always green Used to fail because the record already existed in the database fixes #17 --- test/functional/api/users_controller_test.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'test') diff --git a/test/functional/api/users_controller_test.rb b/test/functional/api/users_controller_test.rb index b69770d..88ecae0 100644 --- a/test/functional/api/users_controller_test.rb +++ b/test/functional/api/users_controller_test.rb @@ -95,11 +95,13 @@ class Api::UsersControllerTest < ApiControllerTest end test "admin can show is_admin property" do - user = FactoryGirl.create :user, login: "admin2" - login user - api_get :show, :id => user.id, :format => :json - assert_response :success - assert_json_response user.to_hash.merge(:is_admin => true) + admin = FactoryGirl.create :user + with_config(admins: [admin.login]) do + login admin + api_get :show, :id => admin.id, :format => :json + assert_response :success + assert_json_response admin.to_hash.merge(:is_admin => true) + end end test "normal users cannot show user" do -- cgit v1.2.3