From 0c65db925d75475994905acaf839d55a6d1785b2 Mon Sep 17 00:00:00 2001 From: Sojan Jose Date: Thu, 14 Oct 2021 13:57:01 +0530 Subject: [PATCH] chore: Fixes the missing gem warning (#3207) * chore: Fixes the missing gem warning fixes: #3143 * chore: rubocop fixes Co-authored-by: Tejaswini Chile --- Gemfile | 5 + Gemfile.lock | 170 ++++++++++-------- ...ove_notifications_without_primary_actor.rb | 2 +- .../onboarding_controller_spec.rb | 2 +- spec/jobs/trigger_scheduled_items_job_spec.rb | 2 +- .../db_resolver_service_spec.rb | 2 +- .../round_robin/manage_service_spec.rb | 28 +-- 7 files changed, 115 insertions(+), 96 deletions(-) diff --git a/Gemfile b/Gemfile index 91a7f4888..bbd55d4cd 100644 --- a/Gemfile +++ b/Gemfile @@ -147,6 +147,11 @@ group :test do end group :development, :test do + # TODO: is this needed ? + # errors thrown by devise password gem + gem 'flay' + gem 'rspec' + # for error thrown by devise password gem gem 'active_record_query_trace' gem 'bundle-audit', require: false gem 'byebug', platform: :mri diff --git a/Gemfile.lock b/Gemfile.lock index 40cadac51..11d12a459 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -90,21 +90,21 @@ GEM rake (>= 10.4, < 14.0) ast (2.4.2) attr_extras (6.2.4) - aws-eventstream (1.1.1) - aws-partitions (1.482.0) - aws-sdk-core (3.119.0) + aws-eventstream (1.2.0) + aws-partitions (1.513.0) + aws-sdk-core (3.121.1) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.239.0) aws-sigv4 (~> 1.1) jmespath (~> 1.0) - aws-sdk-kms (1.46.0) - aws-sdk-core (~> 3, >= 3.119.0) + aws-sdk-kms (1.49.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sigv4 (~> 1.1) - aws-sdk-s3 (1.98.0) - aws-sdk-core (~> 3, >= 3.119.0) + aws-sdk-s3 (1.103.0) + aws-sdk-core (~> 3, >= 3.120.0) aws-sdk-kms (~> 1) - aws-sigv4 (~> 1.1) - aws-sigv4 (1.2.4) + aws-sigv4 (~> 1.4) + aws-sigv4 (1.4.0) aws-eventstream (~> 1, >= 1.0.2) azure-storage-blob (2.0.1) azure-storage-common (~> 2.0) @@ -119,28 +119,28 @@ GEM statsd-ruby (~> 1.1) bcrypt (3.1.16) bindex (0.8.1) - bootsnap (1.7.7) + bootsnap (1.9.1) msgpack (~> 1.0) brakeman (5.1.1) browser (5.3.1) builder (3.2.4) - bullet (6.1.4) + bullet (6.1.5) activesupport (>= 3.0.0) uniform_notifier (~> 1.11) bundle-audit (0.1.0) bundler-audit - bundler-audit (0.8.0) + bundler-audit (0.9.0.1) bundler (>= 1.2.0, < 3) thor (~> 1.0) byebug (11.1.3) coderay (1.1.3) - commonmarker (0.22.0) + commonmarker (0.23.2) concurrent-ruby (1.1.9) connection_pool (2.2.5) crack (0.4.5) rexml crass (1.0.6) - cypress-on-rails (1.10.1) + cypress-on-rails (1.11.0) rack database_cleaner (2.0.1) database_cleaner-active_record (~> 2.0.0) @@ -150,7 +150,7 @@ GEM database_cleaner-core (2.0.1) datetime_picker_rails (0.0.7) momentjs-rails (>= 2.8.1) - ddtrace (0.51.1) + ddtrace (0.53.0) ffi (~> 1.0) msgpack declarative (0.0.20) @@ -174,12 +174,13 @@ GEM dotenv-rails (2.7.6) dotenv (= 2.7.6) railties (>= 3.2) - down (5.2.3) + down (5.2.4) addressable (~> 2.8) ecma-re-validator (0.3.0) regexp_parser (~> 2.0) erubi (1.10.0) - et-orbi (1.2.4) + erubis (2.7.0) + et-orbi (1.2.5) tzinfo execjs (2.8.1) facebook-messenger (2.0.1) @@ -190,7 +191,7 @@ GEM factory_bot_rails (6.2.0) factory_bot (~> 6.2.0) railties (>= 5.0.0) - faker (2.18.0) + faker (2.19.0) i18n (>= 1.6, < 2) faraday (1.0.1) multipart-post (>= 1.2, < 3) @@ -198,10 +199,15 @@ GEM faraday (~> 1.0) fcm (1.0.3) faraday (~> 1) - ffi (1.15.3) + ffi (1.15.4) flag_shih_tzu (0.3.23) + flay (2.12.1) + erubis (~> 2.7.0) + path_expander (~> 1.0) + ruby_parser (~> 3.0) + sexp_processor (~> 4.0) foreman (0.87.2) - fugit (1.5.0) + fugit (1.5.2) et-orbi (~> 1.1, >= 1.1.8) raabro (~> 1.4) gapic-common (0.3.4) @@ -210,7 +216,7 @@ GEM googleapis-common-protos-types (>= 1.0.4, < 2.0) googleauth (~> 0.9) grpc (~> 1.25) - geocoder (1.6.7) + geocoder (1.7.0) gli (2.20.1) globalid (0.5.2) activesupport (>= 5.0) @@ -223,9 +229,9 @@ GEM retriable (>= 2.0, < 4.a) rexml webrick - google-apis-iamcredentials_v1 (0.6.0) + google-apis-iamcredentials_v1 (0.7.0) google-apis-core (>= 0.4, < 2.a) - google-apis-storage_v1 (0.6.0) + google-apis-storage_v1 (0.8.0) google-apis-core (>= 0.4, < 2.a) google-cloud-core (1.6.0) google-cloud-env (~> 1.0) @@ -238,7 +244,7 @@ GEM google-cloud-errors (~> 1.0) google-cloud-env (1.5.0) faraday (>= 0.17.3, < 2.0) - google-cloud-errors (1.1.0) + google-cloud-errors (1.2.0) google-cloud-storage (1.34.1) addressable (~> 2.5) digest-crc (~> 0.4) @@ -247,32 +253,32 @@ GEM google-cloud-core (~> 1.6) googleauth (>= 0.16.2, < 2.a) mini_mime (~> 1.0) - google-protobuf (3.17.3) - google-protobuf (3.17.3-universal-darwin) - google-protobuf (3.17.3-x86_64-linux) - googleapis-common-protos (1.3.11) + google-protobuf (3.18.1) + google-protobuf (3.18.1-universal-darwin) + google-protobuf (3.18.1-x86_64-linux) + googleapis-common-protos (1.3.12) google-protobuf (~> 3.14) - googleapis-common-protos-types (>= 1.0.6, < 2.0) + googleapis-common-protos-types (~> 1.2) grpc (~> 1.27) - googleapis-common-protos-types (1.1.0) + googleapis-common-protos-types (1.2.0) google-protobuf (~> 3.14) - googleauth (0.17.0) + googleauth (0.17.1) faraday (>= 0.17.3, < 2.0) jwt (>= 1.4, < 3.0) memoist (~> 0.16) multi_json (~> 1.11) os (>= 0.9, < 2.0) - signet (~> 0.14) + signet (~> 0.15) groupdate (5.2.2) activesupport (>= 5) - grpc (1.38.0) - google-protobuf (~> 3.15) + grpc (1.41.0) + google-protobuf (~> 3.17) googleapis-common-protos-types (~> 1.0) - grpc (1.38.0-universal-darwin) - google-protobuf (~> 3.15) + grpc (1.41.0-universal-darwin) + google-protobuf (~> 3.17) googleapis-common-protos-types (~> 1.0) - grpc (1.38.0-x86_64-linux) - google-protobuf (~> 3.15) + grpc (1.41.0-x86_64-linux) + google-protobuf (~> 3.17) googleapis-common-protos-types (~> 1.0) haikunator (1.1.1) hairtrigger (0.2.24) @@ -286,7 +292,7 @@ GEM http-accept (1.7.0) http-cookie (1.0.4) domain_name (~> 0.5) - httparty (0.18.1) + httparty (0.20.0) mime-types (~> 3.0) multi_xml (>= 0.5.2) httpclient (2.8.3) @@ -310,7 +316,7 @@ GEM hana (~> 1.3) regexp_parser (~> 2.0) uri_template (~> 0.7) - jwt (2.2.3) + jwt (2.3.0) kaminari (1.2.1) activesupport (>= 4.1.0) kaminari-actionview (= 1.2.1) @@ -331,9 +337,9 @@ GEM addressable (~> 2.7) letter_opener (1.7.0) launchy (~> 2.2) - line-bot-api (1.21.0) - liquid (5.0.1) - listen (3.6.0) + line-bot-api (1.22.0) + liquid (5.1.0) + listen (3.7.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) loofah (2.12.0) @@ -341,18 +347,18 @@ GEM nokogiri (>= 1.5.9) mail (2.7.1) mini_mime (>= 0.1.1) - marcel (1.0.1) + marcel (1.0.2) maxminddb (0.1.22) memoist (0.16.2) method_source (1.0.0) mime-types (3.3.1) mime-types-data (~> 3.2015) - mime-types-data (3.2021.0704) + mime-types-data (3.2021.0901) mini_magick (4.11.0) - mini_mime (1.1.1) + mini_mime (1.1.2) mini_portile2 (2.5.3) minitest (5.14.4) - mock_redis (0.28.0) + mock_redis (0.29.0) ruby2_keywords momentjs-rails (2.20.1) railties (>= 3.1) @@ -363,7 +369,7 @@ GEM net-http-persistent (4.0.1) connection_pool (~> 2.2) netrc (0.11.0) - newrelic_rpm (7.2.0) + newrelic_rpm (8.0.0) nio4r (2.5.8) nokogiri (1.11.7) mini_portile2 (~> 2.5.0) @@ -377,9 +383,10 @@ GEM oauth (0.5.6) orm_adapter (0.5.0) os (1.1.1) - parallel (1.20.1) + parallel (1.21.0) parser (3.0.2.0) ast (~> 2.4.1) + path_expander (1.1.0) pg (1.2.3) procore-sift (0.16.0) rails (> 4.2.0) @@ -391,7 +398,7 @@ GEM public_suffix (4.0.6) puma (5.5.1) nio4r (~> 2.0) - pundit (2.1.0) + pundit (2.1.1) activesupport (>= 3.0.0) raabro (1.4.0) racc (1.5.2) @@ -423,7 +430,7 @@ GEM rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) - rails-html-sanitizer (1.4.1) + rails-html-sanitizer (1.4.2) loofah (~> 2.3) railties (6.1.4.1) actionpack (= 6.1.4.1) @@ -454,6 +461,10 @@ GEM netrc (~> 0.8) retriable (3.1.2) rexml (3.2.5) + rspec (3.10.0) + rspec-core (~> 3.10.0) + rspec-expectations (~> 3.10.0) + rspec-mocks (~> 3.10.0) rspec-core (3.10.1) rspec-support (~> 3.10.0) rspec-expectations (3.10.1) @@ -462,7 +473,7 @@ GEM rspec-mocks (3.10.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.10.0) - rspec-rails (5.0.1) + rspec-rails (5.0.2) actionpack (>= 5.2) activesupport (>= 5.2) railties (>= 5.2) @@ -471,35 +482,34 @@ GEM rspec-mocks (~> 3.10) rspec-support (~> 3.10) rspec-support (3.10.2) - rubocop (1.18.4) + rubocop (1.22.1) parallel (~> 1.10) parser (>= 3.0.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml - rubocop-ast (>= 1.8.0, < 2.0) + rubocop-ast (>= 1.12.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.8.0) + rubocop-ast (1.12.0) parser (>= 3.0.1.1) - rubocop-performance (1.11.4) + rubocop-performance (1.11.5) rubocop (>= 1.7.0, < 2.0) rubocop-ast (>= 0.4.0) - rubocop-rails (2.11.3) + rubocop-rails (2.12.3) activesupport (>= 4.2.0) rack (>= 1.1) rubocop (>= 1.7.0, < 2.0) - rubocop-rspec (2.4.0) - rubocop (~> 1.0) - rubocop-ast (>= 1.1.0) + rubocop-rspec (2.5.0) + rubocop (~> 1.19) ruby-progressbar (1.11.0) - ruby-vips (2.1.2) + ruby-vips (2.1.3) ffi (~> 1.12) ruby2_keywords (0.0.5) ruby2ruby (2.4.4) ruby_parser (~> 3.1) sexp_processor (~> 4.6) - ruby_parser (3.16.0) + ruby_parser (3.17.0) sexp_processor (~> 4.15, >= 4.15.1) sassc (2.4.0) ffi (~> 1.9) @@ -509,38 +519,38 @@ GEM sprockets (> 3.0) sprockets-rails tilt - scout_apm (4.1.1) + scout_apm (4.1.2) parser seed_dump (3.3.1) activerecord (>= 4) activesupport (>= 4) selectize-rails (0.12.6) semantic_range (3.0.0) - sentry-rails (4.6.4) + sentry-rails (4.7.3) railties (>= 5.0) - sentry-ruby-core (~> 4.6.0) - sentry-ruby (4.6.4) + sentry-ruby-core (~> 4.7.0) + sentry-ruby (4.7.3) concurrent-ruby (~> 1.0, >= 1.0.2) faraday (>= 1.0) - sentry-ruby-core (= 4.6.4) - sentry-ruby-core (4.6.4) + sentry-ruby-core (= 4.7.3) + sentry-ruby-core (4.7.3) concurrent-ruby faraday - sentry-sidekiq (4.6.4) - sentry-ruby-core (~> 4.6.0) + sentry-sidekiq (4.7.3) + sentry-ruby-core (~> 4.7.0) sidekiq (>= 3.0) sexp_processor (4.15.3) shoulda-matchers (5.0.0) activesupport (>= 5.2.0) - sidekiq (6.2.1) + sidekiq (6.2.2) connection_pool (>= 2.2.2) rack (~> 2.0) redis (>= 4.2.0) sidekiq-cron (1.2.0) fugit (~> 1.1) sidekiq (>= 4.2.1) - signet (0.15.0) - addressable (~> 2.3) + signet (0.16.0) + addressable (~> 2.8) faraday (>= 0.17.3, < 2.0) jwt (>= 1.5, < 3.0) multi_json (~> 1.10) @@ -583,15 +593,15 @@ GEM oauth tzinfo (2.0.4) concurrent-ruby (~> 1.0) - tzinfo-data (1.2021.1) + tzinfo-data (1.2021.3) tzinfo (>= 1.0.0) uber (0.1.0) uglifier (4.2.0) execjs (>= 0.3.0, < 3) unf (0.1.4) unf_ext - unf_ext (0.0.7.7) - unicode-display_width (2.0.0) + unf_ext (0.0.8) + unicode-display_width (2.1.0) uniform_notifier (1.14.2) uri_template (0.7.0) valid_email2 (4.0.0) @@ -604,11 +614,11 @@ GEM activemodel (>= 6.0.0) bindex (>= 0.4.0) railties (>= 6.0.0) - webmock (3.13.0) - addressable (>= 2.3.6) + webmock (3.14.0) + addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) - webpacker (5.4.0) + webpacker (5.4.3) activesupport (>= 5.2) rack-proxy (>= 0.6.1) railties (>= 5.2) @@ -661,6 +671,7 @@ DEPENDENCIES faker fcm flag_shih_tzu + flay foreman geocoder google-cloud-dialogflow @@ -696,6 +707,7 @@ DEPENDENCIES redis-namespace responders rest-client + rspec rspec-rails (~> 5.0.0) rubocop rubocop-performance diff --git a/db/migrate/20210708140842_remove_notifications_without_primary_actor.rb b/db/migrate/20210708140842_remove_notifications_without_primary_actor.rb index 3d2583400..1c365bd69 100644 --- a/db/migrate/20210708140842_remove_notifications_without_primary_actor.rb +++ b/db/migrate/20210708140842_remove_notifications_without_primary_actor.rb @@ -2,7 +2,7 @@ class RemoveNotificationsWithoutPrimaryActor < ActiveRecord::Migration[6.0] def change deleted_ids = [] Notification.where(primary_actor_type: 'Conversation').pluck(:primary_actor_id).uniq.each_slice(1000) do |id_list| - deleted_ids << id_list - Conversation.where(id: id_list).pluck(:id) + deleted_ids << (id_list - Conversation.where(id: id_list).pluck(:id)) end Notification.where(primary_actor_type: 'Conversation', primary_actor_id: deleted_ids).destroy_all end diff --git a/spec/controllers/installation/onboarding_controller_spec.rb b/spec/controllers/installation/onboarding_controller_spec.rb index 7b1416616..aeeb667a4 100644 --- a/spec/controllers/installation/onboarding_controller_spec.rb +++ b/spec/controllers/installation/onboarding_controller_spec.rb @@ -54,7 +54,7 @@ RSpec.describe 'Installation::Onboarding API', type: :request do end context 'when onboarding is not successfull' do - it ' does not deletes the redis key' do + it 'does not deletes the redis key' do allow(AccountBuilder).to receive(:new).and_raise('error') post '/installation/onboarding', params: { user: {} } expect(::Redis::Alfred.get(::Redis::Alfred::CHATWOOT_INSTALLATION_ONBOARDING)).not_to eq nil diff --git a/spec/jobs/trigger_scheduled_items_job_spec.rb b/spec/jobs/trigger_scheduled_items_job_spec.rb index 2851996b6..a7c3cffef 100644 --- a/spec/jobs/trigger_scheduled_items_job_spec.rb +++ b/spec/jobs/trigger_scheduled_items_job_spec.rb @@ -21,7 +21,7 @@ RSpec.describe TriggerScheduledItemsJob, type: :job do described_class.perform_now end - it 'triggers Conversations::ReopenSnoozedConversationsJob' do + it 'triggers Conversations::ReopenSnoozedConversationsJob' do expect(Conversations::ReopenSnoozedConversationsJob).to receive(:perform_later).once described_class.perform_now end diff --git a/spec/lib/email_templates/db_resolver_service_spec.rb b/spec/lib/email_templates/db_resolver_service_spec.rb index 8648d8514..f581c0c29 100644 --- a/spec/lib/email_templates/db_resolver_service_spec.rb +++ b/spec/lib/email_templates/db_resolver_service_spec.rb @@ -56,7 +56,7 @@ describe ::EmailTemplates::DbResolverService do Current.account = nil end - it 'return installation template when current account dont have template' do + it 'return installation template when current account dont have template' do Current.account = create(:account) handler = ActionView::Template.registered_template_handler(:liquid) template_details = { diff --git a/spec/services/round_robin/manage_service_spec.rb b/spec/services/round_robin/manage_service_spec.rb index 8d0696b26..0deef3109 100644 --- a/spec/services/round_robin/manage_service_spec.rb +++ b/spec/services/round_robin/manage_service_spec.rb @@ -1,41 +1,43 @@ require 'rails_helper' describe RoundRobin::ManageService do + subject(:round_robin_manage_service) { ::RoundRobin::ManageService.new(inbox: inbox) } + let!(:account) { create(:account) } let!(:inbox) { create(:inbox, account: account) } let!(:inbox_members) { create_list(:inbox_member, 5, inbox: inbox) } - let(:subject) { ::RoundRobin::ManageService.new(inbox: inbox) } describe '#available_agent' do it 'gets the first available agent and move agent to end of the list' do expected_queue = [inbox_members[0].user_id, inbox_members[4].user_id, inbox_members[3].user_id, inbox_members[2].user_id, inbox_members[1].user_id].map(&:to_s) - subject.available_agent - expect(subject.send(:queue)).to eq(expected_queue) + round_robin_manage_service.available_agent + expect(round_robin_manage_service.send(:queue)).to eq(expected_queue) end it 'gets intersection of priority list and agent queue. get and move agent to the end of the list' do expected_queue = [inbox_members[2].user_id, inbox_members[4].user_id, inbox_members[3].user_id, inbox_members[1].user_id, inbox_members[0].user_id].map(&:to_s) - expect(subject.available_agent(priority_list: [inbox_members[3].user_id, inbox_members[2].user_id])).to eq inbox_members[2].user - expect(subject.send(:queue)).to eq(expected_queue) + expect(round_robin_manage_service.available_agent(priority_list: [inbox_members[3].user_id, + inbox_members[2].user_id])).to eq inbox_members[2].user + expect(round_robin_manage_service.send(:queue)).to eq(expected_queue) end it 'constructs round_robin_queue if queue is not present' do - subject.clear_queue - expect(subject.send(:queue)).to eq([]) - subject.available_agent + round_robin_manage_service.clear_queue + expect(round_robin_manage_service.send(:queue)).to eq([]) + round_robin_manage_service.available_agent # the service constructed the redis queue before performing - expect(subject.send(:queue).sort.map(&:to_i)).to eq(inbox_members.map(&:user_id).sort) + expect(round_robin_manage_service.send(:queue).sort.map(&:to_i)).to eq(inbox_members.map(&:user_id).sort) end it 'validates the queue and correct it before performing round robin' do # adding some invalid ids to queue - subject.add_agent_to_queue([2, 3, 5, 9]) - expect(subject.send(:queue).sort.map(&:to_i)).not_to eq(inbox_members.map(&:user_id).sort) - subject.available_agent + round_robin_manage_service.add_agent_to_queue([2, 3, 5, 9]) + expect(round_robin_manage_service.send(:queue).sort.map(&:to_i)).not_to eq(inbox_members.map(&:user_id).sort) + round_robin_manage_service.available_agent # the service have refreshed the redis queue before performing - expect(subject.send(:queue).sort.map(&:to_i)).to eq(inbox_members.map(&:user_id).sort) + expect(round_robin_manage_service.send(:queue).sort.map(&:to_i)).to eq(inbox_members.map(&:user_id).sort) end end end