Project

General

Profile

Actions

Bug #5963

closed

Role function has_permissions? fails when called

Added by Martin Ducar over 10 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Users, Roles and Permissions
Target version:
Difficulty:
trivial
Triaged:
Fixed in Releases:
Found in Releases:

Description

called like this:
p_obj = Permission.find_by_name(perm)
if role.has_permission?(p_obj)
...

returns this
rake aborted!
undefined method `to_sym' for #<Permission:0x000000061b8540>
/opt/rh/ruby193/root/usr/share/gems/gems/activemodel-3.2.8/lib/active_model/attribute_methods.rb:407:in `method_missing'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/attribute_methods.rb:149:in `method_missing'
/usr/share/foreman/app/models/role.rb:56:in `has_permission?'
/usr/share/foreman/db/seeds.d/901_add_gdc_roles.rb:101:in `block (2 levels) in <top (required)>'
/usr/share/foreman/db/seeds.d/901_add_gdc_roles.rb:98:in `each'
/usr/share/foreman/db/seeds.d/901_add_gdc_roles.rb:98:in `block in <top (required)>'
/opt/rh/ruby193/root/usr/share/gems/gems/audited-3.0.0/lib/audited/auditor.rb:250:in `call'
/opt/rh/ruby193/root/usr/share/gems/gems/audited-3.0.0/lib/audited/auditor.rb:250:in `without_auditing'
/usr/share/foreman/db/seeds.d/901_add_gdc_roles.rb:1:in `<top (required)>'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `load'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `block in load'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `load'
/usr/share/foreman/db/seeds.rb:53:in `block in <top (required)>'
/usr/share/foreman/db/seeds.rb:51:in `each'
/usr/share/foreman/db/seeds.rb:51:in `<top (required)>'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `load'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `block in load'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency'
/opt/rh/ruby193/root/usr/share/gems/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `load'
/opt/rh/ruby193/root/usr/share/gems/gems/railties-3.2.8/lib/rails/engine.rb:520:in `load_seed'
/opt/rh/ruby193/root/usr/share/gems/gems/activerecord-3.2.8/lib/active_record/railties/databases.rake:309:in `block (2 levels) in <top (required)>'
/opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:205:in `call'
/opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:205:in `block in execute'
/opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:200:in `each'
/opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:200:in `execute'
/opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:158:in `block in invoke_with_call_chain'
/opt/rh/ruby193/root/usr/share/ruby/monitor.rb:211:in `mon_synchronize'
/opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:151:in `invoke_with_call_chain'
/opt/rh/ruby193/root/usr/share/ruby/rake/task.rb:144:in `invoke'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:116:in `invoke_task'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:94:in `block (2 levels) in top_level'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:94:in `each'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:94:in `block in top_level'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:133:in `standard_exception_handling'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:88:in `top_level'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:66:in `block in run'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:133:in `standard_exception_handling'
/opt/rh/ruby193/root/usr/share/ruby/rake/application.rb:63:in `run'
/opt/rh/ruby193/root/usr/bin/rake:32:in `<main>'
Tasks: TOP => db:seed

problem is in this code:
https://github.com/theforeman/foreman/blob/1.5-stable/app/models/role.rb#L56

affected versions are at least foreman 1.4, 1.5

Preparing the fix, which is really simple

Actions #1

Updated by Martin Ducar over 10 years ago

What is recommended way to push to 1.4 and 1.5 stable and also develop? pushing to develop and than you will cherry-pick?

Actions #2

Updated by Dominic Cleal over 10 years ago

  • Status changed from New to Ready For Testing
  • Target version set to 1.8.2
  • Translation missing: en.field_release set to 16

Martin Ducar wrote:

What is recommended way to push to 1.4 and 1.5 stable and also develop? pushing to develop and than you will cherry-pick?

Correct, pull requests to develop and it gets cherry picked for release. We won't do any new 1.4 releases at this stage (save for critical security issues perhaps), but I can include it in a 1.5 release.

https://github.com/theforeman/foreman/pull/1482

Actions #3

Updated by Martin Ducar over 10 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100
Actions #4

Updated by Bryan Kearney over 10 years ago

  • Bugzilla link set to https://bugzilla.redhat.com/show_bug.cgi?id=1107669
Actions

Also available in: Atom PDF