diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-10-30 19:44:33 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-10-30 19:44:33 +0000 |
commit | 21421917fc20abce862f7503f580871659fddd46 (patch) | |
tree | fc99ca4edd75ab41e45bdc32707c34d0b1bb53bd /test/integration | |
parent | cb3072aceede1d3e510cc207c091fe0737e2fda9 (diff) | |
download | redmine-21421917fc20abce862f7503f580871659fddd46.tar.gz redmine-21421917fc20abce862f7503f580871659fddd46.zip |
Code cleanup.
git-svn-id: http://svn.redmine.org/redmine/trunk@14771 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/integration')
-rw-r--r-- | test/integration/issues_test.rb | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/test/integration/issues_test.rb b/test/integration/issues_test.rb index 050f72fff..4dceaa27a 100644 --- a/test/integration/issues_test.rb +++ b/test/integration/issues_test.rb @@ -37,11 +37,12 @@ class IssuesTest < Redmine::IntegrationTest # create an issue def test_add_issue log_user('jsmith', 'jsmith') - get '/projects/1/issues/new', :tracker_id => '1' + get '/projects/ecookbook/issues/new', :tracker_id => '1' assert_response :success assert_template 'issues/new' - post '/projects/1/issues', :tracker_id => "1", + issue = new_record(Issue) do + post '/projects/ecookbook/issues', :tracker_id => "1", :issue => { :start_date => "2006-12-26", :priority_id => "4", :subject => "new test issue", @@ -51,10 +52,7 @@ class IssuesTest < Redmine::IntegrationTest :due_date => "", :assigned_to_id => "" }, :custom_fields => {'2' => 'Value for field 2'} - # find created issue - issue = Issue.find_by_subject("new test issue") - assert_kind_of Issue, issue - + end # check redirection assert_redirected_to :controller => 'issues', :action => 'show', :id => issue follow_redirect! @@ -79,11 +77,10 @@ class IssuesTest < Redmine::IntegrationTest Role.anonymous.remove_permission! :add_issues Member.create!(:project_id => 1, :principal => Group.anonymous, :role_ids => [3]) - assert_difference 'Issue.count' do + issue = new_record(Issue) do post '/projects/1/issues', :tracker_id => "1", :issue => {:subject => "new test issue"} + assert_response 302 end - assert_response 302 - issue = Issue.order("id DESC").first assert_equal User.anonymous, issue.author end @@ -92,15 +89,15 @@ class IssuesTest < Redmine::IntegrationTest log_user('jsmith', 'jsmith') set_tmp_attachments_directory - 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" + 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 - # make sure attachment was saved - attachment = Issue.find(1).attachments.find_by_filename("testfile.txt") - assert_kind_of Attachment, attachment assert_equal Issue.find(1), attachment.container + assert_equal 'testfile.txt', attachment.filename assert_equal 'This is an attachment', attachment.description # verify the size of the attachment stored in db #assert_equal file_data_1.length, attachment.filesize @@ -159,7 +156,7 @@ class IssuesTest < Redmine::IntegrationTest end # Create issue - assert_difference 'Issue.count' do + issue = new_record(Issue) do post '/projects/ecookbook/issues', :issue => { :tracker_id => '1', @@ -167,9 +164,8 @@ class IssuesTest < Redmine::IntegrationTest :subject => 'Issue with user custom field', :custom_field_values => {@field.id.to_s => users.first.id.to_s} } + assert_response 302 end - issue = Issue.order('id DESC').first - assert_response 302 # Issue view follow_redirect! |