提交 86e510a9 编写于 作者: D Devin Nusbaum 提交者: Oleg Nenashev

[JENKINS-49906] Use more specific and less urgent message when renaming (#3326)

* [JENKINS-49906] Use more specific and less urgent message when the name is unchanged

* [JENKINS-49906] Fix tests now that the error message is different
上级 e7fbce37
......@@ -284,6 +284,9 @@ public abstract class AbstractItem extends Actionable implements Item, HttpDelet
try {
Jenkins.checkGoodName(newName);
assert newName != null; // Would have thrown Failure
if (newName.equals(name)) {
return FormValidation.warning(Messages.AbstractItem_NewNameUnchanged());
}
Jenkins.get().getProjectNamingStrategy().checkName(newName);
checkIfNameIsUsed(newName);
checkRename(newName);
......
......@@ -36,6 +36,7 @@ AbstractItem.BeingDeleted={0} is currently being deleted
AbstractItem.FailureToStopBuilds=Failed to interrupt and stop {0,choice,1#{0,number,integer} build|1<{0,number,integer} \
builds} of {1}
AbstractItem.NewNameInUse=The name \u201c{0}\u201d is already in use.
AbstractItem.NewNameUnchanged=The new name is the same as the current name.
AbstractProject.AssignedLabelString_NoMatch_DidYouMean=There\u2019s no agent/cloud that matches this assignment. Did you mean \u2018{1}\u2019 instead of \u2018{0}\u2019?
AbstractProject.NewBuildForWorkspace=Scheduling a new build to get a workspace.
AbstractProject.AwaitingBuildForWorkspace=Awaiting build to get a workspace.
......
......@@ -63,11 +63,13 @@ public class AbstractItemTest {
public void checkRenameValidity() throws Exception {
FreeStyleProject p = j.createFreeStyleProject("foo");
p.getBuildersList().add(new SleepBuilder(10));
j.createFreeStyleProject("foo-exists");
assertThat(checkNameAndReturnError(p, ""), equalTo(Messages.Hudson_NoName()));
assertThat(checkNameAndReturnError(p, ".."), equalTo(Messages.Jenkins_NotAllowedName("..")));
assertThat(checkNameAndReturnError(p, "50%"), equalTo(Messages.Hudson_UnsafeChar('%')));
assertThat(checkNameAndReturnError(p, "foo"), equalTo(Messages.AbstractItem_NewNameInUse("foo")));
assertThat(checkNameAndReturnError(p, "foo"), equalTo(Messages.AbstractItem_NewNameUnchanged()));
assertThat(checkNameAndReturnError(p, "foo-exists"), equalTo(Messages.AbstractItem_NewNameInUse("foo-exists")));
j.jenkins.setProjectNamingStrategy(new ProjectNamingStrategy.PatternProjectNamingStrategy("bar", "", false));
assertThat(checkNameAndReturnError(p, "foo1"), equalTo(jenkins.model.Messages.Hudson_JobNameConventionNotApplyed("foo1", "bar")));
......@@ -84,12 +86,13 @@ public class AbstractItemTest {
mas.grant(Item.READ).everywhere().to("alice");
j.jenkins.setAuthorizationStrategy(mas);
FreeStyleProject p = j.createFreeStyleProject("foo");
j.createFreeStyleProject("foo-exists");
try (ACLContext unused = ACL.as(User.getById("alice", true))) {
assertThat(checkNameAndReturnError(p, "foo"), equalTo(Messages.AbstractItem_NewNameInUse("foo")));
assertThat(checkNameAndReturnError(p, "foo-exists"), equalTo(Messages.AbstractItem_NewNameInUse("foo-exists")));
}
try (ACLContext unused = ACL.as(User.getById("bob", true))) {
assertThat(checkNameAndReturnError(p, "foo"), equalTo(Messages.Jenkins_NotAllowedName("foo")));
assertThat(checkNameAndReturnError(p, "foo-exists"), equalTo(Messages.Jenkins_NotAllowedName("foo-exists")));
}
try (ACLContext unused = ACL.as(User.getById("carol", true))) {
try {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册