Merged r1379 to r1385 from trunk.
git-svn-id: http://redmine.rubyforge.org/svn/branches/0.7-stable@1387 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Vendored
+1
@@ -4,6 +4,7 @@ custom_fields_001:
|
||||
min_length: 0
|
||||
regexp: ""
|
||||
is_for_all: true
|
||||
is_filter: true
|
||||
type: IssueCustomField
|
||||
max_length: 0
|
||||
possible_values: MySQL|PostgreSQL|Oracle
|
||||
|
||||
@@ -169,13 +169,15 @@ 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,
|
||||
:estimated_hours => ''},
|
||||
:custom_fields => {'2' => 'Value for field 2'}
|
||||
assert_redirected_to 'issues/show'
|
||||
|
||||
issue = Issue.find_by_subject('This is the test_new issue')
|
||||
assert_not_nil issue
|
||||
assert_equal 2, issue.author_id
|
||||
assert_nil issue.estimated_hours
|
||||
v = issue.custom_values.find_by_custom_field_id(2)
|
||||
assert_not_nil v
|
||||
assert_equal 'Value for field 2', v.value
|
||||
@@ -254,10 +256,13 @@ class IssuesControllerTest < Test::Unit::TestCase
|
||||
issue = Issue.find(1)
|
||||
assert_equal 1, issue.status_id
|
||||
@request.session[:user_id] = 2
|
||||
post :edit,
|
||||
:id => 1,
|
||||
:issue => { :status_id => 2, :assigned_to_id => 3 },
|
||||
:notes => 'Assigned to dlopper'
|
||||
assert_difference('TimeEntry.count', 0) do
|
||||
post :edit,
|
||||
:id => 1,
|
||||
:issue => { :status_id => 2, :assigned_to_id => 3 },
|
||||
:notes => 'Assigned to dlopper',
|
||||
:time_entry => { :hours => '', :comments => '', :activity_id => Enumeration.get_values('ACTI').first }
|
||||
end
|
||||
assert_redirected_to 'issues/show/1'
|
||||
issue.reload
|
||||
assert_equal 2, issue.status_id
|
||||
@@ -288,10 +293,12 @@ class IssuesControllerTest < Test::Unit::TestCase
|
||||
def test_post_edit_with_note_and_spent_time
|
||||
@request.session[:user_id] = 2
|
||||
spent_hours_before = Issue.find(1).spent_hours
|
||||
post :edit,
|
||||
:id => 1,
|
||||
:notes => '2.5 hours added',
|
||||
:time_entry => { :hours => '2.5', :comments => '', :activity_id => Enumeration.get_values('ACTI').first }
|
||||
assert_difference('TimeEntry.count') do
|
||||
post :edit,
|
||||
:id => 1,
|
||||
:notes => '2.5 hours added',
|
||||
:time_entry => { :hours => '2.5', :comments => '', :activity_id => Enumeration.get_values('ACTI').first }
|
||||
end
|
||||
assert_redirected_to 'issues/show/1'
|
||||
|
||||
issue = Issue.find(1)
|
||||
|
||||
@@ -29,6 +29,80 @@ class QueryTest < Test::Unit::TestCase
|
||||
assert_equal Issue.find(3), issues.first
|
||||
end
|
||||
|
||||
def test_operator_none
|
||||
query = Query.new(:project => Project.find(1), :name => '_')
|
||||
query.add_filter('fixed_version_id', '!*', [''])
|
||||
query.add_filter('cf_1', '!*', [''])
|
||||
assert query.statement.include?("#{Issue.table_name}.fixed_version_id IS NULL")
|
||||
assert query.statement.include?("#{CustomValue.table_name}.value IS NULL OR #{CustomValue.table_name}.value = ''")
|
||||
issues = Issue.find :all,:include => [ :assigned_to, :status, :tracker, :project, :priority ], :conditions => query.statement
|
||||
end
|
||||
|
||||
def test_operator_all
|
||||
query = Query.new(:project => Project.find(1), :name => '_')
|
||||
query.add_filter('fixed_version_id', '*', [''])
|
||||
query.add_filter('cf_1', '*', [''])
|
||||
assert query.statement.include?("#{Issue.table_name}.fixed_version_id IS NOT NULL")
|
||||
assert query.statement.include?("#{CustomValue.table_name}.value IS NOT NULL AND #{CustomValue.table_name}.value <> ''")
|
||||
issues = Issue.find :all,:include => [ :assigned_to, :status, :tracker, :project, :priority ], :conditions => query.statement
|
||||
end
|
||||
|
||||
def test_operator_greater_than
|
||||
query = Query.new(:project => Project.find(1), :name => '_')
|
||||
query.add_filter('done_ratio', '>=', ['40'])
|
||||
assert query.statement.include?("#{Issue.table_name}.done_ratio >= 40")
|
||||
issues = Issue.find :all,:include => [ :assigned_to, :status, :tracker, :project, :priority ], :conditions => query.statement
|
||||
end
|
||||
|
||||
def test_operator_in_more_than
|
||||
query = Query.new(:project => Project.find(1), :name => '_')
|
||||
query.add_filter('due_date', '>t+', ['15'])
|
||||
assert query.statement.include?("#{Issue.table_name}.due_date >=")
|
||||
issues = Issue.find :all,:include => [ :assigned_to, :status, :tracker, :project, :priority ], :conditions => query.statement
|
||||
end
|
||||
|
||||
def test_operator_in_less_than
|
||||
query = Query.new(:project => Project.find(1), :name => '_')
|
||||
query.add_filter('due_date', '<t+', ['15'])
|
||||
assert query.statement.include?("#{Issue.table_name}.due_date BETWEEN")
|
||||
issues = Issue.find :all,:include => [ :assigned_to, :status, :tracker, :project, :priority ], :conditions => query.statement
|
||||
end
|
||||
|
||||
def test_operator_today
|
||||
query = Query.new(:project => Project.find(1), :name => '_')
|
||||
query.add_filter('due_date', 't', [''])
|
||||
assert query.statement.include?("#{Issue.table_name}.due_date BETWEEN")
|
||||
issues = Issue.find :all,:include => [ :assigned_to, :status, :tracker, :project, :priority ], :conditions => query.statement
|
||||
end
|
||||
|
||||
def test_operator_this_week_on_date
|
||||
query = Query.new(:project => Project.find(1), :name => '_')
|
||||
query.add_filter('due_date', 'w', [''])
|
||||
assert query.statement.include?("#{Issue.table_name}.due_date BETWEEN")
|
||||
issues = Issue.find :all,:include => [ :assigned_to, :status, :tracker, :project, :priority ], :conditions => query.statement
|
||||
end
|
||||
|
||||
def test_operator_this_week_on_datetime
|
||||
query = Query.new(:project => Project.find(1), :name => '_')
|
||||
query.add_filter('created_on', 'w', [''])
|
||||
assert query.statement.include?("#{Issue.table_name}.created_on BETWEEN")
|
||||
issues = Issue.find :all,:include => [ :assigned_to, :status, :tracker, :project, :priority ], :conditions => query.statement
|
||||
end
|
||||
|
||||
def test_operator_contains
|
||||
query = Query.new(:project => Project.find(1), :name => '_')
|
||||
query.add_filter('subject', '~', ['string'])
|
||||
assert query.statement.include?("#{Issue.table_name}.subject LIKE '%string%'")
|
||||
issues = Issue.find :all,:include => [ :assigned_to, :status, :tracker, :project, :priority ], :conditions => query.statement
|
||||
end
|
||||
|
||||
def test_operator_does_not_contains
|
||||
query = Query.new(:project => Project.find(1), :name => '_')
|
||||
query.add_filter('subject', '!~', ['string'])
|
||||
assert query.statement.include?("#{Issue.table_name}.subject NOT LIKE '%string%'")
|
||||
issues = Issue.find :all,:include => [ :assigned_to, :status, :tracker, :project, :priority ], :conditions => query.statement
|
||||
end
|
||||
|
||||
def test_default_columns
|
||||
q = Query.new
|
||||
assert !q.columns.empty?
|
||||
|
||||
Reference in New Issue
Block a user