no-workflow-warning-for-roles-v2.patch

Go MAEDA, 2019-02-24 12:25

Download (2.65 KB)

View differences:

app/views/roles/index.html.erb
9 9
  <thead><tr>
10 10
    <th><%=l(:label_role)%></th>
11 11
  <th></th>
12
  <th></th>
12 13
  </tr></thead>
13 14
  <tbody>
14 15
<% for role in @roles %>
15 16
  <tr class="<%= role.builtin? ? "builtin" : "givable" %>">
16 17
  <td class="name"><%= content_tag(role.builtin? ? 'em' : 'span', link_to(role.name, edit_role_path(role))) %></td>
18
  <td>
19
    <% unless role.workflow_rules.exists? || role.builtin? %>
20
      <span class="icon icon-warning">
21
        <%= l(:text_role_no_workflow) %> (<%= link_to l(:button_edit), workflows_edit_path(:role_id => role) %>)
22
      </span>
23
    <% end %>
24
  </td>
17 25
  <td class="buttons">
18 26
    <%= reorder_handle(role) unless role.builtin? %>
19 27
    <%= link_to l(:button_copy), new_role_path(:copy => role), :class => 'icon icon-copy' %>
config/locales/en.yml
1130 1130
  text_caracters_minimum: "Must be at least %{count} characters long."
1131 1131
  text_length_between: "Length between %{min} and %{max} characters."
1132 1132
  text_tracker_no_workflow: No workflow defined for this tracker
1133
  text_role_no_workflow: No workflow defined for this role
1133 1134
  text_unallowed_characters: Unallowed characters
1134 1135
  text_comma_separated: Multiple values allowed (comma separated).
1135 1136
  text_line_separated: Multiple values allowed (one line for each value).
test/functional/roles_controller_test.rb
35 35
    end
36 36
  end
37 37

  
38
  def test_index_should_show_warning_when_no_workflow_is_defined
39
    Role.find_by_name('Developer').workflow_rules.destroy_all
40
    Role.find_by_name('Anonymous').workflow_rules.destroy_all
41

  
42
    get :index
43
    assert_response :success
44
    assert_select 'table.roles' do
45
      # Manager
46
      assert_select 'tr.givable:nth-of-type(1) span.icon-warning', :count => 0
47
      # Developer
48
      assert_select 'tr.givable:nth-of-type(2) span.icon-warning', :text => /#{I18n.t(:text_role_no_workflow)}/
49
      # Reporter
50
      assert_select 'tr.givable:nth-of-type(3) span.icon-warning', :count => 0
51
      # No warnings for built-in roles such as Anonymous and Non-member
52
      assert_select 'tr.builtin span.icon-warning', :count => 0
53
    end
54
  end
55

  
38 56
  def test_new
39 57
    get :new
40 58
    assert_response :success