diff --git a/test/system/users_test.rb b/test/system/users_test.rb --- a/test/system/users_test.rb +++ b/test/system/users_test.rb @@ -41,6 +41,58 @@ assert_text 'section 2' end + test "add multiple users" do + login 'admin', 'admin' + within 'header' do + click_on 'Manage' + click_on 'Users', match: :first + end + + click_on 'New list of users', match: :first + find(:css, 'textarea').fill_in with:"abc1,Boaty McBoatface,abcdef,alias1,remark1,\nabc2,Boaty2 McSecond,acbdef123,aias2,remark2" + click_on 'create users' + + assert_text('remark1') + assert_text('remark2') + end + + test "grant admin right" do + login 'admin', 'admin' + within 'header' do + click_on 'Manage' + click_on 'Users', match: :first + end + + click_on "View administrator" + fill_in 'login', with: 'john' + click_on "Grant" + + visit logout_main_path + login 'john','hello' + within 'header' do + click_on 'Manage' + click_on 'Problem', match: :first + end + assert_text "Turn off all problems" + end + + test "try using admin from normal user" do + login 'admin','admin' + visit bulk_manage_user_admin_index_path + assert_current_path bulk_manage_user_admin_index_path + visit logout_main_path + + login 'jack','morning' + visit bulk_manage_user_admin_index_path + assert_current_path root_path + assert_text 'You are not authorized' + + login 'james','morning' + visit new_list_user_admin_index_path + assert_current_path root_path + assert_text 'You are not authorized' + end + def login(username,password) visit root_path fill_in "Login", with: username