summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2017-07-23 12:27:27 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2017-07-23 12:27:27 +0000
commitb25b4762046adf99809ce609529d16dd22e2a1b4 (patch)
tree4da4b3ad273b79b0036a94629cf3838688662e2c
parent9ec757d9b23437b3dd3e1b8652ad822ba0785d8a (diff)
downloadredmine-b25b4762046adf99809ce609529d16dd22e2a1b4.tar.gz
redmine-b25b4762046adf99809ce609529d16dd22e2a1b4.zip
Renames test/ui to test/system.
git-svn-id: http://svn.redmine.org/redmine/trunk@16863 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r--test/ui/base.rb109
-rw-r--r--test/ui/issues_test_ui.rb303
-rw-r--r--test/ui/my_page_test_ui.rb54
-rw-r--r--test/ui/quick_jump_test_ui.rb68
-rw-r--r--test/ui/sudo_mode_test_ui.rb68
-rw-r--r--test/ui/timelog_test_ui.rb101
6 files changed, 0 insertions, 703 deletions
diff --git a/test/ui/base.rb b/test/ui/base.rb
deleted file mode 100644
index d4ecff985..000000000
--- a/test/ui/base.rb
+++ /dev/null
@@ -1,109 +0,0 @@
-# Redmine - project management software
-# Copyright (C) 2006-2017 Jean-Philippe Lang
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
-require File.expand_path('../../test_helper', __FILE__)
-require 'capybara/rails'
-require 'fileutils'
-require 'timeout'
-
-module Redmine
- module UiTest
- module Downloads
- DOWNLOADS_PATH = File.expand_path(File.join(Rails.root, 'tmp', 'downloads'))
-
- def clear_downloaded_files
- FileUtils.rm downloaded_files
- end
-
- def downloaded_files
- Dir.glob("#{DOWNLOADS_PATH}/*").reject {|f| f=~/crdownload$/}
- end
-
- def downloaded_file
- Timeout.timeout(5) do
- while downloaded_files.empty?
- sleep 0.2
- end
- end
- downloaded_files.first
- end
- end
- end
-end
-
-FileUtils.mkdir_p Redmine::UiTest::Downloads::DOWNLOADS_PATH
-
-Capybara.register_driver :chrome do |app|
- Capybara::Selenium::Driver.new(app,
- :browser => :chrome,
- :desired_capabilities => Selenium::WebDriver::Remote::Capabilities.chrome(
- 'chromeOptions' => {
- 'args' => [ "--window-size=1024,900" ],
- 'prefs' => {
- 'download.default_directory' => Redmine::UiTest::Downloads::DOWNLOADS_PATH,
- 'download.prompt_for_download' => false,
- 'plugins.plugins_disabled' => ["Chrome PDF Viewer"]
- }
- }
- )
- )
-end
-Capybara.default_driver = :chrome
-
-# default: 2
-Capybara.default_wait_time = 2
-
-module Redmine
- module UiTest
- # Base class for UI tests
- class Base < ActionDispatch::IntegrationTest
- include Capybara::DSL
- include Redmine::UiTest::Downloads
-
- # Stop ActiveRecord from wrapping tests in transactions
- # Transactional fixtures do not work with Selenium tests, because Capybara
- # uses a separate server thread, which the transactions would be hidden
- self.use_transactional_tests = false
-
- # Should not depend on locale since Redmine displays login page
- # using default browser locale which depend on system locale for "real" browsers drivers
- def log_user(login, password)
- visit '/my/page'
- assert_equal '/login', current_path
- within('#login-form form') do
- fill_in 'username', :with => login
- fill_in 'password', :with => password
- find('input[name=login]').click
- end
- assert_equal '/my/page', current_path
- end
-
- setup do
- clear_downloaded_files
- Setting.delete_all
- Setting.clear_cache
- end
-
- teardown do
- Capybara.reset_sessions! # Forget the (simulated) browser state
- Capybara.use_default_driver # Revert Capybara.current_driver to Capybara.default_driver
- Setting.delete_all
- Setting.clear_cache
- end
- end
- end
-end
diff --git a/test/ui/issues_test_ui.rb b/test/ui/issues_test_ui.rb
deleted file mode 100644
index 39fa8e7b6..000000000
--- a/test/ui/issues_test_ui.rb
+++ /dev/null
@@ -1,303 +0,0 @@
-# Redmine - project management software
-# Copyright (C) 2006-2017 Jean-Philippe Lang
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
-require File.expand_path('../base', __FILE__)
-
-class Redmine::UiTest::IssuesTest < Redmine::UiTest::Base
- fixtures :projects, :users, :email_addresses, :roles, :members, :member_roles,
- :trackers, :projects_trackers, :enabled_modules, :issue_statuses, :issues,
- :enumerations, :custom_fields, :custom_values, :custom_fields_trackers,
- :watchers, :journals, :journal_details
-
- def test_create_issue
- log_user('jsmith', 'jsmith')
- visit '/projects/ecookbook/issues/new'
- within('form#issue-form') do
- select 'Bug', :from => 'Tracker'
- select 'Low', :from => 'Priority'
- fill_in 'Subject', :with => 'new test issue'
- fill_in 'Description', :with => 'new issue'
- select '0 %', :from => 'Done'
- fill_in 'Searchable field', :with => 'Value for field 2'
- # click_button 'Create' would match both 'Create' and 'Create and continue' buttons
- find('input[name=commit]').click
- end
-
- # find created issue
- issue = Issue.find_by_subject("new test issue")
- assert_kind_of Issue, issue
-
- # check redirection
- find 'div#flash_notice', :visible => true, :text => "Issue \##{issue.id} created."
- assert_equal issue_path(:id => issue), current_path
-
- # check issue attributes
- assert_equal 'jsmith', issue.author.login
- assert_equal 1, issue.project.id
- assert_equal IssueStatus.find_by_name('New'), issue.status
- assert_equal Tracker.find_by_name('Bug'), issue.tracker
- assert_equal IssuePriority.find_by_name('Low'), issue.priority
- assert_equal 'Value for field 2', issue.custom_field_value(CustomField.find_by_name('Searchable field'))
- end
-
- def test_create_issue_with_form_update
- field1 = IssueCustomField.create!(
- :field_format => 'string',
- :name => 'Field1',
- :is_for_all => true,
- :trackers => Tracker.where(:id => [1, 2])
- )
- field2 = IssueCustomField.create!(
- :field_format => 'string',
- :name => 'Field2',
- :is_for_all => true,
- :trackers => Tracker.where(:id => 2)
- )
-
- Role.non_member.add_permission! :add_issues
- Role.non_member.remove_permission! :edit_issues, :add_issue_notes
-
- log_user('someone', 'foo')
- visit '/projects/ecookbook/issues/new'
- assert page.has_no_content?(field2.name)
- assert page.has_content?(field1.name)
-
- fill_in 'Subject', :with => 'New test issue'
- fill_in 'Description', :with => 'New test issue description'
- fill_in field1.name, :with => 'CF1 value'
- select 'Low', :from => 'Priority'
-
- # field2 should show up when changing tracker
- select 'Feature request', :from => 'Tracker'
- assert page.has_content?(field2.name)
- assert page.has_content?(field1.name)
-
- fill_in field2.name, :with => 'CF2 value'
- assert_difference 'Issue.count' do
- page.first(:button, 'Create').click
- end
-
- issue = Issue.order('id desc').first
- assert_equal 'New test issue', issue.subject
- assert_equal 'New test issue description', issue.description
- assert_equal 'Low', issue.priority.name
- assert_equal 'CF1 value', issue.custom_field_value(field1)
- assert_equal 'CF2 value', issue.custom_field_value(field2)
- end
-
- def test_create_issue_with_watchers
- user = User.generate!(:firstname => 'Some', :lastname => 'Watcher')
- assert_equal 'Some Watcher', user.name
- log_user('jsmith', 'jsmith')
- visit '/projects/ecookbook/issues/new'
- fill_in 'Subject', :with => 'Issue with watchers'
- # Add a project member as watcher
- check 'Dave Lopper'
- # Search for another user
- assert page.has_no_css?('form#new-watcher-form')
- assert page.has_no_content?('Some Watcher')
- click_link 'Search for watchers to add'
- within('form#new-watcher-form') do
- fill_in 'user_search', :with => 'watch'
- assert page.has_content?('Some Watcher')
- check 'Some Watcher'
- click_button 'Add'
- end
- assert page.has_css?('form#issue-form')
- assert page.has_css?('p#watchers_form')
- using_wait_time(30) do
- within('span#watchers_inputs') do
- within("label#issue_watcher_user_ids_#{user.id}") do
- assert has_content?('Some Watcher'), "No watcher content"
- end
- end
- end
- assert_difference 'Issue.count' do
- find('input[name=commit]').click
- end
-
- issue = Issue.order('id desc').first
- assert_equal ['Dave Lopper', 'Some Watcher'], issue.watcher_users.map(&:name).sort
- end
-
- def test_preview_issue_description
- log_user('jsmith', 'jsmith')
- visit '/projects/ecookbook/issues/new'
- within('form#issue-form') do
- fill_in 'Subject', :with => 'new issue subject'
- fill_in 'Description', :with => 'new issue description'
- click_link 'Preview'
- end
- find 'div#preview fieldset', :visible => true, :text => 'new issue description'
- assert_difference 'Issue.count' do
- find('input[name=commit]').click
- end
-
- issue = Issue.order('id desc').first
- assert_equal 'new issue description', issue.description
- end
-
- def test_update_issue_with_form_update
- field = IssueCustomField.create!(
- :field_format => 'string',
- :name => 'Form update CF',
- :is_for_all => true,
- :trackers => Tracker.where(:name => 'Feature request')
- )
-
- Role.non_member.add_permission! :edit_issues, :add_issues
- Role.non_member.remove_permission! :add_issue_notes
-
- log_user('someone', 'foo')
- visit '/issues/1'
- assert page.has_no_content?('Form update CF')
-
- page.first(:link, 'Edit').click
- # the custom field should show up when changing tracker
- select 'Feature request', :from => 'Tracker'
- assert page.has_content?('Form update CF')
-
- fill_in 'Form update', :with => 'CF value'
- assert_no_difference 'Issue.count' do
- page.first(:button, 'Submit').click
- end
-
- issue = Issue.find(1)
- assert_equal 'CF value', issue.custom_field_value(field)
- end
-
- def test_remove_issue_watcher_from_sidebar
- user = User.find(3)
- Watcher.create!(:watchable => Issue.find(1), :user => user)
-
- log_user('jsmith', 'jsmith')
- visit '/issues/1'
- assert page.first('#sidebar').has_content?('Watchers (1)')
- assert page.first('#sidebar').has_content?(user.name)
- assert_difference 'Watcher.count', -1 do
- page.first('ul.watchers .user-3 a.delete').click
- assert page.first('#sidebar').has_content?('Watchers (0)')
- end
- assert page.first('#sidebar').has_no_content?(user.name)
- end
-
- def test_watch_should_update_watchers_list
- user = User.find(2)
- log_user('jsmith', 'jsmith')
- visit '/issues/1'
- assert page.first('#sidebar').has_content?('Watchers (0)')
-
- page.first('a.issue-1-watcher').click
- assert page.first('#sidebar').has_content?('Watchers (1)')
- assert page.first('#sidebar').has_content?(user.name)
- end
-
- def test_watch_issue_via_context_menu
- log_user('jsmith', 'jsmith')
- visit '/issues'
- assert page.has_css?('tr#issue-1')
- find('tr#issue-1 td.updated_on').click
- page.execute_script "$('tr#issue-1 td.updated_on').trigger('contextmenu');"
- assert_difference 'Watcher.count' do
- within('#context-menu') do
- click_link 'Watch'
- end
- # wait for ajax response
- assert page.has_css?('#context-menu .issue-1-watcher.icon-fav')
- assert page.has_css?('tr#issue-1')
- end
- assert Issue.find(1).watched_by?(User.find_by_login('jsmith'))
- end
-
- def test_bulk_watch_issues_via_context_menu
- log_user('jsmith', 'jsmith')
- visit '/issues'
- assert page.has_css?('tr#issue-1')
- assert page.has_css?('tr#issue-4')
- find('tr#issue-1 input[type=checkbox]').click
- find('tr#issue-4 input[type=checkbox]').click
- page.execute_script "$('tr#issue-1 td.updated_on').trigger('contextmenu');"
- assert_difference 'Watcher.count', 2 do
- within('#context-menu') do
- click_link 'Watch'
- end
- # wait for ajax response
- assert page.has_css?('#context-menu .issue-bulk-watcher.icon-fav')
- assert page.has_css?('tr#issue-1')
- assert page.has_css?('tr#issue-4')
- end
- assert Issue.find(1).watched_by?(User.find_by_login('jsmith'))
- assert Issue.find(4).watched_by?(User.find_by_login('jsmith'))
- end
-
- def test_issue_list_with_default_totalable_columns
- log_user('admin', 'admin')
- with_settings :issue_list_default_totals => ['estimated_hours'] do
- visit '/projects/ecookbook/issues'
- # Check that the page shows the Estimated hours total
- assert page.has_css?('p.query-totals')
- assert page.has_css?('span.total-for-estimated-hours')
- # Open the Options of the form (necessary for having the totalable columns options clickable)
- page.all('legend')[1].click
- # Deselect the default totalable column (none should be left)
- page.first('input[name="t[]"][value="estimated_hours"]').click
- within('#query_form') do
- click_link 'Apply'
- end
- # Check that Totals are not present in the reloaded page
- assert !page.has_css?('p.query-totals')
- assert !page.has_css?('span.total-for-estimated-hours')
- end
- end
-
- def test_update_journal_notes_with_preview
- log_user('admin', 'admin')
-
- visit '/issues/1'
- # Click on the edit button
- page.first('#change-2 a.icon-edit').click
- # Check that the textarea is displayed
- assert page.has_css?('#change-2 textarea')
- assert page.first('#change-2 textarea').has_content?('Some notes with Redmine links')
- # Update the notes
- fill_in 'Notes', :with => 'Updated notes'
- # Preview the change
- click_on 'Preview'
- assert page.has_css?('#journal_2_preview')
- assert page.first('#journal_2_preview').has_content?('Updated notes')
- # Save
- click_on 'Save'
-
- sleep 1
- assert_equal 'Updated notes', Journal.find(2).notes
- end
-
- def test_index_as_csv_should_reflect_sort
- log_user('admin', 'admin')
-
- visit '/issues'
- # Sort issues by subject
- click_on 'Subject'
- click_on 'CSV'
- click_on 'Export'
-
- csv = CSV.read(downloaded_file)
- subject_index = csv.shift.index('Subject')
- subjects = csv.map {|row| row[subject_index]}
- assert_equal subjects.sort, subjects
- end
-end
diff --git a/test/ui/my_page_test_ui.rb b/test/ui/my_page_test_ui.rb
deleted file mode 100644
index 588f851c3..000000000
--- a/test/ui/my_page_test_ui.rb
+++ /dev/null
@@ -1,54 +0,0 @@
-# Redmine - project management software
-# Copyright (C) 2006-2017 Jean-Philippe Lang
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
-require File.expand_path('../base', __FILE__)
-
-class Redmine::UiTest::MyPageTest < Redmine::UiTest::Base
- fixtures :projects, :users, :email_addresses, :roles, :members, :member_roles,
- :trackers, :projects_trackers, :enabled_modules, :issue_statuses, :issues,
- :enumerations, :custom_fields, :custom_values, :custom_fields_trackers,
- :watchers, :journals, :journal_details
-
- def test_sort_assigned_issues
- preferences = User.find(2).pref
- preferences.my_page_layout = {'top' => ['issuesassignedtome']}
- preferences.my_page_settings = {'issuesassignedtome' => {:columns => ['tracker', 'subject', 'due_date'], :sort => 'id:desc'}}
- preferences.save!
-
- log_user('jsmith', 'jsmith')
- visit '/my/page'
- assert page.has_css?('table.issues.sort-by-id')
- assert page.has_css?('table.issues.sort-desc')
-
- within('#block-issuesassignedtome') do
- # sort by tracker asc
- click_link 'Tracker'
- assert page.has_css?('table.issues.sort-by-tracker')
- assert page.has_css?('table.issues.sort-asc')
-
- # and desc
- click_link 'Tracker'
- assert page.has_css?('table.issues.sort-by-tracker')
- assert page.has_css?('table.issues.sort-desc')
- end
-
- # reload the page, sort order should be preserved
- visit '/my/page'
- assert page.has_css?('table.issues.sort-by-tracker')
- assert page.has_css?('table.issues.sort-desc')
- end
-end
diff --git a/test/ui/quick_jump_test_ui.rb b/test/ui/quick_jump_test_ui.rb
deleted file mode 100644
index 7ac3e727c..000000000
--- a/test/ui/quick_jump_test_ui.rb
+++ /dev/null
@@ -1,68 +0,0 @@
-# encoding: utf-8
-#
-# Redmine - project management software
-# Copyright (C) 2006-2017 Jean-Philippe Lang
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
-require File.expand_path('../base', __FILE__)
-
-class Redmine::UiTest::QuickJumpTest < Redmine::UiTest::Base
- fixtures :projects, :users, :email_addresses, :roles, :members, :member_roles,
- :trackers, :projects_trackers, :enabled_modules, :issue_statuses, :issues,
- :enumerations, :custom_fields, :custom_values, :custom_fields_trackers,
- :watchers, :journals, :journal_details
-
- def test_project_quick_jump
- log_user 'jsmith', 'jsmith'
- visit '/'
-
- within '#header' do
- page.first('span', :text => 'Jump to a project...').click
- click_on 'eCookbook'
- end
- assert_current_path '/projects/ecookbook?jump=welcome'
- end
-
- def test_project_quick_jump_should_jump_to_the_same_tab
- log_user 'jsmith', 'jsmith'
- visit '/issues'
-
- within '#header' do
- page.first('span', :text => 'Jump to a project...').click
- click_on 'eCookbook'
- assert_current_path '/projects/ecookbook/issues'
-
- page.first('span', :text => 'eCookbook').click
- click_on 'All Projects'
- assert_current_path '/issues'
- end
- end
-
- def test_project_quick_search
- Project.generate!(:name => 'Megaproject', :identifier => 'mega')
-
- log_user 'jsmith', 'jsmith'
- visit '/'
-
- within '#header' do
- page.first('span', :text => 'Jump to a project...').click
- # Fill the quick search input that should have focus
- page.first('*:focus').set('meg')
- click_on 'Megaproject'
- end
- assert_current_path '/projects/mega?jump=welcome'
- end
-end
diff --git a/test/ui/sudo_mode_test_ui.rb b/test/ui/sudo_mode_test_ui.rb
deleted file mode 100644
index dd3a45463..000000000
--- a/test/ui/sudo_mode_test_ui.rb
+++ /dev/null
@@ -1,68 +0,0 @@
-# Redmine - project management software
-# Copyright (C) 2006-2017 Jean-Philippe Lang
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
-require File.expand_path('../base', __FILE__)
-
-class Redmine::UiTest::SudoModeTest < Redmine::UiTest::Base
- fixtures :users, :email_addresses
-
- def setup
- Redmine::SudoMode.stubs(:enabled?).returns(true)
- super
- end
-
- def teardown
- travel_back
- super
- end
-
- def test_add_user
- log_user('admin', 'admin')
- expire_sudo_mode!
-
- visit '/users/new'
-
- assert_difference 'User.count' do
- within('form#new_user') do
- fill_in 'Login', :with => 'johnpaul'
- fill_in 'First name', :with => 'John'
- fill_in 'Last name', :with => 'Paul'
- fill_in 'Email', :with => 'john@example.net'
- fill_in 'Password', :with => 'password'
- fill_in 'Confirmation', :with => 'password'
- # click_button 'Create' would match both 'Create' and 'Create and continue' buttons
- find('input[name=commit]').click
- end
-
- assert_equal '/users', current_path
- assert page.has_content?("Confirm your password to continue")
- assert page.has_css?('form#sudo-form')
-
- within('form#sudo-form') do
- fill_in 'Password', :with => 'admin'
- click_button 'Submit'
- end
- end
- end
-
- private
-
- # sudo mode is active after sign, let it expire by advancing the time
- def expire_sudo_mode!
- travel_to 20.minutes.from_now
- end
-end
diff --git a/test/ui/timelog_test_ui.rb b/test/ui/timelog_test_ui.rb
deleted file mode 100644
index 3341a136b..000000000
--- a/test/ui/timelog_test_ui.rb
+++ /dev/null
@@ -1,101 +0,0 @@
-# encoding: utf-8
-#
-# Redmine - project management software
-# Copyright (C) 2006-2017 Jean-Philippe Lang
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
-require File.expand_path('../base', __FILE__)
-
-class Redmine::UiTest::TimelogTest < Redmine::UiTest::Base
- fixtures :projects, :users, :email_addresses, :roles, :members, :member_roles,
- :trackers, :projects_trackers, :enabled_modules, :issue_statuses, :issues,
- :enumerations, :custom_fields, :custom_values, :custom_fields_trackers,
- :time_entries
-
- def test_changing_project_should_update_activities
- project = Project.find(1)
- TimeEntryActivity.create!(:name => 'Design', :project => project, :parent => TimeEntryActivity.find_by_name('Design'), :active => false)
-
- log_user 'jsmith', 'jsmith'
- visit '/time_entries/new'
- within 'select#time_entry_activity_id' do
- assert has_content?('Development')
- assert has_content?('Design')
- end
-
- within 'form#new_time_entry' do
- select 'eCookbook', :from => 'Project'
- end
- within 'select#time_entry_activity_id' do
- assert has_content?('Development')
- assert !has_content?('Design')
- end
- end
-
- def test_bulk_edit
- log_user 'jsmith', 'jsmith'
- visit '/time_entries/bulk_edit?ids[]=1&ids[]=2&ids[]=3'
- fill_in 'Hours', :with => '8.5'
- select 'QA', :from => 'Activity'
- page.first(:button, 'Submit').click
-
- entries = TimeEntry.where(:id => [1,2,3]).to_a
- assert entries.all? {|entry| entry.hours == 8.5}
- assert entries.all? {|entry| entry.activity.name == 'QA'}
- end
-
- def test_bulk_edit_with_failure
- log_user 'jsmith', 'jsmith'
- visit '/time_entries/bulk_edit?ids[]=1&ids[]=2&ids[]=3'
- fill_in 'Hours', :with => 'A'
- page.first(:button, 'Submit').click
-
- assert page.has_css?('#errorExplanation')
- fill_in 'Hours', :with => '7'
- page.first(:button, 'Submit').click
-
- assert_equal "/projects/ecookbook/time_entries", current_path
- entries = TimeEntry.where(:id => [1,2,3]).to_a
- assert entries.all? {|entry| entry.hours == 7.0}
- end
-
- def test_default_query_setting
- # Display the list with the default settings
- visit '/time_entries'
- within 'table.time-entries thead' do
- assert page.has_no_link?('Tracker')
- assert page.has_text?('Comment')
- end
-
- # Change the default columns
- log_user 'admin', 'admin'
- visit '/settings?tab=timelog'
- # Remove a column
- select 'Comment', :from => 'Selected Columns'
- click_on "←"
- # Add a column
- select 'Tracker', :from => 'Available Columns'
- click_on "→"
- click_on 'Save'
-
- # Display the list with updated settings
- visit '/time_entries'
- within 'table.time-entries thead' do
- assert page.has_link?('Tracker')
- assert page.has_no_text?('Comment')
- end
- end
-end