diff options
-rw-r--r-- | actionview/lib/action_view/helpers/date_helper.rb | 1 | ||||
-rw-r--r-- | activerecord/.codeclimate.yml | 27 | ||||
-rw-r--r-- | activerecord/.rubocop.yml | 27 | ||||
-rw-r--r-- | activerecord/test/cases/multiparameter_attributes_test.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/test_case.rb | 4 | ||||
-rw-r--r-- | activesupport/lib/active_support/testing/assertions.rb | 2 | ||||
-rw-r--r-- | guides/source/active_job_basics.md | 22 |
7 files changed, 67 insertions, 18 deletions
diff --git a/actionview/lib/action_view/helpers/date_helper.rb b/actionview/lib/action_view/helpers/date_helper.rb index 9042b9cffd..04dcf01bb7 100644 --- a/actionview/lib/action_view/helpers/date_helper.rb +++ b/actionview/lib/action_view/helpers/date_helper.rb @@ -3,6 +3,7 @@ require 'action_view/helpers/tag_helper' require 'active_support/core_ext/array/extract_options' require 'active_support/core_ext/date/conversions' require 'active_support/core_ext/hash/slice' +require 'active_support/core_ext/object/acts_like' require 'active_support/core_ext/object/with_options' module ActionView diff --git a/activerecord/.codeclimate.yml b/activerecord/.codeclimate.yml new file mode 100644 index 0000000000..877c67873d --- /dev/null +++ b/activerecord/.codeclimate.yml @@ -0,0 +1,27 @@ +engines: + rubocop: + enabled: true + +ratings: + paths: + - "**.rb" + +exclude_paths: + - actioncable/lib/rails/generators/ + - actioncable/test/ + - actionmailer/lib/rails/generators/ + - actionmailer/test/ + - actionpack/test/ + - actionview/test/ + - activejob/lib/rails/generators/ + - activejob/test/ + - activemodel/test/ + - activerecord/lib/rails/generators/ + - activerecord/test/ + - activesupport/test/ + - railties/lib/rails/generators/ + - railties/test/ + - ci/ + - guides/ + - tasks/ + - tools/ diff --git a/activerecord/.rubocop.yml b/activerecord/.rubocop.yml new file mode 100644 index 0000000000..dd8db6af3a --- /dev/null +++ b/activerecord/.rubocop.yml @@ -0,0 +1,27 @@ +AllCops: + TargetRubyVersion: 2.3 + DisabledByDefault: true + +# Two spaces, no tabs (for indentation). +Style/IndentationWidth: + enabled: true + +# No trailing whitespace. +Style/TrailingWhitespace: + enabled: true + +# Blank lines should not have any spaces. +Style/TrailingBlankLines: + enabled: true + +# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }. +Style/HashSyntax: + enabled: true + +# Prefer &&/|| over and/or. +Style/AndOr: + enabled: true + +# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg. +Lint/RequireParentheses: + enabled: true diff --git a/activerecord/test/cases/multiparameter_attributes_test.rb b/activerecord/test/cases/multiparameter_attributes_test.rb index 3304996f6c..d05cb22740 100644 --- a/activerecord/test/cases/multiparameter_attributes_test.rb +++ b/activerecord/test/cases/multiparameter_attributes_test.rb @@ -11,7 +11,7 @@ class MultiParameterAttributeTest < ActiveRecord::TestCase topic.attributes = attributes # note that extra #to_date call allows test to pass for Oracle, which # treats dates/times the same - assert_date_from_db Date.new(2004, 6, 24), topic.last_read.to_date + assert_equal Date.new(2004, 6, 24), topic.last_read.to_date end def test_multiparameter_attributes_on_date_with_empty_year diff --git a/activerecord/test/cases/test_case.rb b/activerecord/test/cases/test_case.rb index 87299c0dab..c8adc21bbc 100644 --- a/activerecord/test/cases/test_case.rb +++ b/activerecord/test/cases/test_case.rb @@ -12,10 +12,6 @@ module ActiveRecord SQLCounter.clear_log end - def assert_date_from_db(expected, actual, message = nil) - assert_equal expected.to_s, actual.to_s, message - end - def capture_sql SQLCounter.clear_log yield diff --git a/activesupport/lib/active_support/testing/assertions.rb b/activesupport/lib/active_support/testing/assertions.rb index 29305e0082..ad83638572 100644 --- a/activesupport/lib/active_support/testing/assertions.rb +++ b/activesupport/lib/active_support/testing/assertions.rb @@ -1,5 +1,3 @@ -require 'active_support/core_ext/object/blank' - module ActiveSupport module Testing module Assertions diff --git a/guides/source/active_job_basics.md b/guides/source/active_job_basics.md index d6de92ace6..c9f70dc87b 100644 --- a/guides/source/active_job_basics.md +++ b/guides/source/active_job_basics.md @@ -62,12 +62,12 @@ $ bin/rails generate job guests_cleanup --queue urgent ``` If you don't want to use a generator, you could create your own file inside of -`app/jobs`, just make sure that it inherits from `ActiveJob::Base`. +`app/jobs`, just make sure that it inherits from `ApplicationJob`. Here's what a job looks like: ```ruby -class GuestsCleanupJob < ActiveJob::Base +class GuestsCleanupJob < ApplicationJob queue_as :default def perform(*guests) @@ -141,7 +141,7 @@ end You can also configure your backend on a per job basis. ```ruby -class GuestsCleanupJob < ActiveJob::Base +class GuestsCleanupJob < ApplicationJob self.queue_adapter = :resque #.... end @@ -171,7 +171,7 @@ Most of the adapters support multiple queues. With Active Job you can schedule the job to run on a specific queue: ```ruby -class GuestsCleanupJob < ActiveJob::Base +class GuestsCleanupJob < ApplicationJob queue_as :low_priority #.... end @@ -189,7 +189,7 @@ module YourApp end # app/jobs/guests_cleanup_job.rb -class GuestsCleanupJob < ActiveJob::Base +class GuestsCleanupJob < ApplicationJob queue_as :low_priority #.... end @@ -212,7 +212,7 @@ module YourApp end # app/jobs/guests_cleanup_job.rb -class GuestsCleanupJob < ActiveJob::Base +class GuestsCleanupJob < ApplicationJob queue_as :low_priority #.... end @@ -234,7 +234,7 @@ block will be executed in the job context (so you can access `self.arguments`) and you must return the queue name: ```ruby -class ProcessVideoJob < ActiveJob::Base +class ProcessVideoJob < ApplicationJob queue_as do video = self.arguments.first if video.owner.premium? @@ -274,7 +274,7 @@ trigger logic during the life cycle of a job. ### Usage ```ruby -class GuestsCleanupJob < ActiveJob::Base +class GuestsCleanupJob < ApplicationJob queue_as :default before_enqueue do |job| @@ -331,7 +331,7 @@ Active Record objects to your job instead of class/id pairs, which you then have to manually deserialize. Before, jobs would look like this: ```ruby -class TrashableCleanupJob < ActiveJob::Base +class TrashableCleanupJob < ApplicationJob def perform(trashable_class, trashable_id, depth) trashable = trashable_class.constantize.find(trashable_id) trashable.cleanup(depth) @@ -342,7 +342,7 @@ end Now you can simply do: ```ruby -class TrashableCleanupJob < ActiveJob::Base +class TrashableCleanupJob < ApplicationJob def perform(trashable, depth) trashable.cleanup(depth) end @@ -360,7 +360,7 @@ Active Job provides a way to catch exceptions raised during the execution of the job: ```ruby -class GuestsCleanupJob < ActiveJob::Base +class GuestsCleanupJob < ApplicationJob queue_as :default rescue_from(ActiveRecord::RecordNotFound) do |exception| |