Created
September 16, 2015 04:38
-
-
Save PandaWhisperer/2d5d670ad898a9a32570 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rails_helper' | |
feature 'Managing users' do | |
given(:user) { create(:user) } | |
given(:admin) { create(:admin_user) } | |
context 'as an Admin' do | |
background do | |
login_as admin | |
user # reference user to ensure it exists | |
end | |
it 'shows the "Manage Users" link' do | |
visit root_path | |
expect(page).to have_link 'Manage Users' | |
end | |
it 'lets me access the "Manage Users" page' do | |
visit manage_users_path | |
expect(page).not_to have_content 'You are not authorized to access this page.' | |
end | |
it 'lists all users' do | |
visit manage_users_path | |
[user, admin].each { |u| expect(page).to have_content u.email } | |
end | |
it 'lets me edit a user' do | |
visit manage_users_path | |
within "tr:contains('#{user.email}')" do | |
click_link 'Edit' | |
end | |
expect(page).to have_content 'Edit User' | |
end | |
it 'lets me delete a user' do | |
visit manage_users_path | |
within "tr:contains('#{user.email}')" do | |
click_link 'Delete' | |
end | |
expect(page).to have_content 'User was successfully destroyed.' | |
end | |
end | |
context 'as another user' do | |
background do | |
login_as user | |
end | |
it 'does not show the "Manage Users" link' do | |
visit root_path | |
expect(page).not_to have_link 'Manage Users' | |
end | |
it 'does not let me access the "Manage Users" page' do | |
visit manage_users_path | |
expect(page).to have_content 'You are not authorized to access this page.' | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment