Fixes #3758 - Saved conditions break on selections without reloading.
This commit is contained in:
parent
dd201db791
commit
a3df6b8581
2 changed files with 46 additions and 0 deletions
|
@ -55,6 +55,7 @@ class CoreWorkflow::Attributes
|
|||
# dont use lookup here because the cache will not
|
||||
# know about new attributes and make crashes
|
||||
@saved_only ||= payload_class.find_by(id: @payload['params']['id'])
|
||||
@saved_only.dup
|
||||
end
|
||||
|
||||
def saved
|
||||
|
|
|
@ -1633,4 +1633,49 @@ RSpec.describe CoreWorkflow, type: :model do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Saved conditions break on selections without reloading #3758', db_strategy: :reset do
|
||||
let(:field_name) { SecureRandom.uuid }
|
||||
let(:screens) do
|
||||
{
|
||||
edit: {
|
||||
'ticket.agent' => {
|
||||
shown: true,
|
||||
},
|
||||
},
|
||||
}
|
||||
end
|
||||
let!(:workflow) do
|
||||
create(:core_workflow,
|
||||
object: 'Ticket',
|
||||
condition_saved: {
|
||||
"ticket.#{field_name}": {
|
||||
operator: 'is_not',
|
||||
value: 'true',
|
||||
},
|
||||
})
|
||||
end
|
||||
let(:payload) do
|
||||
base_payload.merge('params' => { 'id' => ticket.id }, 'screen' => 'edit')
|
||||
end
|
||||
|
||||
before do
|
||||
create(:object_manager_attribute_boolean, object_name: 'Ticket', name: field_name, display: field_name, screens: screens)
|
||||
ObjectManager::Attribute.migration_execute
|
||||
end
|
||||
|
||||
it 'does match the workflow because saved value is false' do
|
||||
expect(result[:matched_workflows]).to include(workflow.id)
|
||||
end
|
||||
|
||||
context 'when params contain boolean field true' do
|
||||
let(:payload) do
|
||||
base_payload.merge('params' => { 'id' => ticket.id, field_name => true }, 'screen' => 'edit')
|
||||
end
|
||||
|
||||
it 'does match the workflow because saved value is false' do
|
||||
expect(result[:matched_workflows]).to include(workflow.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue