discourse/spec
David Taylor 8a3d9d7036
DEV: Run jobs sequentially in test mode (#9897)
When running jobs in tests, we use `Jobs.run_immediately!`. This means that jobs are run synchronously when they are enqueued. Jobs sometimes enqueue other jobs, which are also executed synchronously. This means that the outermost job will block until the inner jobs have finished executing. In some cases (e.g. process_post with hotlinked images) this can lead to a deadlock.

This commit changes the behavior slightly. Now we will never run jobs inside other jobs. Instead, we will queue them up and run them sequentially in the order they were enqueued. As a whole, they are still executed synchronously. Consider the example

```ruby
class Jobs::InnerJob < Jobs::Base
  def execute(args)
    puts "Running inner job"
  end
end

class Jobs::OuterJob < Jobs::Base
  def execute(args)
    puts "Starting outer job"
    Jobs.enqueue(:inner_job)
    puts "Finished outer job"
  end
end

Jobs.enqueue(:outer_job)
puts "All jobs complete"
```

The old behavior would result in:

```
Starting outer job
Running inner job
Finished outer job
All jobs complete
```

The new behavior will result in:
```
Starting outer job
Finished outer job
Running inner job
All jobs complete
```
2020-05-28 12:52:27 +01:00
..
components FIX: allows to have custom emoji translation without static file (#9893) 2020-05-27 20:11:52 +02:00
fabricators Revert "Revert "Merge branch 'master' of https://github.com/discourse/discourse"" 2020-05-23 00:56:13 -04:00
fixtures FIX: Allow post migrations using #change to carry out unsafe migration 2020-05-15 14:23:27 +08:00
helpers DEV: Fix some more flaky tests (#9384) 2020-04-08 12:46:43 +02:00
import_export FEATURE: Rake task to export groups (#9450) 2020-04-17 14:59:54 -07:00
initializers FIX: We need to skip users with associated reviewables when auto-approving (#9080) 2020-03-02 14:33:52 -05:00
integration FIX: Email Styles were evaluated out of order 2020-05-25 12:47:23 -04:00
integrity DEV: Adds an integrity spec for JS constants 2020-05-12 12:23:36 -04:00
jobs DEV: Run jobs sequentially in test mode (#9897) 2020-05-28 12:52:27 +01:00
lib Revert "Revert "Merge branch 'master' of https://github.com/discourse/discourse"" 2020-05-23 00:56:13 -04:00
mailers DEV: Add rubocop-rspec (#9288) 2020-03-27 17:35:40 +01:00
models UX: Rename Priority to score for sorting. (#9846) 2020-05-27 12:50:28 -03:00
multisite FIX: returns false if the upload url is an invalid mailto link (#9877) 2020-05-26 10:32:48 -03:00
requests FIX: sending messages to groups with non-lowercase names 2020-05-27 14:52:08 -06:00
script/import_scripts FIX: Change base importer to create new Bookmark records (#9603) 2020-05-01 11:34:55 +10:00
serializers Revert "Revert "Merge branch 'master' of https://github.com/discourse/discourse"" 2020-05-23 00:56:13 -04:00
services Revert "Revert "Merge branch 'master' of https://github.com/discourse/discourse"" 2020-05-23 00:56:13 -04:00
support DEV: Use response.parsed_body in specs (#9615) 2020-05-07 17:04:12 +02:00
tasks DEV: Clean up some Redis leaks in test env. 2020-05-18 17:27:37 +08:00
views/omniauth_callbacks FEATURE: Use full page redirection for all external auth methods (#8092) 2019-10-08 12:10:43 +01:00
rails_helper.rb Revert "Revert "Merge branch 'master' of https://github.com/discourse/discourse"" 2020-05-23 00:56:13 -04:00
swagger_helper.rb DEV: Add rswag to aid in api documention (#9546) 2020-04-27 16:40:07 -06:00