2012-12-04 02:23:23 +04:00
|
|
|
# Redmine - project management software
|
2013-01-12 13:29:31 +04:00
|
|
|
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
2012-12-04 02:23:23 +04:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
2010-12-13 02:24:34 +03:00
|
|
|
require File.expand_path('../../test_helper', __FILE__)
|
2010-08-27 18:05:54 +04:00
|
|
|
|
|
|
|
class ActivitiesControllerTest < ActionController::TestCase
|
2011-09-24 08:20:08 +04:00
|
|
|
fixtures :projects, :trackers, :issue_statuses, :issues,
|
|
|
|
:enumerations, :users, :issue_categories,
|
|
|
|
:projects_trackers,
|
|
|
|
:roles,
|
|
|
|
:member_roles,
|
|
|
|
:members,
|
|
|
|
:groups_users,
|
|
|
|
:enabled_modules,
|
|
|
|
:workflows,
|
|
|
|
:journals, :journal_details
|
|
|
|
|
2010-08-27 18:05:54 +04:00
|
|
|
|
|
|
|
def test_project_index
|
|
|
|
get :index, :id => 1, :with_subprojects => 0
|
|
|
|
assert_response :success
|
|
|
|
assert_template 'index'
|
|
|
|
assert_not_nil assigns(:events_by_day)
|
2011-05-16 04:09:58 +04:00
|
|
|
|
2012-12-22 13:35:35 +04:00
|
|
|
assert_select 'h3', :text => /#{2.days.ago.to_date.day}/
|
|
|
|
assert_select 'dl dt.issue-edit a', :text => /(#{IssueStatus.find(2).name})/
|
2010-08-27 18:05:54 +04:00
|
|
|
end
|
2011-05-16 04:09:58 +04:00
|
|
|
|
2011-11-29 23:57:07 +04:00
|
|
|
def test_project_index_with_invalid_project_id_should_respond_404
|
|
|
|
get :index, :id => 299
|
|
|
|
assert_response 404
|
|
|
|
end
|
|
|
|
|
2010-08-27 18:05:54 +04:00
|
|
|
def test_previous_project_index
|
2013-01-06 13:54:24 +04:00
|
|
|
get :index, :id => 1, :from => 2.days.ago.to_date
|
2010-08-27 18:05:54 +04:00
|
|
|
assert_response :success
|
|
|
|
assert_template 'index'
|
|
|
|
assert_not_nil assigns(:events_by_day)
|
2011-05-16 04:09:58 +04:00
|
|
|
|
2012-12-22 13:35:35 +04:00
|
|
|
assert_select 'h3', :text => /#{3.days.ago.to_date.day}/
|
|
|
|
assert_select 'dl dt.issue a', :text => /Can't print recipes/
|
2010-08-27 18:05:54 +04:00
|
|
|
end
|
2011-05-16 04:09:58 +04:00
|
|
|
|
2010-08-27 18:05:54 +04:00
|
|
|
def test_global_index
|
2012-06-19 04:43:10 +04:00
|
|
|
@request.session[:user_id] = 1
|
2010-08-27 18:05:54 +04:00
|
|
|
get :index
|
|
|
|
assert_response :success
|
|
|
|
assert_template 'index'
|
|
|
|
assert_not_nil assigns(:events_by_day)
|
2011-05-16 04:09:58 +04:00
|
|
|
|
2012-06-19 04:43:10 +04:00
|
|
|
i5 = Issue.find(5)
|
|
|
|
d5 = User.find(1).time_to_date(i5.created_on)
|
2012-12-22 13:35:35 +04:00
|
|
|
|
|
|
|
assert_select 'h3', :text => /#{d5.day}/
|
|
|
|
assert_select 'dl dt.issue a', :text => /Subproject issue/
|
2010-08-27 18:05:54 +04:00
|
|
|
end
|
2011-05-16 04:09:58 +04:00
|
|
|
|
2010-08-27 18:05:54 +04:00
|
|
|
def test_user_index
|
2012-06-11 08:42:54 +04:00
|
|
|
@request.session[:user_id] = 1
|
2010-08-27 18:05:54 +04:00
|
|
|
get :index, :user_id => 2
|
|
|
|
assert_response :success
|
|
|
|
assert_template 'index'
|
|
|
|
assert_not_nil assigns(:events_by_day)
|
2011-05-16 04:09:58 +04:00
|
|
|
|
2012-06-09 14:32:34 +04:00
|
|
|
assert_select 'h2 a[href=/users/2]', :text => 'John Smith'
|
|
|
|
|
2012-06-11 08:42:54 +04:00
|
|
|
i1 = Issue.find(1)
|
|
|
|
d1 = User.find(1).time_to_date(i1.created_on)
|
|
|
|
|
2012-12-22 13:35:35 +04:00
|
|
|
assert_select 'h3', :text => /#{d1.day}/
|
|
|
|
assert_select 'dl dt.issue a', :text => /Can't print recipes/
|
2010-08-27 18:05:54 +04:00
|
|
|
end
|
2011-05-16 04:09:58 +04:00
|
|
|
|
2011-11-29 23:57:07 +04:00
|
|
|
def test_user_index_with_invalid_user_id_should_respond_404
|
|
|
|
get :index, :user_id => 299
|
|
|
|
assert_response 404
|
|
|
|
end
|
|
|
|
|
2010-08-27 18:05:54 +04:00
|
|
|
def test_index_atom_feed
|
2012-01-14 20:08:51 +04:00
|
|
|
get :index, :format => 'atom', :with_subprojects => 0
|
2010-08-27 18:05:54 +04:00
|
|
|
assert_response :success
|
2012-03-04 16:43:55 +04:00
|
|
|
assert_template 'common/feed'
|
2012-01-14 20:08:51 +04:00
|
|
|
|
2012-12-22 13:35:35 +04:00
|
|
|
assert_select 'feed' do
|
|
|
|
assert_select 'link[rel=self][href=?]', 'http://test.host/activity.atom?with_subprojects=0'
|
|
|
|
assert_select 'link[rel=alternate][href=?]', 'http://test.host/activity?with_subprojects=0'
|
|
|
|
assert_select 'entry' do
|
|
|
|
assert_select 'link[href=?]', 'http://test.host/issues/11'
|
|
|
|
end
|
|
|
|
end
|
2012-01-14 20:08:51 +04:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_index_atom_feed_with_explicit_selection
|
|
|
|
get :index, :format => 'atom', :with_subprojects => 0,
|
|
|
|
:show_changesets => 1,
|
|
|
|
:show_documents => 1,
|
|
|
|
:show_files => 1,
|
|
|
|
:show_issues => 1,
|
|
|
|
:show_messages => 1,
|
|
|
|
:show_news => 1,
|
|
|
|
:show_time_entries => 1,
|
|
|
|
:show_wiki_edits => 1
|
|
|
|
|
|
|
|
assert_response :success
|
2012-03-04 16:43:55 +04:00
|
|
|
assert_template 'common/feed'
|
2012-01-14 20:08:51 +04:00
|
|
|
|
2012-12-22 13:35:35 +04:00
|
|
|
assert_select 'feed' do
|
|
|
|
assert_select 'link[rel=self][href=?]', 'http://test.host/activity.atom?show_changesets=1&show_documents=1&show_files=1&show_issues=1&show_messages=1&show_news=1&show_time_entries=1&show_wiki_edits=1&with_subprojects=0'
|
|
|
|
assert_select 'link[rel=alternate][href=?]', 'http://test.host/activity?show_changesets=1&show_documents=1&show_files=1&show_issues=1&show_messages=1&show_news=1&show_time_entries=1&show_wiki_edits=1&with_subprojects=0'
|
|
|
|
assert_select 'entry' do
|
|
|
|
assert_select 'link[href=?]', 'http://test.host/issues/11'
|
|
|
|
end
|
|
|
|
end
|
2010-08-27 18:05:54 +04:00
|
|
|
end
|
2011-11-29 23:57:07 +04:00
|
|
|
|
|
|
|
def test_index_atom_feed_with_one_item_type
|
|
|
|
get :index, :format => 'atom', :show_issues => '1'
|
|
|
|
assert_response :success
|
2012-03-04 16:43:55 +04:00
|
|
|
assert_template 'common/feed'
|
2012-12-22 13:35:35 +04:00
|
|
|
|
|
|
|
assert_select 'title', :text => /Issues/
|
2011-11-29 23:57:07 +04:00
|
|
|
end
|
2012-10-04 01:36:19 +04:00
|
|
|
|
|
|
|
def test_index_should_show_private_notes_with_permission_only
|
|
|
|
journal = Journal.create!(:journalized => Issue.find(2), :notes => 'Private notes with searchkeyword', :private_notes => true)
|
|
|
|
@request.session[:user_id] = 2
|
|
|
|
|
|
|
|
get :index
|
|
|
|
assert_response :success
|
|
|
|
assert_include journal, assigns(:events_by_day).values.flatten
|
|
|
|
|
|
|
|
Role.find(1).remove_permission! :view_private_notes
|
|
|
|
get :index
|
|
|
|
assert_response :success
|
|
|
|
assert_not_include journal, assigns(:events_by_day).values.flatten
|
|
|
|
end
|
2010-08-27 18:05:54 +04:00
|
|
|
end
|