make cucumber faster by logging in through a much simpler stubby controller. Save about 1m on my laptop.

This commit is contained in:
Raphael Sofaer 2011-07-03 21:09:28 -07:00
parent af6547815e
commit a715630471
6 changed files with 41 additions and 2 deletions

View file

@ -1,7 +1,7 @@
#selected_aspect_contacts.section
.title.no_icon
%h5
- if @aspect_ids.size > 1
- if all_aspects_selected? || @aspect_ids.size > 1
= "#{t('_contacts')}"
- else
= @aspect.name

View file

@ -13,7 +13,7 @@ Feature: Close Account
Then I should be on the home page
When I go to the new user session page
And I try to sign in
And I try to sign in manually
Then I should be on the new user session page
When I wait for the ajax to finish
Then I should see "Invalid email or password."

View file

@ -16,6 +16,18 @@ end
When /^I try to sign in$/ do
@me ||= Factory(:user_with_aspect, :getting_started => false)
#page.driver.post(integration_sessions_path(:user_id => @me.id))
page.driver.visit(new_integration_sessions_path(:user_id => @me.id))
And %(I press "Login")
# To save time as compared to:
#When %(I go to the new user session page)
#When %(I fill in "Username" with "#{@me.username}")
#When %(I fill in "Password" with "#{@me.password}")
#When %(I press "Sign in")
end
When /^I try to sign in manually$/ do
When %(I go to the new user session page)
When %(I fill in "Username" with "#{@me.username}")
When %(I fill in "Password" with "#{@me.password}")

View file

@ -40,6 +40,7 @@ DatabaseCleaner.orm = "active_record"
Cucumber::Rails::World.use_transactional_fixtures = false
require File.join(File.dirname(__FILE__), "database_cleaner_patches")
require File.join(File.dirname(__FILE__), "integration_sessions_controller")
require File.join(File.dirname(__FILE__), "..", "..", "spec", "support", "fake_redis")
require File.join(File.dirname(__FILE__), "..", "..", "spec", "helper_methods")

View file

@ -0,0 +1,25 @@
class IntegrationSessionsController < ApplicationController
def new
@user_id = params[:user_id]
render 'features/support/integration_sessions_form'
end
def create
sign_in_and_redirect User.find(params[:user_id])
end
end
#Copypasta from http://openhood.com/rails/rails%203/2010/07/20/add-routes-at-runtime-rails-3/
begin
_routes = Diaspora::Application.routes
_routes.disable_clear_and_finalize = true
_routes.clear!
Diaspora::Application.routes_reloader.paths.each{ |path| load(path) }
_routes.draw do
# here you can add any route you want
post 'integration_sessions' => 'integration_sessions#create', :as => 'integration_sessions'
get 'integration_sessions' => 'integration_sessions#new', :as => 'new_integration_sessions'
end
ActiveSupport.on_load(:action_controller) { _routes.finalize! }
ensure
_routes.disable_clear_and_finalize = false
end

View file

@ -0,0 +1 @@
= button_to "Login", integration_sessions_path(:user_id => @user_id)