Add missing specs for request aware entity module
[ci skip]
This commit is contained in:
parent
468b47d47c
commit
e072a2740e
2 changed files with 25 additions and 6 deletions
|
@ -2,14 +2,11 @@ module RequestAwareEntity
|
|||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
include Gitlab::Routing.url_helpers
|
||||
include Gitlab::Routing
|
||||
include Gitlab::Allowable
|
||||
end
|
||||
|
||||
def request
|
||||
@options.fetch(:request)
|
||||
end
|
||||
|
||||
def can?(object, action, subject)
|
||||
Ability.allowed?(object, action, subject)
|
||||
options.fetch(:request)
|
||||
end
|
||||
end
|
||||
|
|
22
spec/serializers/request_aware_entity_spec.rb
Normal file
22
spec/serializers/request_aware_entity_spec.rb
Normal 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
|
Loading…
Reference in a new issue