From 7c1aaf68f82f05fd34f567be2481b8283e3328c2 Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Fri, 20 Jul 2018 21:46:01 -0700 Subject: [PATCH] Add spec for BitbucketServer::Representation::Repo --- lib/bitbucket_server/representation/repo.rb | 10 +-- .../representation/repo_spec.rb | 76 +++++++++++++++++++ 2 files changed, 77 insertions(+), 9 deletions(-) create mode 100644 spec/lib/bitbucket_server/representation/repo_spec.rb diff --git a/lib/bitbucket_server/representation/repo.rb b/lib/bitbucket_server/representation/repo.rb index 8e163e8a1fc..1338f877fc1 100644 --- a/lib/bitbucket_server/representation/repo.rb +++ b/lib/bitbucket_server/representation/repo.rb @@ -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 diff --git a/spec/lib/bitbucket_server/representation/repo_spec.rb b/spec/lib/bitbucket_server/representation/repo_spec.rb new file mode 100644 index 00000000000..9021da4c503 --- /dev/null +++ b/spec/lib/bitbucket_server/representation/repo_spec.rb @@ -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