Commit Graph

425 Commits

Author SHA1 Message Date
Akira Matsuda 050018d48e s/perfomed/performed/
[ci skip]
2017-01-17 04:05:52 +09:00
yuuji.yaginuma c2b5c057fa remove unused require
`InlineAdapter` is not used from 1f8558f.
2017-01-15 13:02:03 +09:00
Akira Matsuda 5473e390d3 `self.` is not needed when calling its own instance method
Actually, private methods cannot be called with `self.`, so it's not just redundant, it's a bad habit in Ruby
2017-01-05 19:58:52 +09:00
Rafael Mendonça França b6ffb5efcb
Revert "Merge pull request #27550 from mtsmfm/fix-generator-command-for-nested-rails-engine"
This reverts commit 1e969bfb98, reversing
changes made to a5041f267d.

Reason: It breaks the public API
2017-01-03 21:51:18 -05:00
Fumiaki MATSUSHIMA 085546df45 Fix generator command for nested (namespaced) rails engine
If we create nested (namespaced) rails engine such like bukkits-admin,
`bin/rails g scaffold User name:string age:integer`
will create
`bukkits-admin/app/controllers/bukkits/users_controller.rb`
but it should create
`bukkits-admin/app/controllers/bukkits/admin/users_controller.rb`.

In #6643, we changed `namespaced_path` as root path
because we supposed application_controller is always in root
but nested rails engine's application_controller will not.
2017-01-03 21:18:09 +09:00
Rafael França b92c0fa863 Merge pull request #27508 from zzz6519003/patch-1
remove useless import
2017-01-01 22:58:50 -05:00
Jon Moss 37d956f45f Bump license years for 2017
Per https://www.timeanddate.com/counters/firstnewyear.html, it's already
2017 in a lot of places, so we should bump the Rails license years to
2017.

[ci skip]
2016-12-31 08:34:08 -05:00
Snowmanzzz(Zhengzhong Zhao) 7eef8d35d7 remove useless import 2016-12-30 19:40:26 +08:00
Rafael Mendonça França 030dff74ce
Delayed job doesn't support Active Record 5.1 yet 2016-12-29 17:53:04 -05:00
Akira Matsuda e8ba0c0f21 "Use assert_nil if expecting nil. This will fail in minitest 6." 2016-12-25 02:29:52 +09:00
Akira Matsuda 102ee40557 Privatize unneededly protected method in Active Job 2016-12-24 21:16:13 +09:00
Akira Matsuda 726b71cbb2 No need to nodoc private methods 2016-12-24 21:16:13 +09:00
Akira Matsuda 7269d9de6a Privatize unneededly protected methods in Active Job tests 2016-12-24 00:15:18 +09:00
Kir Shatrov 2f421fa294 Remove warning in ActiveJob
Currently it causes:

```
activejob/Rakefile:5: warning: already initialized constant ACTIVEJOB_ADAPTERS
```
2016-12-21 20:38:12 -05:00
utilum 893069fa02 Output adapter being tested. 2016-12-12 21:52:04 +01:00
Matthew Draper 0e97cd1a0d Avoid race condition in AJ integration tests
Make sure the file doesn't exist until we've finished writing it.
2016-11-30 21:10:52 +10:30
yuuji.yaginuma 5b825c55fe remove Ruby warning from Active Job test helper methods
This removes the following warnings.

```
/home/travis/build/rails/rails/activejob/lib/active_job/test_helper.rb:241: warning: shadowing outer local variable - job
/home/travis/build/rails/rails/activejob/lib/active_job/test_helper.rb:265: warning: shadowing outer local variable - job
```
2016-11-18 18:20:48 +09:00
Maxime Boisvert c061236cc7 Use named parameters instead of `assert_valid_keys` 2016-11-16 17:19:48 -05:00
Rafael Mendonça França fe1f4b2ad5
Add more rubocop rules about whitespaces 2016-10-29 01:17:49 -02:00
Xavier Noria 7506f33906 removes requires already present in active_support/rails 2016-10-27 09:45:20 +02:00
Gabi Stefanini 393f25bdba Uses queue adapter_method instead of ActiveJob::Base.queue_adapter
Change ActiveJob::Base.queue_adapter to use queue_adapter method to make test code consistent.
2016-10-24 22:25:48 -04:00
Gabi Stefanini 0d454d0806 Add examples of queue_adapter and perform_enqueued jobs to API Docs. 2016-10-21 11:59:01 -04:00
yuuji.yaginuma 77bdbb5f41 add missing closing tag [ci skip] 2016-10-14 09:15:51 +09:00
Rafael Mendonça França d1fc0a5eb2
Removed deprecated support to passing the adapter class to .queue_adapter 2016-10-10 15:00:28 -03:00
Rafael Mendonça França d861a1fcf8
Removed deprecated #original_exception in ActiveJob::DeserializationError 2016-10-10 14:55:20 -03:00
Jon Moss 743dba533e Merge pull request #26740 from y-yagi/update_retry_on_example
correct exception class in `retry_on` example [ci skip]
2016-10-08 19:51:42 -04:00
yuuji.yaginuma be199dfae2 correct exception class in `retry_on` example [ci skip]
If the deadlock has occurred `ActiveRecord::Deadlocked` will raise.
Ref: #25107, #26059
2016-10-09 08:46:31 +09:00
Matthew Draper cb0452e9a5 Fixnum and Bignum are deprecated in Ruby trunk
https://bugs.ruby-lang.org/issues/12739
2016-10-08 08:13:11 +10:30
yuuji.yaginuma 6a8e7fd8d8 fix link to `resque` [ci skip]
`1-x-stable` branch does not exist, `master` is 1.x branch.
Ref: http://words.steveklabnik.com/rescuing-resque-again
2016-09-20 08:56:05 +09:00
yuuji.yaginuma 0b2197774c use `descendants` to get class that inherited `ActiveJob::Base`
`subclasses` get only child classes.
Therefore, if create a job common parent class as `ApplicationJob`,
inherited class does not get properly.
2016-09-05 09:21:10 +09:00
Xavier Noria bb1ecdcc67 fixes remaining RuboCop issues [Vipul A M, Xavier Noria] 2016-09-01 23:41:49 +02:00
Rafael Mendonça França 0510208dd1
Add load hooks to all tests classes
Usually users extends tests classes doing something like:

    ActionView::TestCase.include MyCustomTestHelpers

This is bad because it will load the ActionView::TestCase right aways
and this will load ActionController::Base making its on_load hooks to
execute early than it should.

One way to fix this is using the on_load hooks of the components like:

    ActiveSupport.on_load(:action_view) do
      ActionView::TestCase.include MyCustomTestHelpers
    end

The problem with this approach is that the test extension will be only
load when ActionView::Base is loaded and this may happen too late in the
test.

To fix this we are adding hooks to people extend the test classes that
will be loaded exactly when the test classes are needed.
2016-08-25 04:22:48 -03:00
Rafael Mendonça França 7f4b16ed83
Merge pull request #26205 from pedaling-corp/fix/active-job-resque
Add @queue variable to JobWrapper
2016-08-23 00:39:39 -03:00
yuuji.yaginuma 88f9a1540a correct exception class in `retry_on` example [ci skip]
If the deadlock has occurred `ActiveRecord::Deadlocked` will raise.
Ref: #25107, #26059
2016-08-20 17:21:14 +09:00
InJung Chung 9f6461a28c Added instance variable `@queue` to JobWrapper.
This will fix issues in [resque-scheduler](https://github.com/resque/resque-scheduler) `#job_to_hash` method,
so we can use `#enqueue_delayed_selection`, `#remove_delayed` method in resque-scheduler smoothly.
2016-08-19 17:10:27 +09:00
David Heinemeier Hansson a1e4c197cb Yield the job instance so you have access to things like `job.arguments` on the custom logic after retries fail 2016-08-16 16:01:59 -07:00
Rafael Mendonça França 55f9b8129a
Add three new rubocop rules
Style/SpaceBeforeBlockBraces
Style/SpaceInsideBlockBraces
Style/SpaceInsideHashLiteralBraces

Fix all violations in the repository.
2016-08-16 04:30:11 -03:00
Vipul A M 8b984161d6
Pass over changelogs [ci skip] 2016-08-10 09:33:13 +05:30
Xavier Noria a9dc45459a code gardening: removes redundant selfs
A few have been left for aesthetic reasons, but have made a pass
and removed most of them.

Note that if the method `foo` returns an array, `foo << 1`
is a regular push, nothing to do with assignments, so
no self required.
2016-08-08 01:12:38 +02:00
Ryuta Kamizono 762e3f05f3 Add `Style/EmptyLines` in `.rubocop.yml` and remove extra empty lines 2016-08-07 17:50:59 +09:00
Xavier Noria b326e82dc0 applies remaining conventions across the project 2016-08-06 20:20:22 +02:00
Xavier Noria 80e66cc4d9 normalizes indentation and whitespace across the project 2016-08-06 20:16:27 +02:00
Xavier Noria 411ccbdab2 remove redundant curlies from hash arguments 2016-08-06 19:44:11 +02:00
Xavier Noria 301ce2a6d1 modernizes hash syntax in activejob 2016-08-06 19:36:54 +02:00
Xavier Noria e6ab70c439 applies new string literal convention to the rest of the project
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 19:28:46 +02:00
Xavier Noria adca8154c6 applies new string literal convention in the gemspecs
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 19:27:12 +02:00
Xavier Noria bde6547bb6 applies new string literal convention in activejob/test
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 18:41:18 +02:00
Xavier Noria 93c9534c98 applies new string literal convention in activejob/lib
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 18:40:07 +02:00
David Heinemeier Hansson 01a69e27a4 Offer invitations to use retry_on/discard_on for common cases 2016-08-04 14:57:10 -07:00
David Heinemeier Hansson 4f5a9890b7 Guard against jobs that were persisted before we started counting executions by zeroing out nil counters 2016-08-03 14:30:39 -07:00
David Heinemeier Hansson b53da9e90b Amend the CHANGELOG 2016-08-02 15:04:45 -07:00
David Heinemeier Hansson 7efd77fae5 Fix tests against ActiveSupport::Durations 2016-08-02 14:27:01 -07:00
David Heinemeier Hansson 111227c0df Please Rubocup 2016-08-02 12:28:16 -07:00
David Heinemeier Hansson 3118911335 Not needed 2016-08-01 20:29:29 -07:00
David Heinemeier Hansson 9d8d4ee05e Allow for custom handling of exceptions that persist beyond the retry attempts 2016-08-01 16:51:11 -07:00
David Heinemeier Hansson 0be5d5d4c4 Add exponentially_longer and custom wait algorithms 2016-08-01 16:44:29 -07:00
David Heinemeier Hansson 08a92d47b0 Use descriptive exception names 2016-08-01 16:09:16 -07:00
David Heinemeier Hansson a4fc7dc957 Executions counting is not a serialization concern
Let’s do it when we actually execute instead. Then the tests dealing
with comparable serializations won’t fail either!
2016-08-01 16:02:50 -07:00
David Heinemeier Hansson 779148d390 Reraise instead of swallow exceptions that occur beyond the retry attempts 2016-07-29 15:15:31 -07:00
David Heinemeier Hansson f931290e58 Proper logging when we bail on retrying after X attempts 2016-07-29 15:07:50 -07:00
David Heinemeier Hansson 8457e5eb1d Allow retries to happen with different priority and queue 2016-07-29 14:23:39 -07:00
David Heinemeier Hansson b00214d214 Require time extension for 3.seconds default 2016-07-29 14:21:02 -07:00
David Heinemeier Hansson 504a7d0530 Mention defaults 2016-07-29 14:20:29 -07:00
David Heinemeier Hansson 4139b14492 Satisfy pedantic rubocop whitespace detection 2016-07-29 13:59:40 -07:00
David Heinemeier Hansson 5ce59f456f Remove needless require 2016-07-29 13:57:37 -07:00
David Heinemeier Hansson 8b5c04e423 Add retry_on/discard_on for better exception handling 2016-07-29 13:54:55 -07:00
Azzurrio 80e825915c Fix accessing provider_job_id inside active jobs for sidekiq adapter 2016-07-28 04:12:15 +02:00
Vipul A M 8dd9bb6e9b
Fix AJ tests on ruby 2.4 being causes since classes are unified for Integer, and we create test name nased on arg class. Append ar as well to the test name 2016-07-09 16:24:03 -07:00
Jean Boussier be491ecec2 Fix jobs overriding AJ::Base#logger 2016-06-17 13:04:17 -04:00
Steve Lounsbury 38c187b0cc Provide the ability to override the queue adapter used by jobs under
test.

This PR adds a method called `queue_adapter_for_test` to
`ActiveJob::TestHelper`. This method is expected to provide the queue
adapter to be used for jobs under test. It maintains the current
behaviour by defaulting to an instance of
`ActiveJob::QueueAdapter::TestAdapter`. Tests that include
`ActiveJob::TestHelper` or extend from `ActiveJob::TestCase` can provide
a custom queue adapter by overriding `queue_adapter_for_test` in their
class.
2016-06-11 15:18:52 -04:00
Jake Worth ffb6ab4fe1 Fix typo, `of of` -> `of` [ci skip] 2016-06-09 16:23:58 -05:00
Tim Wade ad9882369a
[ci skip] Reword doc for around_enqueue callback
Taken literally, the documentation suggests that the callback gets
called twice (before and after enqueueing). By wording it similarly to
that of around_perform this confusion is avoided.
2016-05-27 15:39:30 -07:00
Javan Makhmali d12209cad2 Remove package:clean task
Introduced in d6f2000a67 and was only used by Action Cable. Now handled by Action Cable’s assets:compile task.
2016-05-24 13:11:28 -04:00
Jeremy Daer 89e2f7e722
Support for unified Integer class in Ruby 2.4+
Ruby 2.4 unifies Fixnum and Bignum into Integer: https://bugs.ruby-lang.org/issues/12005

* Forward compat with new unified Integer class in Ruby 2.4+.
* Backward compat with separate Fixnum/Bignum in Ruby 2.2 & 2.3.
* Drops needless Fixnum distinction in docs, preferring Integer.
2016-05-18 21:58:51 -07:00
Jeremy Daer e35b98e6f5
Action Mailer: Declarative exception handling with `rescue_from`.
Follows the same pattern as controllers and jobs. Exceptions raised in
delivery jobs (enqueued by `#deliver_later`) are also delegated to the
mailer's rescue_from handlers, so you can handle the DeserializationError
raised by delivery jobs:

```ruby
class MyMailer < ApplicationMailer
  rescue_from ActiveJob::DeserializationError do
    …
  end
```

ActiveSupport::Rescuable polish:
* Add the `rescue_with_handler` class method so exceptions may be
  handled at the class level without requiring an instance.
* Rationalize `exception.cause` handling. If no handler matches the
  exception, fall back to the handler that matches its cause.
* Handle exceptions raised elsewhere. Pass `object: …` to execute
  the `rescue_from` handler (e.g. a method call or a block to
  instance_exec) against a different object. Defaults to `self`.
2016-05-15 18:44:16 -07:00
Rafael Mendonça França 8ecc5ab1d8 Start Rails 5.1 development 🎉 2016-05-10 03:46:56 -03:00
Rafael Mendonça França fbdcf5221a Preparing for 5.0.0.rc1 release 2016-05-06 16:54:40 -05:00
lvl0nax 517cf249c3
Chomp: prefer String#chomp where we can for a clarity boost
Closes #24766, #24767

Signed-off-by: Jeremy Daer <jeremydaer@gmail.com>
2016-04-29 13:43:15 -07:00
Prathamesh Sonpatki 1d6f012718
Active Job: Add note about ability to configure adapters on per job basis in CHANGELOG and release notes.
[ci skip]
2016-04-29 07:26:26 +05:30
eileencodes f7a986012a Prep Rails 5 beta 4 2016-04-27 15:48:47 -05:00
Graeme Boy 6e27481dc7 Fix typo in ActiveJob #retry_job doc 2016-04-23 17:23:19 -07:00
Mohit Natoo 23f472ae7c - [ci skip] Active Job Async doesn't support to Async feature as per it's definition.
- [ci skip] Active Job Async doesn't support to Async feature as per it's definition.

- [ci skip] Active Job Async doesn't support to Async feature as per it's definition.

- [ci skip] Active Job Async doesn't support to Async feature as per it's definition.

- [ci skip] Active Job Async doesn't support to Async feature as per it's definition.
2016-04-22 15:37:20 +05:30
Eileen M. Uchitelle e88d63e6f7 Merge pull request #24165 from y-yagi/generate_application_job_when_not_exist
generate ApplicationJob if it does not already exist
2016-04-09 09:46:37 -04:00
yuuji.yaginuma 87824ab583 update `assert_no_performed_jobs` doc to use `assert_no_performed_jobs` method [ci skip] 2016-03-30 08:12:49 +09:00
yuuji.yaginuma 9a9fc01af0 generate ApplicationJob if it does not already exist
ActiveJob jobs now inherit from ApplicationJob by default.
However, when updating to Rails 5 from the old Rails,
since there is a possibility that ApplicationJob does not exist.
2016-03-25 13:21:37 +09:00
Santosh Wadghule 26e76dc879 Added more tests for reserved hash keys of ActiveJob::Arguments.
- Added tests for checking all reserved hash keys of ActiveJob::Arguments.
- Moved unrelated code from the test to the correct place, i.e. newly created
  test.
2016-03-17 18:55:19 +05:30
Xavier Noria 1eb27fafa9 revises the homepage URL in the gemspecs [ci skip]
References https://github.com/rails/homepage/issues/46.
2016-03-10 07:55:27 +01:00
Mike Perham 8c98186742 Add JSON round trip verification testcase 2016-03-09 09:28:16 -08:00
Mike Perham 702ef37767 Job payload should be symmetric across JSON dump/load
Placing non-native JSON data types, like symbols, in the hash to serialize means that the deserialize method will return something different from what was serialized, a common bug and source of frustration for devs.
2016-03-09 08:56:21 -08:00
Arthur Nogueira Neves 15c308582f Merge pull request #23932 from arthurnn/arthurnn/remove_load_paths
Remove load_paths file
2016-03-01 16:10:09 -05:00
Matthew Draper 5bdeb9bfd7 Use AS::Reloader to support reloading in ActiveJob 2016-03-02 02:14:54 +10:30
Jeremy Daer 75097933e2 Merge pull request #23966 from jeremy/activejob/pare-down-async-adapter-for-low-footprint-dev
Active Job: pare down async adapter for low footprint dev
2016-03-01 00:19:20 -07:00
Jeremy Daer a66780bfff Active Job: smaller footprint for the dev/test async adapter
Use one shared worker pool for all queues with 0-#CPU workers rather
than separate pools per queue with 2-10*#CPU workers each.
2016-02-29 15:58:26 -07:00
Mohit Natoo dec21eb5f6 - Updating the dummy app template to have rails_command instead of rake 2016-03-01 02:39:43 +05:30
Arthur Neves 2abcdfd978 Remove load_paths file 2016-02-27 13:03:57 -05:00
Rafael Mendonça França 116581be91 Do not define methods in the included block
Instance methods can be defined in the module itself
2016-02-24 13:37:32 -03:00
eileencodes dbfa8fdfc2 Preparing for 5.0.0.beta3 release
Adds changelog headers for beta3 release
2016-02-24 11:14:40 -05:00
eileencodes 826420b5fc Prep release for Rails 5 beta3 2016-02-24 10:27:02 -05:00
Abhishek Jain 9a2ca9cf69 [ci skip] Fix enqueuing spelling to maintain consistency 2016-02-12 23:49:08 +05:30
yuuji.yaginuma 6809758bc6 fix typo in `assert_enqueued_jobs` example [ci skip] 2016-02-07 09:12:19 +09:00