##// END OF EJS Templates
Speeds up rendering of the project list for users who belong to hundreds of projects....
Speeds up rendering of the project list for users who belong to hundreds of projects. git-svn-id: http://svn.redmine.org/redmine/trunk@16123 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r15313:ec31b616982f
r15741:f8df935dcada
Show More
activities_controller_test.rb
172 lines | 5.6 KiB | text/x-ruby | RubyLexer
/ test / functional / activities_controller_test.rb
Jean-Philippe Lang
Functional tests cleanup....
r10709 # Redmine - project management software
Jean-Philippe Lang
Updates copyright for 2016....
r14856 # Copyright (C) 2006-2016 Jean-Philippe Lang
Jean-Philippe Lang
Functional tests cleanup....
r10709 #
# 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.
Jean-Baptiste Barth
Use absolute paths in test/**/* requires for Ruby 1.9.2 compatibility. #4050...
r4395 require File.expand_path('../../test_helper', __FILE__)
Eric Davis
Refactor: extract ProjectsController#activity to a new Activities controller....
r3933
Jean-Philippe Lang
Adds our own class for controller tests....
r15279 class ActivitiesControllerTest < Redmine::ControllerTest
Toshi MARUYAMA
Rails3: replace "all" fixtures at test/functional/activities_controller_test.rb...
r7366 fixtures :projects, :trackers, :issue_statuses, :issues,
:enumerations, :users, :issue_categories,
:projects_trackers,
:roles,
:member_roles,
:members,
:groups_users,
:enabled_modules,
:journals, :journal_details
Eric Davis
Refactor: extract ProjectsController#activity to a new Activities controller....
r3933
def test_project_index
get :index, :id => 1, :with_subprojects => 0
assert_response :success
Toshi MARUYAMA
remove trailing white-spaces from functional activities controller test....
r5676
Jean-Philippe Lang
Use #assert_select instead of #assert_tag....
r10836 assert_select 'h3', :text => /#{2.days.ago.to_date.day}/
assert_select 'dl dt.issue-edit a', :text => /(#{IssueStatus.find(2).name})/
Eric Davis
Refactor: extract ProjectsController#activity to a new Activities controller....
r3933 end
Toshi MARUYAMA
remove trailing white-spaces from functional activities controller test....
r5676
Jean-Philippe Lang
Adds functional tests for ActivitiesController....
r7866 def test_project_index_with_invalid_project_id_should_respond_404
get :index, :id => 299
assert_response 404
end
Eric Davis
Refactor: extract ProjectsController#activity to a new Activities controller....
r3933 def test_previous_project_index
Jean-Philippe Lang
Test fails when run at the beginning of the day....
r10898 get :index, :id => 1, :from => 2.days.ago.to_date
Eric Davis
Refactor: extract ProjectsController#activity to a new Activities controller....
r3933 assert_response :success
Toshi MARUYAMA
remove trailing white-spaces from functional activities controller test....
r5676
Jean-Philippe Lang
Use #assert_select instead of #assert_tag....
r10836 assert_select 'h3', :text => /#{3.days.ago.to_date.day}/
Jean-Philippe Lang
Removed that quote in a fixture subject....
r13393 assert_select 'dl dt.issue a', :text => /Cannot print recipes/
Eric Davis
Refactor: extract ProjectsController#activity to a new Activities controller....
r3933 end
Toshi MARUYAMA
remove trailing white-spaces from functional activities controller test....
r5676
Eric Davis
Refactor: extract ProjectsController#activity to a new Activities controller....
r3933 def test_global_index
Toshi MARUYAMA
fix test_global_index of functional activities controller test fails around UTC 00:00...
r9688 @request.session[:user_id] = 1
Eric Davis
Refactor: extract ProjectsController#activity to a new Activities controller....
r3933 get :index
assert_response :success
Toshi MARUYAMA
remove trailing white-spaces from functional activities controller test....
r5676
Toshi MARUYAMA
fix test_global_index of functional activities controller test fails around UTC 00:00...
r9688 i5 = Issue.find(5)
d5 = User.find(1).time_to_date(i5.created_on)
Jean-Philippe Lang
Use #assert_select instead of #assert_tag....
r10836
assert_select 'h3', :text => /#{d5.day}/
assert_select 'dl dt.issue a', :text => /Subproject issue/
Eric Davis
Refactor: extract ProjectsController#activity to a new Activities controller....
r3933 end
Toshi MARUYAMA
remove trailing white-spaces from functional activities controller test....
r5676
Eric Davis
Refactor: extract ProjectsController#activity to a new Activities controller....
r3933 def test_user_index
Toshi MARUYAMA
fix test_user_index of activities controller test fails at Japanese morning and afternoon...
r9631 @request.session[:user_id] = 1
Eric Davis
Refactor: extract ProjectsController#activity to a new Activities controller....
r3933 get :index, :user_id => 2
assert_response :success
Toshi MARUYAMA
remove trailing white-spaces from functional activities controller test....
r5676
Jean-Philippe Lang
Quote values in DOM selectors for Nokogiri compatibility....
r13237 assert_select 'h2 a[href="/users/2"]', :text => 'John Smith'
Jean-Philippe Lang
Fixed that link to user is escaped in activity title (#11124)....
r9603
Toshi MARUYAMA
fix test_user_index of activities controller test fails at Japanese morning and afternoon...
r9631 i1 = Issue.find(1)
d1 = User.find(1).time_to_date(i1.created_on)
Jean-Philippe Lang
Use #assert_select instead of #assert_tag....
r10836 assert_select 'h3', :text => /#{d1.day}/
Jean-Philippe Lang
Removed that quote in a fixture subject....
r13393 assert_select 'dl dt.issue a', :text => /Cannot print recipes/
Eric Davis
Refactor: extract ProjectsController#activity to a new Activities controller....
r3933 end
Toshi MARUYAMA
remove trailing white-spaces from functional activities controller test....
r5676
Jean-Philippe Lang
Adds functional tests for ActivitiesController....
r7866 def test_user_index_with_invalid_user_id_should_respond_404
get :index, :user_id => 299
assert_response 404
end
Eric Davis
Refactor: extract ProjectsController#activity to a new Activities controller....
r3933 def test_index_atom_feed
Etienne Massip
Fixed double escaping of Atom feed links....
r8526 get :index, :format => 'atom', :with_subprojects => 0
Eric Davis
Refactor: extract ProjectsController#activity to a new Activities controller....
r3933 assert_response :success
Etienne Massip
Fixed double escaping of Atom feed links....
r8526
Jean-Philippe Lang
Use #assert_select instead of #assert_tag....
r10836 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
Etienne Massip
Fixed double escaping of Atom feed links....
r8526 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
Jean-Philippe Lang
Use #assert_select instead of #assert_tag....
r10836 assert_select 'feed' do
Jean-Philippe Lang
Upgrade to Rails 4.2.0 (#14534)....
r13510 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'
Jean-Philippe Lang
Use #assert_select instead of #assert_tag....
r10836 assert_select 'entry' do
assert_select 'link[href=?]', 'http://test.host/issues/11'
end
end
Eric Davis
Refactor: extract ProjectsController#activity to a new Activities controller....
r3933 end
Jean-Philippe Lang
Adds functional tests for ActivitiesController....
r7866
def test_index_atom_feed_with_one_item_type
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 with_settings :default_language => 'en' do
get :index, :format => 'atom', :show_issues => '1'
assert_response :success
assert_select 'title', :text => /Issues/
end
Jean-Philippe Lang
Adds functional tests for ActivitiesController....
r7866 end
Jean-Philippe Lang
Private issue notes (#1554)....
r10336
Jean-Philippe Lang
Adds a few functional tests....
r13336 def test_index_atom_feed_with_user
get :index, :user_id => 2, :format => 'atom'
assert_response :success
assert_select 'title', :text => "Redmine: #{User.find(2).name}"
end
Jean-Philippe Lang
Private issue notes (#1554)....
r10336 def test_index_should_show_private_notes_with_permission_only
Jean-Philippe Lang
Removes calls to #assert_template and #assigns in functional tests....
r15313 journal = Journal.create!(:journalized => Issue.find(2), :notes => 'Private notes', :private_notes => true)
Jean-Philippe Lang
Private issue notes (#1554)....
r10336 @request.session[:user_id] = 2
get :index
assert_response :success
Jean-Philippe Lang
Removes calls to #assert_template and #assigns in functional tests....
r15313 assert_select 'dl', :text => /Private notes/
Jean-Philippe Lang
Private issue notes (#1554)....
r10336
Role.find(1).remove_permission! :view_private_notes
get :index
assert_response :success
Jean-Philippe Lang
Removes calls to #assert_template and #assigns in functional tests....
r15313 assert_select 'dl', :text => /Private notes/, :count => 0
Jean-Philippe Lang
Private issue notes (#1554)....
r10336 end
Jean-Philippe Lang
Activity page to remember user's selection of activities (#1605)....
r14296
def test_index_with_submitted_scope_should_save_as_preference
@request.session[:user_id] = 2
get :index, :show_issues => '1', :show_messages => '1', :submit => 'Apply'
assert_response :success
assert_equal %w(issues messages), User.find(2).pref.activity_scope.sort
end
def test_index_scope_should_default_to_user_preference
pref = User.find(2).pref
pref.activity_scope = %w(issues news)
pref.save!
@request.session[:user_id] = 2
get :index
assert_response :success
Jean-Philippe Lang
Removes calls to #assert_template and #assigns in functional tests....
r15313
assert_select '#activity_scope_form' do
assert_select 'input[checked=checked]', 2
assert_select 'input[name=show_issues][checked=checked]'
assert_select 'input[name=show_news][checked=checked]'
end
Jean-Philippe Lang
Activity page to remember user's selection of activities (#1605)....
r14296 end
Eric Davis
Refactor: extract ProjectsController#activity to a new Activities controller....
r3933 end