提交 01daea2f 编写于 作者: H huybrechts

[FIXED HUDSON-4160] fixed redirect after deleting view

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@20452 71c3de6d-444a-0410-be80-ed276b4c234a
上级 ae28f88a
...@@ -38,6 +38,9 @@ import org.kohsuke.stapler.StaplerResponse; ...@@ -38,6 +38,9 @@ import org.kohsuke.stapler.StaplerResponse;
/** /**
* A view that delegates to another. * A view that delegates to another.
*
* TODO: this does not respond to renaming or deleting the proxied view.
*
* @author Tom Huybrechts * @author Tom Huybrechts
* *
*/ */
......
...@@ -504,13 +504,13 @@ public abstract class View extends AbstractModelObject implements AccessControll ...@@ -504,13 +504,13 @@ public abstract class View extends AbstractModelObject implements AccessControll
/** /**
* Deletes this view. * Deletes this view.
*/ */
public synchronized HttpResponse doDoDelete() throws IOException, ServletException { public synchronized void doDoDelete(StaplerRequest req, StaplerResponse rsp) throws IOException, ServletException {
requirePOST(); requirePOST();
checkPermission(DELETE); checkPermission(DELETE);
owner.deleteView(this); owner.deleteView(this);
return new HttpRedirect("/" + owner.getUrl()); rsp.sendRedirect2(req.getContextPath()+"/" + owner.getUrl());
} }
......
...@@ -27,7 +27,7 @@ THE SOFTWARE. ...@@ -27,7 +27,7 @@ THE SOFTWARE.
<l:layout> <l:layout>
<st:include page="sidepanel.jelly" /> <st:include page="sidepanel.jelly" />
<l:main-panel> <l:main-panel>
<form method="post" action="doDelete"> <form method="post" action="doDelete" name="delete">
${%Are you sure about deleting the view?} ${%Are you sure about deleting the view?}
<f:submit value="${%Yes}" /> <f:submit value="${%Yes}" />
</form> </form>
......
...@@ -52,6 +52,7 @@ import hudson.model.Saveable; ...@@ -52,6 +52,7 @@ import hudson.model.Saveable;
import hudson.model.TaskListener; import hudson.model.TaskListener;
import hudson.model.UpdateCenter; import hudson.model.UpdateCenter;
import hudson.model.AbstractProject; import hudson.model.AbstractProject;
import hudson.model.View;
import hudson.model.UpdateCenter.UpdateCenterConfiguration; import hudson.model.UpdateCenter.UpdateCenterConfiguration;
import hudson.model.Node.Mode; import hudson.model.Node.Mode;
import hudson.security.csrf.CrumbIssuer; import hudson.security.csrf.CrumbIssuer;
...@@ -883,6 +884,14 @@ public abstract class HudsonTestCase extends TestCase { ...@@ -883,6 +884,14 @@ public abstract class HudsonTestCase extends TestCase {
return goTo(item.toComputer().getUrl()+relative); return goTo(item.toComputer().getUrl()+relative);
} }
public HtmlPage getPage(View view) throws IOException, SAXException {
return goTo(view.getUrl());
}
public HtmlPage getPage(View view, String relative) throws IOException, SAXException {
return goTo(view.getUrl()+relative);
}
/** /**
* @deprecated * @deprecated
* This method expects a full URL. This method is marked as deprecated to warn you * This method expects a full URL. This method is marked as deprecated to warn you
......
...@@ -38,7 +38,8 @@ import static hudson.model.Messages.Hudson_ViewName; ...@@ -38,7 +38,8 @@ import static hudson.model.Messages.Hudson_ViewName;
* @author Kohsuke Kawaguchi * @author Kohsuke Kawaguchi
*/ */
public class ViewTest extends HudsonTestCase { public class ViewTest extends HudsonTestCase {
/**
/**
* Creating two views with the same name. * Creating two views with the same name.
*/ */
@Email("http://d.hatena.ne.jp/ssogabe/20090101/1230744150") @Email("http://d.hatena.ne.jp/ssogabe/20090101/1230744150")
...@@ -92,4 +93,23 @@ public class ViewTest extends HudsonTestCase { ...@@ -92,4 +93,23 @@ public class ViewTest extends HudsonTestCase {
assertEquals(((ProxyView) proxyView).getProxiedViewName(), "listView"); assertEquals(((ProxyView) proxyView).getProxiedViewName(), "listView");
assertEquals(((ProxyView) proxyView).getProxiedView(), listView); assertEquals(((ProxyView) proxyView).getProxiedView(), listView);
} }
public void testDeleteView() throws Exception {
WebClient wc = new WebClient();
ListView v = new ListView("list", hudson);
hudson.addView(v);
HtmlPage delete = wc.getPage(v, "delete");
submit(delete.getFormByName("delete"));
assertNull(hudson.getView("list"));
User user = User.get("user", true);
MyViewsProperty p = user.getProperty(MyViewsProperty.class);
v = new ListView("list", p);
p.addView(v);
delete = wc.getPage(v, "delete");
submit(delete.getFormByName("delete"));
assertNull(p.getView("list"));
}
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册