diff options
author | David Heinemeier Hansson <david@basecamp.com> | 2014-08-17 16:44:30 -0700 |
---|---|---|
committer | David Heinemeier Hansson <david@basecamp.com> | 2014-08-17 16:44:30 -0700 |
commit | 49c9f850fa3e2484e3aaf20b2479f61b1cc9375e (patch) | |
tree | 2f2750a0801c0f2450f6908639973c38d9625963 /activejob/test/cases/queuing_test.rb | |
parent | b2708a635285f2b09040ee9070a8f5a09ab22282 (diff) | |
parent | 080296be61105f4f941441a506a6a9fe5c562772 (diff) | |
download | rails-49c9f850fa3e2484e3aaf20b2479f61b1cc9375e.tar.gz rails-49c9f850fa3e2484e3aaf20b2479f61b1cc9375e.tar.bz2 rails-49c9f850fa3e2484e3aaf20b2479f61b1cc9375e.zip |
Merge pull request #16485 from seuros/activejob
Integrate ActiveJob / DeliverLater / GlobalID with Rails
Diffstat (limited to 'activejob/test/cases/queuing_test.rb')
-rw-r--r-- | activejob/test/cases/queuing_test.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/activejob/test/cases/queuing_test.rb b/activejob/test/cases/queuing_test.rb new file mode 100644 index 0000000000..f020316d7e --- /dev/null +++ b/activejob/test/cases/queuing_test.rb @@ -0,0 +1,44 @@ +require 'helper' +require 'jobs/hello_job' +require 'active_support/core_ext/numeric/time' + + +class QueuingTest < ActiveSupport::TestCase + setup do + JobBuffer.clear + end + + test 'run queued job' do + HelloJob.enqueue + assert_equal "David says hello", JobBuffer.last_value + end + + test 'run queued job with arguments' do + HelloJob.enqueue "Jamie" + assert_equal "Jamie says hello", JobBuffer.last_value + end + + test 'run queued job later' do + begin + result = HelloJob.enqueue_at 1.second.ago, "Jamie" + assert result + rescue NotImplementedError + skip + end + end + + test 'job returned by enqueue has the arguments available' do + job = HelloJob.enqueue "Jamie" + assert_equal [ "Jamie" ], job.arguments + end + + + test 'job returned by enqueue_at has the timestamp available' do + begin + job = HelloJob.enqueue_at Time.utc(2014, 1, 1) + assert_equal Time.utc(2014, 1, 1), job.enqueued_at + rescue NotImplementedError + skip + end + end +end |