Commit Graph

735 Commits

Author SHA1 Message Date
J Smith 69e0e0acf9 Ignore psqlrc files when executing psql commands
psqlrc files can affect the execution of commands in ways that can hold
up execution by blocking or otherwise cause unexpected side effects and
should best be ignored when using psql programmatically.
2018-09-17 12:13:42 -03:00
bogdanvlviv 237ef95338
Print correct rake command on running AJ integration tests
Currently when executing `bundle exec rake test:integration` under `activejob/`
derectory, it prints helpful info like:
```
(snip)
*** rake aj:integration:async ***
(snip)
*** rake aj:integration:delayed_job ***
(snip)
 ```
but  there is no defined `:aj` scope  in `activejob/Rakefile`,
so I think output should be like:
```
(snip)
*** rake test:integration:async ***
(snip)
*** rake test:integration:delayed_job ***
(snip)
 ```

By the way `rake test:integration` doesn't work if execute it without
prepending `bundle exec` to that command. It is probably what we should
fix too.
2018-09-17 08:19:12 +03:00
bogdanvlviv b6b5a7ac52
`retry_job` should publish `enqueue_retry.active_job` notification
Also this commit removes `:wait` from payload of
`retry_stopped.active_job`.

Related to https://github.com/rails/rails/pull/33751#discussion_r214140008
Follow up #33751

/cc @kaspth, @rafaelfranca
2018-09-16 17:46:24 +03:00
Sharang Dashputre ca875d0c02 Update arguments.rb [ci skip]
Fix typo `Instrinsic` -> `Intrinsic`
2018-09-13 22:14:27 +05:30
bogdanvlviv 5a212939c2
Add changelog entries for #33849 [ci skip]
Since these changes related to the public API, I think we should add
changelog entries.

Related to #33838, #33849
2018-09-13 16:58:56 +03:00
Rafael França b79f3cc96b
Merge pull request #33849 from ricardotk002/include-helpers-action-dispatch-integration-test
Include test helpers in ActionDispatch::IntegrationTest
2018-09-12 19:19:17 -04:00
Ricardo Díaz 64a9759aff Include test helpers when ActionDispatch::IntegrationTest is loaded
As @dhh brings up, the point of `ActionDispatch::IntegrationTest` is to
allow users to test the integration of all the pieces called by a
controller. Asserting about the emails and jobs queued is part of that
task.

This commit includes the `ActionMailer::TestHelper` and
`ActiveJob::TestHelper` modules when the ActionMailer and ActiveJob
railties are initialized respectively.
2018-09-12 16:58:14 -05:00
Sharang Dashputre 9203d2b3e1
Update test_helper_test.rb
Fix typo `wiht` -> `with`
2018-09-12 15:35:22 +05:30
Rafael França 66ab9c74dd
Merge pull request #33823 from stoodfarback/aj_backburner_fix_priority
ActiveJob Backburner adapter: fix priority
2018-09-10 17:50:37 -04:00
Eileen M. Uchitelle 12b32d8049
Merge pull request #33826 from tgturner/activejob-retry-attempts
retry_on argument `attempts` clarification
2018-09-09 15:22:18 -04:00
Graham Turner 86aa8f8c56 clarifies documentation around the attempts arugment to retry_on 2018-09-09 09:46:20 -04:00
yuuji.yaginuma 9d848d8545 Add missing `perform_enqueued_jobs` to error logging test
Without `perform_enqueued_jobs`, job are not executed and assertion is not done.
2018-09-09 13:46:43 +09:00
stoodfarback fc4e7d44c8 ActiveJob Backburner adapter: fix priority
The priority wasn't being passed from ActiveJob to Backburner, despite
priority being supported. This also brings it inline with the docs,
which mark Backburner as supporting priorities in the "Backend Features"
table: https://api.rubyonrails.org/classes/ActiveJob/QueueAdapters.html
2018-09-07 21:55:05 -07:00
Rafael França 5bbaae0d20
Merge pull request #33751 from steves/add_retry_notifications_to_aj
Add hooks to ActiveJob around retries and discards
2018-08-30 13:39:51 -05:00
Steve S 3bf33d7c2c
Move ActiveJob retry and discard logging into log subscriber 2018-08-30 13:07:37 -04:00
Steve S 26dc9bc8ee
Add hooks to ActiveJob around retries and discards 2018-08-29 13:28:55 -04:00
Matthew Draper 068fe7dc90
Merge pull request #33718 from kddeisz/permit-list
Finish converting whitelist and blacklist references
2018-08-29 14:07:37 +09:30
Rafael Mendonça França a8fff60814
Add test to make sure the custom object key can't be serialized 2018-08-28 16:31:15 -04:00
Kevin Deisz 7c9751d7fe
Permit list usage cleanup and clearer documentation 2018-08-27 09:51:46 -04:00
Kevin Deisz 0efecd913c
Convert remaining usage of whitelist and blacklist 2018-08-24 16:16:41 -04:00
utilum 96ac7e4cde Remove duplicate test
This patch corrects a duplicate method name introduced in #33635.

Also fixes typo in method names.
2018-08-22 01:41:09 -07:00
bogdanvlviv b8576425ee
DRY in `assert_enqueued_jobs` 2018-08-20 13:05:29 +03:00
bogdanvlviv b7beb5d4e5
Fix formatting of `ActiveJob::TestHelper` api docs 2018-08-20 13:05:29 +03:00
bogdanvlviv 2ec60fb818
Allow `assert_performed_with` to be called without a block.
Example:
```
def test_assert_performed_with
  MyJob.perform_later(1,2,3)

  perform_enqueued_jobs

  assert_performed_with(job: MyJob, args: [1,2,3], queue: 'high')
end
```

Follow up #33626.
2018-08-20 13:05:29 +03:00
bogdanvlviv 11634e8ef8
Fix `assert_performed_jobs` and `assert_no_performed_jobs`
Execution of `assert_performed_jobs`, and `assert_no_performed_jobs`
without a block should respect passed `:except`, `:only`, and `:queue` options.
2018-08-20 13:05:29 +03:00
bogdanvlviv 2bf8b4eb0e
Add changelog entry about adding `:queue` option to job assertions and helpers
Note that it removes changelog entry of #33265 since the entry in this commits
includes that too.
2018-08-20 13:05:29 +03:00
bogdanvlviv de4420da44
Allow `:queue` option to `assert_no_performed_jobs`.
If the `:queue` option is specified, then only the job(s) enqueued to a specific
queue will not be performed.

Example:
```
def test_assert_no_performed_jobs_with_queue_option
  assert_no_performed_jobs queue: :some_queue do
    HelloJob.set(queue: :other_queue).perform_later("jeremy")
  end
end
```
2018-08-20 13:05:29 +03:00
bogdanvlviv d50fb21e4d
Allow `:queue` option to `assert_performed_jobs`.
If the `:queue` option is specified, then only the job(s) enqueued to a specific
queue will be performed.

Example:
```
def test_assert_performed_jobs_with_queue_option
  assert_performed_jobs 1, queue: :some_queue do
    HelloJob.set(queue: :some_queue).perform_later("jeremy")
    HelloJob.set(queue: :other_queue).perform_later("bogdan")
  end
end
```
2018-08-20 13:05:29 +03:00
bogdanvlviv e0cf042fa2
Fix `perform_enqueued_jobs`
Set
````
queue_adapter.perform_enqueued_jobs = true
queue_adapter.perform_enqueued_at_jobs = true
queue_adapter.filter = only
queue_adapter.reject = except
queue_adapter.queue = queue
```
if block given.
Execution of `flush_enqueued_jobs` doesn't require that.
2018-08-20 13:05:22 +03:00
bogdanvlviv ec2e8f645e
Allow `:queue` option to `perform_enqueued_jobs`.
If the `:queue` option is specified, then only the job(s) enqueued to
a specific queue will be performed.

Example:
```
def test_perform_enqueued_jobs_with_queue
  perform_enqueued_jobs queue: :some_queue do
    MyJob.set(queue: :some_queue).perform_later(1, 2, 3) # will be performed
    HelloJob.set(queue: :other_queue).perform_later(1, 2, 3) # will not be performed
  end
  assert_performed_jobs 1
end
```

Follow up #33265

[bogdanvlviv & Jeremy Daer]
2018-08-20 00:20:06 +03:00
yuuji.yaginuma e49fb7921e Increment execution count before deserialize arguments
Currently, the execution count increments after deserializes arguments.
Therefore, if an error occurs with deserialize, it retries indefinitely.

In order to prevent this, the count is moved before deserialize.
Fixes #33344.
2018-08-18 11:22:41 +09:00
bogdanvlviv f169752163
Add example `perform_enqueued_jobs` without block to api docs [ci skip]
Follow up #33626
2018-08-16 09:29:30 +03:00
Kevin Deisz ec16301488
Allow `perform_enqueued_jobs` to be called without a block.
Performs all of the jobs that have been enqueued up to this point in the test.
2018-08-15 15:00:40 -04:00
Mohit Natoo 2d57f2f2f2 Documentation for queue_adapter_name method in ActiveJob::QueueAdapter [ci skip] 2018-08-10 02:02:58 +05:30
Mohit Natoo 39d87a4b7b perform_or_enqueue instead of enqueue_or_perform 2018-08-09 20:33:43 +05:30
Paul McMahon 7b9c19d94b Rails guides are now served over https
http links will be redirected to the https version, but still better to
just directly link to the https version.
2018-07-24 11:29:31 +09:00
Kasper Timm Hansen 7b3ead3b26
[ci skip] Fixup changelog. Trim title. Mention benefit. 2018-07-20 21:40:53 +02:00
zvkemp 2a1884bfe5 Wrap ActiveJob::Enqueue in evented ActiveSupport::Notification 2018-07-17 15:05:12 -07:00
alpaca-tc a07354d9eb ActiveJob::Base no longer dependents on Serializers 2018-07-03 21:48:26 +09:00
Kasper Timm Hansen dca5596f99
Revert "Merge pull request #33234 from alpaca-tc/autoload_activejob_arguments"
It breaks Active Job when run in isolation. E.g. bin/test test/cases/logging_test.rb:
https://travis-ci.org/rails/rails/jobs/398779028

Consider Rafaels suggestion of reviewing the eager loading instead:
https://github.com/rails/rails/pull/33234#issuecomment-401027419

This reverts commit cb0fdaacb2, reversing
changes made to a0a1abb3c7.
2018-07-01 13:22:44 +02:00
bogdanvlviv 22c7d5650c
Allow `queue` option to `assert_no_enqueued_jobs`
It can be asserted that no jobs are enqueued to a specific queue:
```ruby
def test_no_logging
  assert_no_enqueued_jobs queue: 'default' do
    LoggingJob.set(queue: :some_queue).perform_later
  end
end
```
2018-06-30 18:30:55 +03:00
Ryuta Kamizono b3653aee94
Merge pull request #33257 from utilum/ruby-warnings
Fix Ruby warnings tickled by the test suite
2018-06-30 17:58:02 +09:00
utilum e862ee86b7 Fix Ruby warnings tickled by the test suite 2018-06-30 10:20:45 +02:00
bogdanvlviv 58271f6314
Clarify activejob/lib/active_job/test_helper.rb
Rename `in_block_job` to `enqueued_job` since this variable can refer not only
to jobs that were created in the block.
See #33258.

Return back accidentally removed test to activejob/test/cases/test_helper_test.rb
See #33258.

Fix name of tests.
2018-06-29 19:46:55 +03:00
bogdanvlviv 4382fcbc22
Allow call `assert_enqueued_with` and `assert_enqueued_email_with` with no block
Example of `assert_enqueued_with` with no block
```ruby
def test_assert_enqueued_with
  MyJob.perform_later(1,2,3)
  assert_enqueued_with(job: MyJob, args: [1,2,3], queue: 'low')

  MyJob.set(wait_until: Date.tomorrow.noon).perform_later
  assert_enqueued_with(job: MyJob, at: Date.tomorrow.noon)
end
```

Example of `assert_enqueued_email_with` with no block:
```ruby
def test_email
  ContactMailer.welcome.deliver_later
  assert_enqueued_email_with ContactMailer, :welcome
end

def test_email_with_arguments
  ContactMailer.welcome("Hello", "Goodbye").deliver_later
  assert_enqueued_email_with ContactMailer, :welcome, args: ["Hello", "Goodbye"]
end
```

Related to #33243
2018-06-29 15:37:02 +03:00
Rafael Mendonça França 03fd2f3810
Revert "Merge pull request #33243 from evopark/fix/action-mailer-test-helper-no-block"
This reverts commit 9d6bbf4e0b, reversing
changes made to 5a1ea09062.

This method only works with block.
2018-06-28 15:08:01 +02:00
Marcus Ilgner 3919cb398b
Fix ActionMailer assert_enqueued_email_with
The documentation for assert_enqueued_email_with states that it's
supposed to work without a block yet it calls assert_enqueued_with
which doesn't check whether a block was passed before calling `yield`
2018-06-28 11:01:55 +02:00
alpaca-tc ff2fbe2708 Autoload ActiveJob::Arguments 2018-06-27 14:53:49 +09:00
alpaca-tc 391015e238 ActiveJob::Arguments is no longer used in file 2018-06-27 14:53:37 +09:00
bogdanvlviv f1e625f853
Add changelog entry for 3110cae [ci skip]
Since it is changes of the public API, it seems valuable to add a mention
about it to the changelog file.

Follow up 3110caecbe
2018-06-27 00:47:48 +03:00
George Claghorn 3110caecbe Allow passing multiple exceptions to retry_on/discard_on 2018-06-25 18:16:58 -04:00
bogdanvlviv d6702b7ab2
Fix name of the second parameter of block executed by `discard_on` and `retry_on`
[ci skip]

Follow up #32854 and ba07b5fc12.
2018-05-29 07:11:33 +00:00
Oscar Amado ef90adfd27 update README link: md instead rdoc [ci skip] 2018-05-24 17:49:35 +02:00
Oscar Amado d795e94c45 correct link to activejob readme [ci skip] 2018-05-24 16:39:38 +02:00
utilum a48f6a5d9f Enable warnings in all test tasks
Also normalize AJ task use t, like all other Rails test tasks.
2018-05-23 23:05:03 +02:00
Kasper Timm Hansen ba07b5fc12
Rename exception variable to error.
Follows the change from 6fac9bd, so the naming is consistent.
2018-05-21 15:43:16 +02:00
yuuji.yaginuma 6fac9bd599 Pass the error instance as the second parameter of block executed by `discard_on`
I'm not sure what originally wanted to pass to the argument.
However, as long as see the document added along with the commit, it seems just
to be mistaken that trying to pass the error instance.
https://github.com/rails/rails/pull/30622/files#diff-59beb0189c8c6bc862edf7fdb84ff5a7R64

Fixes #32853
2018-05-12 13:55:25 +09:00
Rafael Mendonça França 5b9cd1a579
Make sure that when serialing an just deserialized job arguments are there
When a job was just deserialized `arguments` is `nil` and the serialized
arguments are in the `@serialized_arguments` variable. If we try to
serialize this job again the arguments are going to be `nil` instead of
what was serialized.

The test we had was not checking this case because it was deserializing
the job in the same object that had the arguments.

To fix this, when the `@serialized_arguments` are present we return it
instead of the result of the `arguments` serialized.
2018-05-01 13:33:50 -04:00
Ryuta Kamizono e4a0a04883 Strip duplicated suffixes more strictly
In the previous code incorrectly removes intermediate words.
2018-04-22 14:30:07 +09:00
Yoshiyuki Hirano 8e2c91df4a Fix duplicated suffix for JobGenerator 2018-04-22 12:09:04 +09:00
Jared Rader 48a1d63777 fix spelling in docs for ActiveJob::Serializers::ObjectSerializer#deserialize 2018-04-13 06:59:50 -07:00
Alberto Almagro 6ef720791d Remove support for Qu gem.
Reasons are that the Qu gem wasn't compatible since Rails 5.1,
gem development was stopped in 2014 and maintainers have
confirmed its demise. See issue #32273
2018-03-19 21:27:16 +01:00
Jeremy Green 538463bce7 Add documentation about not accepting PRs for new adapters (#32298) 2018-03-19 14:46:07 -04:00
Rafael Mendonça França ba0ae542ca
Remove changelog header for unreleased version
We only add the header when releasing to avoid some conflicts.

[ci skip]
2018-03-13 15:20:57 -04:00
bogdanvlviv dd075657d0
Fix CHANGELOGs [ci skip]
- Add missing dots.
- Remove reference to itself on GitHub.
  Usually, we add references to fixed issues only in a changelog.

Follow up #32223
2018-03-12 08:44:50 +02:00
bogdanvlviv 6a1e7292bc
Remove passing extra arguments to ActiveJob Callbacks 2018-02-23 00:58:00 +02:00
Andrew White a9d1167b1f Add support for timezones to Active Job
Record what was the current timezone in effect when the job was
enqueued and then restore when the job is executed in same way
that the current locale is recorded and restored.
2018-02-22 14:14:42 +00:00
Rafael França b7b73de0df
Merge pull request #32026 from bogdanvlviv/improve-30941
Improve ActiveJob custom argument serializers #30941
2018-02-20 13:35:34 -05:00
yuuji.yaginuma 7d2b8f3ac9 Fix "warning: BigDecimal.new is deprecated" 2018-02-18 09:59:58 +09:00
Jeremy Daer d4eb0dc89e Rails 6 requires Ruby 2.4.1+
Skipping over 2.4.0 to sidestep the `"symbol_from_string".to_sym.dup` bug.

References #32028
2018-02-17 15:34:57 -08:00
bogdanvlviv 67391879f6
Fix error message about unknown `ActiveJob` argument serializer 2018-02-17 17:48:10 +02:00
bogdanvlviv 30528cda9e
Fix docs of ActiveJob custom argument serializers
Add `:nodoc:` to `ActiveJob::Serializers`
Add `:doc:` to `ActiveJob::Serializers::ObjectSerializer#klass`
Express `ActiveJob::Serializers::ObjectSerializer#klass` as private method
2018-02-17 17:48:10 +02:00
bogdanvlviv d2c094aa50
Add argument serializer `TimeWithZoneSerializer`
The serializer serializes an instance of `ActiveSupport::TimeWithZone`.
The serializer deserializes value to `ActiveSupport::TimeWithZone` if possible.
2018-02-17 17:48:10 +02:00
Rafael França 21cc0432e4
Merge pull request #32002 from y-yagi/fix_set_serializer
Fix custome serializer setting
2018-02-17 00:09:23 -05:00
Rafael Mendonça França 0ea8e7db1a Remove support to Ruby 2.2
Rails 6 will only support Ruby >= 2.3.
2018-02-16 18:52:10 -05:00
Yuji Yaginuma 3cc93de6ad Fix custome serializer setting
The serializer should be set up in `after_initialize` so that it work
properly even if the user specifies serializer with initializers.

Also, since `custom_serializers` is `Array`, it needs to be flattened
before setting the value.
2018-02-16 14:56:05 +09:00
Rafael Mendonça França 25a14bf2bd Add CHANGELOG entry 2018-02-14 13:13:51 -05:00
Rafael Mendonça França b59c7c7e69 Add tests to serialize and deserialze individually
This will make easier to be backwards compatible when changing the
serialization implementation.
2018-02-14 13:10:08 -05:00
Rafael Mendonça França 69645cba72 Simplify the implementation of custom argument serializers
We can speed up things for the supported types by keeping the code in the
way it was.

We can also avoid to loop trough all serializers in the deserialization by
trying to access the class already in the Hash.

We could also speed up the custom serialization if we define the class
that is going to be serialized when registering the serializers, but
that will remove the possibility of defining a serialzer for a
superclass and have the subclass serialized using it.
2018-02-14 13:10:08 -05:00
Rafael Mendonça França 71721dc1c9 Improve documentation on custom serializers 2018-02-14 13:10:08 -05:00
Rafael Mendonça França a5f7357a3d Add configuration to set custom serializers 2018-02-14 13:10:08 -05:00
Rafael Mendonça França 2fe467091b No need to require a autoloaded constant 2018-02-14 13:10:08 -05:00
Rafael Mendonça França d9a5c7011f Add serializers for Time, Date and DateTime 2018-02-14 13:10:08 -05:00
Rafael Mendonça França d2d98d6946 Allow serializers to be used either as classes or objects 2018-02-14 13:10:08 -05:00
Rafael Mendonça França b098584f63 Add symbol and duration serializers 2018-02-14 13:10:08 -05:00
Rafael Mendonça França ea61533245 Only add one more custom key in the serialized hash
Now custom serialziers can register itself in the serialized hash using
the "_aj_serialized" key that constains the serializer name.

This way we can avoid poluting the hash with many reserved keys.
2018-02-14 13:10:07 -05:00
Rafael Mendonça França 9bc8b4bbde Define the interface of a Serializer 2018-02-14 13:10:07 -05:00
Rafael Mendonça França 803f4385c6 Remove unnecessary qualified constant lookups 2018-02-14 13:10:07 -05:00
Rafael Mendonça França ec686a471e Simplify the implementation of custom serialziers
Right now it is only possible to define serializers globally so we don't
need to use a class attribute in the job class.
2018-02-14 13:10:07 -05:00
Evgenii Pecherkin 3785a57299 Remove non-default serializers 2018-02-14 13:10:07 -05:00
Evgenii Pecherkin e360ac1231 Introduce serializers to ActiveJob 2018-02-14 13:10:07 -05:00
Rafael Mendonça França 1c383df324 Start Rails 6.0 development!!!
🎉🎉🎉
2018-01-30 18:51:17 -05:00
Ryuta Kamizono cdb15ba7cd Fix CHANGELOG format [ci skip]
* Add backticks
* Expand tabs
* Fix indentation
2018-01-24 09:24:49 +09:00
Rafael França 4cfd40a580
Merge pull request #30622 from aidanharan/custom-discarded-job-handling
Allow for custom handling of exceptions that are discarded
2018-01-23 17:07:25 -05:00
Ryuta Kamizono 5a50146888 Consolidate `queue_adapter=` and `interpret_adapter`
Since #25037, `queue_adapter=` simply delegates to `interpret_adapter`
only.
2018-01-05 17:18:56 +09:00
Yoshiyuki Hirano b20354afcc Bump license years for 2018 2017-12-31 22:36:55 +09:00
yuuji.yaginuma ce98cd0d0d Explicitly require `sidekiq/cli`
Currently, sidekiq integration test + Ruby 2.5.0-rc1 show exception as follows.

```
#<Thread:0x000000000670bec0@/home/travis/build/rails/rails/vendor/bundle/ruby/2.5.0/gems/sidekiq-5.0.5/lib/sidekiq/util.rb:23 run> terminated with exception (report_on_exception is true):
/home/travis/build/rails/rails/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.1.7/lib/bootsnap/load_path_cache/core_ext/active_support.rb:53:in `block in load_missing_constant': uninitialized constant Sidekiq::CLI (NameError)
	from /home/travis/build/rails/rails/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.1.7/lib/bootsnap/load_path_cache/core_ext/active_support.rb:8:in `without_bootsnap_cache'
	from /home/travis/build/rails/rails/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.1.7/lib/bootsnap/load_path_cache/core_ext/active_support.rb:53:in `rescue in load_missing_constant'
	from /home/travis/build/rails/rails/vendor/bundle/ruby/2.5.0/gems/bootsnap-1.1.7/lib/bootsnap/load_path_cache/core_ext/active_support.rb:42:in `load_missing_constant'
	from /home/travis/build/rails/rails/vendor/bundle/ruby/2.5.0/gems/sidekiq-5.0.5/lib/sidekiq/launcher.rb:65:in `heartbeat'
	from /home/travis/build/rails/rails/vendor/bundle/ruby/2.5.0/gems/sidekiq-5.0.5/lib/sidekiq/launcher.rb:123:in `start_heartbeat'
```

https://travis-ci.org/rails/rails/jobs/317187279#L2152

The reason for this is that `Sidekiq::CLI` has not been loaded.
Sidekiq integration test launches a Sidekiq instance within
another Ruby process. In such a case, need to require 'sidekiq/cli'
in that launch code.

Ref: https://github.com/mperham/sidekiq/pull/3692#issuecomment-352032251
2017-12-16 11:02:26 +09:00
Yasuo Honda e4a6a23aa7 Suppress `warning: BigDecimal.new is deprecated`
`BigDecimal.new` has been deprecated in BigDecimal 1.3.3
 which will be a default for Ruby 2.5.

Refer
533737338d

* This commit has been made as follows:

```
cd rails
git grep -l BigDecimal.new | grep -v guides/source/5_0_release_notes.md | grep -v activesupport/test/xml_mini_test.rb | xargs sed -i -e "s/BigDecimal.new/BigDecimal/g"
```
- `activesupport/test/xml_mini_test.rb`
Editmanually to remove `.new` and `::`

- guides/source/5_0_release_notes.md
This is a Rails 5.0 release notes.
2017-12-15 01:19:57 +00:00
Ryuta Kamizono 245c1dafa8 Enable `Layout/LeadingCommentSpace` to not allow cosmetic changes in the future
Follow up of #31432.
2017-12-14 17:30:54 +09:00
Yoshiyuki Hirano cd049112cb [ci skip] Add a space to comment in SidekiqAdapter
* I think it's better to have a leading space after the `#`
  denoting the start of the comment.
2017-12-14 04:50:49 +09:00
Aidan Haran 66f34a8ea5
Merge branch 'master' into custom-discarded-job-handling 2017-12-09 13:41:02 +00:00
Yoshiyuki Hirano 649f19cab1 Fix example code in ActiveJob::Core [ci skip]
1) It seems that it raise error on example code in `ActiveJob::Core`.

Before:

```ruby
class DeliverWebhookJob < ActiveJob::Base
  def serialize
    super.merge('attempt_number' => (@attempt_number || 0) + 1)
  end

  def deserialize(job_data)
    super
    @attempt_number = job_data['attempt_number']
  end

  rescue_from(Timeout::Error) do |exception|
    raise exception if @attempt_number > 5
    retry_job(wait: 10)
  end

  def perform
    raise Timeout::Error
  end
end
```

Then it run `DeliverWebhookJob.perform_now` in `rails console`. And raise error:

NoMethodError: undefined method `>' for nil:NilClass
from /app/jobs/deliver_webhook_job.rb:12:in `block in <class:DeliverWebhookJob>'

So I thought it's necessary to fix it.

After:

```ruby
class DeliverWebhookJob < ActiveJob::Base
  attr_writer :attempt_number

  def attempt_number
    @attempt_number ||= 0
  end

  def serialize
    super.merge('attempt_number' => attempt_number + 1)
  end

  def deserialize(job_data)
    super
    self.attempt_number = job_data['attempt_number']
  end

  rescue_from(Timeout::Error) do |exception|
    raise exception if attempt_number > 5
    retry_job(wait: 10)
  end

  def perform
    raise Timeout::Error
  end
end
```

Then it run `DeliverWebhookJob.perform_now` in `rails console`. And it does'nt raise error NoMethodError.

2) Use `Timeout::Error` instead of `TimeoutError` (`TimeoutError` is deprecated).
2017-12-05 15:40:22 +09:00
Rafael Mendonça França 2837d0f334
Preparing for 5.2.0.beta2 release 2017-11-28 14:41:02 -05:00
Fatos Morina 37cf9b3466 Fix typos and add a few suggestions 2017-11-28 19:27:43 +01:00
Rafael Mendonça França cceeeb6e57
Preparing for 5.2.0.beta1 release 2017-11-27 14:50:03 -05:00
Jacek Lachowski b1fbb6688c Improve DelayedJob wrapper logging
ActiveJob wraps every adapter into its own class, that is later passed
into DelayedJob which is responsible for displaying all the logs.

This change improves the logging so we can easily trace executed
jobs and see meaningful information in the logs.
2017-11-24 10:40:16 +01:00
Rafael Mendonça França 8dd76a7a6f
Use .tt extension to all the template files
Make clear that the files are not to be run for interpreters.

Fixes #23847.
Fixes #30690.
Closes #23878.
2017-11-13 15:23:28 -05:00
yuuji.yaginuma 8e964556e7 Make sidekiq and resque integration tests work in CI
Since 8f2490b, the integration test of sidekiq and resque is not working
in CI.
https://travis-ci.org/rails/rails/jobs/301276197#L2055
https://travis-ci.org/rails/rails/jobs/301276197#L2061

Because 8f2490b removed password from `redis-server`.
So must also remove passwords from these tests.
2017-11-13 21:02:40 +09:00
yuuji.yaginuma 1ecdd7e8a7 Return a non zero code when can not connect to redis in CI 2017-11-13 21:02:33 +09:00
bogdanvlviv 0835527d6b
`rails new` runs `rails active_storage:install`
Omit `rails activestorage:install` for jdbcmysql, jdbc and shebang tests

AppGeneratorTest#test_config_jdbcmysql_database

  rails aborted!
  LoadError: Could not load 'active_record/connection_adapters/mysql_adapter'.
  Make sure that the adapter in config/database.yml is valid.
  If you use an adapter other than 'mysql2', 'postgresql' or 'sqlite3' add
  the necessary adapter gem to the Gemfile.
  (compressed)
  bin/rails:4:in `<main>'
  Tasks: TOP => activestorage:install => environment
  (See full trace by running task with --trace)

AppGeneratorTest#test_config_jdbc_database

  rails aborted!
  LoadError: Could not load 'active_record/connection_adapters/jdbc_adapter'.
  Make sure that the adapter in config/database.yml is valid.
  If you use an adapter other than 'mysql2', 'postgresql' or 'sqlite3' add
  the necessary adapter gem to the Gemfile.
  (compressed)
  bin/rails:4:in `<main>'
  Tasks: TOP => activestorage:install => environment
  (See full trace by running task with --trace)

AppGeneratorTest#test_shebang_is_added_to_rails_file

  /home/ubuntu/.rbenv/versions/2.4.1/bin/ruby: no Ruby script found in input (LoadError)

Prevent PendingMigrationError in tests

 * Run `bin/rails db:migrate RAILS_ENV=test` in test_cases before start tests to prevent PendingMigrationError
 * FileUtils.rm_r("db/migrate")
 * --skip-active-storage

Fix failed tests in `railties/test/railties/engine_test.rb`

Related to #30111

Imporve `SharedGeneratorTests#test_default_frameworks_are_required_when_others_are_removed`

 - Explicitly skip active_storage
 - Ensure that skipped frameworks are commented
 - Ensure that default frameworks are not commented

Fix error `Errno::ENOSPC: No space left on device - sendfile`

Since `rails new` runs `rails active_storage:install`
that boots an app.

Since adding Bootsnap 0312a5c67e
during booting an app, it creates the cache:

   264K    tmp/cache/bootsnap-load-path-cache
   27M     tmp/cache/bootsnap-compile-cache

* teardown_app must remove app
2017-11-06 21:29:14 +00:00
Shuhei Kitagawa c40b4428e6 removed unnecessary returns 2017-10-28 17:20:38 +09:00
Rafael França 280fb08fc7 Merge pull request #30955 from prathamesh-sonpatki/rm-changelog-entry
Remove CHANGELOG entry for the change that was backported to 5-1-stable [ci skip]
2017-10-23 13:09:41 -04:00
Prathamesh Sonpatki 95de5033cd
Remove CHANGELOT entry for the change that was backported to 5-1-stable [ci skip]
- It was backported in
  0eae8dd4b8
  and is present in Rails 5.1.3
2017-10-23 20:04:31 +05:30
Akira Matsuda feb6ecd313 [Active Job] require_relative => require
This basically reverts fef234f1f0
2017-10-21 22:48:28 +09:00
Ryuta Kamizono a254454deb Merge pull request #30750 from k2nr/fix-active-job
Yield with an error instance instead of error class
2017-10-13 12:58:48 +09:00
Kazunori Kajihiro 34d7b05d27 Test exception message to ensure an exception instance is yielded 2017-10-13 11:55:36 +09:00
Jeremy Daer 53c516d88d
redis-rb 4.0 support
* Use `gem 'redis', '~> 4.0'` for new app Gemfiles
* Loosen Action Cable redis-rb dep to `>= 3.3, < 5`
* Bump redis-namespace for looser Redis version dep
* Avoid using the underlying `redis.client` directly
* Use `Redis.new` instead of `Redis.connect`
2017-10-08 15:37:54 -07:00
Kazunori Kajihiro 4a13c1e1d2 Yield with an error instance instead of error class 2017-09-29 18:15:56 +09:00
Aidan Haran 3291fa3630 Allow for custom handling of exceptions that are discarded 2017-09-16 19:59:32 +01:00
Yoshiyuki Hirano c7cd470bb3 Update activejob doc [ci skip] 2017-08-30 05:08:36 +09:00
Yoshiyuki Hirano 3a11e0586e Update MIT licenses link [ci skip] 2017-08-22 08:46:02 +09:00
Yoshiyuki Hirano 948c2c48df Use ssl in guide and comment [ci skip] 2017-08-19 08:23:37 +09:00
yuuji.yaginuma 0868cac0ef Use `ActiveJob::Base.queue_adapter_name` to get adapter name
Since 673606a, it holds adapter name.
2017-08-17 06:55:55 +09:00
Matthew Draper 788f46d486 Wait for the Delayed Job worker thread to finish 2017-08-13 22:03:40 +09:30
Kazuhiro NISHIYAMA 7f89d4e8bf Use File::NULL instead of "/dev/null" 2017-07-31 21:58:42 +09:00
yuuji.yaginuma 292be1b7de Use `ArgumentError` instead of own error class
If the argument is invalid, I think that it is more intuitive to use
`ArgumentError` than its own error class.
2017-07-20 07:38:26 +09:00
yuuji.yaginuma 2966f9598e Fix `warning: circular argument reference`
This fixes the following warnings:

```
rails/activejob/lib/active_job/test_helper.rb:119: warning: circular argument reference - except
rails/activejob/lib/active_job/test_helper.rb:166: warning: circular argument reference - except
```
2017-07-19 08:56:41 +09:00
posthumanism 4458b76756 Add `except` option for ActiveJob::TestHelper methods 2017-07-18 07:48:03 +09:00
Koichi ITO aa28c5ca65 [Active Job] `rubocop -a --only Layout/EmptyLineAfterMagicComment` 2017-07-11 13:12:32 +09:00
yuuji.yaginuma 46725b33a9 Make sidekiq and resque integration tests work in CI
Since f55ecc6, the integration test of sidekiq and resque is not working
in CI.
https://travis-ci.org/rails/rails/jobs/251783876

Because f55ecc6 required a password to access redis.
Therefore, handling by passing passwords when connecting to redis.
2017-07-10 07:42:17 +09:00
Kir Shatrov 14ece5e429 Use frozen-string-literal in ActiveJob 2017-07-09 20:50:52 +03:00
Akira Matsuda fef234f1f0 [Active Job] require => require_relative 2017-07-01 18:38:05 +09:00
Rafael França cf8c46938b Merge pull request #29588 from greysteil/add-gemspec-links
Add source code and changelog links to gemspecs
2017-06-28 11:24:02 -04:00
Grey Baker 3e6ce1cd69 Add source code and changelog links to gemspecs 2017-06-28 10:06:01 +01:00
utilum b58d73fc57 ActiveJob::Core#serialize stores provider_job_id (fixes #26581). 2017-06-27 07:08:55 +02:00
yuuji.yaginuma 12b3c60388 Remove needless gitignore
The dummy application is created under the tmp directory. Nothing is
created in the `test/dummy` directory.
40bdbce191/activejob/test/support/integration/helper.rb (L9)

I guess that this comment makes it unnecessary.
https://github.com/rails/rails/pull/16541#r16986711
2017-06-26 21:39:09 +09:00
bogdanvlviv 6673cf7071
Use `require_relative` instead of `require` with full path 2017-06-14 12:10:17 +03:00
Genadi Samokovarov b6b0c99ff3 Use mattr_accessor default: option throughout the project 2017-06-03 13:52:48 +03:00
David Heinemeier Hansson 1c275d812f Add option for class_attribute default (#29270)
* Allow a default value to be declared for class_attribute

* Convert to using class_attribute default rather than explicit setter

* Removed instance_accessor option by mistake

* False is a valid default value

* Documentation
2017-05-29 18:01:50 +02:00
yuuji.yaginuma 82e646f3d0 Bring back delayed_job to test list
`delayed_job_active_record` 4.1.2 supports Rails 5.1.
Ref: https://github.com/collectiveidea/delayed_job_active_record/pull/138
2017-05-28 21:39:18 +09:00
Mohit Natoo 4b04f56146 Removed string inquiry.
fixed indentation.

rebased with master.
2017-05-26 19:25:53 +07:00
Mohit Natoo 673606a962 Provides friendlier way to access queue adapters of a job.
- removed predicate method. Used only reader.
2017-05-26 19:00:34 +07:00
bogdanvlviv 40bdbce191
Define path with __dir__
".. with __dir__ we can restore order in the Universe." - by @fxn

Related to 5b8738c2df
2017-05-23 00:53:51 +03:00
dixpac 4f39556577 Improving docs for callbacks execution order [ci skip]
When define callbacks latest definition on the same callback/method
overwrites previous ones.
2017-05-21 18:45:59 +02:00
Ryuta Kamizono 89389428b5 Cleanup CHANGELOGs [ci skip]
* Remove trailing spaces.
* Add backticks around method and command.
* Fix indentation.
2017-04-30 02:41:44 +09:00
yuuji.yaginuma 8ae20e6582 Add missing require
Without this, unit test fails.

```
bundle exec ruby -w -Ilib:lib:test test/cases/logging_test.rb
Using inline
Run options: --seed 41246

# Running:

SE......S....

Finished in 0.052938s, 245.5696 runs/s, 831.1585 assertions/s.

  1) Error:
LoggingTest#test_job_error_logging:
NameError: uninitialized constant LoggingTest::RescueJob
    test/cases/logging_test.rb:130:in `rescue in test_job_error_logging'
    test/cases/logging_test.rb:129:in `test_job_error_logging'

13 runs, 44 assertions, 0 failures, 1 errors, 2 skips

You have skipped tests. Run with --verbose for details.
```
2017-04-21 08:02:26 +09:00
Steven Bull 452f9ee0bc Add error logging to Active Job
Active Job logging instrumentation is changed to log errors (with
backtrace) when a job raises an exception in #perform. This improves
debugging during development and test with the default configuration.

Prior to Rails 5, the default development configuration ran jobs with
InlineAdapter, which would raise exceptions to the caller and be
shown in the development log. In Rails 5, the default adapter was
changed to AsyncAdapter, which would silently swallow exceptions
and log a "Performed SomeJob from Async..." info message. This could
be confusing to a developer, as it would seem that the job was
performed successfully.

This patch removes the "Performed..." info message from the log
and adds an error-level "Error performing SomeJob..." log message
which includes the exception backtrace for jobs that raise an
exception within the #perform method. It provides this behavior for
all adapters.
2017-03-27 17:10:24 -07:00
Matthew Draper 6c08d480f1 Start Rails 5.2 development 2017-03-22 10:11:39 +10:30
David Heinemeier Hansson 85c2b7565f Revert #27850 following test breakage (#28427) 2017-03-15 17:46:28 +01:00
Rafael França cfa2664894 Merge pull request #28112 from bolek/include-job_id-in-all-active-job-logs
Include JobID in all ActiveJob info logs
2017-02-23 16:18:01 -05:00
Rafael Mendonça França f4acdd83ff
Preparing for 5.1.0.beta1 release 2017-02-23 14:53:21 -05:00
Bolek Kurowski 85c62a2c3d Include JobID in all ActiveJob info logs
Currently we provide the Job ID in logs only related to enqueuing a job.

This adds the job id to the remaining ActiveJob logs when:
 - a job started performing
 - a job ended performing

Providing the job id in those logs will ease searching logs by job id.
2017-02-22 17:11:28 -05:00
Jon Moss e342f4e60d Remove extra spaces
[ci skip]
2017-02-21 12:02:14 -05:00
yuuji.yaginuma 70e8fed5a3 remove `ActiveSupport.halt_callback_chains_on_return_false` from everywhere 2017-02-08 17:24:49 +09:00
Akira Matsuda c684f4f3da bin/test for Active Job and Action Cable tests
According to the commit comment on 54d84cbb77, AJ/bin/test was intentionally not added,
but AJ tests doesn't actually do anything special other than specifying ENV['AJ_ADAPTER'],
which can be easily done via command line environment variable.
2017-02-02 16:27:42 +09:00
Yuji Yaginuma 80dc309821 correctly set test adapter when configure the queue adapter on a per job (#26690)
The `ActiveJob::TestHelper` replace the adapter to test adapter in
`before_setup`. It gets the target class using the `descendants`, but if
the test target job class is not loaded, will not be a replacement of
the adapter.
Therefore, instead of replacing with `before_setup`, modified to
replace when setting adapter.

Fixes #26360
2017-01-31 16:37:16 -05:00
Alexander Pauly 08ddca51c6 Append skipped jobs to enqueued_jobs
Refactored ActiveJob TestAdapter

Updated ActiveJob changelog

Fixed typo in changelog

Fixed formatting issue in changelog
2017-01-31 07:36:19 +01:00
yuuji.yaginuma acd4840c2a make backburner integration test to work
Currently, backburner integration test is not running on CI.
https://travis-ci.org/rails/rails/jobs/196005322#L610

Using `Backburner::Worker.connection` to check whether beanstalkd is
running. But `Backburner::Worker.connection` was removed in backburner
1.2.0.
81fde499c2

Therefore, this check process always becomes false, so the test is no
longer done. I fixed it so that check processing is done correctly.
2017-01-28 11:34:28 +09:00
Guillermo Iguaran 1a752b6f2b Merge pull request #27624 from elfassy/assert_enqueued_jobs_with_queue_level
Specify the queue to be used with assert_enqueued_jobs
2017-01-19 20:23:58 -05:00
Michael Elfassy 3738358135 assert_enqueued_jobs with queue option 2017-01-18 09:13:16 -05:00
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