Merge branch 'hotfix/1.2.4' into develop
This commit is contained in:
commit
2eac97c705
6 changed files with 27 additions and 10 deletions
|
@ -5,6 +5,7 @@ class ContactMergeAction
|
|||
ActiveRecord::Base.transaction do
|
||||
validate_contacts
|
||||
merge_conversations
|
||||
merge_messages
|
||||
merge_contact_inboxes
|
||||
remove_mergee_contact
|
||||
end
|
||||
|
@ -26,6 +27,10 @@ class ContactMergeAction
|
|||
Conversation.where(contact_id: @mergee_contact.id).update(contact_id: @base_contact.id)
|
||||
end
|
||||
|
||||
def merge_messages
|
||||
Message.where(contact_id: @mergee_contact.id).update(contact_id: @base_contact.id)
|
||||
end
|
||||
|
||||
def merge_contact_inboxes
|
||||
ContactInbox.where(contact_id: @mergee_contact.id).update(contact_id: @base_contact.id)
|
||||
end
|
||||
|
|
|
@ -28,6 +28,7 @@ class Contact < ApplicationRecord
|
|||
has_many :conversations, dependent: :destroy
|
||||
has_many :contact_inboxes, dependent: :destroy
|
||||
has_many :inboxes, through: :contact_inboxes
|
||||
has_many :messages, dependent: :destroy
|
||||
|
||||
def get_source_id(inbox_id)
|
||||
contact_inboxes.find_by!(inbox_id: inbox_id).source_id
|
||||
|
|
|
@ -83,13 +83,16 @@ Rails.application.configure do
|
|||
config.log_formatter = ::Logger::Formatter.new
|
||||
|
||||
# Use a different logger for distributed setups.
|
||||
# require 'syslog/logger'
|
||||
config.logger = ActiveSupport::Logger.new(Rails.root.join('log', Rails.env + '.log'), 1, ENV.fetch('LOG_SIZE', '1024').to_i.megabytes)
|
||||
|
||||
if ENV['RAILS_LOG_TO_STDOUT'].present?
|
||||
logger = ActiveSupport::Logger.new(STDOUT)
|
||||
logger.formatter = config.log_formatter
|
||||
config.logger = ActiveSupport::TaggedLogging.new(logger)
|
||||
else
|
||||
config.logger = ActiveSupport::Logger.new(
|
||||
Rails.root.join('log', Rails.env + '.log'),
|
||||
1,
|
||||
ENV.fetch('LOG_SIZE', '1024').to_i.megabytes
|
||||
)
|
||||
end
|
||||
|
||||
# Do not dump schema after migrations.
|
||||
|
|
|
@ -47,7 +47,7 @@ COPY . /app
|
|||
|
||||
# generate production assets if production environment
|
||||
RUN if [ "$RAILS_ENV" = "production" ]; then \
|
||||
SECRET_KEY_BASE=precompile_placeholder bundle exec rake assets:precompile; \
|
||||
SECRET_KEY_BASE=precompile_placeholder RAILS_LOG_TO_STDOUT=enabled bundle exec rake assets:precompile; \
|
||||
fi
|
||||
|
||||
# final build stage
|
||||
|
|
|
@ -10,6 +10,7 @@ describe ::ContactMergeAction do
|
|||
before do
|
||||
2.times.each { create(:conversation, contact: base_contact) }
|
||||
2.times.each { create(:conversation, contact: mergee_contact) }
|
||||
2.times.each { create(:message, contact: mergee_contact) }
|
||||
end
|
||||
|
||||
describe '#perform' do
|
||||
|
@ -32,6 +33,13 @@ describe ::ContactMergeAction do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when mergee contact has messages' do
|
||||
it 'moves the messages to base contact' do
|
||||
contact_merge
|
||||
expect(base_contact.messages.count).to be 2
|
||||
end
|
||||
end
|
||||
|
||||
context 'when contacts belong to a different account' do
|
||||
it 'throws an exception' do
|
||||
new_account = create(:account)
|
||||
|
|
12
yarn.lock
12
yarn.lock
|
@ -8810,14 +8810,14 @@ regenerator-runtime@^0.13.3:
|
|||
integrity sha512-naKIZz2GQ8JWh///G7L3X6LaQUAMp2lvb1rvwwsURe/VXwD6VMfr+/1NuNw3ag8v2kY1aQ/go5SNn79O9JU7yw==
|
||||
|
||||
regenerator-runtime@^0.13.4:
|
||||
version "0.13.4"
|
||||
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.4.tgz#e96bf612a3362d12bb69f7e8f74ffeab25c7ac91"
|
||||
integrity sha512-plpwicqEzfEyTQohIKktWigcLzmNStMGwbOUbykx51/29Z3JOGYldaaNGK7ngNXV+UcoqvIMmloZ48Sr74sd+g==
|
||||
version "0.13.5"
|
||||
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.5.tgz#d878a1d094b4306d10b9096484b33ebd55e26697"
|
||||
integrity sha512-ZS5w8CpKFinUzOwW3c83oPeVXoNsrLsaCoLtJvAClH135j/R77RuymhiSErhm2lKcwSCIpmvIWSbDkIfAqKQlA==
|
||||
|
||||
regenerator-transform@^0.14.2:
|
||||
version "0.14.2"
|
||||
resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.14.2.tgz#949d9d87468ff88d5a7e4734ebb994a892de1ff2"
|
||||
integrity sha512-V4+lGplCM/ikqi5/mkkpJ06e9Bujq1NFmNLvsCs56zg3ZbzrnUzAtizZ24TXxtRX/W2jcdScwQCnbL0CICTFkQ==
|
||||
version "0.14.4"
|
||||
resolved "https://registry.yarnpkg.com/regenerator-transform/-/regenerator-transform-0.14.4.tgz#5266857896518d1616a78a0479337a30ea974cc7"
|
||||
integrity sha512-EaJaKPBI9GvKpvUz2mz4fhx7WPgvwRLY9v3hlNHWmAuJHI13T4nwKnNvm5RWJzEdnI5g5UwtOww+S8IdoUC2bw==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.8.4"
|
||||
private "^0.1.8"
|
||||
|
|
Loading…
Reference in a new issue