annotate test/integration/issues_test.rb @ 904:0a8317a50fa0 redmine-1.1

Close obsolete branch redmine-1.1
author Chris Cannam
date Fri, 14 Jan 2011 12:53:21 +0000
parents af80e5618e9b
children cbce1fd3b1b7
rev   line source
Chris@0 1 # redMine - project management software
Chris@0 2 # Copyright (C) 2006-2008 Jean-Philippe Lang
Chris@0 3 #
Chris@0 4 # This program is free software; you can redistribute it and/or
Chris@0 5 # modify it under the terms of the GNU General Public License
Chris@0 6 # as published by the Free Software Foundation; either version 2
Chris@0 7 # of the License, or (at your option) any later version.
Chris@0 8 #
Chris@0 9 # This program is distributed in the hope that it will be useful,
Chris@0 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@0 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@0 12 # GNU General Public License for more details.
Chris@0 13 #
Chris@0 14 # You should have received a copy of the GNU General Public License
Chris@0 15 # along with this program; if not, write to the Free Software
Chris@0 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@0 17
Chris@117 18 require File.expand_path('../../test_helper', __FILE__)
Chris@0 19
Chris@0 20 class IssuesTest < ActionController::IntegrationTest
Chris@0 21 fixtures :projects,
Chris@0 22 :users,
Chris@0 23 :roles,
Chris@0 24 :members,
Chris@0 25 :trackers,
Chris@0 26 :projects_trackers,
Chris@0 27 :enabled_modules,
Chris@0 28 :issue_statuses,
Chris@0 29 :issues,
Chris@0 30 :enumerations,
Chris@0 31 :custom_fields,
Chris@0 32 :custom_values,
Chris@0 33 :custom_fields_trackers
Chris@0 34
Chris@0 35 # create an issue
Chris@0 36 def test_add_issue
Chris@0 37 log_user('jsmith', 'jsmith')
Chris@0 38 get 'projects/1/issues/new', :tracker_id => '1'
Chris@0 39 assert_response :success
Chris@0 40 assert_template 'issues/new'
Chris@0 41
Chris@0 42 post 'projects/1/issues', :tracker_id => "1",
Chris@0 43 :issue => { :start_date => "2006-12-26",
Chris@0 44 :priority_id => "4",
Chris@0 45 :subject => "new test issue",
Chris@0 46 :category_id => "",
Chris@0 47 :description => "new issue",
Chris@0 48 :done_ratio => "0",
Chris@0 49 :due_date => "",
Chris@0 50 :assigned_to_id => "" },
Chris@0 51 :custom_fields => {'2' => 'Value for field 2'}
Chris@0 52 # find created issue
Chris@0 53 issue = Issue.find_by_subject("new test issue")
Chris@0 54 assert_kind_of Issue, issue
Chris@0 55
Chris@0 56 # check redirection
Chris@0 57 assert_redirected_to :controller => 'issues', :action => 'show', :id => issue
Chris@0 58 follow_redirect!
Chris@0 59 assert_equal issue, assigns(:issue)
Chris@0 60
Chris@0 61 # check issue attributes
Chris@0 62 assert_equal 'jsmith', issue.author.login
Chris@0 63 assert_equal 1, issue.project.id
Chris@0 64 assert_equal 1, issue.status.id
Chris@0 65 end
Chris@0 66
Chris@0 67 # add then remove 2 attachments to an issue
Chris@0 68 def test_issue_attachements
Chris@0 69 log_user('jsmith', 'jsmith')
Chris@0 70 set_tmp_attachments_directory
Chris@0 71
chris@22 72 put 'issues/1',
Chris@0 73 :notes => 'Some notes',
Chris@0 74 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'This is an attachment'}}
chris@37 75 assert_redirected_to "/issues/1"
Chris@0 76
Chris@0 77 # make sure attachment was saved
Chris@0 78 attachment = Issue.find(1).attachments.find_by_filename("testfile.txt")
Chris@0 79 assert_kind_of Attachment, attachment
Chris@0 80 assert_equal Issue.find(1), attachment.container
Chris@0 81 assert_equal 'This is an attachment', attachment.description
Chris@0 82 # verify the size of the attachment stored in db
Chris@0 83 #assert_equal file_data_1.length, attachment.filesize
Chris@0 84 # verify that the attachment was written to disk
Chris@0 85 assert File.exist?(attachment.diskfile)
Chris@0 86
Chris@0 87 # remove the attachments
Chris@0 88 Issue.find(1).attachments.each(&:destroy)
Chris@0 89 assert_equal 0, Issue.find(1).attachments.length
Chris@0 90 end
Chris@0 91
Chris@0 92 def test_other_formats_links_on_get_index
Chris@0 93 get '/projects/ecookbook/issues'
Chris@0 94
Chris@0 95 %w(Atom PDF CSV).each do |format|
Chris@0 96 assert_tag :a, :content => format,
Chris@0 97 :attributes => { :href => "/projects/ecookbook/issues.#{format.downcase}",
Chris@0 98 :rel => 'nofollow' }
Chris@0 99 end
Chris@0 100 end
Chris@0 101
Chris@0 102 def test_other_formats_links_on_post_index_without_project_id_in_url
Chris@0 103 post '/issues', :project_id => 'ecookbook'
Chris@0 104
Chris@0 105 %w(Atom PDF CSV).each do |format|
Chris@0 106 assert_tag :a, :content => format,
Chris@0 107 :attributes => { :href => "/projects/ecookbook/issues.#{format.downcase}",
Chris@0 108 :rel => 'nofollow' }
Chris@0 109 end
Chris@0 110 end
Chris@0 111
Chris@0 112 def test_pagination_links_on_get_index
Chris@0 113 Setting.per_page_options = '2'
Chris@0 114 get '/projects/ecookbook/issues'
Chris@0 115
Chris@0 116 assert_tag :a, :content => '2',
Chris@0 117 :attributes => { :href => '/projects/ecookbook/issues?page=2' }
Chris@0 118
Chris@0 119 end
Chris@0 120
Chris@0 121 def test_pagination_links_on_post_index_without_project_id_in_url
Chris@0 122 Setting.per_page_options = '2'
Chris@0 123 post '/issues', :project_id => 'ecookbook'
Chris@0 124
Chris@0 125 assert_tag :a, :content => '2',
Chris@0 126 :attributes => { :href => '/projects/ecookbook/issues?page=2' }
Chris@0 127
Chris@0 128 end
Chris@0 129 end