From feb881336ffdae7e897d0201ded33c5edfc888aa Mon Sep 17 00:00:00 2001 From: Eric-Guo Date: Mon, 18 Mar 2024 22:56:18 +0800 Subject: [PATCH] Revert "Merge pull request #14992 from opf/chore/53122/replace-concurrency-check-with-good-job" This reverts commit 7b02616af5411c5b9675e3264142c14be1ba59b8, reversing changes made to 024376a986fdf154e45a22c3c39d97ba4116a5af. --- Gemfile | 2 +- .../settings/working_days_params_contract.rb | 4 +- app/workers/job_concurrency.rb | 42 ----- .../apply_working_days_change_job.rb | 5 - config/initializers/debugbar.rb | 2 +- config/puma.rb | 2 +- lib/th_annotator/apis/base.rb | 6 +- lib/th_annotator/config.rb | 8 +- lib/th_annotator/helpers.rb | 12 +- .../annotation_documents_controller.rb | 2 +- .../th_work_packages/edoc_files_controller.rb | 2 +- .../th_annotation_documents/callbacks/base.rb | 2 +- .../callbacks/create_annotator.rb | 6 +- .../callbacks/create_comment.rb | 8 +- .../callbacks/delete_annotator.rb | 2 +- .../callbacks/delete_comment.rb | 2 +- .../callbacks/document.rb | 2 +- .../callbacks/update_annotator.rb | 2 +- .../th_annotation_document.rb | 2 +- modules/th_work_packages/config/routes.rb | 6 +- ...05055659_create_th_annotation_documents.rb | 8 +- .../working_days_params_contract_spec.rb | 13 +- ...dule_date_alerts_notifications_job_spec.rb | 144 +++++++++--------- 23 files changed, 117 insertions(+), 167 deletions(-) delete mode 100644 app/workers/job_concurrency.rb diff --git a/Gemfile b/Gemfile index 2fbaa93d9be0..09ac127936b7 100644 --- a/Gemfile +++ b/Gemfile @@ -314,7 +314,7 @@ group :development do gem "ed25519" gem "bcrypt_pbkdf" - gem 'debugbar' + gem "debugbar" # Support cursor / vs code gem "ruby-lsp", require: false end diff --git a/app/contracts/settings/working_days_params_contract.rb b/app/contracts/settings/working_days_params_contract.rb index 42bacb779bab..cd0faf86d21e 100644 --- a/app/contracts/settings/working_days_params_contract.rb +++ b/app/contracts/settings/working_days_params_contract.rb @@ -42,7 +42,9 @@ def working_days_are_present end def unique_job - WorkPackages::ApplyWorkingDaysChangeJob.new.check_concurrency do + if GoodJob::Job + .where(finished_at: nil) + .exists?(job_class: WorkPackages::ApplyWorkingDaysChangeJob.name) errors.add :base, :previous_working_day_changes_unprocessed end end diff --git a/app/workers/job_concurrency.rb b/app/workers/job_concurrency.rb deleted file mode 100644 index c98816841ade..000000000000 --- a/app/workers/job_concurrency.rb +++ /dev/null @@ -1,42 +0,0 @@ -#-- copyright -# OpenProject is an open source project management software. -# Copyright (C) 2012-2024 the OpenProject GmbH -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License version 3. -# -# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: -# Copyright (C) 2006-2013 Jean-Philippe Lang -# Copyright (C) 2010-2013 the ChiliProject Team -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# See COPYRIGHT and LICENSE files for more details. -#++ - -module JobConcurrency - extend ActiveSupport::Concern - - included do - include GoodJob::ActiveJobExtensions::Concurrency - end - - ## - # Run the concurrency check of good_job without actually trying to enqueue it - # Will call the provided block in case the job would be cancelled - def check_concurrency(&block) - good_job_enqueue_concurrency_check(self, on_abort: block, on_enqueue: nil) - end -end diff --git a/app/workers/work_packages/apply_working_days_change_job.rb b/app/workers/work_packages/apply_working_days_change_job.rb index 11ba9b112952..70c5051f0e64 100644 --- a/app/workers/work_packages/apply_working_days_change_job.rb +++ b/app/workers/work_packages/apply_working_days_change_job.rb @@ -27,13 +27,8 @@ #++ class WorkPackages::ApplyWorkingDaysChangeJob < ApplicationJob - include JobConcurrency queue_with_priority :above_normal - good_job_control_concurrency_with( - total_limit: 1 - ) - def perform(user_id:, previous_working_days:, previous_non_working_days:) user = User.find(user_id) diff --git a/config/initializers/debugbar.rb b/config/initializers/debugbar.rb index 6a8b9962a5dc..eb15885f76a9 100644 --- a/config/initializers/debugbar.rb +++ b/config/initializers/debugbar.rb @@ -1,3 +1,3 @@ Debugbar.configure do |config| - config.enabled = ENV["ENABLE_DEBUGBAR"] == 'true' + config.enabled = ENV["ENABLE_DEBUGBAR"] == "true" end if Rails.env.development? diff --git a/config/puma.rb b/config/puma.rb index ad851e498f9d..acbffb47f655 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -21,7 +21,7 @@ # Workers do not work on JRuby or Windows (both of which do not support # processes). # -workers OpenProject::Configuration.web_workers unless ENV["RAILS_ENV"] == 'development' +workers OpenProject::Configuration.web_workers unless ENV["RAILS_ENV"] == "development" # Use the `preload_app!` method when specifying a `workers` number. # This directive tells Puma to first boot the application and load code diff --git a/lib/th_annotator/apis/base.rb b/lib/th_annotator/apis/base.rb index 345f18bf7e54..075dc26408e3 100644 --- a/lib/th_annotator/apis/base.rb +++ b/lib/th_annotator/apis/base.rb @@ -22,7 +22,7 @@ def get_access_token secret: ThAnnotator::Config.app_secret } - result = ThAnnotator::Request.new.get('auth/getToken', params:) + result = ThAnnotator::Request.new.get("auth/getToken", params:) { token: result[:data][:accessToken], @@ -39,7 +39,7 @@ def get_user_token(email:) email: } - result = ThAnnotator::Request.new.get('auth', params:) + result = ThAnnotator::Request.new.get("auth", params:) result[:data][:token] end @@ -62,7 +62,7 @@ def create_document(file_name:, document_type:, view_path:) viewPath: view_path } - result = ThAnnotator::Request.new.post('documents', params:, data:) + result = ThAnnotator::Request.new.post("documents", params:, data:) result[:data][:uuid] end diff --git a/lib/th_annotator/config.rb b/lib/th_annotator/config.rb index 1f3f6d9d3ab1..a312b24decdc 100644 --- a/lib/th_annotator/config.rb +++ b/lib/th_annotator/config.rb @@ -9,24 +9,24 @@ def self.env(key) # 域名 # @return [String] def self.host - env('HOST') + env("HOST") end # 路径前缀 # @return [String] def self.path_prefix - env('PATH_PREFIX') || '' + env("PATH_PREFIX") || "" end # x-app-id # @return [String] def self.app_id - env('APP_ID') + env("APP_ID") end # x-app-secret # @return [String] def self.app_secret - env('APP_SECRET') + env("APP_SECRET") end end diff --git a/lib/th_annotator/helpers.rb b/lib/th_annotator/helpers.rb index 25fe2bb8787c..c113f1e30d30 100644 --- a/lib/th_annotator/helpers.rb +++ b/lib/th_annotator/helpers.rb @@ -17,8 +17,8 @@ def self.hash_with_token(hash = {}, k = :token) def self.query2hash(query) return {} unless query.present? && query.is_a?(String) - query.split('&').reduce({}) do |hash, item| - key, value = item.split('=') + query.split("&").reduce({}) do |hash, item| + key, value = item.split("=") hash[key.to_sym] = URI.decode_www_form_component(value) unless value.nil? hash end @@ -30,11 +30,11 @@ def self.query2hash(query) def self.hash2query(hash) return nil if hash.blank? - hash.to_a.reduce('') do |query, item| + hash.to_a.reduce("") do |query, item| key, value = item query << "&#{key}=#{URI.encode_www_form_component(value)}" unless value.nil? query - end.sub(/^&/, '').presence + end.sub(/^&/, "").presence end # 生成URL @@ -44,7 +44,7 @@ def self.hash2query(hash) # @param fragment [String|Hash] - url#xxxxxx # @return [String] def self._url(host, path, query = nil, fragment = nil) # rubocop:disable Metrics/AbcSize - url = URI(Pathname.new(host).join(path.sub(/^\/+/, '')).to_s) + url = URI(Pathname.new(host).join(path.sub(/^\/+/, "")).to_s) if query.is_a?(Hash) hash = query2hash(url.query).merge!(query) @@ -77,6 +77,6 @@ def self.url(path, params = nil, fragment = nil) end def self.jump_url(token:, uuid:) - _url(ThAnnotator::Config.host, request_path('auth/authorize'), { token:, documentUUID: uuid }) + _url(ThAnnotator::Config.host, request_path("auth/authorize"), { token:, documentUUID: uuid }) end end diff --git a/modules/th_work_packages/app/controllers/th_work_packages/annotation_documents_controller.rb b/modules/th_work_packages/app/controllers/th_work_packages/annotation_documents_controller.rb index 7acce5a08eb9..1045f1cb6a85 100644 --- a/modules/th_work_packages/app/controllers/th_work_packages/annotation_documents_controller.rb +++ b/modules/th_work_packages/app/controllers/th_work_packages/annotation_documents_controller.rb @@ -8,7 +8,7 @@ def callback service.new(params).call render json: { - message: '回调成功' + message: "回调成功" } rescue StandardError => e render status: :bad_request, json: { diff --git a/modules/th_work_packages/app/controllers/th_work_packages/edoc_files_controller.rb b/modules/th_work_packages/app/controllers/th_work_packages/edoc_files_controller.rb index 0309673121f4..f283cbb25474 100644 --- a/modules/th_work_packages/app/controllers/th_work_packages/edoc_files_controller.rb +++ b/modules/th_work_packages/app/controllers/th_work_packages/edoc_files_controller.rb @@ -5,7 +5,7 @@ def annotation_document document = edoc_file.annotation_document || edoc_file.create_annotation_document - render status: 404, html: '未查询到标注文档' unless document.present? + render status: 404, html: "未查询到标注文档" unless document.present? document.sync_members diff --git a/modules/th_work_packages/app/models/th_annotation_documents/callbacks/base.rb b/modules/th_work_packages/app/models/th_annotation_documents/callbacks/base.rb index 73233dd1f98b..5f7038f90a82 100644 --- a/modules/th_work_packages/app/models/th_annotation_documents/callbacks/base.rb +++ b/modules/th_work_packages/app/models/th_annotation_documents/callbacks/base.rb @@ -11,7 +11,7 @@ def initialize(attributes = {}) end def call - raise NotImplementedError, 'You must implement the #write_to_db method in your subclass' + raise NotImplementedError, "You must implement the #write_to_db method in your subclass" end end end diff --git a/modules/th_work_packages/app/models/th_annotation_documents/callbacks/create_annotator.rb b/modules/th_work_packages/app/models/th_annotation_documents/callbacks/create_annotator.rb index a6a0c68bd23b..a9dc13ad9259 100644 --- a/modules/th_work_packages/app/models/th_annotation_documents/callbacks/create_annotator.rb +++ b/modules/th_work_packages/app/models/th_annotation_documents/callbacks/create_annotator.rb @@ -11,13 +11,13 @@ class CreateAnnotator < Base attr_accessor(*FIELDS) def document=(value) - raise ArgumentError, 'Missing document' if value.blank? + raise ArgumentError, "Missing document" if value.blank? @document = Document.new(value) end def annotator=(value) - raise ArgumentError, 'Missing annotator' if value.blank? + raise ArgumentError, "Missing annotator" if value.blank? @annotator = Annotator.new(value) end @@ -27,7 +27,7 @@ def current_user end def title - '创建标注' + "创建标注" end def raw # rubocop:disable Metrics/AbcSize diff --git a/modules/th_work_packages/app/models/th_annotation_documents/callbacks/create_comment.rb b/modules/th_work_packages/app/models/th_annotation_documents/callbacks/create_comment.rb index 34047c4c1b86..bcc883e2bf23 100644 --- a/modules/th_work_packages/app/models/th_annotation_documents/callbacks/create_comment.rb +++ b/modules/th_work_packages/app/models/th_annotation_documents/callbacks/create_comment.rb @@ -12,19 +12,19 @@ class CreateComment < Base attr_accessor(*FIELDS) def document=(value) - raise ArgumentError, 'Missing document' if value.blank? + raise ArgumentError, "Missing document" if value.blank? @document = Document.new(value) end def annotator=(value) - raise ArgumentError, 'Missing annotator' if value.blank? + raise ArgumentError, "Missing annotator" if value.blank? @annotator = Annotator.new(value) end def comment=(value) - raise ArgumentError, 'Missing comment' if value.blank? + raise ArgumentError, "Missing comment" if value.blank? @comment = Comment.new(value) end @@ -34,7 +34,7 @@ def current_user end def title - '创建评论' + "创建评论" end def raw # rubocop:disable Metrics/AbcSize diff --git a/modules/th_work_packages/app/models/th_annotation_documents/callbacks/delete_annotator.rb b/modules/th_work_packages/app/models/th_annotation_documents/callbacks/delete_annotator.rb index dd85ae30cfaf..fc1212a8ca4f 100644 --- a/modules/th_work_packages/app/models/th_annotation_documents/callbacks/delete_annotator.rb +++ b/modules/th_work_packages/app/models/th_annotation_documents/callbacks/delete_annotator.rb @@ -1,7 +1,7 @@ module ThAnnotationDocuments::Callbacks class DeleteAnnotator < CreateAnnotator def title - '删除标注' + "删除标注" end end end diff --git a/modules/th_work_packages/app/models/th_annotation_documents/callbacks/delete_comment.rb b/modules/th_work_packages/app/models/th_annotation_documents/callbacks/delete_comment.rb index 25ed31b8dc16..58af0ae0d5b4 100644 --- a/modules/th_work_packages/app/models/th_annotation_documents/callbacks/delete_comment.rb +++ b/modules/th_work_packages/app/models/th_annotation_documents/callbacks/delete_comment.rb @@ -1,7 +1,7 @@ module ThAnnotationDocuments::Callbacks class DeleteComment < CreateComment def title - '删除评论' + "删除评论" end end end diff --git a/modules/th_work_packages/app/models/th_annotation_documents/callbacks/document.rb b/modules/th_work_packages/app/models/th_annotation_documents/callbacks/document.rb index 990d55334b60..e4b24406e0a5 100644 --- a/modules/th_work_packages/app/models/th_annotation_documents/callbacks/document.rb +++ b/modules/th_work_packages/app/models/th_annotation_documents/callbacks/document.rb @@ -12,7 +12,7 @@ def resource @resource ||= ThAnnotationDocument.find_by!(uuid:) unless @resource.is_a?(WorkPackageEdocFiles::ThAnnotationDocument) - raise StandardError, 'AnnotationDocument is not WorkPackageEdocFiles::ThAnnotationDocument' + raise StandardError, "AnnotationDocument is not WorkPackageEdocFiles::ThAnnotationDocument" end @resource diff --git a/modules/th_work_packages/app/models/th_annotation_documents/callbacks/update_annotator.rb b/modules/th_work_packages/app/models/th_annotation_documents/callbacks/update_annotator.rb index 095d118e6740..aa7a2f54100e 100644 --- a/modules/th_work_packages/app/models/th_annotation_documents/callbacks/update_annotator.rb +++ b/modules/th_work_packages/app/models/th_annotation_documents/callbacks/update_annotator.rb @@ -1,7 +1,7 @@ module ThAnnotationDocuments::Callbacks class UpdateAnnotator < CreateAnnotator def title - '更新标注' + "更新标注" end end end diff --git a/modules/th_work_packages/app/models/work_package_edoc_files/th_annotation_document.rb b/modules/th_work_packages/app/models/work_package_edoc_files/th_annotation_document.rb index 9f3e92651f5f..df9eacad0f5e 100644 --- a/modules/th_work_packages/app/models/work_package_edoc_files/th_annotation_document.rb +++ b/modules/th_work_packages/app/models/work_package_edoc_files/th_annotation_document.rb @@ -11,7 +11,7 @@ def sync_members # rubocop:disable Metrics/AbcSize { name: member.principal.name, email: member.principal.mail, - is_internal: member.principal.mail.end_with?('@thape.com.cn') + is_internal: member.principal.mail.end_with?("@thape.com.cn") } end diff --git a/modules/th_work_packages/config/routes.rb b/modules/th_work_packages/config/routes.rb index 46f4e74b166d..ceb612b64be8 100644 --- a/modules/th_work_packages/config/routes.rb +++ b/modules/th_work_packages/config/routes.rb @@ -1,7 +1,7 @@ OpenProject::Application.routes.draw do - scope 'th_work_packages', as: 'th_work_packages' do + scope "th_work_packages", as: "th_work_packages" do resources :edoc_files, - controller: 'th_work_packages/edoc_files', + controller: "th_work_packages/edoc_files", only: %i[], as: :edoc_files do member do @@ -10,7 +10,7 @@ end resources :annotation_documents, - controller: 'th_work_packages/annotation_documents', + controller: "th_work_packages/annotation_documents", only: %i[], as: :annotation_documents do collection do diff --git a/modules/th_work_packages/db/migrate/20240205055659_create_th_annotation_documents.rb b/modules/th_work_packages/db/migrate/20240205055659_create_th_annotation_documents.rb index 3ceb1974d4a6..db1ddda20ff5 100644 --- a/modules/th_work_packages/db/migrate/20240205055659_create_th_annotation_documents.rb +++ b/modules/th_work_packages/db/migrate/20240205055659_create_th_annotation_documents.rb @@ -1,10 +1,10 @@ class CreateThAnnotationDocuments < ActiveRecord::Migration[7.0] def change create_table :th_annotation_documents do |t| - t.string :uuid, null: false, default: '', index: true, comment: '文档ID' - t.string :type, null: false, default: '', index: true, comment: '文档类型' - t.integer :target_id, null: false, default: 0, index: true, comment: '目标ID' - t.json :members, null: true, default: nil, comment: '成员列表' + t.string :uuid, null: false, default: "", index: true, comment: "文档ID" + t.string :type, null: false, default: "", index: true, comment: "文档类型" + t.integer :target_id, null: false, default: 0, index: true, comment: "目标ID" + t.json :members, null: true, default: nil, comment: "成员列表" t.timestamps end end diff --git a/spec/contracts/settings/working_days_params_contract_spec.rb b/spec/contracts/settings/working_days_params_contract_spec.rb index ddd60516a286..e7132af4ae05 100644 --- a/spec/contracts/settings/working_days_params_contract_spec.rb +++ b/spec/contracts/settings/working_days_params_contract_spec.rb @@ -31,8 +31,8 @@ RSpec.describe Settings::WorkingDaysParamsContract do include_context "ModelContract shared context" - shared_let(:current_user) { create(:admin) } let(:setting) { Setting } + let(:current_user) { build_stubbed(:admin) } let(:params) { { working_days: [1] } } let(:contract) do described_class.new(setting, current_user, params:) @@ -46,16 +46,11 @@ include_examples "contract is invalid", base: :working_days_are_missing end - context "with an ApplyWorkingDaysChangeJob already existing", - with_good_job: WorkPackages::ApplyWorkingDaysChangeJob do + context "with an ApplyWorkingDaysChangeJob already existing" do let(:params) { { working_days: [1, 2, 3] } } - before do - WorkPackages::ApplyWorkingDaysChangeJob - .set(wait: 10.minutes) # GoodJob executes inline job without wait immediately - .perform_later(user_id: current_user.id, - previous_non_working_days: [], - previous_working_days: [1, 2, 3, 4]) + ActiveJob::Base.disable_test_adapter + WorkPackages::ApplyWorkingDaysChangeJob.perform_later end include_examples "contract is invalid", base: :previous_working_day_changes_unprocessed diff --git a/spec/workers/notifications/schedule_date_alerts_notifications_job_spec.rb b/spec/workers/notifications/schedule_date_alerts_notifications_job_spec.rb index eb434f549376..a22ab39837b4 100644 --- a/spec/workers/notifications/schedule_date_alerts_notifications_job_spec.rb +++ b/spec/workers/notifications/schedule_date_alerts_notifications_job_spec.rb @@ -26,24 +26,24 @@ # See docs/COPYRIGHT.rdoc for more details. #++ -require 'spec_helper' +require "spec_helper" RSpec.describe Notifications::ScheduleDateAlertsNotificationsJob, type: :job, with_ee: %i[date_alerts] do include ActiveSupport::Testing::TimeHelpers - shared_let(:project) { create(:project, name: 'main') } + shared_let(:project) { create(:project, name: "main") } # Paris and Berlin are both UTC+01:00 (CET) or UTC+02:00 (CEST) - shared_let(:timezone_paris) { ActiveSupport::TimeZone['Europe/Paris'] } + shared_let(:timezone_paris) { ActiveSupport::TimeZone["Europe/Paris"] } # Kathmandu is UTC+05:45 (no DST) - shared_let(:timezone_kathmandu) { ActiveSupport::TimeZone['Asia/Kathmandu'] } + shared_let(:timezone_kathmandu) { ActiveSupport::TimeZone["Asia/Kathmandu"] } shared_let(:user_paris) do create(:user, - firstname: 'Paris', + firstname: "Paris", preferences: { time_zone: timezone_paris.name }) end shared_let(:user_kathmandu) do create(:user, - firstname: 'Kathmandu', + firstname: "Kathmandu", preferences: { time_zone: timezone_kathmandu.name }) end @@ -60,14 +60,14 @@ def set_scheduled_time(scheduled_at) # Converts "hh:mm" into { hour: h, min: m } def time_hash(time) - %i[hour min].zip(time.split(':', 2).map(&:to_i)).to_h + %i[hour min].zip(time.split(":", 2).map(&:to_i)).to_h end def timezone_time(time, timezone) timezone.now.change(time_hash(time)) end - def run_job(scheduled_at: '1:00', local_time: '1:04', timezone: timezone_paris) + def run_job(scheduled_at: "1:00", local_time: "1:04", timezone: timezone_paris) set_scheduled_time(timezone_time(scheduled_at, timezone)) travel_to(timezone_time(local_time, timezone)) do GoodJob.perform_inline @@ -86,18 +86,18 @@ def deserialize_job(job) def expect_job(job, *arguments) job_data = deserialize_job(job) - expect(job_data['job_class']).to eql(job.job_class) - expect(job_data['arguments']).to match_array arguments - expect(job_data['executions']).to eq 0 + expect(job_data["job_class"]).to eql(job.job_class) + expect(job_data["arguments"]).to match_array arguments + expect(job_data["executions"]).to eq 0 end - shared_examples_for 'job execution creates date alerts creation job' do + shared_examples_for "job execution creates date alerts creation job" do let(:timezone) { timezone_paris } - let(:scheduled_at) { '1:00' } - let(:local_time) { '1:04' } + let(:scheduled_at) { "1:00" } + let(:local_time) { "1:04" } let(:user) { user_paris } - it 'creates the job for the user' do + it "creates the job for the user" do expect do run_job(timezone:, scheduled_at:, local_time:) do j = GoodJob::Job.where(job_class: "Notifications::CreateDateAlertsNotificationsJob") @@ -109,81 +109,81 @@ def expect_job(job, *arguments) end end - shared_examples_for 'job execution creates no date alerts creation job' do + shared_examples_for "job execution creates no date alerts creation job" do let(:timezone) { timezone_paris } - let(:scheduled_at) { '1:00' } - let(:local_time) { '1:04' } + let(:scheduled_at) { "1:00" } + let(:local_time) { "1:04" } - it 'creates no job' do + it "creates no job" do expect do run_job(timezone:, scheduled_at:, local_time:) end.not_to change(GoodJob::Job, :count) end end - describe '#perform' do - context 'for users whose local time is 1:00 am (UTC+1) when the job is executed' do - it_behaves_like 'job execution creates date alerts creation job' do + describe "#perform" do + context "for users whose local time is 1:00 am (UTC+1) when the job is executed" do + it_behaves_like "job execution creates date alerts creation job" do let(:timezone) { timezone_paris } - let(:scheduled_at) { '1:00' } - let(:local_time) { '1:04' } + let(:scheduled_at) { "1:00" } + let(:local_time) { "1:04" } let(:user) { user_paris } end end - context 'for users whose local time is 1:00 am (UTC+05:45) when the job is executed' do - it_behaves_like 'job execution creates date alerts creation job' do + context "for users whose local time is 1:00 am (UTC+05:45) when the job is executed" do + it_behaves_like "job execution creates date alerts creation job" do let(:timezone) { timezone_kathmandu } - let(:scheduled_at) { '1:00' } - let(:local_time) { '1:04' } + let(:scheduled_at) { "1:00" } + let(:local_time) { "1:04" } let(:user) { user_kathmandu } end end - context 'without enterprise token', with_ee: false do - it_behaves_like 'job execution creates no date alerts creation job' do + context "without enterprise token", with_ee: false do + it_behaves_like "job execution creates no date alerts creation job" do let(:timezone) { timezone_paris } - let(:scheduled_at) { '1:00' } - let(:local_time) { '1:04' } + let(:scheduled_at) { "1:00" } + let(:local_time) { "1:04" } end end - context 'when scheduled and executed at 01:00 am local time' do - it_behaves_like 'job execution creates date alerts creation job' do + context "when scheduled and executed at 01:00 am local time" do + it_behaves_like "job execution creates date alerts creation job" do let(:timezone) { timezone_paris } - let(:scheduled_at) { '1:00' } - let(:local_time) { '1:00' } + let(:scheduled_at) { "1:00" } + let(:local_time) { "1:00" } let(:user) { user_paris } end end - context 'when scheduled and executed at 01:14 am local time' do - it_behaves_like 'job execution creates date alerts creation job' do + context "when scheduled and executed at 01:14 am local time" do + it_behaves_like "job execution creates date alerts creation job" do let(:timezone) { timezone_paris } - let(:scheduled_at) { '1:14' } - let(:local_time) { '1:14' } + let(:scheduled_at) { "1:14" } + let(:local_time) { "1:14" } let(:user) { user_paris } end end - context 'when scheduled and executed at 01:15 am local time' do - it_behaves_like 'job execution creates no date alerts creation job' do + context "when scheduled and executed at 01:15 am local time" do + it_behaves_like "job execution creates no date alerts creation job" do let(:timezone) { timezone_paris } - let(:scheduled_at) { '1:15' } - let(:local_time) { '1:15' } + let(:scheduled_at) { "1:15" } + let(:local_time) { "1:15" } end end - context 'when scheduled at 01:00 am local time and executed at 01:37 am local time' do - it_behaves_like 'job execution creates date alerts creation job' do + context "when scheduled at 01:00 am local time and executed at 01:37 am local time" do + it_behaves_like "job execution creates date alerts creation job" do let(:timezone) { timezone_paris } - let(:scheduled_at) { '1:00' } - let(:local_time) { '1:37' } + let(:scheduled_at) { "1:00" } + let(:local_time) { "1:37" } let(:user) { user_paris } end end - context 'with a user having only due_date active in notification settings' do + context "with a user having only due_date active in notification settings" do before do NotificationSetting .where(user: user_paris) @@ -192,15 +192,15 @@ def expect_job(job, *arguments) overdue: nil) end - it_behaves_like 'job execution creates date alerts creation job' do + it_behaves_like "job execution creates date alerts creation job" do let(:timezone) { timezone_paris } - let(:scheduled_at) { '1:00' } - let(:local_time) { '1:00' } + let(:scheduled_at) { "1:00" } + let(:local_time) { "1:00" } let(:user) { user_paris } end end - context 'with a user having only start_date active in notification settings' do + context "with a user having only start_date active in notification settings" do before do NotificationSetting .where(user: user_paris) @@ -209,15 +209,15 @@ def expect_job(job, *arguments) overdue: nil) end - it_behaves_like 'job execution creates date alerts creation job' do + it_behaves_like "job execution creates date alerts creation job" do let(:timezone) { timezone_paris } - let(:scheduled_at) { '1:00' } - let(:local_time) { '1:00' } + let(:scheduled_at) { "1:00" } + let(:local_time) { "1:00" } let(:user) { user_paris } end end - context 'with a user having only overdue active in notification settings' do + context "with a user having only overdue active in notification settings" do before do NotificationSetting .where(user: user_paris) @@ -226,15 +226,15 @@ def expect_job(job, *arguments) overdue: 1) end - it_behaves_like 'job execution creates date alerts creation job' do + it_behaves_like "job execution creates date alerts creation job" do let(:timezone) { timezone_paris } - let(:scheduled_at) { '1:00' } - let(:local_time) { '1:00' } + let(:scheduled_at) { "1:00" } + let(:local_time) { "1:00" } let(:user) { user_paris } end end - context 'without a user having notification settings' do + context "without a user having notification settings" do before do NotificationSetting .where(user: user_paris) @@ -243,14 +243,14 @@ def expect_job(job, *arguments) overdue: nil) end - it_behaves_like 'job execution creates no date alerts creation job' do + it_behaves_like "job execution creates no date alerts creation job" do let(:timezone) { timezone_paris } - let(:scheduled_at) { '1:00' } - let(:local_time) { '1:00' } + let(:scheduled_at) { "1:00" } + let(:local_time) { "1:00" } end end - context 'with a user having only a project active notification settings' do + context "with a user having only a project active notification settings" do before do NotificationSetting .where(user: user_paris) @@ -266,23 +266,23 @@ def expect_job(job, *arguments) overdue: nil) end - it_behaves_like 'job execution creates date alerts creation job' do + it_behaves_like "job execution creates date alerts creation job" do let(:timezone) { timezone_paris } - let(:scheduled_at) { '1:00' } - let(:local_time) { '1:00' } + let(:scheduled_at) { "1:00" } + let(:local_time) { "1:00" } let(:user) { user_paris } end end - context 'with a locked user' do + context "with a locked user" do before do user_paris.locked! end - it_behaves_like 'job execution creates no date alerts creation job' do + it_behaves_like "job execution creates no date alerts creation job" do let(:timezone) { timezone_paris } - let(:scheduled_at) { '1:00' } - let(:local_time) { '1:00' } + let(:scheduled_at) { "1:00" } + let(:local_time) { "1:00" } end end end