Actions
Bug #18235
closedPageletsHelperTest doesn't entirely isolate Pagelet::Manager state
Description
Running these tests in sequence causes failures in the integration test:
- test/controllers/smart_proxies_controller_test.rb
- test/helpers/pagelets_helper_test.rb
- test/integration/smart_proxy_test.rb
1) Error: SmartProxyIntegrationTest#test_0003_edit page: ActionView::Template::Error: Missing partial smart_proxies/_test, application/_test with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :rabl]}. Searched in: * "/home/dcleal/code/foreman/foreman/app/views" * "/home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/foreman-tasks-0.8.6/app/views" * "/home/dcleal/.rvm/gems/ruby-2.3.0@foreman/gems/apipie-rails-0.3.7/app/views" app/helpers/pagelets_helper.rb:43:in `render_pagelet' app/helpers/pagelets_helper.rb:26:in `block in render_tab_content_for' app/helpers/pagelets_helper.rb:23:in `each' app/helpers/pagelets_helper.rb:23:in `render_tab_content_for' app/views/smart_proxies/show.html.erb:116:in `_app_views_smart_proxies_show_html_erb___2994894796435701335_115606720' app/controllers/concerns/application_shared.rb:14:in `set_timezone' app/models/concerns/foreman/thread_session.rb:32:in `clear_thread' lib/middleware/catch_json_parse_errors.rb:8:in `call' lib/middleware/tagged_logging.rb:18:in `call' test/integration/smart_proxy_test.rb:25:in `block in <class:SmartProxyIntegrationTest>'
(plus a few other tests in the same integration test case)
The attempt to save/restore state in PageletsHelperTest is insufficient, as it uses Hash#clone to take a copy of Pagelet::Manager's @pagelets variable. This creates a copy of the top-level hash, but the inner hash references remain the same.
When PageletsHelperTest adds to the "smart_proxies/show" inner hash to register a test pagelet, the pagelet stays registered even after the original state is restored as both the original @pagelets hash and restored @pagelets hash refer to the same inner "smart_proxies/show" hash which was modified. The inner hash isn't saved/restored.
Actions