Add explicit base class for ActiveJob jobs #19034

Merged
merged 1 commit into from Mar 30, 2015

Conversation

Projects
None yet
10 participants
@jvanbaarsen
Contributor

jvanbaarsen commented Feb 22, 2015

  • Jobs generated should inherent from ApplicationJob
  • ApplicationJob inherents from ActiveJob::Base

Fixes #16976

/cc @tamird @rafaelfranca

@georgeclaghorn

This comment has been minimized.

Show comment
Hide comment
@georgeclaghorn

georgeclaghorn Feb 23, 2015

Member

Any reason not to create ApplicationJob when a new app is first created, like ApplicationController?

Member

georgeclaghorn commented Feb 23, 2015

Any reason not to create ApplicationJob when a new app is first created, like ApplicationController?

@jvanbaarsen

This comment has been minimized.

Show comment
Hide comment
@jvanbaarsen

jvanbaarsen Feb 23, 2015

Contributor

@georgeclaghorn Since not everyone might be using ActiveJob. But maybe it would be better to have it there right from the get go. @rafaelfranca @tamird what do you think?

Contributor

jvanbaarsen commented Feb 23, 2015

@georgeclaghorn Since not everyone might be using ActiveJob. But maybe it would be better to have it there right from the get go. @rafaelfranca @tamird what do you think?

@egilburg

This comment has been minimized.

Show comment
Hide comment
@egilburg

egilburg Feb 23, 2015

Contributor

I remember at some point there was Rails PR for ApplicationModel that all models inherited from (rather than ActiveRecord::Base, and then it didn't make it for some reason. :-(

Contributor

egilburg commented Feb 23, 2015

I remember at some point there was Rails PR for ApplicationModel that all models inherited from (rather than ActiveRecord::Base, and then it didn't make it for some reason. :-(

@cristianbica

This comment has been minimized.

Show comment
Hide comment
@cristianbica

cristianbica Feb 23, 2015

Member

app/jobs/application_job.rb should be from the beginning just like application_controller.rb. Also it would be nice if we show a log warning for people that inherit from ActiveJob::Base to switch to ApplicationJob.

Member

cristianbica commented Feb 23, 2015

app/jobs/application_job.rb should be from the beginning just like application_controller.rb. Also it would be nice if we show a log warning for people that inherit from ActiveJob::Base to switch to ApplicationJob.

@jvanbaarsen

This comment has been minimized.

Show comment
Hide comment
@jvanbaarsen

jvanbaarsen Feb 24, 2015

Contributor

Ok! I'll add it to the app generator :-) and I'll see if I can figure out the warning :)

Contributor

jvanbaarsen commented Feb 24, 2015

Ok! I'll add it to the app generator :-) and I'll see if I can figure out the warning :)

@jvanbaarsen

This comment has been minimized.

Show comment
Hide comment
@jvanbaarsen

jvanbaarsen Feb 24, 2015

Contributor

@cristianbica Im looking into the warnings, but not really sure how to tackle this. And besides, I checked with controllers. Its not something we do there (You can use a controller without inhereting from ApplicationController, without a warning). What do you think?

Contributor

jvanbaarsen commented Feb 24, 2015

@cristianbica Im looking into the warnings, but not really sure how to tackle this. And besides, I checked with controllers. Its not something we do there (You can use a controller without inhereting from ApplicationController, without a warning). What do you think?

@senny senny added the activejob label Feb 25, 2015

@rebyn

This comment has been minimized.

Show comment
Hide comment
@rebyn

rebyn Mar 6, 2015

Contributor

Im looking into the warnings, but not really sure how to tackle this.

Some really wild thoughts:

  • warning when people upgrade their Rails gem
  • warning when people run their jobs (and check for the class?)
Contributor

rebyn commented Mar 6, 2015

Im looking into the warnings, but not really sure how to tackle this.

Some really wild thoughts:

  • warning when people upgrade their Rails gem
  • warning when people run their jobs (and check for the class?)
@jvanbaarsen

This comment has been minimized.

Show comment
Hide comment
@jvanbaarsen

jvanbaarsen Mar 6, 2015

Contributor

@cristianbica What do you think?

Contributor

jvanbaarsen commented Mar 6, 2015

@cristianbica What do you think?

@cristianbica

This comment has been minimized.

Show comment
Hide comment
@cristianbica

cristianbica Mar 6, 2015

Member

Yes talked with the rails team and the warning is not something we want. We don't want to prohibit subclassing ActiveJob::Base but we want to encourage people to don't mangle with ActiveJob::Base directly. So there's no need for a warning. We need a changelog and some suggestions in the rails 5 upgrade guide.

Member

cristianbica commented Mar 6, 2015

Yes talked with the rails team and the warning is not something we want. We don't want to prohibit subclassing ActiveJob::Base but we want to encourage people to don't mangle with ActiveJob::Base directly. So there's no need for a warning. We need a changelog and some suggestions in the rails 5 upgrade guide.

@jvanbaarsen

This comment has been minimized.

Show comment
Hide comment
@jvanbaarsen

jvanbaarsen Mar 6, 2015

Contributor

@cristianbica Ok thanks! I'll fix those later tonight.

Contributor

jvanbaarsen commented Mar 6, 2015

@cristianbica Ok thanks! I'll fix those later tonight.

@@ -99,7 +99,7 @@ def test_should_not_eager_load_model_for_rake
end
def test_code_statistics_sanity
- assert_match "Code LOC: 5 Test LOC: 0 Code to Test Ratio: 1:0.0",
+ assert_match "Code LOC: 7 Test LOC: 0 Code to Test Ratio: 1:0.0",

This comment has been minimized.

@jvanbaarsen

jvanbaarsen Mar 16, 2015

Contributor

@cristianbica Somehow I had to change this line otherwise the tests did not pass. Do you have any idea why that is? It is because I added the application_job.rb file?

@jvanbaarsen

jvanbaarsen Mar 16, 2015

Contributor

@cristianbica Somehow I had to change this line otherwise the tests did not pass. Do you have any idea why that is? It is because I added the application_job.rb file?

This comment has been minimized.

@cristianbica

cristianbica Mar 23, 2015

Member

probably yes

@cristianbica

cristianbica Mar 23, 2015

Member

probably yes

@jvanbaarsen

This comment has been minimized.

Show comment
Hide comment
@jvanbaarsen

jvanbaarsen Mar 23, 2015

Contributor

@cristianbica What can I do to get this merged?

Contributor

jvanbaarsen commented Mar 23, 2015

@cristianbica What can I do to get this merged?

@seuros seuros added this to the 5.0.0 milestone Mar 23, 2015

@cristianbica

This comment has been minimized.

Show comment
Hide comment
@cristianbica

cristianbica Mar 23, 2015

Member

Please squash your commits. Otherwise seems good to me.

@rafaelfranca

Member

cristianbica commented Mar 23, 2015

Please squash your commits. Otherwise seems good to me.

@rafaelfranca

Add explicit base class for ActiveJob jobs
* Jobs generated now inherent from ApplicationJob
* ApplicationJob inherents from ActiveJob::Base
* Added entry to changelog

Signed-off-by: Jeroen van Baarsen <jeroenvanbaarsen@gmail.com>
@jvanbaarsen

This comment has been minimized.

Show comment
Hide comment
@jvanbaarsen

jvanbaarsen Mar 23, 2015

Contributor

@cristianbica Squashed commits. Waiting for build to be green

Contributor

jvanbaarsen commented Mar 23, 2015

@cristianbica Squashed commits. Waiting for build to be green

@jvanbaarsen

This comment has been minimized.

Show comment
Hide comment
@jvanbaarsen

jvanbaarsen Mar 30, 2015

Contributor

@cristianbica Test are passing, and the commits are squashed. Anything left for me to do?

Contributor

jvanbaarsen commented Mar 30, 2015

@cristianbica Test are passing, and the commits are squashed. Anything left for me to do?

@matthewd matthewd merged commit 929a794 into rails:master Mar 30, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

matthewd added a commit that referenced this pull request Mar 30, 2015

Merge pull request #19034 from jvanbaarsen/explicit-job-base-class
Add explicit base class for ActiveJob jobs
@cristianbica

This comment has been minimized.

Show comment
Hide comment
@cristianbica

cristianbica Mar 30, 2015

Member

nice. thanks @jvanbaarsen

Member

cristianbica commented Mar 30, 2015

nice. thanks @jvanbaarsen

@jvanbaarsen jvanbaarsen deleted the jvanbaarsen:explicit-job-base-class branch Mar 30, 2015

+* A generated job now inherents from `app/job/application_job.rb` by default.
+
+ *Jeroen van Baarsen*
+

This comment has been minimized.

@chancancode

chancancode Apr 3, 2015

Member

For the future, this should go on top of the file :)

@chancancode

chancancode Apr 3, 2015

Member

For the future, this should go on top of the file :)

This comment has been minimized.

@jvanbaarsen

jvanbaarsen Apr 4, 2015

Contributor

Ah ok :)

@jvanbaarsen

jvanbaarsen Apr 4, 2015

Contributor

Ah ok :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment