summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/fixtures/custom_fields.yml5
-rw-r--r--test/functional/issues_controller_test.rb19
-rw-r--r--test/integration/issues_test.rb14
-rw-r--r--test/unit/custom_value_test.rb11
4 files changed, 44 insertions, 5 deletions
diff --git a/test/fixtures/custom_fields.yml b/test/fixtures/custom_fields.yml
index e73e6de96..e58d8e3dc 100644
--- a/test/fixtures/custom_fields.yml
+++ b/test/fixtures/custom_fields.yml
@@ -10,6 +10,7 @@ custom_fields_001:
id: 1
is_required: false
field_format: list
+ default_value: ""
custom_fields_002:
name: Searchable field
min_length: 1
@@ -22,6 +23,7 @@ custom_fields_002:
is_required: false
field_format: string
searchable: true
+ default_value: "Default string"
custom_fields_003:
name: Development status
min_length: 0
@@ -33,6 +35,7 @@ custom_fields_003:
id: 3
is_required: true
field_format: list
+ default_value: ""
custom_fields_004:
name: Phone number
min_length: 0
@@ -44,6 +47,7 @@ custom_fields_004:
id: 4
is_required: false
field_format: string
+ default_value: ""
custom_fields_005:
name: Money
min_length: 0
@@ -55,4 +59,5 @@ custom_fields_005:
id: 5
is_required: false
field_format: float
+ default_value: ""
\ No newline at end of file
diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb
index 05bfc96e3..f4c99f1ed 100644
--- a/test/functional/issues_controller_test.rb
+++ b/test/functional/issues_controller_test.rb
@@ -34,7 +34,10 @@ class IssuesControllerTest < Test::Unit::TestCase
:enabled_modules,
:enumerations,
:attachments,
- :workflows
+ :workflows,
+ :custom_fields,
+ :custom_values,
+ :custom_fields_trackers
def setup
@controller = IssuesController.new
@@ -132,6 +135,9 @@ class IssuesControllerTest < Test::Unit::TestCase
get :new, :project_id => 1, :tracker_id => 1
assert_response :success
assert_template 'new'
+
+ assert_tag :tag => 'input', :attributes => { :name => 'custom_fields[2]',
+ :value => 'Default string' }
end
def test_get_new_without_tracker_id
@@ -162,9 +168,16 @@ class IssuesControllerTest < Test::Unit::TestCase
:issue => {:tracker_id => 1,
:subject => 'This is the test_new issue',
:description => 'This is the description',
- :priority_id => 5}
+ :priority_id => 5},
+ :custom_fields => {'2' => 'Value for field 2'}
assert_redirected_to 'projects/ecookbook/issues'
- assert Issue.find_by_subject('This is the test_new issue')
+
+ issue = Issue.find_by_subject('This is the test_new issue')
+ assert_not_nil issue
+ assert_equal 2, issue.author_id
+ v = issue.custom_values.find_by_custom_field_id(2)
+ assert_not_nil v
+ assert_equal 'Value for field 2', v.value
end
def test_copy_issue
diff --git a/test/integration/issues_test.rb b/test/integration/issues_test.rb
index 81d27c30f..7249ed3da 100644
--- a/test/integration/issues_test.rb
+++ b/test/integration/issues_test.rb
@@ -1,7 +1,16 @@
require "#{File.dirname(__FILE__)}/../test_helper"
class IssuesTest < ActionController::IntegrationTest
- fixtures :projects, :users, :trackers, :issue_statuses, :issues, :enumerations
+ fixtures :projects,
+ :users,
+ :trackers,
+ :projects_trackers,
+ :issue_statuses,
+ :issues,
+ :enumerations,
+ :custom_fields,
+ :custom_values,
+ :custom_fields_trackers
# create an issue
def test_add_issue
@@ -18,7 +27,8 @@ class IssuesTest < ActionController::IntegrationTest
:description => "new issue",
:done_ratio => "0",
:due_date => "",
- :assigned_to_id => "" }
+ :assigned_to_id => "" },
+ :custom_fields => {'2' => 'Value for field 2'}
# find created issue
issue = Issue.find_by_subject("new test issue")
assert_kind_of Issue, issue
diff --git a/test/unit/custom_value_test.rb b/test/unit/custom_value_test.rb
index 24d09fe49..4d488bae2 100644
--- a/test/unit/custom_value_test.rb
+++ b/test/unit/custom_value_test.rb
@@ -31,4 +31,15 @@ class CustomValueTest < Test::Unit::TestCase
v.value = '6a'
assert !v.save
end
+
+ def test_default_value
+ field = CustomField.find_by_default_value('Default string')
+ assert_not_nil field
+
+ v = CustomValue.new(:custom_field => field)
+ assert_equal 'Default string', v.value
+
+ v = CustomValue.new(:custom_field => field, :value => 'Not empty')
+ assert_equal 'Not empty', v.value
+ end
end