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_helper_test.rb 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # frozen_string_literal: true
  2. # Redmine - project management software
  3. # Copyright (C) 2006-2023 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 '../test_helper'
  19. class TimelogHelperTest < Redmine::HelperTest
  20. include TimelogHelper
  21. include ActionView::Helpers::TextHelper
  22. include ActionView::Helpers::DateHelper
  23. include ERB::Util
  24. fixtures :projects, :roles, :enabled_modules, :users,
  25. :repositories, :changesets,
  26. :trackers, :issue_statuses, :issues, :versions, :documents,
  27. :wikis, :wiki_pages, :wiki_contents,
  28. :boards, :messages,
  29. :attachments,
  30. :enumerations
  31. def test_activities_collection_for_select_options_should_return_array_of_activity_names_and_ids
  32. activities = activity_collection_for_select_options
  33. assert activities.include?(["Design", 9])
  34. assert activities.include?(["Development", 10])
  35. end
  36. def test_activities_collection_for_select_options_should_not_include_inactive_activities
  37. activities = activity_collection_for_select_options
  38. assert !activities.include?(["Inactive Activity", 14])
  39. end
  40. def test_activities_collection_for_select_options_should_use_the_projects_override
  41. project = Project.find(1)
  42. override_activity = TimeEntryActivity.create!({:name => "Design override", :parent => TimeEntryActivity.find_by_name("Design"), :project => project})
  43. activities = activity_collection_for_select_options(nil, project)
  44. assert !activities.include?(["Design", 9]), "System activity found in: " + activities.inspect
  45. assert activities.include?(["Design override", override_activity.id]), "Override activity not found in: " + activities.inspect
  46. end
  47. end