Sha256: 83e50d133878cc52f18d9b1117d1efb9fa8876441cc74fcf843e69241ddea481

Contents?: true

Size: 810 Bytes

Versions: 2

Compression:

Stored size: 810 Bytes

Contents

require 'test_helper'

class CronjobsTest < ActiveSupport::TestCase

  teardown do
    FileUtils.rm_rf Rails.root.join('tmp')
  end

  test 'write' do
    output_path = Rails.root.join('tmp/output')
    FileUtils.mkdir_p output_path.dirname
    FileUtils.touch output_path
    Cronjobs.stubs(:command).returns("cat - > #{output_path}")
    Cronjobs.write
    prefix = '* 1 * * * PATH=$PATH:/usr/local/bin bash -lc'
    redirect = ">> #{Rails.root.join('log/cronjobs.log')} 2>> #{Rails.root.join('log/cronjobs.log')}"
    output = <<-EOF.strip_heredoc
      MAILTO=test@mail.com
      #{prefix} "cd #{Rails.root} && ./bin/rails runner 'Attachs.clear' #{redirect}"
      #{prefix} "cd #{Rails.root} && ./bin/rake certificates:check #{redirect}"
    EOF
    assert_equal output, File.read(output_path)
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
cronjobs-0.1.0 test/cronjobs_test.rb
cronjobs-0.0.1 test/cronjobs_test.rb