summaryrefslogtreecommitdiff
path: root/spec/lib/bitbucket_server/representation/repo_spec.rb
blob: 7a773f47ca55ec05f063441fd1145bd143ba305e (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe BitbucketServer::Representation::Repo do
  let(:sample_data) do
    <<~DATA
    {
      "slug": "rouge",
      "id": 1,
      "name": "rouge",
      "scmId": "git",
      "state": "AVAILABLE",
      "statusMessage": "Available",
      "forkable": true,
      "project": {
        "key": "TEST",
        "id": 1,
        "name": "test",
        "description": "Test",
        "public": false,
        "type": "NORMAL",
        "links": {
          "self": [
            {
              "href": "http://localhost:7990/projects/TEST"
            }
          ]
        }
      },
      "public": false,
      "links": {
        "clone": [
          {
            "href": "http://root@localhost:7990/scm/test/rouge.git",
            "name": "http"
          },
          {
            "href": "ssh://git@localhost:7999/test/rouge.git",
            "name": "ssh"
          }
        ],
        "self": [
          {
            "href": "http://localhost:7990/projects/TEST/repos/rouge/browse"
          }
        ]
      }
    }
    DATA
  end

  subject { described_class.new(Gitlab::Json.parse(sample_data)) }

  describe '#project_key' do
    it { expect(subject.project_key).to eq('TEST') }
  end

  describe '#project_name' do
    it { expect(subject.project_name).to eq('test') }
  end

  describe '#slug' do
    it { expect(subject.slug).to eq('rouge') }
  end

  describe '#browse_url' do
    it { expect(subject.browse_url).to eq('http://localhost:7990/projects/TEST/repos/rouge/browse') }
  end

  describe '#clone_url' do
    it { expect(subject.clone_url).to eq('http://root@localhost:7990/scm/test/rouge.git') }
  end

  describe '#description' do
    it { expect(subject.description).to eq('Test') }
  end

  describe '#full_name' do
    it { expect(subject.full_name).to eq('test/rouge') }
  end
end