chore: Use "destroy!" instead of "destroy" when not checking the return value (#4259)

This commit is contained in:
Jordan Brough 2022-03-24 01:58:25 -06:00 committed by GitHub
parent 8b9aea231c
commit c2647a1f27
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 21 additions and 21 deletions

View file

@ -18,7 +18,7 @@ class Api::V1::Accounts::AgentBotsController < Api::V1::Accounts::BaseController
end end
def destroy def destroy
@agent_bot.destroy @agent_bot.destroy!
head :ok head :ok
end end

View file

@ -18,7 +18,7 @@ class Api::V1::Accounts::AgentsController < Api::V1::Accounts::BaseController
end end
def destroy def destroy
@agent.current_account_user.destroy @agent.current_account_user.destroy!
head :ok head :ok
end end

View file

@ -11,7 +11,7 @@ class Api::V1::Accounts::CampaignsController < Api::V1::Accounts::BaseController
end end
def destroy def destroy
@campaign.destroy @campaign.destroy!
head :ok head :ok
end end

View file

@ -17,7 +17,7 @@ class Api::V1::Accounts::CannedResponsesController < Api::V1::Accounts::BaseCont
end end
def destroy def destroy
@canned_response.destroy @canned_response.destroy!
head :ok head :ok
end end

View file

@ -10,7 +10,7 @@ class Api::V1::Accounts::Contacts::NotesController < Api::V1::Accounts::Contacts
end end
def destroy def destroy
@note.destroy @note.destroy!
head :ok head :ok
end end

View file

@ -18,7 +18,7 @@ class Api::V1::Accounts::CustomAttributeDefinitionsController < Api::V1::Account
end end
def destroy def destroy
@custom_attribute_definition.destroy @custom_attribute_definition.destroy!
head :no_content head :no_content
end end

View file

@ -18,7 +18,7 @@ class Api::V1::Accounts::CustomFiltersController < Api::V1::Accounts::BaseContro
end end
def destroy def destroy
@custom_filter.destroy @custom_filter.destroy!
head :no_content head :no_content
end end

View file

@ -73,7 +73,7 @@ class Api::V1::Accounts::InboxesController < Api::V1::Accounts::BaseController
end end
def destroy def destroy
@inbox.destroy @inbox.destroy!
head :ok head :ok
end end

View file

@ -11,7 +11,7 @@ class Api::V1::Accounts::Integrations::HooksController < Api::V1::Accounts::Base
end end
def destroy def destroy
@hook.destroy @hook.destroy!
head :ok head :ok
end end

View file

@ -20,7 +20,7 @@ class Api::V1::Accounts::Integrations::SlackController < Api::V1::Accounts::Base
end end
def destroy def destroy
@hook.destroy @hook.destroy!
head :ok head :ok
end end

View file

@ -14,7 +14,7 @@ class Api::V1::Accounts::Kbase::CategoriesController < Api::V1::Accounts::Kbase:
end end
def destroy def destroy
@category.destroy @category.destroy!
head :ok head :ok
end end

View file

@ -14,7 +14,7 @@ class Api::V1::Accounts::Kbase::PortalsController < Api::V1::Accounts::Kbase::Ba
end end
def destroy def destroy
@portal.destroy @portal.destroy!
head :ok head :ok
end end

View file

@ -18,7 +18,7 @@ class Api::V1::Accounts::LabelsController < Api::V1::Accounts::BaseController
end end
def destroy def destroy
@label.destroy @label.destroy!
head :ok head :ok
end end

View file

@ -18,7 +18,7 @@ class Api::V1::Accounts::TeamsController < Api::V1::Accounts::BaseController
end end
def destroy def destroy
@team.destroy @team.destroy!
head :ok head :ok
end end

View file

@ -16,7 +16,7 @@ class Api::V1::Accounts::WebhooksController < Api::V1::Accounts::BaseController
end end
def destroy def destroy
@webhook.destroy @webhook.destroy!
head :ok head :ok
end end

View file

@ -9,7 +9,7 @@ class Api::V1::NotificationSubscriptionsController < Api::BaseController
def destroy def destroy
notification_subscription = NotificationSubscription.where(["subscription_attributes->>'push_token' = ?", params[:push_token]]).first notification_subscription = NotificationSubscription.where(["subscription_attributes->>'push_token' = ?", params[:push_token]]).first
notification_subscription.destroy notification_subscription.destroy!
head :ok head :ok
end end

View file

@ -13,7 +13,7 @@ class Platform::Api::V1::AccountUsersController < PlatformController
end end
def destroy def destroy
@resource.account_users.find_by(user_id: account_user_params[:user_id])&.destroy @resource.account_users.find_by(user_id: account_user_params[:user_id])&.destroy!
head :ok head :ok
end end

View file

@ -38,7 +38,7 @@ class Team < ApplicationRecord
end end
def remove_member(user_id) def remove_member(user_id)
team_members.find_by(user_id: user_id)&.destroy team_members.find_by(user_id: user_id)&.destroy!
end end
def messages def messages

View file

@ -33,7 +33,7 @@ RSpec.describe '/api/v1/widget/messages', type: :request do
describe 'POST /api/v1/widget/messages' do describe 'POST /api/v1/widget/messages' do
context 'when post request is made' do context 'when post request is made' do
it 'creates message in conversation' do it 'creates message in conversation' do
conversation.destroy # Test all params conversation.destroy! # Test all params
message_params = { content: 'hello world', timestamp: Time.current } message_params = { content: 'hello world', timestamp: Time.current }
post api_v1_widget_messages_url, post api_v1_widget_messages_url,
params: { website_token: web_widget.website_token, message: message_params }, params: { website_token: web_widget.website_token, message: message_params },
@ -46,7 +46,7 @@ RSpec.describe '/api/v1/widget/messages', type: :request do
end end
it 'does not create the message' do it 'does not create the message' do
conversation.destroy # Test all params conversation.destroy! # Test all params
message_params = { content: "#{'h' * 150 * 1000}a", timestamp: Time.current } message_params = { content: "#{'h' * 150 * 1000}a", timestamp: Time.current }
post api_v1_widget_messages_url, post api_v1_widget_messages_url,
params: { website_token: web_widget.website_token, message: message_params }, params: { website_token: web_widget.website_token, message: message_params },

View file

@ -482,7 +482,7 @@ RSpec.describe Conversation, type: :model do
let!(:notification) { create(:notification, notification_type: 'conversation_creation', primary_actor: conversation) } let!(:notification) { create(:notification, notification_type: 'conversation_creation', primary_actor: conversation) }
it 'delete associated notifications if conversation is deleted' do it 'delete associated notifications if conversation is deleted' do
conversation.destroy conversation.destroy!
expect { notification.reload }.to raise_error ActiveRecord::RecordNotFound expect { notification.reload }.to raise_error ActiveRecord::RecordNotFound
end end
end end