]> source.dussan.org Git - redmine.git/commitdiff
Code cleanup.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 30 Oct 2015 19:44:33 +0000 (19:44 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Fri, 30 Oct 2015 19:44:33 +0000 (19:44 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@14771 e93f8b46-1217-0410-a6f0-8f06a7374b81

test/integration/issues_test.rb

index 050f72fffdb308e2fed126ec9f516d41697bb10f..4dceaa27aa6db0ece7bd4d4d622f59a803564a59 100644 (file)
@@ -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!