Skip to content

Resque::NoQueueError: Jobs must be placed onto a queue. #123

@lawhorkl

Description

@lawhorkl

Getting this error while trying to run specs using resque_spec. The error is pretty clear what is going on, however from what I understand, the queue is defined in the job that's specified in enqueue. I have a queue defined in the job, but for some reason it isn't detecting it?

Fairly new to resque in general so it could possibly be something I'm doing wrong, however, here is my simple job and the method I'm trying to test, hopefully there's something I can do:

jobs/MakeChange.rb:

class MakeChange
    def self.queue
        :notification
    end

    def self.perform(change_id)
        puts 'job started'
        puts 'change is made to ' + change_id.to_s if NotificationManager::Manager.notify(change_id)
        puts 'job finished'
    end
end

services/notification_manager/manager.rb:

module NotificationManager
    class Manager
        def self.notification(owner, change_type, context, target)
            change_id = Notification.new_notification(owner, change_type, context, target)
            Resque.enqueue(MakeChange, change_id)
            # Resque.enqueue_in(
            #   30.seconds,
            #   MakeChange,
            #   change_id
            #   )
                        notification = Notification.find(change_id)
        end

        # run populate_test_data from console
        def self.notify(change_id)
            puts 'the notify method was called'
            unless NotificationManager::Notification.find(change_id).cancelled?
                change = Notification.find(change_id)
                byebug
                similar_changes = group_similar_changes(change.owner, change.target, change.change_type)
                puts 'group_similar_changes finished. size: ' + similar_changes.length.to_s
                mailer = NotificationManager::NotificationMailer
                if mailer.send_email(mailer.construct_email(similar_changes))
                    puts 'the email sent'
                end
            end
        end
        end

spec/services/notification_manager/manager_spec.rb:

require 'spec_helper'

module NotificationManager
    describe Manager do
        describe '#notify' do
            before do
                ResqueSpec.reset!
            end
            let(:notification) { NotificationManager::Manager.notification('kyle', 'removed_as_delegate', 'work_id1', 'testemail@gmail.com') }
            it 'adds notification.notify to the notification queue' do
                expect(Manager).to have_queued(notification.id, :notify)
            end
        end
    end
end

Thanks for the gem, by the way, it it exactly what I needed, only I hope I can get it working :D

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions