27822-tests.patch

Gregor Schmidt, 2018-07-09 16:02

Download (3.82 KB)

View differences:

test/functional/issues_controller_test.rb
2081 2081
    end
2082 2082

  
2083 2083
    assert_select 'div.thumbnails' do
2084
      assert_select 'a[href="/attachments/16/testfile.png"]' do
2084
      assert_select 'a[href="/attachments/16"]' do
2085 2085
        assert_select 'img[src="/attachments/thumbnail/16"]'
2086 2086
      end
2087 2087
    end
test/helpers/application_helper_test.rb
677 677

  
678 678
  def test_attachment_links
679 679
    text = 'attachment:error281.txt'
680
    result = link_to("error281.txt", "/attachments/1/error281.txt",
680
    result = link_to("error281.txt", "/attachments/1",
681 681
                     :class => "attachment")
682 682
    assert_equal "<p>#{result}</p>",
683 683
                 textilizable(text,
......
689 689
    set_tmp_attachments_directory
690 690
    a1 = Attachment.generate!(:filename => "test.txt", :created_on => 1.hour.ago)
691 691
    a2 = Attachment.generate!(:filename => "test.txt")
692
    result = link_to("test.txt", "/attachments/#{a2.id}/test.txt",
692
    result = link_to("test.txt", "/attachments/#{a2.id}",
693 693
                     :class => "attachment")
694 694
    assert_equal "<p>#{result}</p>",
695 695
                 textilizable('attachment:test.txt', :attachments => [a1, a2])
......
700 700

  
701 701
    with_settings :text_formatting => 'textile' do
702 702
      raw = "attachment:image@2x.png should not be parsed in image@2x.png"
703
      assert_match %r{<p><a class="attachment" href="/attachments/#{attachment.id}/image@2x.png">image@2x.png</a> should not be parsed in image@2x.png</p>},
703
      assert_match %r{<p><a class="attachment" href="/attachments/#{attachment.id}">image@2x.png</a> should not be parsed in image@2x.png</p>},
704 704
        textilizable(raw, :attachments => [attachment])
705 705
    end
706 706

  
707 707
    with_settings :text_formatting => 'markdown' do
708 708
      raw = "attachment:image@2x.png should not be parsed in image@2x.png"
709
      assert_match %r{<p><a class="attachment" href="/attachments/#{attachment.id}/image@2x.png">image@2x.png</a> should not be parsed in image@2x.png</p>} ,
709
      assert_match %r{<p><a class="attachment" href="/attachments/#{attachment.id}">image@2x.png</a> should not be parsed in image@2x.png</p>} ,
710 710
        textilizable(raw, :attachments => [attachment])
711 711
    end
712 712
  end
......
1445 1445

  
1446 1446
  def test_link_to_attachment
1447 1447
    a = Attachment.find(3)
1448
    assert_equal '<a href="/attachments/3/logo.gif">logo.gif</a>',
1448
    assert_equal '<a href="/attachments/3">logo.gif</a>',
1449 1449
      link_to_attachment(a)
1450
    assert_equal '<a href="/attachments/3/logo.gif">Text</a>',
1450
    assert_equal '<a href="/attachments/3">Text</a>',
1451 1451
      link_to_attachment(a, :text => 'Text')
1452
    result = link_to("logo.gif", "/attachments/3/logo.gif", :class => "foo")
1452
    result = link_to("logo.gif", "/attachments/3", :class => "foo")
1453 1453
    assert_equal result,
1454 1454
      link_to_attachment(a, :class => 'foo')
1455 1455
    assert_equal '<a href="/attachments/download/3/logo.gif">logo.gif</a>',
1456 1456
      link_to_attachment(a, :download => true)
1457
    assert_equal '<a href="http://test.host/attachments/3/logo.gif">logo.gif</a>',
1457
    assert_equal '<a href="http://test.host/attachments/3">logo.gif</a>',
1458 1458
      link_to_attachment(a, :only_path => false)
1459 1459
  end
1460 1460

  
......
1462 1462
    a = Attachment.find(3)
1463 1463
    assert_select_in thumbnail_tag(a),
1464 1464
      'a[href=?][title=?] img[src=?]',
1465
      "/attachments/3/logo.gif", "logo.gif", "/attachments/thumbnail/3"
1465
      "/attachments/3", "logo.gif", "/attachments/thumbnail/3"
1466 1466
  end
1467 1467

  
1468 1468
  def test_link_to_project