admin_disables_two_factor_spec.rb 705 Bytes
Newer Older
1 2
require 'rails_helper'

3
feature 'Admin disables 2FA for a user' do
4
  scenario 'successfully', :js do
5
    sign_in(create(:admin))
6 7 8 9 10 11 12 13 14 15 16 17 18 19
    user = create(:user, :two_factor)

    edit_user(user)
    page.within('.two-factor-status') do
      click_link 'Disable'
    end

    page.within('.two-factor-status') do
      expect(page).to have_content 'Disabled'
      expect(page).not_to have_button 'Disable'
    end
  end

  scenario 'for a user without 2FA enabled' do
20
    sign_in(create(:admin))
21 22 23 24 25 26 27 28 29 30 31 32 33
    user = create(:user)

    edit_user(user)

    page.within('.two-factor-status') do
      expect(page).not_to have_button 'Disable'
    end
  end

  def edit_user(user)
    visit admin_user_path(user)
  end
end