You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

my_page_test.rb 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. # Redmine - project management software
  2. # Copyright (C) 2006-2017 Jean-Philippe Lang
  3. #
  4. # This program is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU General Public License
  6. # as published by the Free Software Foundation; either version 2
  7. # of the License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software
  16. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. require File.expand_path('../../application_system_test_case', __FILE__)
  18. class MyPageTest < ApplicationSystemTestCase
  19. fixtures :projects, :users, :email_addresses, :roles, :members, :member_roles,
  20. :trackers, :projects_trackers, :enabled_modules, :issue_statuses, :issues,
  21. :enumerations, :custom_fields, :custom_values, :custom_fields_trackers,
  22. :watchers, :journals, :journal_details
  23. def test_sort_assigned_issues
  24. preferences = User.find(2).pref
  25. preferences.my_page_layout = {'top' => ['issuesassignedtome']}
  26. preferences.my_page_settings = {'issuesassignedtome' => {:columns => ['tracker', 'subject', 'due_date'], :sort => 'id:desc'}}
  27. preferences.save!
  28. log_user('jsmith', 'jsmith')
  29. visit '/my/page'
  30. assert page.has_css?('table.issues.sort-by-id')
  31. assert page.has_css?('table.issues.sort-desc')
  32. within('#block-issuesassignedtome') do
  33. # sort by tracker asc
  34. click_link 'Tracker'
  35. assert page.has_css?('table.issues.sort-by-tracker')
  36. assert page.has_css?('table.issues.sort-asc')
  37. # and desc
  38. click_link 'Tracker'
  39. assert page.has_css?('table.issues.sort-by-tracker')
  40. assert page.has_css?('table.issues.sort-desc')
  41. end
  42. # reload the page, sort order should be preserved
  43. visit '/my/page'
  44. assert page.has_css?('table.issues.sort-by-tracker')
  45. assert page.has_css?('table.issues.sort-desc')
  46. end
  47. def test_add_block
  48. preferences = User.find(2).pref
  49. preferences.my_page_layout = {'top' => ['issuesassignedtome']}
  50. preferences.save!
  51. log_user('jsmith', 'jsmith')
  52. visit '/my/page'
  53. select 'Watched issues', :from => 'Add'
  54. assert page.has_css?('#block-issueswatched')
  55. assert_equal({'top' => ['issueswatched', 'issuesassignedtome']},
  56. preferences.reload.my_page_layout)
  57. end
  58. def test_add_issue_query_block
  59. preferences = User.find(2).pref
  60. preferences.my_page_layout = {'top' => ['issuesassignedtome']}
  61. preferences.save!
  62. query = IssueQuery.create!(:name => 'My query', :user_id => 2)
  63. log_user('jsmith', 'jsmith')
  64. visit '/my/page'
  65. select 'Issues', :from => 'Add'
  66. # Select which query to display
  67. select query.name, :from => 'Custom query'
  68. click_on 'Save'
  69. assert page.has_css?('#block-issuequery table.issues')
  70. assert_equal({'top' => ['issuequery', 'issuesassignedtome']}, preferences.reload.my_page_layout)
  71. assert_equal({:query_id => query.id.to_s}, preferences.my_page_settings['issuequery'])
  72. end
  73. def test_remove_block
  74. preferences = User.find(2).pref
  75. preferences.my_page_layout = {'top' => ['issuesassignedtome']}
  76. preferences.save!
  77. log_user('jsmith', 'jsmith')
  78. visit '/my/page'
  79. within '#block-issuesassignedtome' do
  80. click_on 'Delete'
  81. end
  82. assert page.has_no_css?('#block-issuesassignedtome')
  83. assert_equal({'top' => []}, preferences.reload.my_page_layout)
  84. end
  85. end