Sha256: 114f59f924eb633caf5ba2ef5c052371788d452e418e8900a2d08ee8562fd84e

Contents?: true

Size: 983 Bytes

Versions: 11

Compression:

Stored size: 983 Bytes

Contents

require 'test_helper'

class RoolerTest < ActiveSupport::TestCase
  
  test "processes scheduled rules" do
    foo = Foo.create
    rule = create(:rule, klass_name: 'Foo', klass_finder_method: 'active_record_finder',  check_frequency: 1.minute)
        
    assert_difference 'Rooler::Delivery.count' do
      Rooler.process_scheduled_rules
    end
    
    assert_equal foo, Rooler::Delivery.last.deliverable
  end
  
  test 'resets resetable deliveries' do
    foo = Foo.create(active: true)
    rule = create(:rule, klass_name: 'Foo', klass_finder_method: 'active_finder')
    rule.process    
    foo.update_attributes(active: false)
    
    assert_difference 'Rooler::Delivery.count', -1 do
      Rooler.clear_non_applicable_deliveries
    end
    
  end
  
  
  test 'delivers pending emails' do
    delivery = create(:delivery)
    Rooler.deliver_pending_emails
    assert !ActionMailer::Base.deliveries.empty?
    assert_not_nil delivery.reload.delivered_at
  end
  
  
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
rooler-0.0.11 test/rooler_test.rb
rooler-0.0.10 test/rooler_test.rb
rooler-0.0.9 test/rooler_test.rb
rooler-0.0.8 test/rooler_test.rb
rooler-0.0.7 test/rooler_test.rb
rooler-0.0.6 test/rooler_test.rb
rooler-0.0.5 test/rooler_test.rb
rooler-0.0.4 test/rooler_test.rb
rooler-0.0.3 test/rooler_test.rb
rooler-0.0.2 test/rooler_test.rb
rooler-0.0.1 test/rooler_test.rb