Fixes #2920 - Link-Template attributes within Organizations and user cause Organization and user creation to fail within UI
This commit is contained in:
parent
0a70711695
commit
82149f463a
3 changed files with 65 additions and 2 deletions
|
@ -361,7 +361,7 @@ class App.ControllerForm extends App.Controller
|
|||
return item
|
||||
else
|
||||
placeholderObjects = {}
|
||||
if @model.className && !_.isEmpty(attribute.linktemplate) && !_.isEmpty(@params[attribute.name])
|
||||
if @model.className && @params && !_.isEmpty(attribute.linktemplate) && !_.isEmpty(@params[attribute.name])
|
||||
placeholderObjects = { attribute: attribute, session: App.Session.get(), config: App.Config.all() }
|
||||
placeholderObjects[@model.className.toLowerCase()] = @params
|
||||
fullItem = $(
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
FactoryBot.define do
|
||||
factory :object_manager_attribute, class: ObjectManager::Attribute do
|
||||
object_lookup_id { ObjectLookup.by_name('Ticket') }
|
||||
transient do
|
||||
object_name { 'Ticket' }
|
||||
additional_data_options { nil }
|
||||
end
|
||||
|
||||
object_lookup_id { ObjectLookup.by_name(object_name) }
|
||||
sequence(:name) { |n| "internal_name#{n}" }
|
||||
sequence(:display) { |n| "Display Name #{n}" }
|
||||
data_option_new { {} }
|
||||
|
@ -23,6 +28,13 @@ FactoryBot.define do
|
|||
'edit' => {}
|
||||
}
|
||||
end
|
||||
|
||||
callback(:after_stub, :before_create) do |object, context|
|
||||
next if context.additional_data_options.blank?
|
||||
|
||||
object.data_option ||= {}
|
||||
object.data_option.merge! context.additional_data_options
|
||||
end
|
||||
end
|
||||
|
||||
factory :object_manager_attribute_text, parent: :object_manager_attribute do
|
||||
|
|
51
spec/system/manage/organizations_spec.rb
Normal file
51
spec/system/manage/organizations_spec.rb
Normal file
|
@ -0,0 +1,51 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe 'Manage > Organizations', type: :system do
|
||||
|
||||
context 'custom attribute' do
|
||||
|
||||
context 'text' do
|
||||
|
||||
context 'linktemplate' do
|
||||
|
||||
it 'creates record', db_strategy: :reset do
|
||||
|
||||
# required to edit attribute in admin interface
|
||||
screens = { edit: { "admin.organization": { shown: true, required: false } } }
|
||||
|
||||
attribute = create(:object_manager_attribute_text,
|
||||
object_name: 'Organization',
|
||||
screens: screens,
|
||||
additional_data_options: { linktemplate: 'https://example.com' })
|
||||
|
||||
ObjectManager::Attribute.migration_execute
|
||||
|
||||
refresh
|
||||
|
||||
visit 'manage/organizations'
|
||||
|
||||
within(:active_content) do
|
||||
click '[data-type="new"]'
|
||||
end
|
||||
|
||||
modal_ready
|
||||
|
||||
name = "Organization #{rand(999_999)}"
|
||||
|
||||
within '.modal-dialog' do
|
||||
fill_in 'name', with: name
|
||||
fill_in attribute.name, with: 'value'
|
||||
|
||||
click '.js-submit'
|
||||
end
|
||||
|
||||
modal_disappear
|
||||
|
||||
within(:active_content) do
|
||||
expect(page).to have_text name
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue