From ebc7d2c45b45a145cb29dc2bb61f14ba7d99562b Mon Sep 17 00:00:00 2001 From: Gopesh Tulsyan Date: Fri, 18 Jul 2014 19:57:34 +0530 Subject: [PATCH] User deletion test fixed --- app/views/admin/users/index.html.haml | 2 +- spec/features/user_spec.rb | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/app/views/admin/users/index.html.haml b/app/views/admin/users/index.html.haml index d66a475d..b7c5e7ea 100644 --- a/app/views/admin/users/index.html.haml +++ b/app/views/admin/users/index.html.haml @@ -70,7 +70,7 @@ - if current_user.id == user.id or user.role_ids.include? 3 =link_to 'Delete',admin_user_path(user), :method => :delete , :data => {:confirm => 'Are you sure ?'}, :disabled => true,:class => "btn btn-primary disabled btn-danger",:role => "button" - else - =link_to 'Delete',admin_user_path(user), :method=> :delete , :data=> {:confirm => 'Are you sure ?'},:class => "btn btn-primary btn-danger" + =link_to 'Delete',admin_user_path(user), :method=> :delete , :data=> {:confirm => 'Are you sure ?'},:class => "btn btn-primary btn-danger", id: "user-delete-#{user.id}" :javascript diff --git a/spec/features/user_spec.rb b/spec/features/user_spec.rb index ddec87b8..c5205400 100644 --- a/spec/features/user_spec.rb +++ b/spec/features/user_spec.rb @@ -8,15 +8,13 @@ feature User do shared_examples 'admin ability' do |user| scenario 'deletes a user', feature: true, js: true do sign_in(admin) + @user = create(:user) visit admin_users_path expected_count = User.count - 1 - page.all('btn btn-primary btn-danger') do - click_link 'Delete' - page.evaluate_script('window.confirm = function() { return true; }') - page.click('OK') - expect(flash).to eq('User got deleted') - expect(User.count).to eq(expected_count) - end + find("#user-delete-#{@user.id}").click + page.evaluate_script('window.confirm = function() { return true; }') + expect(flash).to eq('User got deleted') + expect(User.count).to eq(expected_count) sign_out end scenario 'can modify roles', feature: true, js: true do