##// 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:

r15481:51227270bda4
r15741:f8df935dcada
Show More
issues_test.rb
283 lines | 9.9 KiB | text/x-ruby | RubyLexer
Jean-Philippe Lang
Adds User and Version custom field format that can be used to reference a project member or version in custom fields (#2096)....
r5152 # Redmine - project management software
Jean-Philippe Lang
Updates copyright for 2016....
r14856 # Copyright (C) 2006-2016 Jean-Philippe Lang
Jean-Philippe Lang
File viewer for attached text files....
r1506 #
# 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.
Toshi MARUYAMA
remove trailing white-spaces from test/integration/issues_test.rb....
r6534 #
Jean-Philippe Lang
File viewer for attached text files....
r1506 # 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.
Toshi MARUYAMA
remove trailing white-spaces from test/integration/issues_test.rb....
r6534 #
Jean-Philippe Lang
File viewer for attached text files....
r1506 # 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__)
Jean-Philippe Lang
added issues integration tests...
r121
Jean-Philippe Lang
Moved helpers for integration tests in a specific class....
r13298 class IssuesTest < Redmine::IntegrationTest
Toshi MARUYAMA
remove trailing white-spaces from test/integration/issues_test.rb....
r6534 fixtures :projects,
Jean-Philippe Lang
Add support for multiple email addresses per user (#4244)....
r13504 :users, :email_addresses,
Jean-Philippe Lang
Merged Rails 2.1 compatibility branch....
r1609 :roles,
:members,
Jean-Baptiste Barth
Fixed some more test/integration/*_test.rb breaking when run alone (#12285)...
r10566 :member_roles,
Jean-Philippe Lang
Added default value for custom fields. Fixed javascript on custom field form for project and user custom fields....
r1076 :trackers,
:projects_trackers,
Jean-Philippe Lang
Merged Rails 2.1 compatibility branch....
r1609 :enabled_modules,
Jean-Philippe Lang
Added default value for custom fields. Fixed javascript on custom field form for project and user custom fields....
r1076 :issue_statuses,
:issues,
:enumerations,
:custom_fields,
:custom_values,
Jean-Philippe Lang
Missing fixtures....
r14388 :custom_fields_trackers,
:attachments
Jean-Philippe Lang
added issues integration tests...
r121
# create an issue
def test_add_issue
log_user('jsmith', 'jsmith')
Jean-Philippe Lang
Moved tracker_id param....
r14390
get '/projects/ecookbook/issues/new'
Jean-Philippe Lang
added issues integration tests...
r121 assert_response :success
Toshi MARUYAMA
remove trailing white-spaces from test/integration/issues_test.rb....
r6534
Jean-Philippe Lang
Code cleanup....
r14389 issue = new_record(Issue) do
Jean-Philippe Lang
Moved tracker_id param....
r14390 post '/projects/ecookbook/issues',
:issue => { :tracker_id => "1",
:start_date => "2006-12-26",
Toshi MARUYAMA
remove trailing white-spaces from test/integration/issues_test.rb....
r6534 :priority_id => "4",
:subject => "new test issue",
:category_id => "",
:description => "new issue",
Jean-Philippe Lang
added issues integration tests...
r121 :done_ratio => "0",
:due_date => "",
Jean-Philippe Lang
Added default value for custom fields. Fixed javascript on custom field form for project and user custom fields....
r1076 :assigned_to_id => "" },
:custom_fields => {'2' => 'Value for field 2'}
Jean-Philippe Lang
Code cleanup....
r14389 end
Jean-Philippe Lang
added issues integration tests...
r121 # check redirection
Jean-Philippe Lang
Merged Rails 2.2 branch. Redmine now requires Rails 2.2.2....
r2430 assert_redirected_to :controller => 'issues', :action => 'show', :id => issue
Jean-Philippe Lang
added issues integration tests...
r121 follow_redirect!
Toshi MARUYAMA
remove trailing white-spaces from test/integration/issues_test.rb....
r6534 # check issue attributes
Jean-Philippe Lang
added issues integration tests...
r121 assert_equal 'jsmith', issue.author.login
assert_equal 1, issue.project.id
assert_equal 1, issue.status.id
end
Jean-Philippe Lang
Adds buit-in groups to give specific permissions to anonymous and non members users per project (#17976)....
r13053 def test_create_issue_by_anonymous_without_permission_should_fail
Role.anonymous.remove_permission! :add_issues
assert_no_difference 'Issue.count' do
Jean-Philippe Lang
Leading slash required with Rails 4.2....
r13401 post '/projects/1/issues', :tracker_id => "1", :issue => {:subject => "new test issue"}
Jean-Philippe Lang
Adds buit-in groups to give specific permissions to anonymous and non members users per project (#17976)....
r13053 end
assert_response 302
end
def test_create_issue_by_anonymous_with_custom_permission_should_succeed
Role.anonymous.remove_permission! :add_issues
Member.create!(:project_id => 1, :principal => Group.anonymous, :role_ids => [3])
Jean-Philippe Lang
Code cleanup....
r14389 issue = new_record(Issue) do
Jean-Philippe Lang
Leading slash required with Rails 4.2....
r13401 post '/projects/1/issues', :tracker_id => "1", :issue => {:subject => "new test issue"}
Jean-Philippe Lang
Code cleanup....
r14389 assert_response 302
Jean-Philippe Lang
Adds buit-in groups to give specific permissions to anonymous and non members users per project (#17976)....
r13053 end
assert_equal User.anonymous, issue.author
end
Jean-Philippe Lang
added issues integration tests...
r121 # add then remove 2 attachments to an issue
Toshi MARUYAMA
Fix typo "attachements" in test/integration/issues_test.rb....
r5169 def test_issue_attachments
Jean-Philippe Lang
added issues integration tests...
r121 log_user('jsmith', 'jsmith')
Jean-Philippe Lang
File viewer for attached text files....
r1506 set_tmp_attachments_directory
Jean-Philippe Lang
added issues integration tests...
r121
Jean-Philippe Lang
Code cleanup....
r14389 attachment = new_record(Attachment) do
put '/issues/1',
:notes => 'Some notes',
:attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'This is an attachment'}}
assert_redirected_to "/issues/1"
end
Toshi MARUYAMA
remove trailing white-spaces from test/integration/issues_test.rb....
r6534
Jean-Philippe Lang
added issues integration tests...
r121 assert_equal Issue.find(1), attachment.container
Jean-Philippe Lang
Code cleanup....
r14389 assert_equal 'testfile.txt', attachment.filename
Jean-Philippe Lang
Adds an optional description to attachments....
r1166 assert_equal 'This is an attachment', attachment.description
Jean-Philippe Lang
added issues integration tests...
r121 # verify the size of the attachment stored in db
Jean-Philippe Lang
file upload test now uses ActionController::TestUploadedFile...
r248 #assert_equal file_data_1.length, attachment.filesize
Jean-Philippe Lang
added issues integration tests...
r121 # verify that the attachment was written to disk
assert File.exist?(attachment.diskfile)
Toshi MARUYAMA
remove trailing white-spaces from test/integration/issues_test.rb....
r6534
Jean-Philippe Lang
added issues integration tests...
r121 # remove the attachments
Issue.find(1).attachments.each(&:destroy)
assert_equal 0, Issue.find(1).attachments.length
end
Toshi MARUYAMA
remove trailing white-spaces from test/integration/issues_test.rb....
r6534
Jean-Philippe Lang
Error with MS SQL when displaying an issue from a list grouped and sorted by fixed version (#23839)....
r15470 def test_next_and_previous_links_should_be_displayed_after_query_grouped_and_sorted_by_version
with_settings :default_language => 'en' do
Jean-Philippe Lang
Test failures....
r15481 get '/projects/ecookbook/issues?set_filter=1&group_by=fixed_version&sort=priority:desc,fixed_version,id'
Jean-Philippe Lang
Error with MS SQL when displaying an issue from a list grouped and sorted by fixed version (#23839)....
r15470 assert_response :success
assert_select 'td.id', :text => '5'
get '/issues/5'
assert_response :success
assert_select '.next-prev-links .position', :text => '5 of 6'
end
end
Jean-Philippe Lang
Previous/Next navigation on a issue is not displayed on r15639 and later (#23781)....
r15468 def test_next_and_previous_links_should_be_displayed_after_filter
with_settings :default_language => 'en' do
get '/projects/ecookbook/issues?set_filter=1&tracker_id=1'
assert_response :success
assert_select 'td.id', :text => '5'
get '/issues/5'
assert_response :success
assert_select '.next-prev-links .position', :text => '3 of 5'
end
end
def test_next_and_previous_links_should_be_displayed_after_saved_query
query = IssueQuery.create!(:name => 'Calendar Query',
:visibility => IssueQuery::VISIBILITY_PUBLIC,
:filters => {'tracker_id' => {:operator => '=', :values => ['1']}}
)
with_settings :default_language => 'en' do
get "/projects/ecookbook/issues?set_filter=1&query_id=#{query.id}"
assert_response :success
assert_select 'td.id', :text => '5'
get '/issues/5'
assert_response :success
assert_select '.next-prev-links .position', :text => '6 of 8'
end
end
Jean-Philippe Lang
Removed obsolete routes....
r7897 def test_other_formats_links_on_index
Jean-Philippe Lang
Fixed: export links on the issue list lose project param after applying a filter (#2908)....
r2486 get '/projects/ecookbook/issues'
Toshi MARUYAMA
remove trailing white-spaces from test/integration/issues_test.rb....
r6534
Jean-Philippe Lang
Fixed: export links on the issue list lose project param after applying a filter (#2908)....
r2486 %w(Atom PDF CSV).each do |format|
Jean-Philippe Lang
Replaced remaining #assert_tag with #assert_select....
r13242 assert_select 'a[rel=nofollow][href=?]', "/projects/ecookbook/issues.#{format.downcase}", :text => format
Jean-Philippe Lang
Fixed: export links on the issue list lose project param after applying a filter (#2908)....
r2486 end
end
Toshi MARUYAMA
remove trailing white-spaces from test/integration/issues_test.rb....
r6534
Jean-Philippe Lang
Removed obsolete routes....
r7897 def test_other_formats_links_on_index_without_project_id_in_url
get '/issues', :project_id => 'ecookbook'
Toshi MARUYAMA
remove trailing white-spaces from test/integration/issues_test.rb....
r6534
Jean-Philippe Lang
Fixed: export links on the issue list lose project param after applying a filter (#2908)....
r2486 %w(Atom PDF CSV).each do |format|
Jean-Philippe Lang
Don't generate urls with params....
r15249 assert_select 'a[rel=nofollow][href=?]', "/issues.#{format.downcase}?project_id=ecookbook", :text => format
Jean-Philippe Lang
Fixed: export links on the issue list lose project param after applying a filter (#2908)....
r2486 end
end
Toshi MARUYAMA
remove trailing white-spaces from test/integration/issues_test.rb....
r6534
Jean-Philippe Lang
Removed obsolete routes....
r7897 def test_pagination_links_on_index
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 with_settings :per_page_options => '2' do
get '/projects/ecookbook/issues'
Toshi MARUYAMA
remove trailing white-spaces from test/integration/issues_test.rb....
r6534
Jean-Philippe Lang
Replaced remaining #assert_tag with #assert_select....
r13242 assert_select 'a[href=?]', '/projects/ecookbook/issues?page=2', :text => '2'
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 end
Jean-Philippe Lang
Fixed: export links on the issue list lose project param after applying a filter (#2908)....
r2486 end
Toshi MARUYAMA
remove trailing white-spaces from test/integration/issues_test.rb....
r6534
Jean-Philippe Lang
Don't generate pagination links with params....
r15245 def test_pagination_links_should_preserve_query_parameters
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 with_settings :per_page_options => '2' do
Jean-Philippe Lang
Don't generate pagination links with params....
r15245 get '/projects/ecookbook/issues?foo=bar'
assert_select 'a[href=?]', '/projects/ecookbook/issues?foo=bar&page=2', :text => '2'
Jean-Philippe Lang
Merged rails-4.1 branch (#14534)....
r13100 end
Jean-Philippe Lang
Fixed: export links on the issue list lose project param after applying a filter (#2908)....
r2486 end
Toshi MARUYAMA
remove trailing white-spaces from test/integration/issues_test.rb....
r6534
Jean-Philippe Lang
Don't generate sort links with params....
r15246 def test_pagination_links_should_not_use_params_as_url_options
with_settings :per_page_options => '2' do
get '/projects/ecookbook/issues?host=foo'
assert_select 'a[href=?]', '/projects/ecookbook/issues?host=foo&page=2', :text => '2'
end
end
def test_sort_links_on_index
get '/projects/ecookbook/issues'
assert_select 'a[href=?]', '/projects/ecookbook/issues?sort=subject%2Cid%3Adesc', :text => 'Subject'
end
def test_sort_links_should_preserve_query_parameters
get '/projects/ecookbook/issues?foo=bar'
assert_select 'a[href=?]', '/projects/ecookbook/issues?foo=bar&sort=subject%2Cid%3Adesc', :text => 'Subject'
end
def test_sort_links_should_not_use_params_as_url_options
get '/projects/ecookbook/issues?host=foo'
assert_select 'a[href=?]', '/projects/ecookbook/issues?host=foo&sort=subject%2Cid%3Adesc', :text => 'Subject'
end
Jean-Philippe Lang
Adds User and Version custom field format that can be used to reference a project member or version in custom fields (#2096)....
r5152 def test_issue_with_user_custom_field
@field = IssueCustomField.create!(:name => 'Tester', :field_format => 'user', :is_for_all => true, :trackers => Tracker.all)
Role.anonymous.add_permission! :add_issues, :edit_issues
Jean-Philippe Lang
Use .distinct instead of .uniq....
r15272 users = Project.find(1).users.sort
Jean-Philippe Lang
Adds User and Version custom field format that can be used to reference a project member or version in custom fields (#2096)....
r5152 tester = users.first
Toshi MARUYAMA
remove trailing white-spaces from test/integration/issues_test.rb....
r6534
Jean-Philippe Lang
Adds User and Version custom field format that can be used to reference a project member or version in custom fields (#2096)....
r5152 # Issue form
get '/projects/ecookbook/issues/new'
assert_response :success
Jean-Philippe Lang
Replaced remaining #assert_tag with #assert_select....
r13242 assert_select 'select[name=?]', "issue[custom_field_values][#{@field.id}]" do
assert_select 'option', users.size + 1 # +1 for blank value
assert_select 'option[value=?]', tester.id.to_s, :text => tester.name
end
Toshi MARUYAMA
remove trailing white-spaces from test/integration/issues_test.rb....
r6534
Jean-Philippe Lang
Adds User and Version custom field format that can be used to reference a project member or version in custom fields (#2096)....
r5152 # Create issue
Jean-Philippe Lang
Code cleanup....
r14389 issue = new_record(Issue) do
Toshi MARUYAMA
remove trailing white-spaces from test/integration/issues_test.rb....
r6534 post '/projects/ecookbook/issues',
Jean-Philippe Lang
Adds User and Version custom field format that can be used to reference a project member or version in custom fields (#2096)....
r5152 :issue => {
:tracker_id => '1',
:priority_id => '4',
:subject => 'Issue with user custom field',
:custom_field_values => {@field.id.to_s => users.first.id.to_s}
}
Jean-Philippe Lang
Code cleanup....
r14389 assert_response 302
Jean-Philippe Lang
Adds User and Version custom field format that can be used to reference a project member or version in custom fields (#2096)....
r5152 end
Toshi MARUYAMA
remove trailing white-spaces from test/integration/issues_test.rb....
r6534
Jean-Philippe Lang
Adds User and Version custom field format that can be used to reference a project member or version in custom fields (#2096)....
r5152 # Issue view
follow_redirect!
Jean-Philippe Lang
Render issue attributes using divs instead of a table for responsiveness (#19097)....
r14466 assert_select ".cf_#{@field.id}" do
assert_select '.label', :text => 'Tester:'
assert_select '.value', :text => tester.name
end
Jean-Philippe Lang
Replaced remaining #assert_tag with #assert_select....
r13242 assert_select 'select[name=?]', "issue[custom_field_values][#{@field.id}]" do
assert_select 'option', users.size + 1 # +1 for blank value
assert_select 'option[value=?][selected=selected]', tester.id.to_s, :text => tester.name
end
Toshi MARUYAMA
remove trailing white-spaces from test/integration/issues_test.rb....
r6534
Jean-Philippe Lang
Adds User and Version custom field format that can be used to reference a project member or version in custom fields (#2096)....
r5152 new_tester = users[1]
Toshi MARUYAMA
use English at integration IssuesTest#test_issue_with_user_custom_field...
r13271 with_settings :default_language => 'en' do
# Update issue
assert_difference 'Journal.count' do
put "/issues/#{issue.id}",
:notes => 'Updating custom field',
:issue => {
:custom_field_values => {@field.id.to_s => new_tester.id.to_s}
}
assert_redirected_to "/issues/#{issue.id}"
end
# Issue view
follow_redirect!
assert_select 'ul.details li', :text => "Tester changed from #{tester} to #{new_tester}"
Jean-Philippe Lang
Adds User and Version custom field format that can be used to reference a project member or version in custom fields (#2096)....
r5152 end
end
Jean-Philippe Lang
Removes all #verify calls in controllers. Verification is handled at routing level now that the default route is removed....
r8941
def test_update_using_invalid_http_verbs
subject = 'Updated by an invalid http verb'
get '/issues/update/1', {:issue => {:subject => subject}}, credentials('jsmith')
assert_response 404
assert_not_equal subject, Issue.find(1).subject
post '/issues/1', {:issue => {:subject => subject}}, credentials('jsmith')
Jean-Philippe Lang
Merged rails-3.2 branch....
r9346 assert_response 404
Jean-Philippe Lang
Removes all #verify calls in controllers. Verification is handled at routing level now that the default route is removed....
r8941 assert_not_equal subject, Issue.find(1).subject
end
def test_get_watch_should_be_invalid
assert_no_difference 'Watcher.count' do
get '/watchers/watch?object_type=issue&object_id=1', {}, credentials('jsmith')
Jean-Philippe Lang
Merged rails-3.2 branch....
r9346 assert_response 404
Jean-Philippe Lang
Removes all #verify calls in controllers. Verification is handled at routing level now that the default route is removed....
r8941 end
end
Jean-Philippe Lang
added issues integration tests...
r121 end