summaryrefslogtreecommitdiff
path: root/spec/requests/api/api_internal_helpers_spec.rb
blob: be4bc39ada20cbb7a9617f0baef1093ffc1a4c4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
require 'spec_helper'

describe ::API::Helpers::InternalHelpers do
  include ::API::Helpers::InternalHelpers

  describe '.clean_project_path' do
    project = 'namespace/project'
    namespaced = File.join('namespace2', project)

    {
      File.join(Dir.pwd, project)    => project,
      File.join(Dir.pwd, namespaced) => namespaced,
      project                        => project,
      namespaced                     => namespaced,
      project + '.git'               => project,
      namespaced + '.git'            => namespaced,
      "/" + project                  => project,
      "/" + namespaced               => namespaced,
    }.each do |project_path, expected|
      context project_path do
        # Relative and absolute storage paths, with and without trailing /
        ['.', './', Dir.pwd, Dir.pwd + '/'].each do |storage_path|
          context "storage path is #{storage_path}" do
            subject { clean_project_path(project_path, [storage_path]) }

            it { is_expected.to eq(expected) }
          end
        end
      end
    end
  end
end