<% issues, query = issues_items(block, settings) %>
+<% if query %>
<div class="contextual">
<%= link_to_function l(:label_options), "$('##{block}-settings').toggle();", :class => 'icon-only icon-settings', :title => l(:label_options) %>
</div>
issues_path(query.as_params.merge(:format => 'atom', :key => User.current.rss_key)),
{:title => query.name}) %>
<% end %>
+
+<% else %>
+<% visible_queries = IssueQuery.visible.sorted %>
+
+<h3>
+ <%= l(:label_issue_plural) %>
+</h3>
+
+<div id="<%= block %>-settings">
+ <%= form_tag(my_page_path, :remote => true) do %>
+ <div class="box">
+ <p>
+ <label>
+ <%= l(:label_query) %>
+ <%= select_tag 'settings[issuequery][query_id]', content_tag("option") + options_from_collection_for_select(visible_queries, :id, :name, settings[:query_id]) %>
+ </label>
+ </p>
+ </div>
+ <p>
+ <%= submit_tag l(:button_save) %>
+ </p>
+ <% end %>
+</div>
+
+<% end %>
'issuesassignedtome' => {:label => :label_assigned_to_me_issues, :partial => 'my/blocks/issues'},
'issuesreportedbyme' => {:label => :label_reported_issues, :partial => 'my/blocks/issues'},
'issueswatched' => {:label => :label_watched_issues, :partial => 'my/blocks/issues'},
+ 'issuequery' => {:label => :label_issue_plural, :partial => 'my/blocks/issues'},
'news' => {:label => :label_news_latest, :partial => 'my/blocks/news'},
'calendar' => {:label => :label_calendar, :partial => 'my/blocks/calendar'},
'documents' => {:label => :label_document_plural, :partial => 'my/blocks/documents'},
class MyControllerTest < Redmine::ControllerTest
fixtures :users, :email_addresses, :user_preferences, :roles, :projects, :members, :member_roles,
- :issues, :issue_statuses, :trackers, :enumerations, :custom_fields, :auth_sources
+ :issues, :issue_statuses, :trackers, :enumerations, :custom_fields, :auth_sources, :queries
def setup
@request.session[:user_id] = 2
assert_select 'table.issues.sort-by-due-date'
end
end
+
+ def test_page_with_issuequery_block_and_no_settings
+ user = User.find(2)
+ user.pref.my_page_layout = {'top' => ['issuequery']}
+ user.pref.save!
+
+ get :page
+ assert_response :success
+
+ assert_select '#block-issuequery' do
+ assert_select 'h3', :text => 'Issues'
+ assert_select 'select[name=?]', 'settings[issuequery][query_id]' do
+ assert_select 'option[value="5"]', :text => 'Open issues by priority and tracker'
+ end
+ end
+ end
+
+ def test_page_with_issuequery_block_and_selected_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']}
+ user.pref.my_page_settings = {'issuequery' => {:query_id => query.id}}
+ user.pref.save!
+
+ get :page
+ assert_response :success
+
+ assert_select '#block-issuequery' do
+ # 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_selected_query_and_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']}
+ user.pref.my_page_settings = {'issuequery' => {:query_id => query.id, :columns => [:subject, :due_date]}}
+ user.pref.save!
+
+ get :page
+ assert_response :success
+
+ assert_select '#block-issuequery' do
+ # assert number of columns (columns from query + id column + checkbox column)
+ assert_select 'table.issues th', 4
+ assert_select 'table.issues th', :text => 'Due date'
+ end
+ end
def test_page_with_all_blocks
blocks = Redmine::MyPage.blocks.keys