Skip to content

Commit

Permalink
Fix scheduling job with wait
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminwols committed May 21, 2023
1 parent bb5aec9 commit fd69e0f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 13 deletions.
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
# Specify your gem's dependencies in rails_async_methods.gemspec.
gemspec

gem "pg"
gem 'delayed_job_active_record'
gem 'daemons'

Expand Down
2 changes: 1 addition & 1 deletion lib/rails_async_methods/active_job_options_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def initialize(opts={})
@prefix = method_prefix(opts[:prefix])
@queue = opts[:queue]
@wait_until = opts[:wait_until].to_f if opts[:wait_until]
@wait = opts[:wait].seconds.from_now.to_f if opts[:wait]
@wait = opts[:wait].seconds.to_f if opts[:wait]
@priority = opts[:priority].to_i if opts[:priority]
@job = get_job_obj(opts[:job])
end
Expand Down
16 changes: 8 additions & 8 deletions rails_async_methods.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Gem::Specification.new do |spec|
spec.version = RailsAsyncMethods::VERSION
spec.authors = ["benngarcia"]
spec.email = ["[email protected]"]
spec.homepage = "https://github.com/benngarcia/rails_async_methods"
spec.summary = "Quickly, create async callers and receivers for your rails methods, because y'know DRY."
spec.description = "Utilizes the ActiveJob api to provide async callers and receivers without duplicating code."
spec.homepage = "https://github.com/benngarcia/rails_async_methods"
spec.summary = "Quickly, create async callers and receivers for your rails methods, because y'know DRY."
spec.description = "Utilizes the ActiveJob api to provide async callers and receivers without duplicating code."
spec.license = "MIT"

spec.metadata["homepage_uri"] = spec.homepage
Expand All @@ -17,10 +17,10 @@ Gem::Specification.new do |spec|
Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.md"]
end

spec.add_dependency "rails", ">= 7.0.2.4"
spec.add_dependency "activesupport"
spec.add_development_dependency 'minitest'
spec.add_development_dependency 'pg'
spec.add_development_dependency 'pry'
spec.add_development_dependency 'sidekiq'
spec.add_dependency "rails", ">= 7.0.2.4"
spec.add_development_dependency "minitest"
spec.add_development_dependency "pg"
spec.add_development_dependency "pry"
spec.add_development_dependency "sidekiq"
end
5 changes: 2 additions & 3 deletions test/async_method_rails_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class RailsAsyncMethodsTest < ActiveSupport::TestCase
ex = AsyncExample.create!
dj = ex.async_method_with_diff_wait_time_and_priority

assert_in_epsilon dj.scheduled_at, 1.week.from_now.to_i, 60
assert_in_delta dj.scheduled_at, 1.week.from_now.to_i, 60
assert_equal dj.priority, -10
end

Expand Down Expand Up @@ -120,7 +120,7 @@ class RailsAsyncMethodsTest < ActiveSupport::TestCase
assert_equal dj.queue_name, 'fast'
assert_equal dj.class, ExampleCustomAsyncJob
assert_not_nil ex.reload.testfield
assert_in_epsilon dj.scheduled_at, 1.week.from_now.to_i, 60
assert_in_delta dj.scheduled_at, 1.week.from_now.to_i, 60
run_last
assert_nil ex.reload.testfield
end
Expand All @@ -132,5 +132,4 @@ class RailsAsyncMethodsTest < ActiveSupport::TestCase

assert_equal ex.reload.testfield, '[2, 3, 4]'
end

end

0 comments on commit fd69e0f

Please sign in to comment.