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

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