tracks/test/selenium_helper.rb
Luke Melia 901a58f8a3 Upgraded to Rails 2.1. This can have wide ranging consequences, so please help track down any issues introduced by the upgrade. Requires environment.rb modifications.
Changes you will need to make:

 * In your environment.rb, you will need to update references to a few files per environment.rb.tmpl
 * In your environment.rb, you will need to specify the local time zone of the computer that is running your Tracks install.

Other notes on my changes:

 * Modified our code to take advantage of Rails 2.1's slick time zone support.
 * Upgraded will_paginate for compatibility
 * Hacked the Selenium on Rails plugin, which has not been updated in some time and does not support Rails 2.1
 * Verified that all tests pass on my machine, including Selenium tests -- I'd like confirmation from others, too.
2008-06-17 01:13:25 -04:00

54 lines
No EOL
1.6 KiB
Ruby

class SeleniumHelperController < ActionController::Base
def login
if params[:as]
user = User.find_by_login(params[:as].to_s)
session['user_id'] = user
user.contexts.each do |c|
cookies["tracks_#{user.login}_context_c#{c.id}_collapsed"] = nil
end
end
render :text => "Logged in as #{params[:as]}"
end
end
module SeleniumOnRails::TestBuilderActions
def login options = {}
options = {options => nil} unless options.is_a? Hash
opts = {:controller => 'selenium_helper', :action => 'login'}.merge(options)
open opts
end
end
# The accessors available for SeleniumOnRails::TestBuilder tests.
#
# For each +store_foo+ there's +assert_foo+, +assert_not_foo+, +verify_foo+,
# +verify_not_foo+, +wait_for_foo+, +wait_for_not_foo+.
module SeleniumOnRails::TestBuilderAccessors
# How many elements with the class "context" are present on the page?
#
# Related Assertions, automatically generated:
# * +assert_context_count+
# * +assert_not_context_count+
# * +verify_context_count+
# * +verify_not_context_count+
# * +wait_for_context_count+
# * +wait_for_not_context_count+
def store_context_count variable_name
command 'storeContextCount', variable_name
end
each_assertion 'store_context_count' do |assertion_method, command_name|
define_method assertion_method do |expected_count|
command command_name, expected_count
end
end
def assert_context_count_incremented(&block)
store_context_count 'initial_context_count'
store_eval "${initial_context_count} + 1", 'expected_context_count'
yield
wait_for_context_count "${expected_context_count}"
end
end