PageRenderTime 42ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/spec/lib/gitlab/import_sources_spec.rb

https://bitbucket.org/terrchen/gitlab-ce
Ruby | 94 lines | 84 code | 10 blank | 0 comment | 0 complexity | 2a8974b15a231ae1647e10fbb7b2ab3f MD5 | raw file
Possible License(s): Apache-2.0, CC0-1.0
  1. require 'spec_helper'
  2. describe Gitlab::ImportSources do
  3. describe '.options' do
  4. it 'returns a hash' do
  5. expected =
  6. {
  7. 'GitHub' => 'github',
  8. 'Bitbucket' => 'bitbucket',
  9. 'GitLab.com' => 'gitlab',
  10. 'Google Code' => 'google_code',
  11. 'FogBugz' => 'fogbugz',
  12. 'Repo by URL' => 'git',
  13. 'GitLab export' => 'gitlab_project',
  14. 'Gitea' => 'gitea'
  15. }
  16. expect(described_class.options).to eq(expected)
  17. end
  18. end
  19. describe '.values' do
  20. it 'returns an array' do
  21. expected =
  22. %w(
  23. github
  24. bitbucket
  25. gitlab
  26. google_code
  27. fogbugz
  28. git
  29. gitlab_project
  30. gitea
  31. )
  32. expect(described_class.values).to eq(expected)
  33. end
  34. end
  35. describe '.importer_names' do
  36. it 'returns an array of importer names' do
  37. expected =
  38. %w(
  39. github
  40. bitbucket
  41. gitlab
  42. google_code
  43. fogbugz
  44. gitlab_project
  45. gitea
  46. )
  47. expect(described_class.importer_names).to eq(expected)
  48. end
  49. end
  50. describe '.importer' do
  51. import_sources = {
  52. 'github' => Gitlab::GithubImport::ParallelImporter,
  53. 'bitbucket' => Gitlab::BitbucketImport::Importer,
  54. 'gitlab' => Gitlab::GitlabImport::Importer,
  55. 'google_code' => Gitlab::GoogleCodeImport::Importer,
  56. 'fogbugz' => Gitlab::FogbugzImport::Importer,
  57. 'git' => nil,
  58. 'gitlab_project' => Gitlab::ImportExport::Importer,
  59. 'gitea' => Gitlab::LegacyGithubImport::Importer
  60. }
  61. import_sources.each do |name, klass|
  62. it "returns #{klass} when given #{name}" do
  63. expect(described_class.importer(name)).to eq(klass)
  64. end
  65. end
  66. end
  67. describe '.title' do
  68. import_sources = {
  69. 'github' => 'GitHub',
  70. 'bitbucket' => 'Bitbucket',
  71. 'gitlab' => 'GitLab.com',
  72. 'google_code' => 'Google Code',
  73. 'fogbugz' => 'FogBugz',
  74. 'git' => 'Repo by URL',
  75. 'gitlab_project' => 'GitLab export',
  76. 'gitea' => 'Gitea'
  77. }
  78. import_sources.each do |name, title|
  79. it "returns #{title} when given #{name}" do
  80. expect(described_class.title(name)).to eq(title)
  81. end
  82. end
  83. end
  84. end