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.

activities_controller_test.rb 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. require File.expand_path('../../test_helper', __FILE__)
  2. class ActivitiesControllerTest < ActionController::TestCase
  3. fixtures :projects, :trackers, :issue_statuses, :issues,
  4. :enumerations, :users, :issue_categories,
  5. :projects_trackers,
  6. :roles,
  7. :member_roles,
  8. :members,
  9. :groups_users,
  10. :enabled_modules,
  11. :workflows,
  12. :journals, :journal_details
  13. def test_project_index
  14. get :index, :id => 1, :with_subprojects => 0
  15. assert_response :success
  16. assert_template 'index'
  17. assert_not_nil assigns(:events_by_day)
  18. assert_tag :tag => "h3",
  19. :content => /#{2.days.ago.to_date.day}/,
  20. :sibling => { :tag => "dl",
  21. :child => { :tag => "dt",
  22. :attributes => { :class => /issue-edit/ },
  23. :child => { :tag => "a",
  24. :content => /(#{IssueStatus.find(2).name})/,
  25. }
  26. }
  27. }
  28. end
  29. def test_project_index_with_invalid_project_id_should_respond_404
  30. get :index, :id => 299
  31. assert_response 404
  32. end
  33. def test_previous_project_index
  34. get :index, :id => 1, :from => 3.days.ago.to_date
  35. assert_response :success
  36. assert_template 'index'
  37. assert_not_nil assigns(:events_by_day)
  38. assert_tag :tag => "h3",
  39. :content => /#{3.day.ago.to_date.day}/,
  40. :sibling => { :tag => "dl",
  41. :child => { :tag => "dt",
  42. :attributes => { :class => /issue/ },
  43. :child => { :tag => "a",
  44. :content => /#{Issue.find(1).subject}/,
  45. }
  46. }
  47. }
  48. end
  49. def test_global_index
  50. get :index
  51. assert_response :success
  52. assert_template 'index'
  53. assert_not_nil assigns(:events_by_day)
  54. assert_tag :tag => "h3",
  55. :content => /#{5.day.ago.to_date.day}/,
  56. :sibling => { :tag => "dl",
  57. :child => { :tag => "dt",
  58. :attributes => { :class => /issue/ },
  59. :child => { :tag => "a",
  60. :content => /#{Issue.find(5).subject}/,
  61. }
  62. }
  63. }
  64. end
  65. def test_user_index
  66. get :index, :user_id => 2
  67. assert_response :success
  68. assert_template 'index'
  69. assert_not_nil assigns(:events_by_day)
  70. assert_tag :tag => "h3",
  71. :content => /#{3.day.ago.to_date.day}/,
  72. :sibling => { :tag => "dl",
  73. :child => { :tag => "dt",
  74. :attributes => { :class => /issue/ },
  75. :child => { :tag => "a",
  76. :content => /#{Issue.find(1).subject}/,
  77. }
  78. }
  79. }
  80. end
  81. def test_user_index_with_invalid_user_id_should_respond_404
  82. get :index, :user_id => 299
  83. assert_response 404
  84. end
  85. def test_index_atom_feed
  86. get :index, :format => 'atom', :with_subprojects => 0
  87. assert_response :success
  88. assert_template 'common/feed'
  89. assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil },
  90. :attributes => {:rel => 'self', :href => 'http://test.host/activity.atom?with_subprojects=0'}
  91. assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil },
  92. :attributes => {:rel => 'alternate', :href => 'http://test.host/activity?with_subprojects=0'}
  93. assert_tag :tag => 'entry', :child => {
  94. :tag => 'link',
  95. :attributes => {:href => 'http://test.host/issues/11'}}
  96. end
  97. def test_index_atom_feed_with_explicit_selection
  98. get :index, :format => 'atom', :with_subprojects => 0,
  99. :show_changesets => 1,
  100. :show_documents => 1,
  101. :show_files => 1,
  102. :show_issues => 1,
  103. :show_messages => 1,
  104. :show_news => 1,
  105. :show_time_entries => 1,
  106. :show_wiki_edits => 1
  107. assert_response :success
  108. assert_template 'common/feed'
  109. assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil },
  110. :attributes => {:rel => 'self', :href => 'http://test.host/activity.atom?show_changesets=1&amp;show_documents=1&amp;show_files=1&amp;show_issues=1&amp;show_messages=1&amp;show_news=1&amp;show_time_entries=1&amp;show_wiki_edits=1&amp;with_subprojects=0'}
  111. assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil },
  112. :attributes => {:rel => 'alternate', :href => 'http://test.host/activity?show_changesets=1&amp;show_documents=1&amp;show_files=1&amp;show_issues=1&amp;show_messages=1&amp;show_news=1&amp;show_time_entries=1&amp;show_wiki_edits=1&amp;with_subprojects=0'}
  113. assert_tag :tag => 'entry', :child => {
  114. :tag => 'link',
  115. :attributes => {:href => 'http://test.host/issues/11'}}
  116. end
  117. def test_index_atom_feed_with_one_item_type
  118. get :index, :format => 'atom', :show_issues => '1'
  119. assert_response :success
  120. assert_template 'common/feed'
  121. assert_tag :tag => 'title', :content => /Issues/
  122. end
  123. end