annotate .svn/pristine/f1/f12ea0342f077f022ecf07312830410824f9f131.svn-base @ 1298:4f746d8966dd redmine_2.3_integration

Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author Chris Cannam
date Fri, 14 Jun 2013 09:28:30 +0100
parents 622f24f53b42
children
rev   line source
Chris@1295 1 require File.expand_path('../../test_helper', __FILE__)
Chris@1295 2
Chris@1295 3 class ActivitiesControllerTest < ActionController::TestCase
Chris@1295 4 fixtures :projects, :trackers, :issue_statuses, :issues,
Chris@1295 5 :enumerations, :users, :issue_categories,
Chris@1295 6 :projects_trackers,
Chris@1295 7 :roles,
Chris@1295 8 :member_roles,
Chris@1295 9 :members,
Chris@1295 10 :groups_users,
Chris@1295 11 :enabled_modules,
Chris@1295 12 :workflows,
Chris@1295 13 :journals, :journal_details
Chris@1295 14
Chris@1295 15
Chris@1295 16 def test_project_index
Chris@1295 17 get :index, :id => 1, :with_subprojects => 0
Chris@1295 18 assert_response :success
Chris@1295 19 assert_template 'index'
Chris@1295 20 assert_not_nil assigns(:events_by_day)
Chris@1295 21
Chris@1295 22 assert_tag :tag => "h3",
Chris@1295 23 :content => /#{2.days.ago.to_date.day}/,
Chris@1295 24 :sibling => { :tag => "dl",
Chris@1295 25 :child => { :tag => "dt",
Chris@1295 26 :attributes => { :class => /issue-edit/ },
Chris@1295 27 :child => { :tag => "a",
Chris@1295 28 :content => /(#{IssueStatus.find(2).name})/,
Chris@1295 29 }
Chris@1295 30 }
Chris@1295 31 }
Chris@1295 32 end
Chris@1295 33
Chris@1295 34 def test_project_index_with_invalid_project_id_should_respond_404
Chris@1295 35 get :index, :id => 299
Chris@1295 36 assert_response 404
Chris@1295 37 end
Chris@1295 38
Chris@1295 39 def test_previous_project_index
Chris@1295 40 get :index, :id => 1, :from => 3.days.ago.to_date
Chris@1295 41 assert_response :success
Chris@1295 42 assert_template 'index'
Chris@1295 43 assert_not_nil assigns(:events_by_day)
Chris@1295 44
Chris@1295 45 assert_tag :tag => "h3",
Chris@1295 46 :content => /#{3.day.ago.to_date.day}/,
Chris@1295 47 :sibling => { :tag => "dl",
Chris@1295 48 :child => { :tag => "dt",
Chris@1295 49 :attributes => { :class => /issue/ },
Chris@1295 50 :child => { :tag => "a",
Chris@1295 51 :content => /Can&#x27;t print recipes/,
Chris@1295 52 }
Chris@1295 53 }
Chris@1295 54 }
Chris@1295 55 end
Chris@1295 56
Chris@1295 57 def test_global_index
Chris@1295 58 @request.session[:user_id] = 1
Chris@1295 59 get :index
Chris@1295 60 assert_response :success
Chris@1295 61 assert_template 'index'
Chris@1295 62 assert_not_nil assigns(:events_by_day)
Chris@1295 63
Chris@1295 64 i5 = Issue.find(5)
Chris@1295 65 d5 = User.find(1).time_to_date(i5.created_on)
Chris@1295 66 assert_tag :tag => "h3",
Chris@1295 67 :content => /#{d5.day}/,
Chris@1295 68 :sibling => { :tag => "dl",
Chris@1295 69 :child => { :tag => "dt",
Chris@1295 70 :attributes => { :class => /issue/ },
Chris@1295 71 :child => { :tag => "a",
Chris@1295 72 :content => /Subproject issue/,
Chris@1295 73 }
Chris@1295 74 }
Chris@1295 75 }
Chris@1295 76 end
Chris@1295 77
Chris@1295 78 def test_user_index
Chris@1295 79 @request.session[:user_id] = 1
Chris@1295 80 get :index, :user_id => 2
Chris@1295 81 assert_response :success
Chris@1295 82 assert_template 'index'
Chris@1295 83 assert_not_nil assigns(:events_by_day)
Chris@1295 84
Chris@1295 85 assert_select 'h2 a[href=/users/2]', :text => 'John Smith'
Chris@1295 86
Chris@1295 87 i1 = Issue.find(1)
Chris@1295 88 d1 = User.find(1).time_to_date(i1.created_on)
Chris@1295 89
Chris@1295 90 assert_tag :tag => "h3",
Chris@1295 91 :content => /#{d1.day}/,
Chris@1295 92 :sibling => { :tag => "dl",
Chris@1295 93 :child => { :tag => "dt",
Chris@1295 94 :attributes => { :class => /issue/ },
Chris@1295 95 :child => { :tag => "a",
Chris@1295 96 :content => /Can&#x27;t print recipes/,
Chris@1295 97 }
Chris@1295 98 }
Chris@1295 99 }
Chris@1295 100 end
Chris@1295 101
Chris@1295 102 def test_user_index_with_invalid_user_id_should_respond_404
Chris@1295 103 get :index, :user_id => 299
Chris@1295 104 assert_response 404
Chris@1295 105 end
Chris@1295 106
Chris@1295 107 def test_index_atom_feed
Chris@1295 108 get :index, :format => 'atom', :with_subprojects => 0
Chris@1295 109 assert_response :success
Chris@1295 110 assert_template 'common/feed'
Chris@1295 111
Chris@1295 112 assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil },
Chris@1295 113 :attributes => {:rel => 'self', :href => 'http://test.host/activity.atom?with_subprojects=0'}
Chris@1295 114 assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil },
Chris@1295 115 :attributes => {:rel => 'alternate', :href => 'http://test.host/activity?with_subprojects=0'}
Chris@1295 116
Chris@1295 117 assert_tag :tag => 'entry', :child => {
Chris@1295 118 :tag => 'link',
Chris@1295 119 :attributes => {:href => 'http://test.host/issues/11'}}
Chris@1295 120 end
Chris@1295 121
Chris@1295 122 def test_index_atom_feed_with_explicit_selection
Chris@1295 123 get :index, :format => 'atom', :with_subprojects => 0,
Chris@1295 124 :show_changesets => 1,
Chris@1295 125 :show_documents => 1,
Chris@1295 126 :show_files => 1,
Chris@1295 127 :show_issues => 1,
Chris@1295 128 :show_messages => 1,
Chris@1295 129 :show_news => 1,
Chris@1295 130 :show_time_entries => 1,
Chris@1295 131 :show_wiki_edits => 1
Chris@1295 132
Chris@1295 133 assert_response :success
Chris@1295 134 assert_template 'common/feed'
Chris@1295 135
Chris@1295 136 assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil },
Chris@1295 137 :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'}
Chris@1295 138 assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil },
Chris@1295 139 :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'}
Chris@1295 140
Chris@1295 141 assert_tag :tag => 'entry', :child => {
Chris@1295 142 :tag => 'link',
Chris@1295 143 :attributes => {:href => 'http://test.host/issues/11'}}
Chris@1295 144 end
Chris@1295 145
Chris@1295 146 def test_index_atom_feed_with_one_item_type
Chris@1295 147 get :index, :format => 'atom', :show_issues => '1'
Chris@1295 148 assert_response :success
Chris@1295 149 assert_template 'common/feed'
Chris@1295 150 assert_tag :tag => 'title', :content => /Issues/
Chris@1295 151 end
Chris@1295 152
Chris@1295 153 def test_index_should_show_private_notes_with_permission_only
Chris@1295 154 journal = Journal.create!(:journalized => Issue.find(2), :notes => 'Private notes with searchkeyword', :private_notes => true)
Chris@1295 155 @request.session[:user_id] = 2
Chris@1295 156
Chris@1295 157 get :index
Chris@1295 158 assert_response :success
Chris@1295 159 assert_include journal, assigns(:events_by_day).values.flatten
Chris@1295 160
Chris@1295 161 Role.find(1).remove_permission! :view_private_notes
Chris@1295 162 get :index
Chris@1295 163 assert_response :success
Chris@1295 164 assert_not_include journal, assigns(:events_by_day).values.flatten
Chris@1295 165 end
Chris@1295 166 end