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.6KB

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