Fixes #22430 - Plugin permissions are cleared on tests #5218
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Some tests are removing all plugins (plugin_test, rabl_test,
belongs_to_proxy_test) from the registry. This has, among others,
one important consequence: the plugin permissions are removed.
Take an example. Foreman Ansible overrides the Host#form with a
list of 'Ansible Roles' to choose.
When the view for this Host#form is rendered (e.g: a
HostController or HostJSTest), the list of 'Ansible Roles' has
also to be rendered.
Since a previous test removed the plugin from the
Foreman::Plugin.all
registry, but the plugin is still installedas a Rails Engine, the overrides by deface still apply.
Some tests that render the Host form fail to run as rendering is
impossible without the 'ansible_roles' permission. These
permissions are only loaded in tests if the plugin is registered
in Foreman::Plugin*
I realize this is a tough one to test, you have a reproducer here (make sure plugin_test runs before host_js_test) theforeman/foreman_ansible#114 (comment)