Patch #44832 ยป 0001-Add-any-operator-to-the-status-filter-of-the-project.patch
| app/models/project_query.rb | ||
|---|---|---|
|
def initialize_available_filters
|
||
|
add_available_filter(
|
||
|
"status",
|
||
|
:type => :list, :values => lambda {project_statuses_values}
|
||
|
:type => :list_optional, :values => lambda {project_statuses_values}
|
||
|
)
|
||
|
add_available_filter(
|
||
|
"id",
|
||
| test/unit/project_query_test.rb | ||
|---|---|---|
|
assert_equal ['1', '5'], values.map(&:second)
|
||
|
end
|
||
|
def test_project_statuses_filter_should_offer_the_any_operator
|
||
|
query = ProjectQuery.new(:name => '_')
|
||
|
type = query.available_filters['status'][:type]
|
||
|
assert_include '*', query.operators_by_filter_type[type]
|
||
|
end
|
||
|
def test_project_statuses_filter_with_any_operator_should_return_active_and_closed_projects
|
||
|
User.current = User.find(1)
|
||
|
closed = Project.find(2)
|
||
|
closed.update_attribute(:status, Project::STATUS_CLOSED)
|
||
|
query = ProjectQuery.new(:name => '_')
|
||
|
query.filters = {'status' => {:operator => '*', :values => ['']}}
|
||
|
assert query.valid?
|
||
|
projects = query.results_scope.to_a
|
||
|
assert_include closed, projects
|
||
|
assert_include Project.find(1), projects
|
||
|
end
|
||
|
def test_default_columns
|
||
|
q = ProjectQuery.new
|
||
|
assert q.columns.any?
|
||