@@ -0,0 +1,63 | |||||
|
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 |
@@ -0,0 +1,68 | |||||
|
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('../base', __FILE__) | |||
|
19 | ||||
|
20 | class Redmine::UiTest::IssuesTest < Redmine::UiTest::Base | |||
|
21 | fixtures :projects, :users, :roles, :members, :member_roles, | |||
|
22 | :trackers, :projects_trackers, :enabled_modules, :issue_statuses, :issues, | |||
|
23 | :enumerations, :custom_fields, :custom_values, :custom_fields_trackers | |||
|
24 | ||||
|
25 | # create an issue | |||
|
26 | def test_add_issue | |||
|
27 | log_user('jsmith', 'jsmith') | |||
|
28 | visit new_issue_path(:project_id => 1) | |||
|
29 | within('form#issue-form') do | |||
|
30 | select 'Bug', :from => 'Tracker' | |||
|
31 | select 'Low', :from => 'Priority' | |||
|
32 | fill_in 'Subject', :with => 'new test issue' | |||
|
33 | fill_in 'Description', :with => 'new issue' | |||
|
34 | select '0 %', :from => 'Done' | |||
|
35 | fill_in 'Due date', :with => '' | |||
|
36 | select '', :from => 'Assignee' | |||
|
37 | fill_in 'Searchable field', :with => 'Value for field 2' | |||
|
38 | # click_button 'Create' would match both 'Create' and 'Create and continue' buttons | |||
|
39 | find('input[name=commit]').click | |||
|
40 | end | |||
|
41 | ||||
|
42 | # find created issue | |||
|
43 | issue = Issue.find_by_subject("new test issue") | |||
|
44 | assert_kind_of Issue, issue | |||
|
45 | ||||
|
46 | # check redirection | |||
|
47 | find 'div#flash_notice', :visible => true, :text => "Issue \##{issue.id} created." | |||
|
48 | assert_equal issue_path(:id => issue), current_path | |||
|
49 | ||||
|
50 | # check issue attributes | |||
|
51 | assert_equal 'jsmith', issue.author.login | |||
|
52 | assert_equal 1, issue.project.id | |||
|
53 | assert_equal IssueStatus.find_by_name('New'), issue.status | |||
|
54 | assert_equal Tracker.find_by_name('Bug'), issue.tracker | |||
|
55 | assert_equal IssuePriority.find_by_name('Low'), issue.priority | |||
|
56 | assert_equal 'Value for field 2', issue.custom_field_value(CustomField.find_by_name('Searchable field')) | |||
|
57 | end | |||
|
58 | ||||
|
59 | def test_preview_issue_description | |||
|
60 | log_user('jsmith', 'jsmith') | |||
|
61 | visit new_issue_path(:project_id => 1) | |||
|
62 | within('form#issue-form') do | |||
|
63 | fill_in 'Description', :with => 'new issue description' | |||
|
64 | click_link 'Preview' | |||
|
65 | end | |||
|
66 | find 'div#preview fieldset', :visible => true, :text => 'new issue description' | |||
|
67 | end | |||
|
68 | end |
@@ -1,95 +1,96 | |||||
1 | source 'http://rubygems.org' |
|
1 | source 'http://rubygems.org' | |
2 |
|
2 | |||
3 | gem 'rails', '3.2.11' |
|
3 | gem 'rails', '3.2.11' | |
4 | gem "jquery-rails", "~> 2.0.2" |
|
4 | gem "jquery-rails", "~> 2.0.2" | |
5 | gem "i18n", "~> 0.6.0" |
|
5 | gem "i18n", "~> 0.6.0" | |
6 | gem "coderay", "~> 1.0.6" |
|
6 | gem "coderay", "~> 1.0.6" | |
7 | gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby] |
|
7 | gem "fastercsv", "~> 1.5.0", :platforms => [:mri_18, :mingw_18, :jruby] | |
8 | gem "builder", "3.0.0" |
|
8 | gem "builder", "3.0.0" | |
9 |
|
9 | |||
10 | # Optional gem for LDAP authentication |
|
10 | # Optional gem for LDAP authentication | |
11 | group :ldap do |
|
11 | group :ldap do | |
12 | gem "net-ldap", "~> 0.3.1" |
|
12 | gem "net-ldap", "~> 0.3.1" | |
13 | end |
|
13 | end | |
14 |
|
14 | |||
15 | # Optional gem for OpenID authentication |
|
15 | # Optional gem for OpenID authentication | |
16 | group :openid do |
|
16 | group :openid do | |
17 | gem "ruby-openid", "~> 2.1.4", :require => "openid" |
|
17 | gem "ruby-openid", "~> 2.1.4", :require => "openid" | |
18 | gem "rack-openid" |
|
18 | gem "rack-openid" | |
19 | end |
|
19 | end | |
20 |
|
20 | |||
21 | # Optional gem for exporting the gantt to a PNG file, not supported with jruby |
|
21 | # Optional gem for exporting the gantt to a PNG file, not supported with jruby | |
22 | platforms :mri, :mingw do |
|
22 | platforms :mri, :mingw do | |
23 | group :rmagick do |
|
23 | group :rmagick do | |
24 | # RMagick 2 supports ruby 1.9 |
|
24 | # RMagick 2 supports ruby 1.9 | |
25 | # RMagick 1 would be fine for ruby 1.8 but Bundler does not support |
|
25 | # RMagick 1 would be fine for ruby 1.8 but Bundler does not support | |
26 | # different requirements for the same gem on different platforms |
|
26 | # different requirements for the same gem on different platforms | |
27 | gem "rmagick", ">= 2.0.0" |
|
27 | gem "rmagick", ">= 2.0.0" | |
28 | end |
|
28 | end | |
29 | end |
|
29 | end | |
30 |
|
30 | |||
31 | platforms :jruby do |
|
31 | platforms :jruby do | |
32 | # jruby-openssl is bundled with JRuby 1.7.0 |
|
32 | # jruby-openssl is bundled with JRuby 1.7.0 | |
33 | gem "jruby-openssl" if Object.const_defined?(:JRUBY_VERSION) && JRUBY_VERSION < '1.7.0' |
|
33 | gem "jruby-openssl" if Object.const_defined?(:JRUBY_VERSION) && JRUBY_VERSION < '1.7.0' | |
34 | gem "activerecord-jdbc-adapter", "1.2.5" |
|
34 | gem "activerecord-jdbc-adapter", "1.2.5" | |
35 | end |
|
35 | end | |
36 |
|
36 | |||
37 | # Include database gems for the adapters found in the database |
|
37 | # Include database gems for the adapters found in the database | |
38 | # configuration file |
|
38 | # configuration file | |
39 | database_file = File.join(File.dirname(__FILE__), "config/database.yml") |
|
39 | database_file = File.join(File.dirname(__FILE__), "config/database.yml") | |
40 | if File.exist?(database_file) |
|
40 | if File.exist?(database_file) | |
41 | database_config = YAML.load_file(database_file) |
|
41 | database_config = YAML.load_file(database_file) | |
42 | adapters = database_config.values.map {|c| c['adapter']}.compact.uniq |
|
42 | adapters = database_config.values.map {|c| c['adapter']}.compact.uniq | |
43 | if adapters.any? |
|
43 | if adapters.any? | |
44 | adapters.each do |adapter| |
|
44 | adapters.each do |adapter| | |
45 | case adapter |
|
45 | case adapter | |
46 | when /mysql/ |
|
46 | when /mysql/ | |
47 | gem "mysql", "~> 2.8.1", :platforms => [:mri_18, :mingw_18] |
|
47 | gem "mysql", "~> 2.8.1", :platforms => [:mri_18, :mingw_18] | |
48 | gem "mysql2", "~> 0.3.11", :platforms => [:mri_19, :mingw_19] |
|
48 | gem "mysql2", "~> 0.3.11", :platforms => [:mri_19, :mingw_19] | |
49 | gem "activerecord-jdbcmysql-adapter", :platforms => :jruby |
|
49 | gem "activerecord-jdbcmysql-adapter", :platforms => :jruby | |
50 | when /postgresql/ |
|
50 | when /postgresql/ | |
51 | gem "pg", ">= 0.11.0", :platforms => [:mri, :mingw] |
|
51 | gem "pg", ">= 0.11.0", :platforms => [:mri, :mingw] | |
52 | gem "activerecord-jdbcpostgresql-adapter", :platforms => :jruby |
|
52 | gem "activerecord-jdbcpostgresql-adapter", :platforms => :jruby | |
53 | when /sqlite3/ |
|
53 | when /sqlite3/ | |
54 | gem "sqlite3", :platforms => [:mri, :mingw] |
|
54 | gem "sqlite3", :platforms => [:mri, :mingw] | |
55 | gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby |
|
55 | gem "activerecord-jdbcsqlite3-adapter", :platforms => :jruby | |
56 | when /sqlserver/ |
|
56 | when /sqlserver/ | |
57 | gem "tiny_tds", "~> 0.5.1", :platforms => [:mri, :mingw] |
|
57 | gem "tiny_tds", "~> 0.5.1", :platforms => [:mri, :mingw] | |
58 | gem "activerecord-sqlserver-adapter", :platforms => [:mri, :mingw] |
|
58 | gem "activerecord-sqlserver-adapter", :platforms => [:mri, :mingw] | |
59 | else |
|
59 | else | |
60 | warn("Unknown database adapter `#{adapter}` found in config/database.yml, use Gemfile.local to load your own database gems") |
|
60 | warn("Unknown database adapter `#{adapter}` found in config/database.yml, use Gemfile.local to load your own database gems") | |
61 | end |
|
61 | end | |
62 | end |
|
62 | end | |
63 | else |
|
63 | else | |
64 | warn("No adapter found in config/database.yml, please configure it first") |
|
64 | warn("No adapter found in config/database.yml, please configure it first") | |
65 | end |
|
65 | end | |
66 | else |
|
66 | else | |
67 | warn("Please configure your config/database.yml first") |
|
67 | warn("Please configure your config/database.yml first") | |
68 | end |
|
68 | end | |
69 |
|
69 | |||
70 | group :development do |
|
70 | group :development do | |
71 | gem "rdoc", ">= 2.4.2" |
|
71 | gem "rdoc", ">= 2.4.2" | |
72 | gem "yard" |
|
72 | gem "yard" | |
73 | end |
|
73 | end | |
74 |
|
74 | |||
75 | group :test do |
|
75 | group :test do | |
76 | gem "shoulda", "~> 2.11" |
|
76 | gem "shoulda", "~> 2.11" | |
77 | # Shoulda does not work nice on Ruby 1.9.3 and JRuby 1.7. |
|
77 | # Shoulda does not work nice on Ruby 1.9.3 and JRuby 1.7. | |
78 | # It seems to need test-unit explicitely. |
|
78 | # It seems to need test-unit explicitely. | |
79 | platforms = [:mri_19] |
|
79 | platforms = [:mri_19] | |
80 | platforms << :jruby if defined?(JRUBY_VERSION) && JRUBY_VERSION >= "1.7" |
|
80 | platforms << :jruby if defined?(JRUBY_VERSION) && JRUBY_VERSION >= "1.7" | |
81 | gem "test-unit", :platforms => platforms |
|
81 | gem "test-unit", :platforms => platforms | |
82 | gem "mocha", "0.12.3" |
|
82 | gem "mocha", "0.12.3" | |
|
83 | gem 'capybara', '~> 2.0.0' | |||
83 | end |
|
84 | end | |
84 |
|
85 | |||
85 | local_gemfile = File.join(File.dirname(__FILE__), "Gemfile.local") |
|
86 | local_gemfile = File.join(File.dirname(__FILE__), "Gemfile.local") | |
86 | if File.exists?(local_gemfile) |
|
87 | if File.exists?(local_gemfile) | |
87 | puts "Loading Gemfile.local ..." if $DEBUG # `ruby -d` or `bundle -v` |
|
88 | puts "Loading Gemfile.local ..." if $DEBUG # `ruby -d` or `bundle -v` | |
88 | instance_eval File.read(local_gemfile) |
|
89 | instance_eval File.read(local_gemfile) | |
89 | end |
|
90 | end | |
90 |
|
91 | |||
91 | # Load plugins' Gemfiles |
|
92 | # Load plugins' Gemfiles | |
92 | Dir.glob File.expand_path("../plugins/*/Gemfile", __FILE__) do |file| |
|
93 | Dir.glob File.expand_path("../plugins/*/Gemfile", __FILE__) do |file| | |
93 | puts "Loading #{file} ..." if $DEBUG # `ruby -d` or `bundle -v` |
|
94 | puts "Loading #{file} ..." if $DEBUG # `ruby -d` or `bundle -v` | |
94 | instance_eval File.read(file) |
|
95 | instance_eval File.read(file) | |
95 | end |
|
96 | end |
@@ -1,60 +1,69 | |||||
1 | Installing gems for testing |
|
1 | Installing gems for testing | |
2 | =========================== |
|
2 | =========================== | |
3 |
|
3 | |||
4 | Remove your .bundle/config if you've already installed Redmine without |
|
4 | Remove your .bundle/config if you've already installed Redmine without | |
5 | the test dependencies. Then, run `bundle install`. |
|
5 | the test dependencies. Then, run `bundle install`. | |
6 |
|
6 | |||
7 | Running Tests |
|
7 | Running Tests | |
8 | ============= |
|
8 | ============= | |
9 |
|
9 | |||
10 | Run `rake --tasks test` to see available tests. |
|
10 | Run `rake --tasks test` to see available tests. | |
11 | Run `rake test` to run the entire test suite (except the tests for the |
|
11 | Run `rake test` to run the entire test suite (except the tests for the | |
12 | Apache perl module Redmine.pm, see below). |
|
12 | Apache perl module Redmine.pm and Capybara tests, see below). | |
13 |
|
13 | |||
14 | You can run `ruby test/unit/issue_test.rb` for running a single test case. |
|
14 | You can run `ruby test/unit/issue_test.rb` for running a single test case. | |
15 |
|
15 | |||
16 | Before running tests, you need to configure both development |
|
16 | Before running tests, you need to configure both development | |
17 | and test databases. |
|
17 | and test databases. | |
18 |
|
18 | |||
19 | Creating test repositories |
|
19 | Creating test repositories | |
20 | ========================== |
|
20 | ========================== | |
21 |
|
21 | |||
22 | Redmine supports a wide array of different version control systems. |
|
22 | Redmine supports a wide array of different version control systems. | |
23 | To test the support, a test repository needs to be created for each of those. |
|
23 | To test the support, a test repository needs to be created for each of those. | |
24 |
|
24 | |||
25 | Run `rake --tasks test:scm:setup` for a list of available test-repositories or |
|
25 | Run `rake --tasks test:scm:setup` for a list of available test-repositories or | |
26 | run `rake test:scm:setup:all` to set up all of them. The repositories are |
|
26 | run `rake test:scm:setup:all` to set up all of them. The repositories are | |
27 | unpacked into {redmine_root}/tmp/test. |
|
27 | unpacked into {redmine_root}/tmp/test. | |
28 |
|
28 | |||
29 | If the test repositories are not present, the tests that need them will be |
|
29 | If the test repositories are not present, the tests that need them will be | |
30 | skipped. |
|
30 | skipped. | |
31 |
|
31 | |||
32 | Creating a test ldap database |
|
32 | Creating a test ldap database | |
33 | ============================= |
|
33 | ============================= | |
34 |
|
34 | |||
35 | Redmine supports using LDAP for user authentications. To test LDAP |
|
35 | Redmine supports using LDAP for user authentications. To test LDAP | |
36 | with Redmine, load the LDAP export from test/fixtures/ldap/test-ldap.ldif |
|
36 | with Redmine, load the LDAP export from test/fixtures/ldap/test-ldap.ldif | |
37 | into a testing LDAP server. Make sure that the LDAP server can be accessed |
|
37 | into a testing LDAP server. Make sure that the LDAP server can be accessed | |
38 | at 127.0.0.1 on port 389. |
|
38 | at 127.0.0.1 on port 389. | |
39 |
|
39 | |||
40 | Setting up the test LDAP server is beyond the scope of this documentation. |
|
40 | Setting up the test LDAP server is beyond the scope of this documentation. | |
41 | The OpenLDAP project provides a simple LDAP implementation that should work |
|
41 | The OpenLDAP project provides a simple LDAP implementation that should work | |
42 | good as a test server. |
|
42 | good as a test server. | |
43 |
|
43 | |||
44 | If the LDAP is not available, the tests that need it will be skipped. |
|
44 | If the LDAP is not available, the tests that need it will be skipped. | |
45 |
|
45 | |||
46 | Running Redmine.pm tests |
|
46 | Running Redmine.pm tests | |
47 | ======================== |
|
47 | ======================== | |
48 |
|
48 | |||
49 | (work in progress) |
|
49 | (work in progress) | |
50 |
|
50 | |||
51 | Running the tests for the Redmine.pm perl module needs a bit more setup. |
|
51 | Running the tests for the Redmine.pm perl module needs a bit more setup. | |
52 | You need an Apache server with mod_perl, mod_dav_svn and Redmine.pm configured. |
|
52 | You need an Apache server with mod_perl, mod_dav_svn and Redmine.pm configured. | |
53 | See: http://www.redmine.org/projects/redmine/wiki/Repositories_access_control_with_apache_mod_dav_svn_and_mod_perl |
|
53 | See: http://www.redmine.org/projects/redmine/wiki/Repositories_access_control_with_apache_mod_dav_svn_and_mod_perl | |
54 |
|
54 | |||
55 | You need an empty repository accessible at http://127.0.0.1/svn/ecookbook |
|
55 | You need an empty repository accessible at http://127.0.0.1/svn/ecookbook | |
56 | Then, you can run the tests with: |
|
56 | Then, you can run the tests with: | |
57 | `ruby test\extra\redmine_pm\repository_subversion_test.rb` |
|
57 | `ruby test\extra\redmine_pm\repository_subversion_test.rb` | |
58 |
|
58 | |||
59 | If you svn server is not running on localhost, you can use the REDMINE_TEST_DAV_SERVER |
|
59 | If you svn server is not running on localhost, you can use the REDMINE_TEST_DAV_SERVER | |
60 | environment variable to specify another host. |
|
60 | environment variable to specify another host. | |
|
61 | ||||
|
62 | Running Capybara tests | |||
|
63 | ====================== | |||
|
64 | ||||
|
65 | You need to have PhantomJS WebDriver listening on port 4444: | |||
|
66 | `phantomjs --webdriver 4444` | |||
|
67 | ||||
|
68 | Capybara tests can be run with: | |||
|
69 | `rake test:ui` |
@@ -1,103 +1,110 | |||||
1 | ### From http://svn.geekdaily.org/public/rails/plugins/generally_useful/tasks/coverage_via_rcov.rake |
|
1 | ### From http://svn.geekdaily.org/public/rails/plugins/generally_useful/tasks/coverage_via_rcov.rake | |
2 |
|
2 | |||
3 | namespace :test do |
|
3 | namespace :test do | |
4 | desc 'Measures test coverage' |
|
4 | desc 'Measures test coverage' | |
5 | task :coverage do |
|
5 | task :coverage do | |
6 | rm_f "coverage" |
|
6 | rm_f "coverage" | |
7 | rm_f "coverage.data" |
|
7 | rm_f "coverage.data" | |
8 | rcov = "rcov --rails --aggregate coverage.data --text-summary -Ilib --html --exclude gems/" |
|
8 | rcov = "rcov --rails --aggregate coverage.data --text-summary -Ilib --html --exclude gems/" | |
9 | files = %w(unit functional integration).map {|dir| Dir.glob("test/#{dir}/**/*_test.rb")}.flatten.join(" ") |
|
9 | files = %w(unit functional integration).map {|dir| Dir.glob("test/#{dir}/**/*_test.rb")}.flatten.join(" ") | |
10 | system("#{rcov} #{files}") |
|
10 | system("#{rcov} #{files}") | |
11 | end |
|
11 | end | |
12 |
|
12 | |||
13 | desc 'Run unit and functional scm tests' |
|
13 | desc 'Run unit and functional scm tests' | |
14 | task :scm do |
|
14 | task :scm do | |
15 | errors = %w(test:scm:units test:scm:functionals).collect do |task| |
|
15 | errors = %w(test:scm:units test:scm:functionals).collect do |task| | |
16 | begin |
|
16 | begin | |
17 | Rake::Task[task].invoke |
|
17 | Rake::Task[task].invoke | |
18 | nil |
|
18 | nil | |
19 | rescue => e |
|
19 | rescue => e | |
20 | task |
|
20 | task | |
21 | end |
|
21 | end | |
22 | end.compact |
|
22 | end.compact | |
23 | abort "Errors running #{errors.to_sentence(:locale => :en)}!" if errors.any? |
|
23 | abort "Errors running #{errors.to_sentence(:locale => :en)}!" if errors.any? | |
24 | end |
|
24 | end | |
25 |
|
25 | |||
26 | namespace :scm do |
|
26 | namespace :scm do | |
27 | namespace :setup do |
|
27 | namespace :setup do | |
28 | desc "Creates directory for test repositories" |
|
28 | desc "Creates directory for test repositories" | |
29 | task :create_dir do |
|
29 | task :create_dir do | |
30 | FileUtils.mkdir_p Rails.root + '/tmp/test' |
|
30 | FileUtils.mkdir_p Rails.root + '/tmp/test' | |
31 | end |
|
31 | end | |
32 |
|
32 | |||
33 | supported_scms = [:subversion, :cvs, :bazaar, :mercurial, :git, :darcs, :filesystem] |
|
33 | supported_scms = [:subversion, :cvs, :bazaar, :mercurial, :git, :darcs, :filesystem] | |
34 |
|
34 | |||
35 | desc "Creates a test subversion repository" |
|
35 | desc "Creates a test subversion repository" | |
36 | task :subversion => :create_dir do |
|
36 | task :subversion => :create_dir do | |
37 | repo_path = "tmp/test/subversion_repository" |
|
37 | repo_path = "tmp/test/subversion_repository" | |
38 | unless File.exists?(repo_path) |
|
38 | unless File.exists?(repo_path) | |
39 | system "svnadmin create #{repo_path}" |
|
39 | system "svnadmin create #{repo_path}" | |
40 | system "gunzip < test/fixtures/repositories/subversion_repository.dump.gz | svnadmin load #{repo_path}" |
|
40 | system "gunzip < test/fixtures/repositories/subversion_repository.dump.gz | svnadmin load #{repo_path}" | |
41 | end |
|
41 | end | |
42 | end |
|
42 | end | |
43 |
|
43 | |||
44 | desc "Creates a test mercurial repository" |
|
44 | desc "Creates a test mercurial repository" | |
45 | task :mercurial => :create_dir do |
|
45 | task :mercurial => :create_dir do | |
46 | repo_path = "tmp/test/mercurial_repository" |
|
46 | repo_path = "tmp/test/mercurial_repository" | |
47 | unless File.exists?(repo_path) |
|
47 | unless File.exists?(repo_path) | |
48 | bundle_path = "test/fixtures/repositories/mercurial_repository.hg" |
|
48 | bundle_path = "test/fixtures/repositories/mercurial_repository.hg" | |
49 | system "hg init #{repo_path}" |
|
49 | system "hg init #{repo_path}" | |
50 | system "hg -R #{repo_path} pull #{bundle_path}" |
|
50 | system "hg -R #{repo_path} pull #{bundle_path}" | |
51 | end |
|
51 | end | |
52 | end |
|
52 | end | |
53 |
|
53 | |||
54 | (supported_scms - [:subversion, :mercurial]).each do |scm| |
|
54 | (supported_scms - [:subversion, :mercurial]).each do |scm| | |
55 | desc "Creates a test #{scm} repository" |
|
55 | desc "Creates a test #{scm} repository" | |
56 | task scm => :create_dir do |
|
56 | task scm => :create_dir do | |
57 | unless File.exists?("tmp/test/#{scm}_repository") |
|
57 | unless File.exists?("tmp/test/#{scm}_repository") | |
58 | # system "gunzip < test/fixtures/repositories/#{scm}_repository.tar.gz | tar -xv -C tmp/test" |
|
58 | # system "gunzip < test/fixtures/repositories/#{scm}_repository.tar.gz | tar -xv -C tmp/test" | |
59 | system "tar -xvz -C tmp/test -f test/fixtures/repositories/#{scm}_repository.tar.gz" |
|
59 | system "tar -xvz -C tmp/test -f test/fixtures/repositories/#{scm}_repository.tar.gz" | |
60 | end |
|
60 | end | |
61 | end |
|
61 | end | |
62 | end |
|
62 | end | |
63 |
|
63 | |||
64 | desc "Creates all test repositories" |
|
64 | desc "Creates all test repositories" | |
65 | task :all => supported_scms |
|
65 | task :all => supported_scms | |
66 | end |
|
66 | end | |
67 |
|
67 | |||
68 | desc "Updates installed test repositories" |
|
68 | desc "Updates installed test repositories" | |
69 | task :update do |
|
69 | task :update do | |
70 | require 'fileutils' |
|
70 | require 'fileutils' | |
71 | Dir.glob("tmp/test/*_repository").each do |dir| |
|
71 | Dir.glob("tmp/test/*_repository").each do |dir| | |
72 | next unless File.basename(dir) =~ %r{^(.+)_repository$} && File.directory?(dir) |
|
72 | next unless File.basename(dir) =~ %r{^(.+)_repository$} && File.directory?(dir) | |
73 | scm = $1 |
|
73 | scm = $1 | |
74 | next unless fixture = Dir.glob("test/fixtures/repositories/#{scm}_repository.*").first |
|
74 | next unless fixture = Dir.glob("test/fixtures/repositories/#{scm}_repository.*").first | |
75 | next if File.stat(dir).ctime > File.stat(fixture).mtime |
|
75 | next if File.stat(dir).ctime > File.stat(fixture).mtime | |
76 |
|
76 | |||
77 | FileUtils.rm_rf dir |
|
77 | FileUtils.rm_rf dir | |
78 | Rake::Task["test:scm:setup:#{scm}"].execute |
|
78 | Rake::Task["test:scm:setup:#{scm}"].execute | |
79 | end |
|
79 | end | |
80 | end |
|
80 | end | |
81 |
|
81 | |||
82 | Rake::TestTask.new(:units => "db:test:prepare") do |t| |
|
82 | Rake::TestTask.new(:units => "db:test:prepare") do |t| | |
83 | t.libs << "test" |
|
83 | t.libs << "test" | |
84 | t.verbose = true |
|
84 | t.verbose = true | |
85 | t.test_files = FileList['test/unit/repository*_test.rb'] + FileList['test/unit/lib/redmine/scm/**/*_test.rb'] |
|
85 | t.test_files = FileList['test/unit/repository*_test.rb'] + FileList['test/unit/lib/redmine/scm/**/*_test.rb'] | |
86 | end |
|
86 | end | |
87 | Rake::Task['test:scm:units'].comment = "Run the scm unit tests" |
|
87 | Rake::Task['test:scm:units'].comment = "Run the scm unit tests" | |
88 |
|
88 | |||
89 | Rake::TestTask.new(:functionals => "db:test:prepare") do |t| |
|
89 | Rake::TestTask.new(:functionals => "db:test:prepare") do |t| | |
90 | t.libs << "test" |
|
90 | t.libs << "test" | |
91 | t.verbose = true |
|
91 | t.verbose = true | |
92 | t.test_files = FileList['test/functional/repositories*_test.rb'] |
|
92 | t.test_files = FileList['test/functional/repositories*_test.rb'] | |
93 | end |
|
93 | end | |
94 | Rake::Task['test:scm:functionals'].comment = "Run the scm functional tests" |
|
94 | Rake::Task['test:scm:functionals'].comment = "Run the scm functional tests" | |
95 | end |
|
95 | end | |
96 |
|
96 | |||
97 | Rake::TestTask.new(:rdm_routing) do |t| |
|
97 | Rake::TestTask.new(:rdm_routing) do |t| | |
98 | t.libs << "test" |
|
98 | t.libs << "test" | |
99 | t.verbose = true |
|
99 | t.verbose = true | |
100 | t.test_files = FileList['test/integration/routing/*_test.rb'] |
|
100 | t.test_files = FileList['test/integration/routing/*_test.rb'] | |
101 | end |
|
101 | end | |
102 | Rake::Task['test:rdm_routing'].comment = "Run the routing tests" |
|
102 | Rake::Task['test:rdm_routing'].comment = "Run the routing tests" | |
|
103 | ||||
|
104 | Rake::TestTask.new(:ui => "db:test:prepare") do |t| | |||
|
105 | t.libs << "test" | |||
|
106 | t.verbose = true | |||
|
107 | t.test_files = FileList['test/ui/**/*_test.rb'] | |||
|
108 | end | |||
|
109 | Rake::Task['test:ui'].comment = "Run the UI tests with Capybara (PhantomJS listening on port 4444 is required)" | |||
103 | end |
|
110 | end |
General Comments 0
You need to be logged in to leave comments.
Login now