30431.patch

Yuichi HARADA, 2019-04-26 06:57

Download (2.5 KB)

View differences:

app/views/roles/_form.html.erb
47 47

  
48 48
<h3><%= l(:label_permissions) %></h3>
49 49
<div class="box tabular" id="permissions">
50
<% perms_by_module = @role.setable_permissions.group_by {|p| p.project_module.to_s} %>
50
<% setable_permissions = @role.setable_permissions %>
51
<% perms_by_module = setable_permissions.group_by {|p| p.project_module.to_s} %>
51 52
<% perms_by_module.keys.sort.each do |mod| %>
52 53
    <% module_name = mod.blank? ? 'module_project' : "module_#{mod}" %>
53 54
    <fieldset id="<%= module_name %>"><legend><%= toggle_checkboxes_link("##{module_name}\ input") %><%= mod.blank? ? l(:label_project) : l_or_humanize(mod, :prefix => 'project_module_') %></legend>
......
67 68

  
68 69
<div id="role-permissions-trackers" class="view_issues_shown">
69 70
<h3><%= l(:label_issue_tracking) %></h3>
70
<% permissions = %w(view_issues add_issues edit_issues add_issue_notes delete_issues) %>
71
<% permissions = [:view_issues, :add_issues, :edit_issues, :add_issue_notes, :delete_issues] %>
72
<% permissions.delete_if{|permission| !setable_permissions.collect(&:name).include?(permission)} %>
71 73

  
72 74
<div class="autoscroll">
73 75
<table class="list">
test/functional/roles_controller_test.rb
158 158

  
159 159
    assert_select 'input[name=?][value=?]', 'role[name]', 'Manager'
160 160
    assert_select 'select[name=?]', 'role[issues_visibility]'
161
    assert_select '#role-permissions-trackers table .delete_issues_shown'
161 162
  end
162 163

  
163 164
  def test_edit_anonymous
......
166 167

  
167 168
    assert_select 'input[name=?]', 'role[name]', 0
168 169
    assert_select 'select[name=?]', 'role[issues_visibility]', 0
170
    assert_select '#role-permissions-trackers table .delete_issues_shown', 0
169 171
  end
170 172

  
171 173
  def test_edit_invalid_should_respond_with_404
......
222 224
  def test_destroy_role_in_use
223 225
    delete :destroy, :params => {:id => 1}
224 226
    assert_redirected_to '/roles'
225
    assert_equal 'This role is in use and cannot be deleted.', flash[:error] 
227
    assert_equal 'This role is in use and cannot be deleted.', flash[:error]
226 228
    assert_not_nil Role.find_by_id(1)
227 229
  end
228 230