# Returns the issues
# Valid options are :order, :offset, :limit, :include, :conditions
def issues(options={})
- order_option = [group_by_sort_order, options[:order]].reject {|s| s.blank?}.join(',')
- order_option = nil if order_option.blank?
+ order_option = [group_by_sort_order, options[:order]].flatten.reject(&:blank?)
issues = Issue.visible.where(options[:conditions]).all(
:include => ([:status, :project] + (options[:include] || [])).uniq,
:conditions => statement,
:order => order_option,
- :joins => joins_for_order_statement(order_option),
+ :joins => joins_for_order_statement(order_option.join(',')),
:limit => options[:limit],
:offset => options[:offset]
)
# Returns the issues ids
def issue_ids(options={})
- order_option = [group_by_sort_order, options[:order]].reject {|s| s.blank?}.join(',')
- order_option = nil if order_option.blank?
+ order_option = [group_by_sort_order, options[:order]].flatten.reject(&:blank?)
Issue.visible.scoped(:conditions => options[:conditions]).scoped(:include => ([:status, :project] + (options[:include] || [])).uniq,
:conditions => statement,
:order => order_option,
- :joins => joins_for_order_statement(order_option),
+ :joins => joins_for_order_statement(order_option.join(',')),
:limit => options[:limit],
:offset => options[:offset]).find_ids
rescue ::ActiveRecord::StatementInvalid => e
sort_init 'attr1', 'desc'
sort_update(['attr1', 'attr2'])
- assert_equal 'attr1 DESC', sort_clause
+ assert_equal ['attr1 DESC'], sort_clause
end
def test_default_sort_clause_with_hash
sort_init 'attr1', 'desc'
sort_update({'attr1' => 'table1.attr1', 'attr2' => 'table2.attr2'})
- assert_equal 'table1.attr1 DESC', sort_clause
+ assert_equal ['table1.attr1 DESC'], sort_clause
end
def test_default_sort_clause_with_multiple_columns
sort_init 'attr1', 'desc'
sort_update({'attr1' => ['table1.attr1', 'table1.attr2'], 'attr2' => 'table2.attr2'})
- assert_equal 'table1.attr1 DESC, table1.attr2 DESC', sort_clause
+ assert_equal ['table1.attr1 DESC', 'table1.attr2 DESC'], sort_clause
end
def test_params_sort
sort_init 'attr1', 'desc'
sort_update({'attr1' => 'table1.attr1', 'attr2' => 'table2.attr2'})
- assert_equal 'table1.attr1, table2.attr2 DESC', sort_clause
+ assert_equal ['table1.attr1', 'table2.attr2 DESC'], sort_clause
assert_equal 'attr1,attr2:desc', @session['foo_bar_sort']
end
sort_init 'attr1', 'desc'
sort_update({'attr1' => 'table1.attr1', 'attr2' => 'table2.attr2'})
- assert_equal 'table1.attr1 DESC', sort_clause
+ assert_equal ['table1.attr1 DESC'], sort_clause
assert_equal 'attr1:desc', @session['foo_bar_sort']
end
sort_init 'attr1', 'desc'
sort_update({'attr1' => 'table1.attr1', 'attr2' => 'table2.attr2'})
- assert_equal 'table1.attr1, table2.attr2', sort_clause
+ assert_equal ['table1.attr1', 'table2.attr2'], sort_clause
assert_equal 'attr1,attr2', @session['foo_bar_sort']
end