Skip to content

Commit

Permalink
Add paths to markdown report
Browse files Browse the repository at this point in the history
Signed-off-by: Shane Lattanzio <slattanzio@pivotal.io>
  • Loading branch information
xtreme-lisheng-tai authored and xtreme-shane-lattanzio committed Nov 22, 2017
1 parent e8d32b1 commit 3bc52ec
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
7 changes: 7 additions & 0 deletions lib/license_finder/reports/templates/markdown_report.erb
Expand Up @@ -24,6 +24,13 @@ As of <%= Time.now.strftime("%B %e, %Y %l:%M%P") %>. <%= dependencies.size %> to
### <%= link_to_dependency(dependency) %> <%= version_groups(dependency) %>
#### <%= dependency.summary %>
<% if dependency.is_a?(MergedPackage) && dependency.aggregate_paths&.count > 0-%>
##### Paths
<% dependency.aggregate_paths.each do |path| -%>
* <%= path %>
<% end -%>
<% end -%>
<% if dependency.approved_manually? -%>
<%= license_links(dependency) %> manually approved

Expand Down
34 changes: 33 additions & 1 deletion spec/lib/license_finder/reports/markdown_report_spec.rb
Expand Up @@ -13,8 +13,40 @@ module LicenseFinder
result.approved_manually!(double(:approval).as_null_object)
result
end
let(:dependencies) { [dep2, dep1] }

subject { MarkdownReport.new([dep2, dep1], project_name: 'new_project_name').to_s }
subject { MarkdownReport.new(dependencies, project_name: 'new_project_name').to_s }

it 'should not show the paths section' do
is_expected.not_to match 'Paths'
end

context 'when the dependency is a merged package' do
context 'when there is at least one aggregate path' do
let(:merged_dependency) do
dep = MergedPackage.new(dep1, ['path1','path2'])
dep.decide_on_license License.find_by_name('MIT')
dep
end
let(:dependencies) { [merged_dependency] }
it 'should show each of the aggregate paths' do
is_expected.to match 'Paths'
is_expected.to match 'path1'
is_expected.to match 'path2'
end
end
context 'when there are no aggregate paths' do
let(:merged_dependency) do
dep = MergedPackage.new(dep1, [])
dep.decide_on_license License.find_by_name('MIT')
dep
end
let(:dependencies) { [merged_dependency] }
it 'should not show the paths section' do
is_expected.not_to match 'Paths'
end
end
end

it 'should have the correct header' do
is_expected.to match '# new_project_name'
Expand Down

0 comments on commit 3bc52ec

Please sign in to comment.