2015-01-18 05:15:21 -08:00
|
|
|
include Warden::Test::Helpers
|
|
|
|
Warden.test_mode!
|
|
|
|
|
|
|
|
# Feature: Ban users
|
|
|
|
# As a user
|
|
|
|
# I want to get banned
|
|
|
|
# So I can't sign in anymore
|
|
|
|
feature "Ban users", :devise do
|
|
|
|
|
|
|
|
after :each do
|
|
|
|
Warden.test_reset!
|
|
|
|
end
|
|
|
|
|
|
|
|
# Scenario: User gets banned
|
|
|
|
# Given I am signed in
|
|
|
|
# When I visit another page
|
|
|
|
# And I am banned
|
|
|
|
# Then I see the sign in page
|
|
|
|
scenario "user gets banned", js: true do
|
|
|
|
me = FactoryGirl.create :user
|
|
|
|
|
|
|
|
login_as me, scope: :user
|
|
|
|
visit root_path
|
|
|
|
expect(page).to have_text("Timeline")
|
2015-05-11 02:10:42 -07:00
|
|
|
page.driver.render Rails.root.join("tmp/ban_#{Time.now.to_i}_1.png"), full: true
|
2015-01-18 05:15:21 -08:00
|
|
|
|
2015-05-11 02:10:42 -07:00
|
|
|
me.permanently_banned = true
|
2015-01-18 05:15:21 -08:00
|
|
|
me.save
|
2015-05-11 02:10:42 -07:00
|
|
|
|
|
|
|
visit "/inbox"
|
|
|
|
|
2015-01-18 05:15:21 -08:00
|
|
|
expect(current_path).to eq(new_user_session_path)
|
2015-05-11 02:10:42 -07:00
|
|
|
page.driver.render Rails.root.join("tmp/ban_#{Time.now.to_i}_2.png"), full: true
|
2015-01-18 05:15:21 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'user visits banned user profiles', js: true do
|
|
|
|
evil_user = FactoryGirl.create :user
|
2015-05-11 02:10:42 -07:00
|
|
|
evil_user.permanently_banned = true
|
2015-01-18 05:15:21 -08:00
|
|
|
evil_user.save
|
|
|
|
|
|
|
|
visit show_user_profile_path(evil_user.screen_name)
|
2015-05-11 02:10:42 -07:00
|
|
|
expect(page).to have_text('BANNED')
|
|
|
|
page.driver.render Rails.root.join("tmp/ban_#{Time.now.to_i}_3.png"), full: true
|
2015-01-18 05:15:21 -08:00
|
|
|
end
|
|
|
|
end
|