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 3.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. # Redmine - project management software
  2. # Copyright (C) 2006-2017 Jean-Philippe Lang
  3. #
  4. # This program is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU General Public License
  6. # as published by the Free Software Foundation; either version 2
  7. # of the License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. require File.expand_path('../../test_helper', __FILE__)
  18. class RepositoryFilesystemTest < ActiveSupport::TestCase
  19. fixtures :projects
  20. include Redmine::I18n
  21. REPOSITORY_PATH = Rails.root.join('tmp/test/filesystem_repository').to_s
  22. def setup
  23. @project = Project.find(3)
  24. Setting.enabled_scm << 'Filesystem' unless Setting.enabled_scm.include?('Filesystem')
  25. @repository = Repository::Filesystem.create(
  26. :project => @project,
  27. :url => REPOSITORY_PATH
  28. )
  29. assert @repository
  30. end
  31. def test_blank_root_directory_error_message
  32. set_language_if_valid 'en'
  33. repo = Repository::Filesystem.new(
  34. :project => @project,
  35. :identifier => 'test'
  36. )
  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. str = "R\xc3\xa9pertoire racine doit \xc3\xaatre renseign\xc3\xa9(e)".force_encoding('UTF-8')
  44. repo = Repository::Filesystem.new(
  45. :project => @project,
  46. :url => "",
  47. :identifier => 'test',
  48. :path_encoding => ''
  49. )
  50. assert !repo.save
  51. assert_include str, 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