Project

General

Profile

Defect #37881 » fix-37881.patch

Mizuki ISHIKAWA, 2022-12-21 02:08

View differences:

lib/redmine/wiki_formatting/macros.rb
279 279
        size = size.to_i
280 280
        size = 200 unless size > 0
281 281

  
282
        attachments = obj.attachments if obj.respond_to?(:attachments)
282
        container = obj.is_a?(Journal) ? obj.journalized : obj
283
        attachments = container.attachments if container.respond_to?(:attachments)
283 284
        if (controller_name == 'previews' || action_name == 'preview') && @attachments.present?
284 285
          attachments = (attachments.to_a + @attachments).compact
285 286
        end
test/functional/issues_controller_test.rb
8457 8457
    end
8458 8458
  end
8459 8459

  
8460
  def test_show_should_be_available_with_thumbnail_macro_of_another_journal_attachment_of_the_same_issue
8461
    @request.session[:user_id] = 1
8462
    issue = Issue.find(2)
8463
    attachment = Attachment.generate!(filename: 'foo.png', digest: Redmine::Utils.random_hex(32))
8464
    attachment.update(container: issue)
8465

  
8466
    issue.init_journal(User.first, "{{thumbnail(#{attachment.filename})}}")
8467
    issue.save!
8468
    issue.reload
8469

  
8470
    get :show, params: { id: issue.id }
8471
    assert_select "div#history div#journal-#{issue.journals.last.id}-notes" do
8472
      assert_select "a.thumbnail[title=?][href='/attachments/#{attachment.id}']", 'foo.png'
8473
    end
8474
  end
8475

  
8460 8476
  def test_index_should_retrieve_default_query
8461 8477
    query = IssueQuery.find(4)
8462 8478
    IssueQuery.stubs(:default).returns query
(2-2/2)