diff --git a/src/api/app/helpers/webui/patchinfo_helper.rb b/src/api/app/helpers/webui/patchinfo_helper.rb index 971b8f95fd0..c7e50384214 100644 --- a/src/api/app/helpers/webui/patchinfo_helper.rb +++ b/src/api/app/helpers/webui/patchinfo_helper.rb @@ -1,21 +1,7 @@ module Webui::PatchinfoHelper include Webui::ProjectHelper - def patchinfo_bread_crumb( *args ) - args.insert(0, link_to( @package, action: :show, project: @project, package: @package )) - project_bread_crumb( *args ) - end - - def issue_link( issue ) - # list issue-names with urls and summary from the patchinfo-file - # issue[0] = tracker-name - # issue[1] = issueid - # issue[2] = issue-url - # issue[3] = issue-summary - - if issue[0] == "CVE" - content_tag(:li, link_to((issue[1]).to_s, issue[2]) + ": #{issue[3]}") - else - content_tag(:li, link_to("#{issue[0]}##{issue[1]}", issue[2]) + ": #{issue[3]}") - end + def patchinfo_bread_crumb(*args) + args.insert(0, link_to(@package, package_show_path(project: @project, package: @package))) + project_bread_crumb(*args) end end diff --git a/src/api/app/views/webui/patchinfo/show.html.haml b/src/api/app/views/webui/patchinfo/show.html.haml index 2d4e85e6c84..b34140ed03b 100644 --- a/src/api/app/views/webui/patchinfo/show.html.haml +++ b/src/api/app/views/webui/patchinfo/show.html.haml @@ -41,7 +41,12 @@ - if @issues.present? %ul - @issues.each do |issue| - = issue_link(issue) + - if issue[0] == "CVE" + %li + = link_to((issue[1]).to_s, issue[2]) + ": #{issue[3]}" + - else + %li + = link_to("#{issue[0]}##{issue[1]}", issue[2]) + ": #{issue[3]}" .box.show_left.show_right %b Required actions: %br/ diff --git a/src/api/spec/helpers/webui/patchinfo_helper_spec.rb b/src/api/spec/helpers/webui/patchinfo_helper_spec.rb new file mode 100644 index 00000000000..51e7970ae80 --- /dev/null +++ b/src/api/spec/helpers/webui/patchinfo_helper_spec.rb @@ -0,0 +1,27 @@ +require 'rails_helper' + +RSpec.describe Webui::PatchinfoHelper, type: :helper do + describe '#patchinfo_bread_crumb' do + let(:project) { create(:project_with_package) } + + before do + @project = project.name + @package = project.packages.first.name + end + + it "creates a list of project_bread_crumb links, link to the patchinfo package" do + expect(patchinfo_bread_crumb).to eq([ + project_bread_crumb, + link_to(@package, package_show_path(project: @project, package: @package)) + ].flatten) + end + + it "the parameter content to the list" do + expect(patchinfo_bread_crumb('Text')).to eq([ + project_bread_crumb, + link_to(@package, package_show_path(project: @project, package: @package)), + 'Text' + ].flatten) + end + end +end diff --git a/src/api/spec/helpers/webui/project_helper_spec.rb b/src/api/spec/helpers/webui/project_helper_spec.rb index b244399ebc2..8bfd4e334d4 100644 --- a/src/api/spec/helpers/webui/project_helper_spec.rb +++ b/src/api/spec/helpers/webui/project_helper_spec.rb @@ -6,7 +6,51 @@ end describe '#project_bread_crumb' do - skip + let(:project) { create(:project_with_package) } + + before do + @project = project.name + end + + it 'creates a list with a link to projects list' do + expect(project_bread_crumb).to eq([link_to('Projects', project_list_public_path)]) + end + + context "when it's called with a parameter" do + it 'adds the content of the parameter to the list' do + expect(project_bread_crumb('my label')).to eq([link_to('Projects', project_list_public_path), 'my label']) + end + end + + context 'when the project has parent projects' do + let(:child_project) { create(:project_with_package, name: "#{project}:child") } + + before do + @project = child_project + @package = project.packages.first.name + end + + it 'adds a link to the parent projects to the list' do + expect(project_bread_crumb('Text')).to eq( + [ + link_to('Projects', project_list_public_path), + [ + link_to(project, project_show_path(project: project)), + link_to('child', project_show_path(project: child_project)) + ], + 'Text' + ] + ) + end + end + + context 'when @spider_bot is true' do + before do + @spider_bot = true + end + + it { expect(project_bread_crumb).to be nil } + end end describe '#format_seconds' do