chore: Limit objects returned by conversation API (#2721)
This commit is contained in:
@@ -114,13 +114,13 @@ class ConversationFinder
|
||||
end
|
||||
|
||||
def current_page
|
||||
params[:page]
|
||||
params[:page] || 1
|
||||
end
|
||||
|
||||
def conversations
|
||||
@conversations = @conversations.includes(
|
||||
:taggings, :inbox, { assignee: { avatar_attachment: [:blob] } }, { contact: { avatar_attachment: [:blob] } }, :team
|
||||
)
|
||||
current_page ? @conversations.latest.page(current_page) : @conversations.latest
|
||||
@conversations.latest.page(current_page)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -23,7 +23,7 @@ describe ::ContactMergeAction do
|
||||
it 'does not delete contact' do
|
||||
mergee_contact = base_contact
|
||||
contact_merge
|
||||
expect { mergee_contact.reload }.not_to raise_error(ActiveRecord::RecordNotFound)
|
||||
expect(mergee_contact.reload).not_to eq nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -61,14 +61,14 @@ RSpec.describe 'Accounts API', type: :request do
|
||||
|
||||
context 'when ENABLE_ACCOUNT_SIGNUP env variable is set to api_only' do
|
||||
it 'does not respond 404 on requests' do
|
||||
params = { account_name: 'test', email: email, user_full_name: user_full_name }
|
||||
params = { account_name: 'test', email: email, user_full_name: user_full_name, password: 'Password1!' }
|
||||
ENV['ENABLE_ACCOUNT_SIGNUP'] = 'api_only'
|
||||
|
||||
post api_v1_accounts_url,
|
||||
params: params,
|
||||
as: :json
|
||||
|
||||
expect(response).not_to have_http_status(:not_found)
|
||||
expect(response).to have_http_status(:success)
|
||||
ENV['ENABLE_ACCOUNT_SIGNUP'] = nil
|
||||
end
|
||||
end
|
||||
|
||||
@@ -26,7 +26,7 @@ describe ::ConversationFinder do
|
||||
|
||||
it 'filter conversations by status' do
|
||||
result = conversation_finder.perform
|
||||
expect(result[:conversations].count).to be 2
|
||||
expect(result[:conversations].length).to be 2
|
||||
end
|
||||
end
|
||||
|
||||
@@ -35,7 +35,7 @@ describe ::ConversationFinder do
|
||||
|
||||
it 'filter conversations by assignee type all' do
|
||||
result = conversation_finder.perform
|
||||
expect(result[:conversations].count).to be 4
|
||||
expect(result[:conversations].length).to be 4
|
||||
end
|
||||
end
|
||||
|
||||
@@ -44,7 +44,7 @@ describe ::ConversationFinder do
|
||||
|
||||
it 'filter conversations by assignee type unassigned' do
|
||||
result = conversation_finder.perform
|
||||
expect(result[:conversations].count).to be 1
|
||||
expect(result[:conversations].length).to be 1
|
||||
end
|
||||
end
|
||||
|
||||
@@ -53,7 +53,7 @@ describe ::ConversationFinder do
|
||||
|
||||
it 'filter conversations by assignee type assigned' do
|
||||
result = conversation_finder.perform
|
||||
expect(result[:conversations].count).to be 3
|
||||
expect(result[:conversations].length).to be 3
|
||||
end
|
||||
|
||||
it 'returns the correct meta' do
|
||||
@@ -74,7 +74,7 @@ describe ::ConversationFinder do
|
||||
it 'filter conversations by team' do
|
||||
create(:conversation, account: account, inbox: inbox, team: team)
|
||||
result = conversation_finder.perform
|
||||
expect(result[:conversations].count).to be 1
|
||||
expect(result[:conversations].length).to be 1
|
||||
end
|
||||
end
|
||||
|
||||
@@ -86,7 +86,7 @@ describe ::ConversationFinder do
|
||||
conversation.update_labels('resolved')
|
||||
|
||||
result = conversation_finder.perform
|
||||
expect(result[:conversations].count).to be 1
|
||||
expect(result[:conversations].length).to be 1
|
||||
end
|
||||
end
|
||||
|
||||
@@ -96,7 +96,7 @@ describe ::ConversationFinder do
|
||||
it 'returns paginated conversations' do
|
||||
create_list(:conversation, 50, account: account, inbox: inbox, assignee: user_1)
|
||||
result = conversation_finder.perform
|
||||
expect(result[:conversations].count).to be 25
|
||||
expect(result[:conversations].length).to be 25
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
require 'rails_helper'
|
||||
require Rails.root.join 'spec/models/concerns/access_tokenable_spec.rb'
|
||||
require Rails.root.join 'spec/models/concerns/access_tokenable_shared.rb'
|
||||
|
||||
RSpec.describe AgentBot, type: :model do
|
||||
describe 'associations' do
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
require Rails.root.join 'spec/models/concerns/reauthorizable_spec.rb'
|
||||
require Rails.root.join 'spec/models/concerns/reauthorizable_shared.rb'
|
||||
|
||||
RSpec.describe Channel::FacebookPage do
|
||||
let(:channel) { create(:channel_facebook_page) }
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
require Rails.root.join 'spec/models/concerns/assignment_handler_spec.rb'
|
||||
require Rails.root.join 'spec/models/concerns/round_robin_handler_spec.rb'
|
||||
require Rails.root.join 'spec/models/concerns/assignment_handler_shared.rb'
|
||||
require Rails.root.join 'spec/models/concerns/round_robin_handler_shared.rb'
|
||||
|
||||
RSpec.describe Conversation, type: :model do
|
||||
describe 'associations' do
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
require Rails.root.join 'spec/models/concerns/out_of_offisable_spec.rb'
|
||||
require Rails.root.join 'spec/models/concerns/out_of_offisable_shared.rb'
|
||||
|
||||
RSpec.describe Inbox do
|
||||
describe 'validations' do
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
require Rails.root.join 'spec/models/concerns/access_tokenable_spec.rb'
|
||||
require Rails.root.join 'spec/models/concerns/access_tokenable_shared.rb'
|
||||
|
||||
RSpec.describe PlatformApp do
|
||||
let(:platform_app) { create(:platform_app) }
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
require Rails.root.join 'spec/models/concerns/access_tokenable_spec.rb'
|
||||
require Rails.root.join 'spec/models/concerns/access_tokenable_shared.rb'
|
||||
|
||||
RSpec.describe User do
|
||||
let!(:user) { create(:user) }
|
||||
|
||||
Reference in New Issue
Block a user