f0887817e25c082838f50d260e6a3d4e69a14bdfEileen BolloffGiven(/^I am logged in as a admin$/) do
f0887817e25c082838f50d260e6a3d4e69a14bdfEileen Bolloff @admin = FactoryGirl.create :admin
f0887817e25c082838f50d260e6a3d4e69a14bdfEileen Bolloff login_as @admin, :scope => :user
f0887817e25c082838f50d260e6a3d4e69a14bdfEileen Bolloffend
f0887817e25c082838f50d260e6a3d4e69a14bdfEileen Bolloff
f0887817e25c082838f50d260e6a3d4e69a14bdfEileen BolloffGiven(/^there is a user$/) do
f0887817e25c082838f50d260e6a3d4e69a14bdfEileen Bolloff @user = FactoryGirl.create :user
f0887817e25c082838f50d260e6a3d4e69a14bdfEileen Bolloff @user_name = @user.name
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen Bolloff @user_email = @user.email
f0887817e25c082838f50d260e6a3d4e69a14bdfEileen Bolloffend
f0887817e25c082838f50d260e6a3d4e69a14bdfEileen Bolloff
f0887817e25c082838f50d260e6a3d4e69a14bdfEileen BolloffWhen(/^I visit the users overview page$/) do
f0887817e25c082838f50d260e6a3d4e69a14bdfEileen Bolloff visit admin_users_path
f0887817e25c082838f50d260e6a3d4e69a14bdfEileen Bolloffend
f0887817e25c082838f50d260e6a3d4e69a14bdfEileen Bolloff
f0887817e25c082838f50d260e6a3d4e69a14bdfEileen BolloffWhen(/^I visit the users edit page$/) do
f0887817e25c082838f50d260e6a3d4e69a14bdfEileen Bolloff within(:css, '#list_users') do
f0887817e25c082838f50d260e6a3d4e69a14bdfEileen Bolloff @edit_button = first(:css, 'tbody > tr').find_link('edit')
f0887817e25c082838f50d260e6a3d4e69a14bdfEileen Bolloff @edit_button.click
f0887817e25c082838f50d260e6a3d4e69a14bdfEileen Bolloff end
f0887817e25c082838f50d260e6a3d4e69a14bdfEileen Bolloffend
f0887817e25c082838f50d260e6a3d4e69a14bdfEileen Bolloff
f0887817e25c082838f50d260e6a3d4e69a14bdfEileen BolloffWhen(/^I change the name of the user$/) do
f0887817e25c082838f50d260e6a3d4e69a14bdfEileen Bolloff fill_in 'Name', with: "NewUser"
f0887817e25c082838f50d260e6a3d4e69a14bdfEileen Bolloffend
f0887817e25c082838f50d260e6a3d4e69a14bdfEileen Bolloff
f0887817e25c082838f50d260e6a3d4e69a14bdfEileen BolloffWhen(/^I submit the form$/) do
f0887817e25c082838f50d260e6a3d4e69a14bdfEileen Bolloff click_button('Update User')
f0887817e25c082838f50d260e6a3d4e69a14bdfEileen Bolloffend
f0887817e25c082838f50d260e6a3d4e69a14bdfEileen Bolloff
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen BolloffThen(/^I should see the users overview page and the updated user name$/) do
f0887817e25c082838f50d260e6a3d4e69a14bdfEileen Bolloff within(:css, '#list_users') do
f0887817e25c082838f50d260e6a3d4e69a14bdfEileen Bolloff expect(page).to have_content("NewUser")
f0887817e25c082838f50d260e6a3d4e69a14bdfEileen Bolloff expect(page).not_to have_content("@user_name")
f0887817e25c082838f50d260e6a3d4e69a14bdfEileen Bolloff end
f0887817e25c082838f50d260e6a3d4e69a14bdfEileen Bolloffend
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen Bolloff
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen BolloffWhen(/^I change the email adress of the user$/) do
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen Bolloff fill_in 'E-Mail', with: "newuser@example.com"
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen Bolloffend
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen Bolloff
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen BolloffThen(/^I should see the users overview page and the updated user email adress$/) do
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen Bolloff within(:css, '#list_users') do
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen Bolloff expect(page).to have_content("newuser@example.com")
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen Bolloff expect(page).not_to have_content("@user_email")
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen Bolloff end
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen Bolloffend
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen Bolloff
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen BolloffWhen(/^I allow the user admin status$/) do
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen Bolloff check('Admin')
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen Bolloffend
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen Bolloff
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen BolloffThen(/^I should see the users overview page and the updated admin user status$/) do
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen Bolloff expect(@user.reload.admin).to eq(true)
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen Bolloff within(:css, '#list_users') do
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen Bolloff expect(page).to have_content("#{@user.name}")
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen Bolloff expect(page).to have_content("#{@user.email}")
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen Bolloff end
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen Bolloffend
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen Bolloff
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen BolloffWhen(/^I delete the user admin status$/) do
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen Bolloff uncheck('Admin')
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen Bolloffend
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen Bolloff
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen BolloffThen(/^I should see the users overview page and the updated non admin user status$/) do
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen Bolloff expect(@user.reload.admin).to eq(false)
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen Bolloff within(:css, '#list_users') do
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen Bolloff expect(page).to have_content("#{@user.name}")
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen Bolloff expect(page).to have_content("#{@user.email}")
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen Bolloff end
e63ed6e798b2e9284e3e4d9ec50e8d605e7b0000Eileen Bolloffend