end
def as_params
- params = {}
- filters.each do |field, options|
- params[:f] ||= []
- params[:f] << field
- params[:op] ||= {}
- params[:op][field] = options[:operator]
- params[:v] ||= {}
- params[:v][field] = options[:values]
+ if new_record?
+ params = {}
+ filters.each do |field, options|
+ params[:f] ||= []
+ params[:f] << field
+ params[:op] ||= {}
+ params[:op][field] = options[:operator]
+ params[:v] ||= {}
+ params[:v][field] = options[:values]
+ end
+ params[:c] = column_names
+ params[:sort] = sort_criteria.to_param
+ params[:set_filter] = 1
+ params
+ else
+ {:query_id => id}
end
- params[:c] = column_names
- params[:sort] = sort_criteria.to_param
- params[:set_filter] = 1
- params
end
def validate_query_filters
</div>
<h3>
- <%= link_to query.name, issues_path(query.as_params) %>
+ <%= "#{query.project} |" if query.project %>
+ <%= link_to query.name, _project_issues_path(query.project, query.as_params) %>
(<%= query.issue_count %>)
</h3>
<% content_for :header_tags do %>
<%= auto_discovery_link_tag(:atom,
- issues_path(query.as_params.merge(:format => 'atom', :key => User.current.rss_key)),
+ _project_issues_path(query.project, query.as_params.merge(:format => 'atom', :key => User.current.rss_key)),
{:title => query.name}) %>
<% end %>
end
end
- def test_page_with_issuequery_block_and_selected_query
+ def test_page_with_issuequery_block_and_global_query
user = User.find(2)
query = IssueQuery.create!(:name => 'All issues', :user => user, :column_names => [:tracker, :subject, :status, :assigned_to])
user.pref.my_page_layout = {'top' => ['issuequery']}
assert_response :success
assert_select '#block-issuequery' do
+ assert_select 'a[href=?]', "/issues?query_id=#{query.id}"
# assert number of columns (columns from query + id column + checkbox column)
assert_select 'table.issues th', 6
# assert results limit
end
end
- def test_page_with_issuequery_block_and_selected_query_and_custom_columns
+ def test_page_with_issuequery_block_and_project_query
+ user = User.find(2)
+ query = IssueQuery.create!(:name => 'All issues', :project => Project.find(1), :user => user, :column_names => [:tracker, :subject, :status, :assigned_to])
+ user.pref.my_page_layout = {'top' => ['issuequery']}
+ user.pref.my_page_settings = {'issuequery' => {:query_id => query.id}}
+ user.pref.save!
+
+ get :page
+ assert_response :success
+
+ assert_select '#block-issuequery' do
+ assert_select 'a[href=?]', "/projects/ecookbook/issues?query_id=#{query.id}"
+ # assert number of columns (columns from query + id column + checkbox column)
+ assert_select 'table.issues th', 6
+ # assert results limit
+ assert_select 'table.issues tr.issue', 10
+ assert_select 'table.issues td.assigned_to'
+ end
+ end
+
+ def test_page_with_issuequery_block_and_query_should_display_custom_columns
user = User.find(2)
query = IssueQuery.create!(:name => 'All issues', :user => user, :column_names => [:tracker, :subject, :status, :assigned_to])
user.pref.my_page_layout = {'top' => ['issuequery']}