Skip to content

Commit

Permalink
add test to ensure job is queued and clean up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vasconsaurus committed Sep 16, 2024
1 parent e35c643 commit 324ad39
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions test/workers/generic_worker_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,41 @@ def setup
def teardown
end

test "should schedule a job for a method that takes a hash: Tag creation" do
test "should run a job, without raising an error, for a method that takes a hash as a parameter" do
Sidekiq::Testing.inline!

assert_nothing_raised do
GenericWorker.perform_async('Team', 'create!', name: 'BackgroundTeam', slug: 'background-team')
end
end

test "should run a job, without raising an error, for a method that takes standalone parameters" do
Sidekiq::Testing.inline!

t = create_team
p = create_project team: t
pm = create_project_media project: p

project_media_id = pm.id
tags_json = ['one', 'two'].to_json

assert_nothing_raised do
GenericWorker.perform_async('Tag', 'create!', annotated_type: 'ProjectMedia' , annotated_id: pm.id, tag: 'test_tag', skip_check_ability: true, user_id: pm.user_id)
GenericWorker.perform_async('ProjectMedia', 'create_tags', project_media_id, tags_json, user_id: pm.user_id)
end
end

test "should schedule a job for a method that takes a hash: Team creation" do
Sidekiq::Testing.inline!
test "should schedule a job, without raising an error, for a method that takes a hash as a parameter" do
Sidekiq::Testing.fake!

assert_nothing_raised do
GenericWorker.perform_async('Team', 'create!', name: 'BackgroundTeam', slug: 'background-team')
end

assert_equal 1, GenericWorker.jobs.size
end

test "should schedule a job for a method that takes standalone parameters" do
Sidekiq::Testing.inline!
test "should schedule a job, without raising an error, for a method that takes standalone parameters" do
Sidekiq::Testing.fake!

t = create_team
p = create_project team: t
Expand All @@ -42,5 +55,7 @@ def teardown
assert_nothing_raised do
GenericWorker.perform_async('ProjectMedia', 'create_tags', project_media_id, tags_json, user_id: pm.user_id)
end

assert_equal 1, GenericWorker.jobs.size
end
end

0 comments on commit 324ad39

Please sign in to comment.