Project

General

Profile

Defect #13385 » rm13385-do_not_present_searchable_for_not_searchable_cf_formats-trunk_r12224.diff

Mischa The Evil, 2013-10-18 04:37

View differences:

test/functional/custom_fields_controller_test.rb (working copy)
80 80
    assert_select '[name=?]', 'custom_field[default_value]', 0
81 81
  end
82 82

  
83
  def test_searchable_should_be_present_for_string_text_list_custom_field_formats_only
84
    searchable_klasses = %w( IssueCustomField ProjectCustomField )
85
    Redmine::CustomFieldFormat.available_formats.each do |format|
86
      searchable_klasses.each do |sk|
87
        get :new, :type => sk, :custom_field => {:field_format => format}
88
        assert_response :success
89
        case format
90
          when 'string', 'text', 'list'
91
            assert_select 'input[name=?][type=checkbox]', 'custom_field[searchable]', 1, format + " " + sk + " doesn't present searchable while it should"
92
          when 'int', 'float', 'date', 'bool', 'user', 'version'
93
            assert_select 'input[name=?][type=checkbox]', 'custom_field[searchable]', 0, format + " " + sk + " presents searchable while it shouldn't"
94
        end
95
      end
96
    end
97
  end
98

  
83 99
  def test_new_js
84 100
    get :new, :type => 'IssueCustomField', :custom_field => {:field_format => 'list'}, :format => 'js'
85 101
    assert_response :success
app/views/custom_fields/_form.html.erb (working copy)
63 63
    <p><%= f.check_box :is_required %></p>
64 64
    <p><%= f.check_box :is_for_all %></p>
65 65
    <p><%= f.check_box :is_filter %></p>
66
    <p><%= f.check_box :searchable %></p>
66
    <% unless @custom_field.format_in? 'int', 'float', 'date', 'bool', 'user', 'version' %>
67
      <p><%= f.check_box :searchable %></p>
68
    <% end %>
67 69
    <p>
68 70
      <label><%= l(:field_visible) %></label>
69 71
      <label class="block">
......
92 94
<% when "ProjectCustomField" %>
93 95
    <p><%= f.check_box :is_required %></p>
94 96
    <p><%= f.check_box :visible %></p>
95
    <p><%= f.check_box :searchable %></p>
97
    <% unless @custom_field.format_in? 'int', 'float', 'date', 'bool', 'user', 'version' %>
98
      <p><%= f.check_box :searchable %></p>
99
    <% end %>
96 100
    <p><%= f.check_box :is_filter %></p>
97 101

  
98 102
<% when "VersionCustomField" %>
(2-2/2)