annotate .svn/pristine/f1/f12ea0342f077f022ecf07312830410824f9f131.svn-base @ 1327:287f201c2802 redmine-2.2-integration

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