diff --git a/.rubocop.yml b/.rubocop.yml index e22e762d0..25d684cbe 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -2,8 +2,8 @@ plugins: - rubocop-performance - rubocop-rails - rubocop-rspec - - rubocop-factory_bot - rubocop-rspec_rails + - rubocop-factory_bot require: - ./rubocop/use_from_email.rb @@ -130,13 +130,12 @@ Rails/InverseOf: Rails/UniqueValidationWithoutIndex: Exclude: - - 'app/models/canned_response.rb' - - 'app/models/telegram_bot.rb' - - 'enterprise/app/models/captain_inbox.rb' + - app/models/canned_response.rb + - app/models/telegram_bot.rb + - enterprise/app/models/captain_inbox.rb - 'app/models/channel/twitter_profile.rb' - 'app/models/webhook.rb' - 'app/models/contact.rb' - - 'app/models/integrations/hook.rb' Style/ClassAndModuleChildren: EnforcedStyle: compact @@ -169,27 +168,6 @@ Naming/MemoizedInstanceVariableName: Exclude: - 'app/models/message.rb' -Naming/PredicateName: - Exclude: - - 'app/builders/messages/instagram/base_message_builder.rb' - - 'app/controllers/public/api/v1/csat_survey_controller.rb' - - 'app/controllers/public/api/v1/inboxes/messages_controller.rb' - - 'app/jobs/webhooks/line_events_job.rb' - - 'app/services/account/sign_up_email_validation_service.rb' - - 'app/services/automation_rules/condition_validation_service.rb' - - 'app/services/line/incoming_message_service.rb' - - 'app/services/search_service.rb' - - 'app/services/telegram/send_attachments_service.rb' - - 'app/services/twitter/webhook_subscribe_service.rb' - - 'app/services/whatsapp/template_parameter_converter_service.rb' - - 'enterprise/app/jobs/captain/conversation/response_builder_job.rb' - - 'enterprise/app/services/captain/tools/base_service.rb' - - 'enterprise/lib/captain/tool.rb' - - 'lib/chatwoot_app.rb' - - 'lib/custom_markdown_renderer.rb' - - 'lib/linear.rb' - - 'lib/redis/lock_manager.rb' - Style/GuardClause: Exclude: - 'app/builders/account_builder.rb' @@ -201,6 +179,10 @@ Metrics/AbcSize: Exclude: - 'app/controllers/concerns/auth_helper.rb' + - 'app/models/integrations/hook.rb' + - 'app/models/canned_response.rb' + - 'app/models/telegram_bot.rb' + Rails/RenderInline: Exclude: - 'app/controllers/swagger_controller.rb' @@ -222,6 +204,12 @@ RSpec/MultipleExpectations: RSpec/MultipleMemoizedHelpers: Max: 14 +RSpecRails/InferredSpecType: + Enabled: false + +RSpecRails/NegationBeValid: + Enabled: false + # custom rules UseFromEmail: Enabled: true @@ -367,25 +355,3 @@ FactoryBot/RedundantFactoryOption: FactoryBot/FactoryAssociationWithStrategy: Enabled: false - -# Rules disabled to keep Rails upgrade PR focused on functional changes only -Layout/EmptyLineAfterGuardClause: - Enabled: false - -Performance/Count: - Enabled: false - -RSpec/PredicateMatcher: - Enabled: false - -RSpec/DescribeClass: - Enabled: false - -Performance/MapCompact: - Enabled: false - -Performance/CollectionLiteralInLoop: - Enabled: false - -Style/RedundantAssignment: - Enabled: false diff --git a/spec/config/markdown_embeds_spec.rb b/spec/config/markdown_embeds_spec.rb index c91ab60d2..9e9e56898 100644 --- a/spec/config/markdown_embeds_spec.rb +++ b/spec/config/markdown_embeds_spec.rb @@ -1,6 +1,8 @@ require 'rails_helper' +# rubocop:disable RSpec/DescribeClass describe 'Markdown Embeds Configuration' do + # rubocop:enable RSpec/DescribeClass let(:config) { YAML.load_file(Rails.root.join('config/markdown_embeds.yml')) } describe 'YAML structure' do diff --git a/spec/controllers/devise_overrides/sessions_controller_spec.rb b/spec/controllers/devise_overrides/sessions_controller_spec.rb index 6c968cdc8..8ee012670 100644 --- a/spec/controllers/devise_overrides/sessions_controller_spec.rb +++ b/spec/controllers/devise_overrides/sessions_controller_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe DeviseOverrides::SessionsController do +RSpec.describe DeviseOverrides::SessionsController, type: :controller do include Devise::Test::ControllerHelpers before do diff --git a/spec/helpers/reporting_event_helper_spec.rb b/spec/helpers/reporting_event_helper_spec.rb index 841df4529..e4a3c0255 100644 --- a/spec/helpers/reporting_event_helper_spec.rb +++ b/spec/helpers/reporting_event_helper_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe ReportingEventHelper do +RSpec.describe ReportingEventHelper, type: :helper do describe '#last_non_human_activity' do let(:account) { create(:account) } let(:inbox) { create(:inbox, account: account) } diff --git a/spec/jobs/auto_assignment/assignment_job_spec.rb b/spec/jobs/auto_assignment/assignment_job_spec.rb index c47df2e16..d13f9fef8 100644 --- a/spec/jobs/auto_assignment/assignment_job_spec.rb +++ b/spec/jobs/auto_assignment/assignment_job_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe AutoAssignment::AssignmentJob do +RSpec.describe AutoAssignment::AssignmentJob, type: :job do let(:account) { create(:account) } let(:inbox) { create(:inbox, account: account, enable_auto_assignment: true) } let(:agent) { create(:user, account: account, role: :agent, availability: :online) } diff --git a/spec/jobs/auto_assignment/periodic_assignment_job_spec.rb b/spec/jobs/auto_assignment/periodic_assignment_job_spec.rb index 2ff30a46b..4b06decd0 100644 --- a/spec/jobs/auto_assignment/periodic_assignment_job_spec.rb +++ b/spec/jobs/auto_assignment/periodic_assignment_job_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe AutoAssignment::PeriodicAssignmentJob do +RSpec.describe AutoAssignment::PeriodicAssignmentJob, type: :job do let(:account) { create(:account) } let(:inbox) { create(:inbox, account: account, enable_auto_assignment: true) } let(:assignment_policy) { create(:assignment_policy, account: account) } diff --git a/spec/jobs/contacts/bulk_action_job_spec.rb b/spec/jobs/contacts/bulk_action_job_spec.rb index d2caf15f4..12a727000 100644 --- a/spec/jobs/contacts/bulk_action_job_spec.rb +++ b/spec/jobs/contacts/bulk_action_job_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe Contacts::BulkActionJob do +RSpec.describe Contacts::BulkActionJob, type: :job do let(:account) { create(:account) } let(:user) { create(:user, account: account) } let(:params) { { 'ids' => [1], 'labels' => { 'add' => ['vip'] } } } diff --git a/spec/jobs/conversation_reply_email_job_spec.rb b/spec/jobs/conversation_reply_email_job_spec.rb index f0d068a7d..32758c48e 100644 --- a/spec/jobs/conversation_reply_email_job_spec.rb +++ b/spec/jobs/conversation_reply_email_job_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe ConversationReplyEmailJob do +RSpec.describe ConversationReplyEmailJob, type: :job do let(:conversation) { create(:conversation) } let(:mailer) { double } let(:mailer_action) { double } diff --git a/spec/jobs/delete_object_job_spec.rb b/spec/jobs/delete_object_job_spec.rb index 56969b400..8267ba0f0 100644 --- a/spec/jobs/delete_object_job_spec.rb +++ b/spec/jobs/delete_object_job_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe DeleteObjectJob do +RSpec.describe DeleteObjectJob, type: :job do describe '#perform' do context 'when object is heavy (Inbox)' do let!(:account) { create(:account) } diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index 5402532db..5ccff6517 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -143,13 +143,13 @@ RSpec.describe Account do context 'when auto_resolve_after' do it 'validates minimum value' do account.settings = { auto_resolve_after: 4 } - expect(account).not_to be_valid + expect(account).to be_invalid expect(account.errors.messages).to eq({ auto_resolve_after: ['must be greater than or equal to 10'] }) end it 'validates maximum value' do account.settings = { auto_resolve_after: 1_439_857 } - expect(account).not_to be_valid + expect(account).to be_invalid expect(account.errors.messages).to eq({ auto_resolve_after: ['must be less than or equal to 1439856'] }) end diff --git a/spec/models/enterprise/audit/conversation_spec.rb b/spec/models/enterprise/audit/conversation_spec.rb index 01def63a5..56ea2910d 100644 --- a/spec/models/enterprise/audit/conversation_spec.rb +++ b/spec/models/enterprise/audit/conversation_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe 'Conversation Audit' do +RSpec.describe 'Conversation Audit', type: :model do let(:account) { create(:account) } let(:conversation) { create(:conversation, account: account) } diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 851b0dcfa..bb8ea89e1 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -41,7 +41,7 @@ end RSpec.configure do |config| config.include FactoryBot::Syntax::Methods # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures - config.fixture_paths = [Rails.root.join('spec/fixtures')] + config.fixture_path = Rails.root.join('spec/fixtures') # If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false diff --git a/spec/requests/api/v1/accounts/base_controller_spec.rb b/spec/requests/api/v1/accounts/base_controller_spec.rb index 9252bf748..6493bc986 100644 --- a/spec/requests/api/v1/accounts/base_controller_spec.rb +++ b/spec/requests/api/v1/accounts/base_controller_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe 'Api::V1::Accounts::BaseController' do +RSpec.describe 'Api::V1::Accounts::BaseController', type: :request do let(:account) { create(:account) } let(:inbox) { create(:inbox, account: account) } let!(:conversation) { create(:conversation, account: account, inbox: inbox) } diff --git a/spec/requests/api/v1/profile/mfa_controller_spec.rb b/spec/requests/api/v1/profile/mfa_controller_spec.rb index c5830cac1..97a2e206f 100644 --- a/spec/requests/api/v1/profile/mfa_controller_spec.rb +++ b/spec/requests/api/v1/profile/mfa_controller_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe 'MFA API' do +RSpec.describe 'MFA API', type: :request do before do skip('Skipping since MFA is not configured in this environment') unless Chatwoot.encryption_configured? allow(Chatwoot).to receive(:mfa_enabled?).and_return(true)