Factlink / pavlov

Provides a Command/Query/Interactor framework.
MIT License
22 stars 4 forks source link

Use authorized? also if it is private #9

Closed janpaul123 closed 11 years ago

coveralls commented 11 years ago

Coverage Status

Coverage decreased (-0%) when pulling ec4a3f8d42a6e3b48490d2018ce985e555ad0c7c on feature/fix-authorized into 72a5ebb1577a377e7fff05cee028129d452cdb8c on develop.

markijbema commented 11 years ago

Please also add a test which reproduces the bug this pull-request fixes.

jjoos commented 11 years ago

Just added a testcase for this, but i can't seem to reproduce this issue.

 let 'test_class_with_private_authorized?' do
    Class.new do
      include Pavlov::Interactor

      private
      def authorized?
        true
      end
    end
  end

  it "raises an error when .authorized? does not exist" do
    expect {
      test_class_with_private_authorized?.new
    }.to_not raise_error(NotImplementedError)
  end
markijbema commented 11 years ago

The problem was that when you return false, it will let you through, and not say it isn't authorized. So make the test to return false, and expect an AuthorizationError (or whatever it's called)

coveralls commented 11 years ago

Coverage Status

Coverage remained the same when pulling 31a5ab742cd9bb431352c495350324670c9e309e on feature/fix-authorized into da639346d711af324f9212fe2b6fcb8072146d53 on develop.