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.

repository_filesystem_test.rb 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 '../test_helper'
  19. class RepositoryFilesystemTest < ActiveSupport::TestCase
  20. fixtures :projects
  21. include Redmine::I18n
  22. REPOSITORY_PATH = Rails.root.join('tmp/test/filesystem_repository').to_s
  23. def setup
  24. User.current = nil
  25. @project = Project.find(3)
  26. Setting.enabled_scm << 'Filesystem' unless Setting.enabled_scm.include?('Filesystem')
  27. @repository =
  28. Repository::Filesystem.
  29. create(:project => @project, :url => REPOSITORY_PATH)
  30. assert @repository
  31. end
  32. def test_blank_root_directory_error_message
  33. set_language_if_valid 'en'
  34. repo =
  35. Repository::Filesystem.
  36. new(:project => @project, :identifier => 'test')
  37. assert !repo.save
  38. assert_include "Root directory cannot be blank",
  39. repo.errors.full_messages
  40. end
  41. def test_blank_root_directory_error_message_fr
  42. set_language_if_valid 'fr'
  43. repo =
  44. Repository::Filesystem.new(
  45. :project => @project,
  46. :url => "",
  47. :identifier => 'test',
  48. :path_encoding => ''
  49. )
  50. assert !repo.save
  51. assert_include 'Répertoire racine doit être renseigné(e)', repo.errors.full_messages
  52. end
  53. if File.directory?(REPOSITORY_PATH)
  54. def test_fetch_changesets
  55. assert_equal 0, @repository.changesets.count
  56. assert_equal 0, @repository.filechanges.count
  57. @repository.fetch_changesets
  58. @project.reload
  59. assert_equal 0, @repository.changesets.count
  60. assert_equal 0, @repository.filechanges.count
  61. end
  62. def test_entries
  63. entries = @repository.entries("", 2)
  64. assert_kind_of Redmine::Scm::Adapters::Entries, entries
  65. assert_equal 3, entries.size
  66. end
  67. def test_entries_in_directory
  68. assert_equal 2, @repository.entries("dir", 3).size
  69. end
  70. def test_cat
  71. assert_equal "TEST CAT\n", @repository.scm.cat("test")
  72. end
  73. else
  74. puts "Filesystem test repository NOT FOUND. Skipping unit tests !!! See doc/RUNNING_TESTS."
  75. def test_fake; assert true end
  76. end
  77. end