Mercurial > hg > soundsoftware-site
comparison test/ui/base.rb @ 1298:4f746d8966dd redmine_2.3_integration
Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:28:30 +0100 |
parents | 622f24f53b42 |
children |
comparison
equal
deleted
inserted
replaced
1297:0a574315af3e | 1298:4f746d8966dd |
---|---|
1 # Redmine - project management software | |
2 # Copyright (C) 2006-2013 Jean-Philippe Lang | |
3 # | |
4 # This program is free software; you can redistribute it and/or | |
5 # modify it under the terms of the GNU General Public License | |
6 # as published by the Free Software Foundation; either version 2 | |
7 # of the License, or (at your option) any later version. | |
8 # | |
9 # This program is distributed in the hope that it will be useful, | |
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 # GNU General Public License for more details. | |
13 # | |
14 # You should have received a copy of the GNU General Public License | |
15 # along with this program; if not, write to the Free Software | |
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 | |
18 require File.expand_path('../../test_helper', __FILE__) | |
19 require 'capybara/rails' | |
20 | |
21 Capybara.default_driver = :selenium | |
22 Capybara.register_driver :selenium do |app| | |
23 # Use the following driver definition to test locally using Chrome (also requires chromedriver to be in PATH) | |
24 # Capybara::Selenium::Driver.new(app, :browser => :chrome) | |
25 # Add :switches => %w[--lang=en] to force default browser locale to English | |
26 # Default for Selenium remote driver is to connect to local host on port 4444 | |
27 # This can be change using :url => 'http://localhost:9195' if necessary | |
28 # PhantomJS 1.8 now directly supports Webdriver Wire API, simply run it with `phantomjs --webdriver 4444` | |
29 # Add :desired_capabilities => Selenium::WebDriver::Remote::Capabilities.internet_explorer) to run on Selenium Grid Hub with IE | |
30 Capybara::Selenium::Driver.new(app, :browser => :remote) | |
31 end | |
32 | |
33 module Redmine | |
34 module UiTest | |
35 # Base class for UI tests | |
36 class Base < ActionDispatch::IntegrationTest | |
37 include Capybara::DSL | |
38 | |
39 # Stop ActiveRecord from wrapping tests in transactions | |
40 # Transactional fixtures do not work with Selenium tests, because Capybara | |
41 # uses a separate server thread, which the transactions would be hidden | |
42 self.use_transactional_fixtures = false | |
43 | |
44 # Should not depend on locale since Redmine displays login page | |
45 # using default browser locale which depend on system locale for "real" browsers drivers | |
46 def log_user(login, password) | |
47 visit '/my/page' | |
48 assert_equal '/login', current_path | |
49 within('#login-form form') do | |
50 fill_in 'username', :with => login | |
51 fill_in 'password', :with => password | |
52 find('input[name=login]').click | |
53 end | |
54 assert_equal '/my/page', current_path | |
55 end | |
56 | |
57 teardown do | |
58 Capybara.reset_sessions! # Forget the (simulated) browser state | |
59 Capybara.use_default_driver # Revert Capybara.current_driver to Capybara.default_driver | |
60 end | |
61 end | |
62 end | |
63 end |