@query.project = params[:query_is_for_all] ? nil : @project
@query.build_from_params(params)
@query.column_names = nil if params[:default_columns]
- @query.sort_criteria = params[:query] && params[:query][:sort_criteria]
+ @query.sort_criteria = (params[:query] && params[:query][:sort_criteria]) || @query.sort_criteria
@query.name = params[:query] && params[:query][:name]
if User.current.allowed_to?(:manage_public_queries, @query.project) || User.current.admin?
@query.visibility = (params[:query] && params[:query][:visibility]) || Query::VISIBILITY_PRIVATE
def build_from_params(params, defaults={})
super
- self.draw_relations = params[:draw_relations] || (params[:query] && params[:query][:draw_relations])
- self.draw_progress_line = params[:draw_progress_line] || (params[:query] && params[:query][:draw_progress_line])
+ self.draw_relations = params[:draw_relations] || (params[:query] && params[:query][:draw_relations]) || options[:draw_relations]
+ self.draw_progress_line = params[:draw_progress_line] || (params[:query] && params[:query][:draw_progress_line]) || options[:draw_progress_line]
self
end
end
query_params = params[:query] || defaults || {}
- self.group_by = params[:group_by] || query_params[:group_by]
- self.column_names = params[:c] || query_params[:column_names]
- self.totalable_names = params[:t] || query_params[:totalable_names]
- self.sort_criteria = params[:sort] || query_params[:sort_criteria]
+ self.group_by = params[:group_by] || query_params[:group_by] || self.group_by
+ self.column_names = params[:c] || query_params[:column_names] || self.column_names
+ self.totalable_names = params[:t] || query_params[:totalable_names] || self.totalable_names
+ self.sort_criteria = params[:sort] || query_params[:sort_criteria] || self.sort_criteria
self
end
assert_nil IssueQuery.visible(User.find(1)).find_by_id(q.id)
end
+ def test_build_from_params_should_not_update_query_with_nil_param_values
+ q = IssueQuery.create!(:name => 'Query',
+ :type => "IssueQuery",
+ :user => User.find(7),
+ :filters => {"status_id" => {:values => ["1"], :operator => "o"}},
+ :column_names => [:tracker, :status],
+ :sort_criteria => ['id', 'asc'],
+ :group_by => "project",
+ :options => { :totalable_names=>[:estimated_hours], :draw_relations => '1', :draw_progress_line => '1' }
+ )
+ old_attributes = q.attributes
+ q.build_from_params({})
+ assert_equal old_attributes, q.attributes
+ end
+
test "#available_filters should include users of visible projects in cross-project view" do
users = IssueQuery.new.available_filters["assigned_to_id"]
assert_not_nil users