-
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 1 commit
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
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
# added members & repos | ||
module Remover | ||
class Team | ||
attr_accessor :github_client, :github_team | ||
|
@@ -15,12 +14,38 @@ 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 |
||
github_client.team_members(github_team.id).size | ||
if with_members? | ||
github_client.team_members(github_team.id).size | ||
else | ||
0 | ||
end | ||
end | ||
|
||
def repositories_amount | ||
github_client.team_repositories(github_team.id).size | ||
if with_repositories? | ||
github_client.team_repositories(github_team.id).size | ||
else | ||
0 | ||
end | ||
end | ||
|
||
private | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
describe Remover::Team do | ||
let(:github_client) { double('Github Client', members_amount: 1, repositories_amount: 1) } | ||
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,14 +9,30 @@ | |
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(1)] } | ||
let(:members_amount) { [double('Github Member')] } | ||
|
||
before do | ||
allow(github_client).to receive(:team_members) { members_amount } | ||
end | ||
|
||
context 'must be equal' do | ||
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 | ||
|
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.