added specs for the new octo_fetcher. Also had to refactor a bit to deal with hashes and arrays instead of objects

This commit is contained in:
Andrew Waage
2016-05-19 23:46:13 -07:00
committed by Olle Jonsson
parent e494fc004e
commit 4fb674b68e
26 changed files with 354 additions and 36 deletions

View File

@@ -107,13 +107,13 @@ module GitHubChangelogGenerator
issues.each do |dict|
added = false
dict.labels.each do |label|
if @options[:bug_labels].include? label.name
dict['labels'].each do |label|
if @options[:bug_labels].include? label['name']
bugs_a.push dict
added = true
next
end
if @options[:enhancement_labels].include? label.name
if @options[:enhancement_labels].include? label['name']
enhancement_a.push dict
added = true
next
@@ -123,16 +123,16 @@ module GitHubChangelogGenerator
end
added_pull_requests = []
pull_requests.each do |dict|
dict.labels.each do |label|
if @options[:bug_labels].include? label.name
bugs_a.push dict
added_pull_requests.push dict
pull_requests.each do |pr|
pr['labels'].each do |label|
if @options[:bug_labels].include? label['name']
bugs_a.push pr
added_pull_requests.push pr
next
end
if @options[:enhancement_labels].include? label.name
enhancement_a.push dict
added_pull_requests.push dict
if @options[:enhancement_labels].include? label['name']
enhancement_a.push pr
added_pull_requests.push pr
next
end
end

View File

@@ -166,9 +166,9 @@ module GitHubChangelogGenerator
# @param [Hash] issue Fetched issue from GitHub
# @return [String] Markdown-formatted single issue
def get_string_for_issue(issue)
encapsulated_title = encapsulate_string issue[:title]
encapsulated_title = encapsulate_string issue['title']
title_with_number = "#{encapsulated_title} [\\##{issue[:number]}](#{issue.html_url})"
title_with_number = "#{encapsulated_title} [\\##{issue['number']}](#{issue['html_url']})"
issue_line_with_user(title_with_number, issue)
end
@@ -177,13 +177,13 @@ module GitHubChangelogGenerator
def issue_line_with_user(line, issue)
return line if !@options[:author] || issue.pull_request.nil?
user = issue.user
user = issue['user']
return "#{line} ({Null user})" unless user
if @options[:usernames_as_github_logins]
"#{line} (@#{user.login})"
"#{line} (@#{user['login']})"
else
"#{line} ([#{user.login}](#{user.html_url}))"
"#{line} ([#{user['login']}](#{user['html_url']}))"
end
end
end

View File

@@ -8,7 +8,7 @@ module GitHubChangelogGenerator
return issues if !@options[:exclude_labels] || @options[:exclude_labels].empty?
issues.reject do |issue|
labels = issue.labels.map(&:name)
labels = issue['labels'].map{|l| l['name'] }
(labels & @options[:exclude_labels]).any?
end
end
@@ -123,7 +123,7 @@ module GitHubChangelogGenerator
def filter_wo_labels(issues)
if @options[:add_issues_wo_labels]
issues_wo_labels = issues.select do |issue|
!issue.labels.map(&:name).any?
!issue['labels'].map{|l| l['name'] }.any?
end
return issues_wo_labels
end
@@ -135,7 +135,7 @@ module GitHubChangelogGenerator
issues
else
issues.select do |issue|
labels = issue.labels.map(&:name) & @options[:include_labels]
labels = issue['labels'].map { |l| l['name'] } & @options[:include_labels]
labels.any?
end
end
@@ -179,16 +179,16 @@ module GitHubChangelogGenerator
pull_requests.each do |pr|
fetched_pr = closed_pull_requests.find do |fpr|
fpr.number == pr.number
fpr['number'] == pr['number']
end
if fetched_pr
pr[:merged_at] = fetched_pr[:merged_at]
pr['merged_at'] = fetched_pr['merged_at']
closed_pull_requests.delete(fetched_pr)
end
end
pull_requests.select! do |pr|
!pr[:merged_at].nil?
!pr['merged_at'].nil?
end
pull_requests