feat: Add support for minutes in auto resolve feature (#11269)
### Summary - Converts conversation auto-resolution duration from days to minutes for more granular control - Updates validation to allow values from 10 minutes (minimum) to 999 days (maximum) - Implements smart messaging to show appropriate time units in activity messages ### Changes - Created migration to convert existing durations from days to minutes (x1440) - Updated conversation resolver to use minutes instead of days - Added dynamic translation key selection based on duration value - Updated related specs and documentation - Added support for displaying durations in days, hours, or minutes based on value ### Test plan - Verify account validation accepts new minute-based ranges - Confirm existing account settings are correctly migrated - Test auto-resolution works properly with minute values - Ensure proper time unit display in activity messages --------- Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
This commit is contained in:
@@ -213,11 +213,18 @@ RSpec.describe Conversation do
|
||||
end
|
||||
|
||||
it 'adds a message for system auto resolution if marked resolved by system' do
|
||||
account.update(auto_resolve_duration: 40)
|
||||
account.update(auto_resolve_after: 40 * 24 * 60)
|
||||
conversation2 = create(:conversation, status: 'open', account: account, assignee: old_assignee)
|
||||
Current.user = nil
|
||||
|
||||
system_resolved_message = "Conversation was marked resolved by system due to #{account.auto_resolve_duration} days of inactivity"
|
||||
message_data = if account.auto_resolve_after >= 1440 && account.auto_resolve_after % 1440 == 0
|
||||
{ key: 'auto_resolved_days', count: account.auto_resolve_after / 1440 }
|
||||
elsif account.auto_resolve_after >= 60 && account.auto_resolve_after % 60 == 0
|
||||
{ key: 'auto_resolved_hours', count: account.auto_resolve_after / 60 }
|
||||
else
|
||||
{ key: 'auto_resolved_minutes', count: account.auto_resolve_after }
|
||||
end
|
||||
system_resolved_message = "Conversation was marked resolved by system due to #{message_data[:count]} days of inactivity"
|
||||
expect { conversation2.update(status: :resolved) }
|
||||
.to have_enqueued_job(Conversations::ActivityMessageJob)
|
||||
.with(conversation2, { account_id: conversation2.account_id, inbox_id: conversation2.inbox_id, message_type: :activity,
|
||||
|
||||
Reference in New Issue
Block a user