-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Max Larionov - Github-team-remover progress(Finished.) #3
base: master
Are you sure you want to change the base?
Changes from 5 commits
488f8df
6c456cb
b357104
052e05a
29e78b2
a424990
a96ebc2
4a5f510
9f95957
f80a83d
35ea487
b99d78c
04df849
ad8307d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require 'thor' | ||
require 'colorize' | ||
require 'octokit' | ||
|
||
module Remover | ||
class Commander < Thor | ||
|
||
def color | ||
end | ||
|
||
def verbose | ||
end | ||
|
||
def delete | ||
end | ||
|
||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,40 @@ def name | |
github_team.name | ||
end | ||
|
||
def members_url | ||
if with_members? | ||
hash = Hash(*github_client.team_members(github_team.id)) | ||
hash[:html_url] | ||
else | ||
'no members' | ||
end | ||
end | ||
|
||
def repositories_url | ||
if with_repositories? | ||
hash = Hash(*github_client.team_repositories(github_team.id)) | ||
hash[:html_url] | ||
else | ||
'no repositories' | ||
end | ||
end | ||
|
||
def members_amount | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please use these new methods in the |
||
if with_members? | ||
github_client.team_members(github_team.id).size | ||
else | ||
0 | ||
end | ||
end | ||
|
||
def repositories_amount | ||
if with_repositories? | ||
github_client.team_repositories(github_team.id).size | ||
else | ||
0 | ||
end | ||
end | ||
|
||
private | ||
|
||
def with_members? | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
describe Remover::Commander do | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
describe Remover::Team do | ||
let(:github_client) { double('Github Client') } | ||
let(:github_client) { double('Github Client', members_amount: 1, repositories_amount: 1, members_url: 'url') } | ||
let(:github_team) { double('Github Team', id: 1, name: 'Owners') } | ||
let(:team) { Remover::Team.new(github_client, github_team) } | ||
|
||
|
@@ -9,6 +9,50 @@ | |
end | ||
end | ||
|
||
|
||
describe '#members_url' do | ||
let(:members_url) {[double('Github Member')]} | ||
|
||
before do | ||
allow(github_client).to receive(:team_members) {members_url} | ||
end | ||
|
||
context 'members_url' do | ||
it 'returns members url' do | ||
expect(team.members_url).to eq(github_client.members_url) | ||
end | ||
end | ||
end | ||
|
||
|
||
describe '#members' do | ||
let(:members_amount) { [double('Github Member')] } | ||
|
||
before do | ||
allow(github_client).to receive(:team_members) { members_amount } | ||
end | ||
|
||
context 'memebers amount' do | ||
it 'returns amount of members' do | ||
expect(team.members_amount.size).to eq(github_client.members_amount.size) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why you count size of integer here? |
||
end | ||
end | ||
end | ||
|
||
describe '#repositories_amount' do | ||
let(:repositories_amount) { [double(1)] } | ||
|
||
before do | ||
allow(github_client).to receive(:team_repositories) { repositories_amount } | ||
end | ||
|
||
context 'must be equal' do | ||
it 'returns amount of repos' do | ||
expect(team.repositories_amount.size).to eq(github_client.repositories_amount.size) | ||
end | ||
end | ||
end | ||
|
||
describe '#used' do | ||
let(:members) { [double('Github Member')] } | ||
let(:repositories) { [double('Github Repository')] } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please create separata class for outputting invormation.
Logic should be incapsulated there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, will do it today and global refactoring.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got really huge troubles with making another class, code not working on my PC, but works on another.