Project

General

Profile

Defect #42458 » 42458-v2.patch

Go MAEDA, 2025-03-25 10:17

View differences:

app/views/queries/_form.html.erb
32 32

  
33 33
<% unless @query.is_a?(ProjectQuery) %>
34 34
  <p><label for="query_is_for_all"><%=l(:field_is_for_all)%></label>
35
  <%= check_box_tag 'query_is_for_all', 1, @query.project.nil?, :class => (User.current.admin? ? '' : 'disable-unless-private') %></p>
35
  <%= check_box_tag 'query_is_for_all', 1, @query.project.nil?, :disabled => (!@query.new_record? && @query.project.nil?), :class => (User.current.admin? ? '' : 'disable-unless-private') %></p>
36 36
<% end %>
37 37

  
38 38
<% unless params[:calendar] %>
test/functional/queries_controller_test.rb
1030 1030
    assert_include ["Development", "10"], json
1031 1031
    assert_include ["Inactive Activity", "14"], json
1032 1032
  end
1033

  
1034
  def test_new_query_is_for_all_checkbox_not_disabled
1035
    @request.session[:user_id] = 1
1036
    get :new
1037
    assert_response :success
1038
    # Verify that the "For all projects" checkbox is not disabled when creating a new query
1039
    assert_select 'input[name=query_is_for_all][type=checkbox][checked]:not([disabled])'
1040
  end
1041

  
1042
  def test_new_project_query_is_for_all_checkbox_not_disabled
1043
    @request.session[:user_id] = 1
1044
    get(:new, :params => {:project_id => 1})
1045
    assert_response :success
1046
    # Verify that the checkbox is not disabled when creating a new query within a project
1047
    assert_select 'input[name=query_is_for_all][type=checkbox]:not([checked]):not([disabled])'
1048
  end
1049

  
1050
  def test_edit_global_query_is_for_all_checkbox_disabled
1051
    @request.session[:user_id] = 1
1052
    # Create a global query (project_id = nil)
1053
    query = IssueQuery.create!(:name => 'test_global_query', :user_id => 1, :project_id => nil)
1054

  
1055
    get(:edit, :params => {:id => query.id})
1056
    assert_response :success
1057

  
1058
    # Verify that the "For all projects" checkbox is disabled when editing an existing global query
1059
    assert_select 'input[name=query_is_for_all][type=checkbox][checked][disabled]'
1060
  end
1061

  
1062
  def test_edit_project_query_is_for_all_checkbox_not_disabled
1063
    @request.session[:user_id] = 1
1064
    # Create a project-specific query
1065
    query = IssueQuery.create!(:name => 'test_project_query', :user_id => 1, :project_id => 1)
1066

  
1067
    get(:edit, :params => {:id => query.id})
1068
    assert_response :success
1069

  
1070
    # Verify that the checkbox is not disabled when editing a project-specific query
1071
    assert_select 'input[name=query_is_for_all][type=checkbox]:not([checked]):not([disabled])'
1072
  end
1033 1073
end
(2-2/2)