Project

General

Profile

Actions

Patch #41238

closed

Fix test failure in IssuesSystemTest due to incorrect attachment count expectation

Added by Katsuya HIDAKA 3 months ago. Updated 3 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Code cleanup/refactoring
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:

Description

The following system test is failing in trunk (r23047).

$ bin/rails test test/system/issues_test.rb:260
Run options: --seed 21762
(snip)
F

Failure:
IssuesSystemTest#test_update_issue_with_form_update_should_keep_newly_added_attachments [test/system/issues_test.rb:277]:
Expected: 1
  Actual: 3

The failing test is:

# redmine/test/system/issues_test.rb:260
  def test_update_issue_with_form_update_should_keep_newly_added_attachments
    set_tmp_attachments_directory
    log_user('jsmith', 'jsmith')

    visit '/issues/2'
    page.first(:link, 'Edit').click
    attach_file 'attachments[dummy][file]', Rails.root.join('test/fixtures/files/testfile.txt')

    assert page.has_css?('span#attachments_1')

    page.find("#issue_status_id").select("Closed")

    # check that attachment still exists on the page
    assert page.has_css?('span#attachments_1')

    click_on 'Submit'

    assert_equal 3, Issue.find(2).attachments.count
  end

https://github.com/redmine/redmine/blob/e8879d891f39539fe1d0d6cb14c26a02944234a5/test/system/issues_test.rb#L260-L278

The failing assertion is:

    assert_equal 3, Issue.find(2).attachments.count

And here's a screenshot of the failure:

The test is failing simply because the expected number of attachments for Issue#2 is wrong.

In the fixture data, Issue#2 has 2 attachments.

$ git grep -h -C 3 "container_id: 2" -- test/fixtures/attachments.yml
attachments_004:
  created_on: 2006-07-19 21:07:27 +02:00
  container_type: Issue
  container_id: 2
  downloads: 0
  disk_filename: 060719210727_source.rb
  disk_directory: "2006/07" 
--
attachments_010:
  created_on: 2006-07-19 21:07:27 +02:00
  container_type: Issue
  container_id: 2
  downloads: 0
  disk_filename: 060719210727_picture.jpg
  disk_directory: "2006/07" 

So since Issue#2 originally had 2 attachments and this test adds one attachment, the final number of attachments for Issue#2 should be 3.

This patch fixes by modifing the expected number of attachments to 3 from 1.

diff --git a/test/system/issues_test.rb b/test/system/issues_test.rb
index 2b83ef362..be0744157 100644
--- a/test/system/issues_test.rb
+++ b/test/system/issues_test.rb
@@ -274,7 +274,7 @@ class IssuesSystemTest < ApplicationSystemTestCase

     click_on 'Submit'

-    assert_equal 1, Issue.find(2).attachments.count
+    assert_equal 3, Issue.find(2).attachments.count
   end

   test "removing issue shows confirm dialog" do


Files

Actions #1

Updated by Go MAEDA 3 months ago

  • Category set to Code cleanup/refactoring
  • Target version set to 6.0.0
Actions #2

Updated by Go MAEDA 3 months ago

  • Subject changed from Fix a system test that fails due to incorrect expectation to Fix test failure in IssuesSystemTest due to incorrect attachment count expectation
  • Status changed from New to Closed
  • Assignee set to Go MAEDA

Committed the patch in r23051. Thank you.

Actions

Also available in: Atom PDF