Project

General

Profile

Feature #22481 » 0001-Run-test-only-when-GhostScript-is-available.patch

Marius BĂLTEANU, 2019-06-02 19:15

View differences:

test/functional/attachments_controller_test.rb
404 404
      assert_response 304
405 405
    end
406 406

  
407
    def test_thumbnail_for_pdf_should_be_png
408
      Attachment.clear_thumbnails
409
      @request.session[:user_id] = 2
410
      get :thumbnail, :params => {
411
          :id => 23   # ecookbook-gantt.pdf
412
        }
413
      assert_response :success
414
      assert_equal 'image/png', response.content_type
415
    end
416

  
417 407
    def test_thumbnail_should_not_exceed_maximum_size
418 408
      Redmine::Thumbnail.expects(:generate).with {|source, target, size| size == 800}
419 409

  
......
463 453
    puts '(ImageMagick convert not available)'
464 454
  end
465 455

  
456
  if gs_installed?
457
    def test_thumbnail_for_pdf_should_be_png
458
      Attachment.clear_thumbnails
459
      @request.session[:user_id] = 2
460
      get :thumbnail, :params => {
461
          :id => 23   # ecookbook-gantt.pdf
462
        }
463
      assert_response :success
464
      assert_equal 'image/png', response.content_type
465
    end
466
  else
467
    puts '(GhostScript convert not available)'
468
  end
469

  
466 470
  def test_edit_all
467 471
    @request.session[:user_id] = 2
468 472
    get :edit_all, :params => {
......
519 523
          '1' => {
520 524
            :filename => 'newname.text',
521 525
            :description => ''
522
          },    
526
          },
523 527
                  '4' => {
524 528
            :filename => 'newname.rb',
525 529
            :description => 'Renamed'
526
          },    
527
                
530
          },
531

  
528 532
        }
529 533
      }
530 534

  
......
543 547
          '1' => {
544 548
            :filename => '',
545 549
            :description => ''
546
          },    
550
          },
547 551
                  '4' => {
548 552
            :filename => 'newname.rb',
549 553
            :description => 'Renamed'
550
          },    
551
                
554
          },
555

  
552 556
        }
553 557
      }
554 558

  
test/test_helper.rb
134 134
    self.class.convert_installed?
135 135
  end
136 136

  
137
  def self.gs_installed?
138
    Redmine::Thumbnail.gs_available?
139
  end
140

  
141
  def gs_installed?
142
    self.class.gs_installed?
143
  end
144

  
137 145
  # Returns the path to the test +vendor+ repository
138 146
  def self.repository_path(vendor)
139 147
    path = Rails.root.join("tmp/test/#{vendor.downcase}_repository").to_s
......
254 262
module Redmine
255 263
  class MockFile
256 264
    attr_reader :size, :original_filename, :content_type
257
  
265

  
258 266
    def initialize(options={})
259 267
      @size = options[:size] || 32
260 268
      @original_filename = options[:original_filename] || options[:filename]
261 269
      @content_type = options[:content_type]
262 270
      @content = options[:content] || 'x'*size
263 271
    end
264
  
272

  
265 273
    def read(*args)
266 274
      if @eof
267 275
        false
......
308 316
      ids = css_select('tr.issue td.id').map(&:text).map(&:to_i)
309 317
      Issue.where(:id => ids).sort_by {|issue| ids.index(issue.id)}
310 318
    end
311
  
319

  
312 320
    # Return the columns that are displayed in the issue list
313 321
    def columns_in_issues_list
314 322
      css_select('table.issues thead th:not(.checkbox)').map(&:text).select(&:present?)
315 323
    end
316
  
324

  
317 325
    # Return the columns that are displayed in the list
318 326
    def columns_in_list
319 327
      css_select('table.list thead th:not(.checkbox)').map(&:text).select(&:present?)
......
328 336
    def assert_query_filters(expected_filters)
329 337
      response.body =~ /initFilters\(\);\s*((addFilter\(.+\);\s*)*)/
330 338
      filter_init = $1.to_s
331
  
339

  
332 340
      expected_filters.each do |field, operator, values|
333 341
        s = "addFilter(#{field.to_json}, #{operator.to_json}, #{Array(values).to_json});"
334 342
        assert_include s, filter_init
......
437 445
        request = arg.keys.detect {|key| key.is_a?(String)}
438 446
        raise ArgumentError unless request
439 447
        options = arg.slice!(request)
440
  
448

  
441 449
        API_FORMATS.each do |format|
442 450
          format_request = request.sub /$/, ".#{format}"
443 451
          super options.merge(format_request => arg[request], :format => format)
(9-9/9)