Skip to content
Permalink
Browse files

Merge pull request #40 from olivergondza/dashboard-link

[FIXED JENKINS-26410] Dashboard links broken when inside folder
  • Loading branch information
olivergondza committed Jan 20, 2015
2 parents 9a87271 + 4c0b645 commit 43441a36485b713c6462ce8b1883af1e5643edfb
@@ -4,7 +4,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.424</version>
<version>1.480.3</version>
</parent>

<artifactId>cobertura</artifactId>
@@ -79,6 +79,12 @@
<version>3.0.3</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>cloudbees-folder</artifactId>
<version>4.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
@@ -47,7 +47,7 @@ THE SOFTWARE.
<j:set var="result" value="${it.getCoverageResult(r)}"/>
<j:set var="metrics" value="${result.metrics}"/>
<tr style="border-top: 0px; border: 1px #bbb solid;">
<td><t:buildLink jobName="${r.parent.name}" job="${r.parent}" number="${r.number}" href="${r.url}" /></td>
<td><t:buildLink jobName="${r.parent.name}" job="${r.parent}" number="${r.number}" /></td>
<j:choose>
<j:when test="${empty(metrics)}">
<td colspan="6">${%N/A}</td>
@@ -75,4 +75,4 @@ THE SOFTWARE.
</j:otherwise>
</j:choose>
</dp:decorate>
</j:jelly>
</j:jelly>
@@ -47,7 +47,7 @@ THE SOFTWARE.
<j:set var="result" value="${it.getCoverageResult(r)}"/>
<j:set var="metrics" value="${result.metricsWithEmpty}"/>
<tr style="border-top: 0px; border: 1px #bbb solid;">
<td><t:buildLink jobName="${r.parent.name}" job="${r.parent}" number="${r.number}" href="${r.url}" /></td>
<td><t:buildLink jobName="${r.parent.name}" job="${r.parent}" number="${r.number}" /></td>
<j:choose>
<j:when test="${empty(metrics)}">
<td colspan="6">${%N/A}</td>
@@ -89,4 +89,4 @@ THE SOFTWARE.
</j:otherwise>
</j:choose>
</dp:decorate>
</j:jelly>
</j:jelly>
@@ -0,0 +1,74 @@
/*
* The MIT License
*
* Copyright (c) 2015 Red Hat, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package CoverageTablePortlet;

import hudson.model.FreeStyleBuild;
import hudson.model.FreeStyleProject;
import hudson.plugins.cobertura.CoberturaBuildAction;
import hudson.plugins.cobertura.dashboard.CoverageTablePortlet;
import hudson.plugins.cobertura.targets.CoverageResult;
import hudson.plugins.view.dashboard.Dashboard;

import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.Bug;
import org.jvnet.hudson.test.JenkinsRule;
import org.jvnet.hudson.test.JenkinsRule.WebClient;

import com.cloudbees.hudson.plugins.folder.Folder;
import com.gargoylesoftware.htmlunit.html.HtmlPage;

public class CoverageTablePortletTest {

public @Rule JenkinsRule j = new JenkinsRule();

@Test @Bug(26410)
public void testBuildUrlShouldBeCorrectInFolder() throws Exception {
Folder folder = j.jenkins.createProject(Folder.class, "folder");

FreeStyleProject p = folder.createProject(FreeStyleProject.class, "project");
FreeStyleBuild build = p.scheduleBuild2(0).get();
// fake cobertura run
build.getActions().add(CoberturaBuildAction.load(
build, new CoverageResult(null, null, "cresult"), null, null, false, false, false, false, false
));

Dashboard view = new Dashboard("view");
folder.addView(view);
view.add(p);
final CoverageTablePortlet portlet = new CoverageTablePortlet("coverage portlet");
String portletId = portlet.getId();
view.getTopPortlets().add(portlet);

WebClient wc = j.createWebClient();
// FailingHttpStatusCodeException: 404 Not Found for http://localhost:34512/plugin/dashboard-view/js/dashboard-view.js
wc.setJavaScriptEnabled(false);

HtmlPage page = wc.getPage(view);
page.getAnchorByText("project #1").click();

page = wc.getPage(view, "portlet/" + portletId);
page.getAnchorByText("project #1").click();
}
}

0 comments on commit 43441a3

Please sign in to comment.
You can’t perform that action at this time.