Skip to content

Commit

Permalink
[rails6][rbac/filterer_spec.rb] Use .default_scoped
Browse files Browse the repository at this point in the history
Adds a fix for the following deprecation error:

  DEPRECATION WARNING: Class level methods will no longer inherit
  scoping from `create!` in Rails 6.1. To continue using the scoped
  relation, pass it into the block directly. To instead access the full
  set of models, as Rails 6.1 will, use `Vm.default_scoped`.

  (called from validate_each at /Users/nicklamuro/code/redhat/manageiq/spec/lib/rbac/filterer_spec.rb:2086)

This was added to fix "leaking scopes" in Rails 6.1, but was added as a
deprecation warning first:

- rails/rails#35280
- rails/rails#37727

This specifically was just a fake `Vm` model specifically used for the Rbac
specs, so this isn't something that needs to be fixed in the app codebase
proper.
  • Loading branch information
NickLaMuro committed Dec 8, 2020
1 parent 22309d9 commit ae4b9ad
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions spec/lib/rbac/filterer_spec.rb
Expand Up @@ -2082,8 +2082,8 @@ def get_rbac_results_for_and_expect_objects(klass, expected_objects)
vm.tag_with(@tags.values.join(" "), :ns => "*") if i > 0
end

Vm.scope :group_scope, ->(group_num) { Vm.where("name LIKE ?", "Test Group #{group_num}%") }
Vm.scope :is_on, -> { Vm.where(:power_state => "on") }
Vm.scope :group_scope, ->(group_num) { Vm.default_scoped.where("name LIKE ?", "Test Group #{group_num}%") }
Vm.scope :is_on, -> { Vm.default_scoped.where(:power_state => "on") }
end

context ".search" do
Expand Down

0 comments on commit ae4b9ad

Please sign in to comment.