diff --git a/app/finders/conversation_finder.rb b/app/finders/conversation_finder.rb index 6ee4a4d21..63846acaa 100644 --- a/app/finders/conversation_finder.rb +++ b/app/finders/conversation_finder.rb @@ -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 diff --git a/spec/actions/contact_merge_action_spec.rb b/spec/actions/contact_merge_action_spec.rb index 9cbdeb343..b87644a92 100644 --- a/spec/actions/contact_merge_action_spec.rb +++ b/spec/actions/contact_merge_action_spec.rb @@ -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 diff --git a/spec/controllers/api/v1/accounts_controller_spec.rb b/spec/controllers/api/v1/accounts_controller_spec.rb index 24607f250..cba78e56b 100644 --- a/spec/controllers/api/v1/accounts_controller_spec.rb +++ b/spec/controllers/api/v1/accounts_controller_spec.rb @@ -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 diff --git a/spec/finders/conversation_finder_spec.rb b/spec/finders/conversation_finder_spec.rb index d739179bf..82a479837 100644 --- a/spec/finders/conversation_finder_spec.rb +++ b/spec/finders/conversation_finder_spec.rb @@ -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 diff --git a/spec/models/agent_bot_spec.rb b/spec/models/agent_bot_spec.rb index be71a36c9..682da1e74 100644 --- a/spec/models/agent_bot_spec.rb +++ b/spec/models/agent_bot_spec.rb @@ -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 diff --git a/spec/models/channel/facebook_page_spec.rb b/spec/models/channel/facebook_page_spec.rb index 309cc74dc..bcd468556 100644 --- a/spec/models/channel/facebook_page_spec.rb +++ b/spec/models/channel/facebook_page_spec.rb @@ -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) } diff --git a/spec/models/concerns/access_tokenable_spec.rb b/spec/models/concerns/access_tokenable_shared.rb similarity index 100% rename from spec/models/concerns/access_tokenable_spec.rb rename to spec/models/concerns/access_tokenable_shared.rb diff --git a/spec/models/concerns/assignment_handler_spec.rb b/spec/models/concerns/assignment_handler_shared.rb similarity index 100% rename from spec/models/concerns/assignment_handler_spec.rb rename to spec/models/concerns/assignment_handler_shared.rb diff --git a/spec/models/concerns/out_of_offisable_spec.rb b/spec/models/concerns/out_of_offisable_shared.rb similarity index 100% rename from spec/models/concerns/out_of_offisable_spec.rb rename to spec/models/concerns/out_of_offisable_shared.rb diff --git a/spec/models/concerns/reauthorizable_spec.rb b/spec/models/concerns/reauthorizable_shared.rb similarity index 100% rename from spec/models/concerns/reauthorizable_spec.rb rename to spec/models/concerns/reauthorizable_shared.rb diff --git a/spec/models/concerns/round_robin_handler_spec.rb b/spec/models/concerns/round_robin_handler_shared.rb similarity index 100% rename from spec/models/concerns/round_robin_handler_spec.rb rename to spec/models/concerns/round_robin_handler_shared.rb diff --git a/spec/models/conversation_spec.rb b/spec/models/conversation_spec.rb index 08f9b001e..62e4030d3 100644 --- a/spec/models/conversation_spec.rb +++ b/spec/models/conversation_spec.rb @@ -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 diff --git a/spec/models/inbox_spec.rb b/spec/models/inbox_spec.rb index 04dd265ce..e80b7b7e8 100644 --- a/spec/models/inbox_spec.rb +++ b/spec/models/inbox_spec.rb @@ -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 diff --git a/spec/models/platform_app_spec.rb b/spec/models/platform_app_spec.rb index 1841929bb..ad4202f41 100644 --- a/spec/models/platform_app_spec.rb +++ b/spec/models/platform_app_spec.rb @@ -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) } diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 8acff2aaa..5c4ce6850 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -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) }