]> source.dussan.org Git - redmine.git/commitdiff
No blank option for custom fields marked as required on workflow settings.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 15 Jul 2012 16:57:04 +0000 (16:57 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 15 Jul 2012 16:57:04 +0000 (16:57 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10001 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/workflows_helper.rb
test/functional/workflows_controller_test.rb

index a9bc5ac81b067ec77cd2174d9bd4025a538a8b49..62dca80b3cdffcc0ba6a79601e1d8e2efd53abbe 100644 (file)
 module WorkflowsHelper
   def field_permission_tag(permissions, status, field)
     name = field.is_a?(CustomField) ? field.id.to_s : field
-    select_tag("permissions[#{name}][#{status.id}]",
-      options_for_select([["", ""], [l(:label_readonly), "readonly"], [l(:label_required), "required"]], permissions[status.id][name])
-    )
+    options = [["", ""], [l(:label_readonly), "readonly"], [l(:label_required), "required"]]
+
+    if field.is_a?(CustomField) && field.is_required?
+      options = [["(#{l(:label_required)})", ""], [l(:label_readonly), "readonly"]]
+    end
+
+    select_tag("permissions[#{name}][#{status.id}]", options_for_select(options, permissions[status.id][name]))
   end
 end
index 0a35df5df3c72127437d02203aa2ba7825c3695a..32ac03b9717670d0578dc2852f38c367d003aa46 100644 (file)
@@ -191,6 +191,22 @@ class WorkflowsControllerTest < ActionController::TestCase
     end
   end
 
+  def test_get_permissions_with_always_required_custom_field
+    cf = IssueCustomField.create!(:name => 'Foo', :field_format => 'string', :tracker_ids => [1], :is_required => true)
+
+    get :permissions, :role_id => 1, :tracker_id => 1
+    assert_response :success
+    assert_template 'permissions'
+
+    # Custom field that is always required
+    # The default option is "(Required)"
+    assert_select 'select[name=?]', "permissions[#{cf.id}][3]" do
+      assert_select 'option[value=]', :text => '(Required)'
+      assert_select 'option[value=readonly]', :text => 'Read-only'
+      assert_select 'option[value=required]', 0
+    end
+  end
+
   def test_get_permissions_with_role_and_tracker_and_all_statuses
     WorkflowTransition.delete_all