mirror of
https://github.com/varvet/pundit.git
synced 2022-11-09 12:30:11 -05:00
Use activesupport deprecation module for more detailed deprecation warning
This commit is contained in:
parent
4d9b5849f4
commit
0455f59ff6
2 changed files with 13 additions and 6 deletions
|
@ -55,7 +55,9 @@ module Pundit
|
|||
class NotDefinedError < Error; end
|
||||
|
||||
def self.included(base)
|
||||
warn "[DEPRECATION] 'include Pundit' is deprecated. Please use 'include Pundit::Authorization' instead."
|
||||
ActiveSupport::Deprecation.warn <<~WARNING.strip_heredoc
|
||||
'include Pundit' is deprecated. Please use 'include Pundit::Authorization' instead.
|
||||
WARNING
|
||||
base.include Authorization
|
||||
end
|
||||
|
||||
|
|
|
@ -398,18 +398,23 @@ RSpec.describe Pundit do
|
|||
describe ".included" do
|
||||
it "includes Authorization module" do
|
||||
klass = Class.new
|
||||
klass.include Pundit
|
||||
|
||||
ActiveSupport::Deprecation.silence do
|
||||
klass.include Pundit
|
||||
end
|
||||
|
||||
expect(klass).to include Pundit::Authorization
|
||||
end
|
||||
|
||||
it "warns about deprecation" do
|
||||
allow(Pundit).to receive(:warn)
|
||||
|
||||
klass = Class.new
|
||||
klass.include Pundit
|
||||
allow(ActiveSupport::Deprecation).to receive(:warn)
|
||||
|
||||
expect(Pundit).to have_received(:warn).with start_with("[DEPRECATION]")
|
||||
ActiveSupport::Deprecation.silence do
|
||||
klass.include Pundit
|
||||
end
|
||||
|
||||
expect(ActiveSupport::Deprecation).to have_received(:warn).with start_with("'include Pundit' is deprecated")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue