##// END OF EJS Templates
Merged r9391 from trunk....
Merged r9391 from trunk. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.4-stable@9403 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r8941:b3866b05c14b
r9269:4c330a1241aa
Show More
issues_test.rb
228 lines | 7.7 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
# Copyright (C) 2006-2011 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
class IssuesTest < ActionController::IntegrationTest
Toshi MARUYAMA
remove trailing white-spaces from test/integration/issues_test.rb....
r6534 fixtures :projects,
Jean-Philippe Lang
Added default value for custom fields. Fixed javascript on custom field form for project and user custom fields....
r1076 :users,
Jean-Philippe Lang
Merged Rails 2.1 compatibility branch....
r1609 :roles,
:members,
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,
:custom_fields_trackers
Jean-Philippe Lang
added issues integration tests...
r121
# create an issue
def test_add_issue
log_user('jsmith', 'jsmith')
Jean-Philippe Lang
ProjectsController#add_issue moved to IssuesController#new....
r1066 get 'projects/1/issues/new', :tracker_id => '1'
Jean-Philippe Lang
added issues integration tests...
r121 assert_response :success
Jean-Philippe Lang
ProjectsController#add_issue moved to IssuesController#new....
r1066 assert_template 'issues/new'
Toshi MARUYAMA
remove trailing white-spaces from test/integration/issues_test.rb....
r6534
Eric Davis
Converted routing and urls to follow the Rails REST convention....
r2315 post 'projects/1/issues', :tracker_id => "1",
Toshi MARUYAMA
remove trailing white-spaces from test/integration/issues_test.rb....
r6534 :issue => { :start_date => "2006-12-26",
: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
added issues integration tests...
r121 # find created issue
issue = Issue.find_by_subject("new test issue")
assert_kind_of Issue, issue
# 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!
Jean-Philippe Lang
Fix tests broken by r1243 (Redirect to issue page after creating a new issue)....
r1242 assert_equal issue, assigns(:issue)
Jean-Philippe Lang
added issues integration tests...
r121
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
Fixed broken issue form update when changing tracker....
r8075 def test_update_issue_form
log_user('jsmith', 'jsmith')
post 'projects/ecookbook/issues/new', :issue => { :tracker_id => "2"}
assert_response :success
assert_tag 'select',
:attributes => {:name => 'issue[tracker_id]'},
:child => {:tag => 'option', :attributes => {:value => '2', :selected => 'selected'}}
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
Eric Davis
Refactor: convert many of the custom Issue routes to REST resources....
r3927 put 'issues/1',
Jean-Philippe Lang
Merged IssuesController change_status and add_note actions....
r1030 :notes => 'Some notes',
Jean-Philippe Lang
Renames uploaded_test_file helper....
r2795 :attachments => {'1' => {'file' => uploaded_test_file('testfile.txt', 'text/plain'), 'description' => 'This is an attachment'}}
Jean-Philippe Lang
Adds leading slash to all assert_redirected_to arguments (#6887)....
r4293 assert_redirected_to "/issues/1"
Toshi MARUYAMA
remove trailing white-spaces from test/integration/issues_test.rb....
r6534
Jean-Philippe Lang
added issues integration tests...
r121 # make sure attachment was saved
Jean-Philippe Lang
file upload test now uses ActionController::TestUploadedFile...
r248 attachment = Issue.find(1).attachments.find_by_filename("testfile.txt")
Jean-Philippe Lang
added issues integration tests...
r121 assert_kind_of Attachment, attachment
assert_equal Issue.find(1), attachment.container
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
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|
assert_tag :a, :content => format,
:attributes => { :href => "/projects/ecookbook/issues.#{format.downcase}",
:rel => 'nofollow' }
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|
assert_tag :a, :content => format,
:attributes => { :href => "/projects/ecookbook/issues.#{format.downcase}",
:rel => 'nofollow' }
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
Fixed: export links on the issue list lose project param after applying a filter (#2908)....
r2486 Setting.per_page_options = '2'
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 assert_tag :a, :content => '2',
:attributes => { :href => '/projects/ecookbook/issues?page=2' }
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 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_without_project_id_in_url
Jean-Philippe Lang
Fixed: export links on the issue list lose project param after applying a filter (#2908)....
r2486 Setting.per_page_options = '2'
Jean-Philippe Lang
Removed obsolete routes....
r7897 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 assert_tag :a, :content => '2',
:attributes => { :href => '/projects/ecookbook/issues?page=2' }
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 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 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
users = Project.find(1).users
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
assert_tag :select,
:attributes => {:name => "issue[custom_field_values][#{@field.id}]"},
:children => {:count => (users.size + 1)}, # +1 for blank value
:child => {
:tag => 'option',
:attributes => {:value => tester.id.to_s},
:content => tester.name
}
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
assert_difference 'Issue.count' 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}
}
end
issue = Issue.first(:order => 'id DESC')
assert_response 302
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!
assert_tag :th,
:content => /Tester/,
:sibling => {
:tag => 'td',
:content => tester.name
}
assert_tag :select,
:attributes => {:name => "issue[custom_field_values][#{@field.id}]"},
:children => {:count => (users.size + 1)}, # +1 for blank value
:child => {
:tag => 'option',
:attributes => {:value => tester.id.to_s, :selected => 'selected'},
:content => tester.name
}
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 # Update issue
new_tester = users[1]
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}
}
end
assert_response 302
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!
assert_tag :content => 'Tester',
:ancestor => {:tag => 'ul', :attributes => {:class => /details/}},
:sibling => {
:content => tester.name,
:sibling => {
:content => new_tester.name
}
}
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')
assert_response 405
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')
assert_response 405
end
end
Jean-Philippe Lang
added issues integration tests...
r121 end