Fixed issue #1025 - “Update Database" plus restart does not work correctly.
This commit is contained in:
parent
060051b710
commit
1fbd368f02
3 changed files with 239 additions and 0 deletions
|
@ -227,6 +227,11 @@ possible types
|
|||
|
||||
# if data_option has changed, store it for next migration
|
||||
if !force
|
||||
[:name, :display, :data_type, :position, :active].each { |key|
|
||||
next if record[key] == data[key]
|
||||
data[:to_config] = true
|
||||
break
|
||||
}
|
||||
if record[:data_option] != data[:data_option]
|
||||
|
||||
# do we need a database migration?
|
||||
|
@ -587,7 +592,9 @@ to send no browser reload event, pass false
|
|||
end
|
||||
|
||||
# restart processes
|
||||
attribute.to_create = false
|
||||
attribute.to_migrate = false
|
||||
attribute.to_delete = false
|
||||
attribute.save!
|
||||
reset_database_info(model)
|
||||
execute_db_count += 1
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
require 'browser_test_helper'
|
||||
|
||||
class AdminObjectManagerTest < TestCase
|
||||
|
||||
def test_basic_a
|
||||
|
||||
@browser = browser_instance
|
||||
|
@ -388,4 +389,113 @@ class AdminObjectManagerTest < TestCase
|
|||
)
|
||||
end
|
||||
|
||||
def test_basic_c
|
||||
@browser = browser_instance
|
||||
login(
|
||||
username: 'master@example.com',
|
||||
password: 'test',
|
||||
url: browser_url,
|
||||
)
|
||||
tasks_close_all()
|
||||
|
||||
# valid name
|
||||
object_manager_attribute_create(
|
||||
data: {
|
||||
name: 'browser_update_test1',
|
||||
display: 'Browser Update Test 1',
|
||||
data_type: 'Text',
|
||||
},
|
||||
)
|
||||
|
||||
watch_for(
|
||||
css: '.content.active',
|
||||
value: 'Database Update required',
|
||||
)
|
||||
click(css: '.content.active .tab-pane.active div.js-execute')
|
||||
watch_for(
|
||||
css: '.modal',
|
||||
value: 'restart',
|
||||
)
|
||||
watch_for_disappear(
|
||||
css: '.modal',
|
||||
timeout: 120,
|
||||
)
|
||||
sleep 5
|
||||
watch_for(
|
||||
css: '.content.active',
|
||||
)
|
||||
match_not(
|
||||
css: '.content.active',
|
||||
value: 'Database Update required',
|
||||
)
|
||||
|
||||
# valid name
|
||||
object_manager_attribute_update(
|
||||
data: {
|
||||
name: 'browser_update_test1',
|
||||
display: 'Browser Update Test 2',
|
||||
data_type: 'Text',
|
||||
},
|
||||
)
|
||||
|
||||
watch_for(
|
||||
css: '.content.active',
|
||||
value: 'Database Update required',
|
||||
)
|
||||
click(css: '.content.active .tab-pane.active div.js-execute')
|
||||
watch_for(
|
||||
css: '.modal',
|
||||
value: 'configuration of Zammad has changed',
|
||||
)
|
||||
click(css: '.modal .js-submit')
|
||||
watch_for_disappear(
|
||||
css: '.modal',
|
||||
timeout: 120,
|
||||
)
|
||||
sleep 5
|
||||
watch_for(
|
||||
css: '.content.active',
|
||||
)
|
||||
match_not(
|
||||
css: '.content.active',
|
||||
value: 'Database Update required',
|
||||
)
|
||||
|
||||
object_manager_attribute_delete(
|
||||
data: {
|
||||
name: 'browser_update_test1',
|
||||
},
|
||||
)
|
||||
watch_for(
|
||||
css: '.content.active',
|
||||
value: 'Database Update required',
|
||||
)
|
||||
watch_for(
|
||||
css: '.content.active table',
|
||||
value: 'browser_update_test1',
|
||||
)
|
||||
click(css: '.content.active .tab-pane.active div.js-execute')
|
||||
watch_for(
|
||||
css: '.modal',
|
||||
value: 'restart',
|
||||
)
|
||||
watch_for_disappear(
|
||||
css: '.modal',
|
||||
timeout: 120,
|
||||
)
|
||||
sleep 5
|
||||
watch_for(
|
||||
css: '.content.active',
|
||||
)
|
||||
match_not(
|
||||
css: '.content.active',
|
||||
value: 'Database Update required',
|
||||
)
|
||||
match_not(
|
||||
css: '.content.active table',
|
||||
value: 'browser_update_test1',
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -3376,6 +3376,128 @@ wait untill text in selector disabppears
|
|||
raise 'object manager attribute creation failed'
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
object_manager_attribute_update(
|
||||
browser: browser2,
|
||||
data: {
|
||||
name: 'field_name' + random,
|
||||
display: 'Display Name of Field',
|
||||
data_type: 'Select',
|
||||
data_option: {
|
||||
options: {
|
||||
'aa' => 'AA',
|
||||
'bb' => 'BB',
|
||||
},
|
||||
|
||||
default: 'abc',
|
||||
},
|
||||
},
|
||||
error: 'already exists'
|
||||
)
|
||||
|
||||
=end
|
||||
|
||||
def object_manager_attribute_update(params = {})
|
||||
switch_window_focus(params)
|
||||
log('object_manager_attribute_update', params)
|
||||
|
||||
instance = params[:browser] || @browser
|
||||
data = params[:data]
|
||||
|
||||
click(
|
||||
browser: instance,
|
||||
css: 'a[href="#manage"]',
|
||||
mute_log: true,
|
||||
)
|
||||
click(
|
||||
browser: instance,
|
||||
css: '.content.active a[href="#system/object_manager"]',
|
||||
mute_log: true,
|
||||
)
|
||||
sleep 4
|
||||
|
||||
instance.execute_script("$(\".content.active td:contains('#{data[:name]}')\").first().click()")
|
||||
modal_ready(browser: instance)
|
||||
element = instance.find_elements(css: '.modal input[name=display]')[0]
|
||||
element.clear
|
||||
element.send_keys(data[:display])
|
||||
select(
|
||||
browser: instance,
|
||||
css: '.modal select[name="data_type"]',
|
||||
value: data[:data_type],
|
||||
mute_log: true,
|
||||
)
|
||||
if data[:data_option]
|
||||
if data[:data_option][:options]
|
||||
if data[:data_type] == 'Boolean'
|
||||
element = instance.find_elements(css: '.modal .js-valueTrue').first
|
||||
element.clear
|
||||
element.send_keys(data[:data_option][:options][:true])
|
||||
element = instance.find_elements(css: '.modal .js-valueFalse').first
|
||||
element.clear
|
||||
element.send_keys(data[:data_option][:options][:false])
|
||||
else
|
||||
data[:data_option][:options].each { |key, value|
|
||||
element = instance.find_elements(css: '.modal .js-Table .js-key').last
|
||||
element.clear
|
||||
element.send_keys(key)
|
||||
element = instance.find_elements(css: '.modal .js-Table .js-value').last
|
||||
element.clear
|
||||
element.send_keys(value)
|
||||
element = instance.find_elements(css: '.modal .js-Table .js-add')[0]
|
||||
element.click
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
[:default, :min, :max, :diff].each { |key|
|
||||
next if !data[:data_option].key?(key)
|
||||
element = instance.find_elements(css: ".modal [name=\"data_option::#{key}\"]").first
|
||||
element.clear
|
||||
element.send_keys(data[:data_option][key])
|
||||
}
|
||||
|
||||
[:future, :past].each { |key|
|
||||
next if !data[:data_option].key?(key)
|
||||
select(
|
||||
browser: instance,
|
||||
css: ".modal select[name=\"data_option::#{key}\"]",
|
||||
value: data[:data_option][key],
|
||||
mute_log: true,
|
||||
)
|
||||
}
|
||||
|
||||
end
|
||||
instance.find_elements(css: '.modal button.js-submit')[0].click
|
||||
if params[:error]
|
||||
sleep 4
|
||||
watch_for(
|
||||
css: '.modal',
|
||||
value: params[:error],
|
||||
)
|
||||
click(
|
||||
browser: instance,
|
||||
css: '.modal .js-close',
|
||||
)
|
||||
modal_disappear(browser: instance)
|
||||
return
|
||||
end
|
||||
|
||||
11.times {
|
||||
element = instance.find_elements(css: 'body')[0]
|
||||
text = element.text
|
||||
if text =~ /#{Regexp.quote(data[:name])}/
|
||||
assert(true, 'object manager attribute updated')
|
||||
sleep 1
|
||||
return true
|
||||
end
|
||||
sleep 1
|
||||
}
|
||||
screenshot(browser: instance, comment: 'object_manager_attribute_update_failed')
|
||||
raise 'object manager attribute update failed'
|
||||
end
|
||||
|
||||
=begin
|
||||
|
||||
object_manager_attribute_delete(
|
||||
|
|
Loading…
Reference in a new issue