Add missing specs for request aware entity module

[ci skip]
This commit is contained in:
Grzegorz Bizon 2016-12-21 15:31:49 +01:00
parent 468b47d47c
commit e072a2740e
2 changed files with 25 additions and 6 deletions

View file

@ -2,14 +2,11 @@ module RequestAwareEntity
extend ActiveSupport::Concern extend ActiveSupport::Concern
included do included do
include Gitlab::Routing.url_helpers include Gitlab::Routing
include Gitlab::Allowable
end end
def request def request
@options.fetch(:request) options.fetch(:request)
end
def can?(object, action, subject)
Ability.allowed?(object, action, subject)
end end
end end

View file

@ -0,0 +1,22 @@
require 'spec_helper'
describe RequestAwareEntity do
subject do
Class.new.include(described_class).new
end
it 'includes URL helpers' do
expect(subject).to respond_to(:namespace_project_path)
end
it 'includes method for checking abilities' do
expect(subject).to respond_to(:can?)
end
it 'fetches request from options' do
expect(subject).to receive(:options)
.and_return({request: 'some value'})
expect(subject.request).to eq 'some value'
end
end