2009-05-22 23:14:40 +02:00
|
|
|
Given /^I have logged in as "(.*)" with password "(.*)"$/ do |username, password|
|
2011-02-26 11:38:39 +01:00
|
|
|
When "I go to the login page"
|
2010-02-02 22:52:32 +01:00
|
|
|
fill_in "Login", :with => username
|
|
|
|
|
fill_in "Password", :with => password
|
2010-11-10 23:48:56 +01:00
|
|
|
uncheck "Stay logged in:"
|
2010-02-02 22:52:32 +01:00
|
|
|
click_button
|
2010-05-05 19:08:41 +02:00
|
|
|
if response.respond_to? :selenium
|
|
|
|
|
selenium.wait_for_page_to_load(5000)
|
|
|
|
|
end
|
2011-02-26 14:20:51 +01:00
|
|
|
logout_regexp = @mobile_interface ? "Logout" : "Logout \(#{username}\)"
|
|
|
|
|
response.should contain(logout_regexp)
|
2009-05-22 23:14:40 +02:00
|
|
|
@current_user = User.find_by_login(username)
|
2009-04-13 22:26:20 +02:00
|
|
|
end
|
2009-04-17 08:56:11 +02:00
|
|
|
|
2009-05-22 23:14:40 +02:00
|
|
|
When /^I submit the login form as user "([^\"]*)" with password "([^\"]*)"$/ do |username, password|
|
|
|
|
|
fill_in 'Login', :with => username
|
|
|
|
|
fill_in 'Password', :with => password
|
2010-11-10 23:48:56 +01:00
|
|
|
uncheck "Stay logged in:"
|
2009-04-17 08:56:11 +02:00
|
|
|
click_button
|
2010-02-02 22:52:32 +01:00
|
|
|
end
|
2010-11-10 23:48:56 +01:00
|
|
|
|
|
|
|
|
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);
|
2011-08-18 12:48:59 +02:00
|
|
|
|
2010-11-10 23:48:56 +01:00
|
|
|
# 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
|
2011-08-18 12:48:59 +02:00
|
|
|
|
|
|
|
|
When /^I log out of Tracks$/ do
|
|
|
|
|
When "I go to the logout page"
|
|
|
|
|
end
|