chore: Apply fixes for items in rubocop_todo [CW-1806] (#8864)
This PR addresses several items listed in our rubocop_todo by implementing the necessary corrections and enhancements. As a result, we are now able to remove the rubocop_todo file entirely, streamlining our codebase and ensuring adherence to our coding standards. fixes: https://linear.app/chatwoot/issue/CW-1806/chore-rubocop-audit
This commit is contained in:
@@ -5,11 +5,11 @@ require 'rails_helper'
|
||||
require Rails.root.join 'spec/models/concerns/avatarable_shared.rb'
|
||||
|
||||
RSpec.describe Contact do
|
||||
context 'validations' do
|
||||
context 'with validations' do
|
||||
it { is_expected.to validate_presence_of(:account_id) }
|
||||
end
|
||||
|
||||
context 'associations' do
|
||||
context 'with associations' do
|
||||
it { is_expected.to belong_to(:account) }
|
||||
it { is_expected.to have_many(:conversations).dependent(:destroy_async) }
|
||||
end
|
||||
@@ -18,7 +18,7 @@ RSpec.describe Contact do
|
||||
it_behaves_like 'avatarable'
|
||||
end
|
||||
|
||||
context 'prepare contact attributes before validation' do
|
||||
context 'when prepare contact attributes before validation' do
|
||||
it 'sets email to lowercase' do
|
||||
contact = create(:contact, email: 'Test@test.com')
|
||||
expect(contact.email).to eq('test@test.com')
|
||||
|
||||
@@ -115,7 +115,7 @@ RSpec.describe Conversation do
|
||||
let!(:conversation) do
|
||||
create(:conversation, status: 'open', account: account, assignee: old_assignee)
|
||||
end
|
||||
let(:assignment_mailer) { double(deliver: true) }
|
||||
let(:assignment_mailer) { instance_double(AssignmentMailer, deliver: true) }
|
||||
let(:label) { create(:label, account: account) }
|
||||
|
||||
before do
|
||||
@@ -142,7 +142,7 @@ RSpec.describe Conversation do
|
||||
it 'runs after_update callbacks' do
|
||||
conversation.update(
|
||||
status: :resolved,
|
||||
contact_last_seen_at: Time.now,
|
||||
contact_last_seen_at: Time.zone.now,
|
||||
assignee: new_assignee
|
||||
)
|
||||
status_change = conversation.status_change
|
||||
@@ -193,7 +193,7 @@ RSpec.describe Conversation do
|
||||
it 'creates conversation activities' do
|
||||
conversation.update(
|
||||
status: :resolved,
|
||||
contact_last_seen_at: Time.now,
|
||||
contact_last_seen_at: Time.zone.now,
|
||||
assignee: new_assignee,
|
||||
label_list: [label.title]
|
||||
)
|
||||
@@ -611,7 +611,7 @@ RSpec.describe Conversation do
|
||||
account: conversation.account,
|
||||
inbox: facebook_inbox,
|
||||
conversation: conversation,
|
||||
created_at: Time.now - 48.hours
|
||||
created_at: 48.hours.ago
|
||||
)
|
||||
|
||||
expect(conversation.can_reply?).to be true
|
||||
@@ -626,7 +626,7 @@ RSpec.describe Conversation do
|
||||
account: conversation.account,
|
||||
inbox: facebook_inbox,
|
||||
conversation: conversation,
|
||||
created_at: Time.now - 48.hours
|
||||
created_at: 48.hours.ago
|
||||
)
|
||||
|
||||
expect(conversation.can_reply?).to be false
|
||||
@@ -646,7 +646,7 @@ RSpec.describe Conversation do
|
||||
account: conversation.account,
|
||||
inbox: api_channel.inbox,
|
||||
conversation: conversation,
|
||||
created_at: Time.now - 13.hours
|
||||
created_at: 13.hours.ago
|
||||
)
|
||||
|
||||
expect(api_channel.additional_attributes['agent_reply_time_window']).to be_nil
|
||||
@@ -662,7 +662,7 @@ RSpec.describe Conversation do
|
||||
account: conversation.account,
|
||||
inbox: api_channel_with_limit.inbox,
|
||||
conversation: conversation,
|
||||
created_at: Time.now - 13.hours
|
||||
created_at: 13.hours.ago
|
||||
)
|
||||
|
||||
expect(api_channel_with_limit.additional_attributes['agent_reply_time_window']).to eq '12'
|
||||
|
||||
@@ -7,11 +7,11 @@ require Rails.root.join 'spec/models/concerns/avatarable_shared.rb'
|
||||
RSpec.describe User do
|
||||
let!(:user) { create(:user) }
|
||||
|
||||
context 'validations' do
|
||||
context 'with validations' do
|
||||
it { is_expected.to validate_presence_of(:email) }
|
||||
end
|
||||
|
||||
context 'associations' do
|
||||
context 'with associations' do
|
||||
it { is_expected.to have_many(:accounts).through(:account_users) }
|
||||
it { is_expected.to have_many(:account_users) }
|
||||
it { is_expected.to have_many(:assigned_conversations).class_name('Conversation').dependent(:nullify) }
|
||||
@@ -33,7 +33,7 @@ RSpec.describe User do
|
||||
it { expect(user.pubsub_token).not_to be_nil }
|
||||
it { expect(user.saved_changes.keys).not_to eq('pubsub_token') }
|
||||
|
||||
context 'rotates the pubsub_token' do
|
||||
context 'with rotate the pubsub_token' do
|
||||
it 'changes the pubsub_token when password changes' do
|
||||
pubsub_token = user.pubsub_token
|
||||
user.password = Faker::Internet.password(special_characters: true)
|
||||
@@ -68,7 +68,7 @@ RSpec.describe User do
|
||||
end
|
||||
end
|
||||
|
||||
context 'sso_auth_token' do
|
||||
context 'with sso_auth_token' do
|
||||
it 'can generate multiple sso tokens which can be validated' do
|
||||
sso_auth_token1 = user.generate_sso_auth_token
|
||||
sso_auth_token2 = user.generate_sso_auth_token
|
||||
|
||||
Reference in New Issue
Block a user