# PERMISSION TEMPLATES
#
#------------------------------------------------------------------------------
-permission_templates=Permission templates
-permission_templates.page=Permission templates
+permission_templates=Permission Templates
+permission_templates.page=Permission Templates
permission_template.new_template=New permission template
-permission_template.create_template=Create permission template
+permission_template.create_template=Create
permission_template.delete_confirm_title=Delete permission template
permission_template.do_you_want_to_delete_template=Are you sure that you want to delete this permission template?
-permission_template.delete_template=Delete permission template
+permission_template.delete_template=Delete
permission_template.edit_template=Edit permission template
+permission_template.update_template=Update
permission_template.edit_permissions=Edit permissions
-permission_template.update_permissions=Apply template changes
+permission_template.update_permissions=Save
+permission_template.no_results=No template to display
#------------------------------------------------------------------------------
package org.sonar.server.permission;
import com.google.common.collect.Lists;
+import org.h2.util.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sonar.api.ServerComponent;
}
private void validateTemplateName(Long templateId, String templateName) {
- if(templateName == null) {
- String errorMsg = "The name field is mandatory";
+ if(StringUtils.isNullOrEmpty(templateName)) {
+ String errorMsg = "Name can't be blank";
LOG.error(errorMsg);
throw new BadRequestException(errorMsg);
}
def edit_form
@permission_template = Internal.permission_templates.selectPermissionTemplate(params[:name])
render :partial => 'permission_templates/permission_template_form',
- :locals => {:form_action => 'edit', :message_title => 'edit_template', :message_submit => 'edit_template'}
+ :locals => {:form_action => 'edit', :message_title => 'edit_template', :message_submit => 'update_template'}
end
#
<tbody>
<% if @permission_templates.empty? %>
<tr class="even">
- <td colspan="4" align="left"><%= message('no_results') %></td>
+ <td colspan="6" align="left"><%= message('permission_template.no_results') %></td>
</tr>
<% end %>
<% @permission_templates.each do |permission_template| %>
</td>
<td align="right">
<%= link_to message('delete'), {:action => :delete_form, :name => permission_template.name},
- :id => "delete-template-#{u permission_template.name}", :class => 'open-modal link-action' %>
+ :id => "delete-template-#{u permission_template.name}", :class => 'open-modal link-action link-red' %>
</td>
</tr>
<%
permissionTemplateService.createPermissionTemplate(DEFAULT_NAME, DEFAULT_DESC);
}
+ @Test
+ public void should_reject_empty_name_on_creation() throws Exception {
+ expected.expect(BadRequestException.class);
+ expected.expectMessage("Name can't be blank");
+
+ permissionTemplateService.createPermissionTemplate("", DEFAULT_DESC);
+ }
+
@Test
public void should_delete_permission_template() throws Exception {
when(permissionDao.selectTemplateByName(DEFAULT_NAME)).thenReturn(DEFAULT_TEMPLATE);