Add spec for BitbucketServer::Representation::Repo

This commit is contained in:
Stan Hu 2018-07-20 21:46:01 -07:00
parent 48ea89af12
commit 7c1aaf68f8
2 changed files with 77 additions and 9 deletions

View file

@ -9,10 +9,6 @@ module BitbucketServer
raw.dig('project', 'name')
end
def owner
project['name']
end
def slug
raw['slug']
end
@ -30,7 +26,7 @@ module BitbucketServer
end
def full_name
"#{owner}/#{name}"
"#{project_name}/#{name}"
end
def issues_enabled?
@ -45,10 +41,6 @@ module BitbucketServer
raw['scmId'] == 'git'
end
def has_wiki?
false
end
def visibility_level
if project['public']
Gitlab::VisibilityLevel::PUBLIC

View file

@ -0,0 +1,76 @@
require 'spec_helper'
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(JSON.parse(sample_data)) }
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