mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-28 12:58:48 +01:00
migrate logging_in
This commit is contained in:
parent
b874b49336
commit
75f2afc2e1
4 changed files with 16 additions and 24 deletions
|
|
@ -50,10 +50,10 @@ Feature: Existing user logging in
|
|||
| "top secret" project for user "testuser" | "top secret" project for user "testuser" | Logout (Test User) |
|
||||
| context page for "@secret location" for user "testuser" | context page for "@secret location" for user "testuser" | Logout (Test User) |
|
||||
|
||||
@selenium
|
||||
@javascript
|
||||
Scenario: When session expires, you should be logged out
|
||||
When I go to the login page
|
||||
And I submit the login form as user "testuser" with password "secret"
|
||||
Then I should be on the login page
|
||||
And I submit the login form as user "testuser" with password "secret"
|
||||
Then I should be on the home page
|
||||
When my session expires
|
||||
Then I should be on the login page
|
||||
|
|
@ -3,10 +3,8 @@ Given /^I have logged in as "(.*)" with password "(.*)"$/ do |username, password
|
|||
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
|
||||
click_button "Sign in »"
|
||||
|
||||
logout_regexp = @mobile_interface ? "Logout" : "Logout \(#{username}\)"
|
||||
response.should contain(logout_regexp)
|
||||
@current_user = User.find_by_login(username)
|
||||
|
|
@ -16,21 +14,17 @@ When /^I submit the login form as user "([^\"]*)" with password "([^\"]*)"$/ do
|
|||
fill_in 'Login', :with => username
|
||||
fill_in 'Password', :with => password
|
||||
uncheck "Stay logged in:"
|
||||
click_button
|
||||
click_button "Sign in »"
|
||||
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);
|
||||
page.execute_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)
|
||||
page.execute_script(js);
|
||||
end
|
||||
|
||||
When /^I log out of Tracks$/ do
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
Then /^I should be redirected to (.+?)$/ do |page_name|
|
||||
request.headers['HTTP_REFERER'].should_not be_nil
|
||||
request.headers['HTTP_REFERER'].should_not == request.request_uri
|
||||
|
||||
Then "I should be on #{page_name}"
|
||||
end
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
|
||||
# It is recommended to regenerate this file in the future when you upgrade to a
|
||||
# newer version of cucumber-rails. Consider adding your own code to a new file
|
||||
# It is recommended to regenerate this file in the future when you upgrade to a
|
||||
# newer version of cucumber-rails. Consider adding your own code to a new file
|
||||
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
|
||||
# files.
|
||||
|
||||
|
|
@ -16,14 +16,15 @@ require 'cucumber/web/tableish'
|
|||
require 'capybara/rails'
|
||||
require 'capybara/cucumber'
|
||||
require 'capybara/session'
|
||||
require 'cucumber/rails/capybara_javascript_emulation' # Lets you click links with onclick javascript handlers without using @culerity or @javascript
|
||||
# BUG in this version of cucumber/capybara: require 'cucumber/rails/capybara_javascript_emulation' # Lets you click links with onclick javascript handlers without using @culerity or @javascript
|
||||
|
||||
# Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
|
||||
# order to ease the transition to Capybara we set the default here. If you'd
|
||||
# prefer to use XPath just remove this line and adjust any selectors in your
|
||||
# steps to use the XPath syntax.
|
||||
Capybara.default_selector = :css
|
||||
|
||||
# If you set this to false, any error raised from within your app will bubble
|
||||
# If you set this to false, any error raised from within your app will bubble
|
||||
# up to your step definition and out to cucumber unless you catch it somewhere
|
||||
# on the way. You can make Rails rescue errors and render error pages on a
|
||||
# per-scenario basis by tagging a scenario or feature with the @allow-rescue tag.
|
||||
|
|
@ -35,15 +36,15 @@ Capybara.default_selector = :css
|
|||
ActionController::Base.allow_rescue = false
|
||||
|
||||
# If you set this to true, each scenario will run in a database transaction.
|
||||
# You can still turn off transactions on a per-scenario basis, simply tagging
|
||||
# You can still turn off transactions on a per-scenario basis, simply tagging
|
||||
# a feature or scenario with the @no-txn tag. If you are using Capybara,
|
||||
# tagging with @culerity or @javascript will also turn transactions off.
|
||||
#
|
||||
# If you set this to false, transactions will be off for all scenarios,
|
||||
# regardless of whether you use @no-txn or not.
|
||||
#
|
||||
# Beware that turning transactions off will leave data in your database
|
||||
# after each scenario, which can lead to hard-to-debug failures in
|
||||
# Beware that turning transactions off will leave data in your database
|
||||
# after each scenario, which can lead to hard-to-debug failures in
|
||||
# subsequent scenarios. If you do this, we recommend you create a Before
|
||||
# block that will explicitly put your database in a known state.
|
||||
Cucumber::Rails::World.use_transactional_fixtures = true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue