Project

General

Profile

Actions

Patch #33268

closed

Add missing test: ProjectCustomField creation

Added by Vincent Robert over 4 years ago. Updated almost 4 years ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
Code cleanup/refactoring
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:

Description

Hello

I would like to complete the test suite, and add a test about the creation of ProjectCustomFields.

Currently, the functional tests only relate to IssueCustomFields.

Thank you

diff --git a/test/functional/custom_fields_controller_test.rb b/test/functional/custom_fields_controller_test.rb
index 7f41888ff..8b5e33155 100644
--- a/test/functional/custom_fields_controller_test.rb
+++ b/test/functional/custom_fields_controller_test.rb
@@ -303,6 +303,29 @@ class CustomFieldsControllerTest < Redmine::ControllerTest
     assert_equal 1, field.trackers.size
   end

+  def test_create_project_custom_field
+    field = new_record(ProjectCustomField) do
+      post :create, :params => {
+          :type => "ProjectCustomField",
+          :custom_field => {
+            :field_format => "string",
+            :name => "test_new_project_custom_field",
+            :description => "",
+            :min_length => "",
+            :max_length => "",
+            :regexp => "",
+            :text_formatting => "",
+            :default_value => "",
+            :url_pattern => "",
+            :is_filter => "0",
+            :is_required =>"0" 
+          }
+        }
+    end
+    assert_redirected_to "/custom_fields/#{field.id}/edit" 
+    assert_equal "test_new_project_custom_field", field.name
+  end
+
   def test_create_with_project_ids
     assert_difference 'CustomField.count' do
       post :create, :params => {

Files

custom_fields_controller_test.diff (1.22 KB) custom_fields_controller_test.diff Vincent Robert, 2020-04-07 13:32
Actions #1

Updated by Vincent Robert over 4 years ago

  • Description updated (diff)
Actions #2

Updated by Vincent Robert over 4 years ago

  • Target version set to 4.1.2
Actions #3

Updated by Marius BĂLTEANU almost 4 years ago

  • Assignee set to Go MAEDA
  • Target version changed from 4.1.2 to 4.0.8

Go Maeda, looks good to me, we can add this test to all stable versions or only to 4.2.0.

Actions #4

Updated by Go MAEDA almost 4 years ago

Marius BALTEANU wrote:

Go Maeda, looks good to me, we can add this test to all stable versions or only to 4.2.0.

Thank you for reviewing the patch.

Since the new test is not for detecting existing bugs, but simply adds a new test, I think it is appropriate to set the target version to 4.2.0.

Actions #5

Updated by Marius BĂLTEANU almost 4 years ago

  • Target version changed from 4.0.8 to 4.2.0
Actions #6

Updated by Go MAEDA almost 4 years ago

  • Category set to Code cleanup/refactoring
  • Status changed from New to Closed

Committed the patch. Thank you for your contribution.

Actions

Also available in: Atom PDF