Skip to content
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

Patchinfo tests #3160

Merged
merged 3 commits into from May 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 3 additions & 17 deletions 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
7 changes: 6 additions & 1 deletion src/api/app/views/webui/patchinfo/show.html.haml
Expand Up @@ -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/
Expand Down
27 changes: 27 additions & 0 deletions 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
46 changes: 45 additions & 1 deletion src/api/spec/helpers/webui/project_helper_spec.rb
Expand Up @@ -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
Expand Down