Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refs #17684: Enhances rdoc for ActiveJob assert_performed assertions #17687

Closed
wants to merge 4 commits into from
Closed

Refs #17684: Enhances rdoc for ActiveJob assert_performed assertions #17687

wants to merge 4 commits into from

Conversation

fabiolnm
Copy link
Contributor

No description provided.

#
# def test_jobs
# queue_adapter.perform_enqueued_jobs = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could just tell about the condition but not show how to enable. This code for example will change the global state of the tests and will make test order dependent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right about the global state change, but not showing how to enable is little help.

My feeling is that something like this is missing, maybe in test_helper:

def perform_enqueued_jobs
  @old_perform_enqueued_jobs = queue_adapter.perform_enqueued_jobs
  queue_adapter.perform_enqueued_jobs = true
  yield
ensure
  queue_adapter.perform_enqueued_jobs = @old_perform_enqueued_jobs
end

Maybe this may be placed in test_adapter.

So one can code this test:

perform_enqueued_jobs do
  assert_performed_jobs 1 do
    # ...
  end
end

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but I'd make it the default value of assert_performed_jobs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems a good approach, too...
How do we proceed now?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can add a new commit to this PR adding support to enable perform_enqueued_jobs by default in the block version of assert_performed_jobs

@fabiolnm
Copy link
Contributor Author

@rafaelfranca Do you agree the following lines

setup { queue_adapter.perform_enqueued_at_jobs = true }

and

setup { queue_adapter.perform_enqueued_jobs = true }

are potentially dangerous, as they change queue_adapter state?

@rafaelfranca
Copy link
Member

Yeah, they should have a after block too.

@rafaelfranca rafaelfranca added this to the 4.2.0 milestone Nov 25, 2014
@rafaelfranca
Copy link
Member

Squashed and merged at 0bc04ce...d886a27

rafaelfranca pushed a commit that referenced this pull request Nov 25, 2014
Refs #17684: Enhances rdoc for ActiveJob assert_performed assertions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants