-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
325 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# frozen_string_literal: true | ||
|
||
module Tinybucket | ||
module Resource | ||
class Projects < Base | ||
attr_accessor :owner | ||
|
||
# Initialize | ||
# | ||
# @param owner_name [String] | ||
# @param options [Hash] | ||
def initialize(owner_name, options = {}) | ||
@owner = owner_name | ||
@args = [options] | ||
end | ||
|
||
# Find the project | ||
# | ||
# @param project_key [String] | ||
# @param options [Hash] | ||
# @return [Tinybucket::Model::Project] | ||
def find(project_key, options = {}) | ||
projects_api.find(project_key, options) | ||
end | ||
|
||
# Create a new project | ||
# | ||
# NOTE: Not Implemented yet. | ||
# | ||
# @param params [Hash] | ||
# @raise [NotImplementedError] to be implemented | ||
def create(params) | ||
raise NotImplementedError | ||
end | ||
|
||
private | ||
|
||
def projects_api | ||
create_api('Projects').tap do |api| | ||
api.owner = @owner | ||
end | ||
end | ||
|
||
def enumerator | ||
create_enumerator(projects_api, :list, *@args) | ||
end | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
{ | ||
"pagelen": 10, | ||
"values": [ | ||
{ | ||
"uuid": "{45d24c3d-efa0-4c2a-be4e-78c1b30a30d0}", | ||
"links": { | ||
"self": { | ||
"href": "https://api.bitbucket.org/2.0/teams/test_team/projects/TEST" | ||
}, | ||
"html": { | ||
"href": "https://bitbucket.org/account/user/test_team/projects/TEST" | ||
}, | ||
"repositories": { | ||
"href": "https://api.bitbucket.org/2.0/repositories/test_team?q='project.key=\"TEST\"'" | ||
}, | ||
"avatar": { | ||
"href": "https://bitbucket.org/account/user/test_team/projects/TEST/avatar/32" | ||
} | ||
}, | ||
"description": null, | ||
"created_on": "2016-03-19T03:34:27.792230+00:00", | ||
"key": "TEST", | ||
"owner": { | ||
"username": "test_team", | ||
"display_name": "test team", | ||
"type": "team", | ||
"uuid": "{e0f17982-effb-43eb-8589-7bacabb37cab}", | ||
"links": { | ||
"self": { | ||
"href": "https://api.bitbucket.org/2.0/teams/test_team" | ||
}, | ||
"html": { | ||
"href": "https://bitbucket.org/test_team/" | ||
}, | ||
"avatar": { | ||
"href": "https://bitbucket.org/account/test_team/avatar/32/" | ||
} | ||
} | ||
}, | ||
"updated_on": "2016-03-19T03:34:27.792256+00:00", | ||
"type": "project", | ||
"is_private": false, | ||
"name": "test" | ||
}, | ||
{ | ||
"uuid": "{59278b96-1238-4418-a2b9-8f438234ae45}", | ||
"links": { | ||
"self": { | ||
"href": "https://api.bitbucket.org/2.0/teams/test_team/projects/PROJ" | ||
}, | ||
"html": { | ||
"href": "https://bitbucket.org/account/user/test_team/projects/PROJ" | ||
}, | ||
"repositories": { | ||
"href": "https://api.bitbucket.org/2.0/repositories/test_team?q='project.key=\"PROJ\"'" | ||
}, | ||
"avatar": { | ||
"href": "https://bitbucket.org/account/user/test_team/projects/PROJ/avatar/32" | ||
} | ||
}, | ||
"description": "Project created by Bitbucket for test", | ||
"created_on": "2015-12-04T02:27:25.909083+00:00", | ||
"key": "PROJ", | ||
"owner": { | ||
"username": "test_team", | ||
"display_name": "test team", | ||
"type": "team", | ||
"uuid": "{e0f17982-effb-41cb-8589-7bacabb37cab}", | ||
"links": { | ||
"self": { | ||
"href": "https://api.bitbucket.org/2.0/teams/test_team" | ||
}, | ||
"html": { | ||
"href": "https://bitbucket.org/test_team/" | ||
}, | ||
"avatar": { | ||
"href": "https://bitbucket.org/account/test_team/avatar/32/" | ||
} | ||
} | ||
}, | ||
"updated_on": "2015-12-04T02:27:25.909123+00:00", | ||
"type": "project", | ||
"is_private": false, | ||
"name": "Untitled project" | ||
} | ||
], | ||
"page": 1, | ||
"size": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"uuid": "{45234c3d-efa0-4c2a-be4e-78c1b30a30d0}", | ||
"links": { | ||
"self": { | ||
"href": "https://api.bitbucket.org/2.0/teams/test_team/projects/myprj" | ||
}, | ||
"html": { | ||
"href": "https://bitbucket.org/account/user/test_team/projects/myprj" | ||
}, | ||
"repositories": { | ||
"href": "https://api.bitbucket.org/2.0/repositories/test_team?q='project.key=\"myprj\"'" | ||
}, | ||
"avatar": { | ||
"href": "https://bitbucket.org/account/user/test_team/projects/myprj/avatar/32" | ||
} | ||
}, | ||
"description": null, | ||
"created_on": "2016-03-19T03:34:27.792230+00:00", | ||
"key": "myprj", | ||
"owner": { | ||
"username": "test_team", | ||
"display_name": "test team", | ||
"type": "team", | ||
"uuid": "{e0f17982-efab-43cb-8589-7bacabb37cab}", | ||
"links": { | ||
"self": { | ||
"href": "https://api.bitbucket.org/2.0/teams/test_team" | ||
}, | ||
"html": { | ||
"href": "https://bitbucket.org/test_team/" | ||
}, | ||
"avatar": { | ||
"href": "https://bitbucket.org/account/test_team/avatar/32/" | ||
} | ||
} | ||
}, | ||
"updated_on": "2016-03-19T03:34:27.792256+00:00", | ||
"type": "project", | ||
"is_private": false, | ||
"name": "myprj" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe Tinybucket::Api::ProjectsApi do | ||
include ApiResponseMacros | ||
|
||
let(:api) { Tinybucket::Api::ProjectsApi.new } | ||
let(:owner) { 'test_team' } | ||
let(:request_path) { nil } | ||
before do | ||
api.owner = owner | ||
stub_apiresponse(:get, request_path) if request_path | ||
end | ||
|
||
it { expect(api).to be_a_kind_of(Tinybucket::Api::BaseApi) } | ||
|
||
describe 'list' do | ||
subject { api.list() } | ||
let(:request_path) { '/teams/test_team/projects/' } | ||
it { expect(subject).to be_an_instance_of(Tinybucket::Model::Page) } | ||
end | ||
|
||
describe 'find' do | ||
let(:project_key) { 'myprj' } | ||
subject { api.find(project_key) } | ||
|
||
let(:request_path) { "/teams/test_team/projects/#{project_key}" } | ||
it { expect(subject).to be_an_instance_of(Tinybucket::Model::Project) } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe Tinybucket::Model::Project do | ||
include ApiResponseMacros | ||
|
||
let(:model_json) { load_json_fixture('teams/test_team/projects/myprj/get') } | ||
let(:instance) { Tinybucket::Model::Project.new(model_json) } | ||
|
||
it_behaves_like 'model has acceptable_attributes', | ||
Tinybucket::Model::Project, | ||
load_json_fixture('teams/test_team/projects/myprj/get') | ||
|
||
describe '#update' do | ||
subject { instance.update({}) } | ||
it { expect { subject }.to raise_error(NotImplementedError) } | ||
end | ||
|
||
describe '#destroy' do | ||
subject { instance.destroy() } | ||
it { expect { subject }.to raise_error(NotImplementedError) } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.