You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

timelog_test.rb 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. # encoding: utf-8
  2. #
  3. # Redmine - project management software
  4. # Copyright (C) 2006-2017 Jean-Philippe Lang
  5. #
  6. # This program is free software; you can redistribute it and/or
  7. # modify it under the terms of the GNU General Public License
  8. # as published by the Free Software Foundation; either version 2
  9. # of the License, or (at your option) any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program; if not, write to the Free Software
  18. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. require File.expand_path('../../application_system_test_case', __FILE__)
  20. Capybara.default_max_wait_time = 2
  21. class TimelogTest < ApplicationSystemTestCase
  22. fixtures :projects, :users, :email_addresses, :roles, :members, :member_roles,
  23. :trackers, :projects_trackers, :enabled_modules, :issue_statuses, :issues,
  24. :enumerations, :custom_fields, :custom_values, :custom_fields_trackers,
  25. :time_entries
  26. def test_changing_project_should_update_activities
  27. project = Project.find(1)
  28. TimeEntryActivity.create!(:name => 'Design', :project => project, :parent => TimeEntryActivity.find_by_name('Design'), :active => false)
  29. log_user 'jsmith', 'jsmith'
  30. visit '/time_entries/new'
  31. within 'select#time_entry_activity_id' do
  32. assert has_content?('Development')
  33. assert has_content?('Design')
  34. end
  35. within 'form#new_time_entry' do
  36. select 'eCookbook', :from => 'Project'
  37. end
  38. within 'select#time_entry_activity_id' do
  39. assert has_content?('Development')
  40. assert !has_content?('Design')
  41. end
  42. end
  43. def test_bulk_edit
  44. log_user 'jsmith', 'jsmith'
  45. visit '/time_entries/bulk_edit?ids[]=1&ids[]=2&ids[]=3'
  46. fill_in 'Hours', :with => '8.5'
  47. select 'QA', :from => 'Activity'
  48. page.first(:button, 'Submit').click
  49. entries = TimeEntry.where(:id => [1,2,3]).to_a
  50. assert entries.all? {|entry| entry.hours == 8.5}
  51. assert entries.all? {|entry| entry.activity.name == 'QA'}
  52. end
  53. def test_bulk_edit_with_failure
  54. log_user 'jsmith', 'jsmith'
  55. visit '/time_entries/bulk_edit?ids[]=1&ids[]=2&ids[]=3'
  56. fill_in 'Hours', :with => 'A'
  57. page.first(:button, 'Submit').click
  58. assert page.has_css?('#errorExplanation')
  59. fill_in 'Hours', :with => '7'
  60. page.first(:button, 'Submit').click
  61. assert_equal "/projects/ecookbook/time_entries", current_path
  62. entries = TimeEntry.where(:id => [1,2,3]).to_a
  63. assert entries.all? {|entry| entry.hours == 7.0}
  64. end
  65. def test_default_query_setting
  66. # Display the list with the default settings
  67. visit '/time_entries'
  68. within 'table.time-entries thead' do
  69. assert page.has_no_link?('Tracker')
  70. assert page.has_text?('Comment')
  71. end
  72. # Change the default columns
  73. log_user 'admin', 'admin'
  74. visit '/settings?tab=timelog'
  75. # Remove a column
  76. select 'Comment', :from => 'Selected Columns'
  77. click_on "←"
  78. # Add a column
  79. select 'Tracker', :from => 'Available Columns'
  80. click_on "→"
  81. click_on 'Save'
  82. # Display the list with updated settings
  83. visit '/time_entries'
  84. within 'table.time-entries thead' do
  85. assert page.has_link?('Tracker')
  86. assert page.has_no_text?('Comment')
  87. end
  88. end
  89. end