Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #22065 - Fix missing permissions table in tests #5146

Merged
merged 1 commit into from
Jan 3, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion app/registries/foreman/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ def add_permissions_to_default_roles(args)
# Add plugin permissions to Manager and Viewer roles. Use this method if there are no special cases that need to be taken care of.
# Otherwise add_permissions_to_default_roles or add_resource_permissions_to_default_roles might be the methods you are looking for.
def add_all_permissions_to_default_roles
return if Foreman.in_rake?('db:migrate')
return if Foreman.in_rake?('db:migrate') || !permission_table_exists?
Plugin::RbacSupport.new.add_all_permissions_to_default_roles(Permission.where(:name => @rbac_registry.permission_names))
end

Expand Down Expand Up @@ -431,6 +431,12 @@ def rabl_template_extensions(virtual_path)

private

def permission_table_exists?
exists = Permission.connection.table_exists?(Permission.table_name)
Rails.logger.debug("Not adding permissions from plugin #{@id} to default roles - permissions table not found") if !exists && !Rails.env.test?
exists
end

def extend_template_helpers_by_module(mod)
mod = mod.constantize

Expand Down