:type => :list, :values => activities.map {|a| [a.name, a.id.to_s]}
)
+ add_available_filter("project.status",
+ :type => :list,
+ :name => l(:label_attribute_of_project, :name => l(:field_status)),
+ :values => lambda { project_statuses_values }
+ ) if project.nil? || !project.leaf?
+
add_available_filter "comments", :type => :text
add_available_filter "hours", :type => :float
sql_for_field("category_id", operator, value, Issue.table_name, "category_id")
end
+ def sql_for_project_status_field(field, operator, value, options={})
+ sql_for_field(field, operator, value, Project.table_name, "status")
+ end
+
# Accepts :from/:to params as shortcut filters
def build_from_params(params, defaults={})
super
assert_equal [entry].map(&:id).map(&:to_s), css_select('input[name="ids[]"]').map {|e| e.attr('value')}
end
+ def test_index_with_project_status_filter
+ project = Project.find(3)
+ project.close
+ project.save
+
+ get :index, :params => {
+ :set_filter => 1,
+ :f => ['project.status'],
+ :op => {'project.status' => '='},
+ :v => {'project.status' => ['1']}
+ }
+
+ assert_response :success
+
+ time_entries = css_select('input[name="ids[]"]').map {|e| e.attr('value')}
+ assert_include '1', time_entries
+ assert_not_include '4', time_entries
+ end
+
def test_index_with_issue_status_column
issue = Issue.generate!(:project_id => 1, :tracker_id => 1, :status_id => 4)
entry = TimeEntry.generate!(:issue => issue)
query = TimeEntryQuery.new(:project => nil, :name => '_')
assert !query.available_filters.has_key?('issue.category_id')
end
+
+ def test_project_status_filter_should_be_available_in_global_queries
+ query = TimeEntryQuery.new(:project => nil, :name => '_')
+ assert query.available_filters.has_key?('project.status')
+ end
+
+ def test_project_status_filter_should_be_available_when_project_has_subprojects
+ query = TimeEntryQuery.new(:project => Project.find(1), :name => '_')
+ assert query.available_filters.has_key?('project.status')
+ end
+
+ def test_project_status_filter_should_not_be_available_when_project_is_leaf
+ query = TimeEntryQuery.new(:project => Project.find(2), :name => '_')
+ assert !query.available_filters.has_key?('project.status')
+ end
end