tracks/features/step_definitions/login_steps.rb
Reinier Balt 7b3c07a754 add a cucumber test to simulate expiration of a session
Signed-off-by: Reinier Balt <lrbalt@gmail.com>
2011-02-03 18:17:17 +01:00

33 lines
1 KiB
Ruby

Given /^I have logged in as "(.*)" with password "(.*)"$/ do |username, password|
visit login_path
fill_in "Login", :with => username
fill_in "Password", :with => password
uncheck "Stay logged in:"
click_button
if response.respond_to? :selenium
selenium.wait_for_page_to_load(5000)
end
response.should contain(/Login successful/)
@current_user = User.find_by_login(username)
end
When /^I submit the login form as user "([^\"]*)" with password "([^\"]*)"$/ do |username, password|
fill_in 'Login', :with => username
fill_in 'Password', :with => password
uncheck "Stay logged in:"
click_button
end
When /^my session expires$/ do
selenium.wait_for_page_to_load(5000)
# use expire_session to force expiry of session
js = '$.ajax({type: "GET", url: "/login/expire_session", dataType: "script", async: false});'
selenium.run_script(js);
# force check of expiry bypassing timeout
js = '$.ajax({type: "GET", url: "/login/check_expiry", dataType: "script", async: false});'
selenium.run_script(js);
sleep(2)
end