diff options
author | Nick Thomas <nick@gitlab.com> | 2019-04-04 11:38:16 +0000 |
---|---|---|
committer | Nick Thomas <nick@gitlab.com> | 2019-04-04 11:38:16 +0000 |
commit | 7af1ba122fb425214d6b7c9e51ea621a515d6ac0 (patch) | |
tree | 9f37fe6e0e7b68ab3bf36df2606936c51b701c0e /spec/lib | |
parent | 60a0ef21d385e1943f9e6a68adc9d7e04e8d69c8 (diff) | |
parent | 8cf0d8926a325c8be7707c356ef20f42139d7bf3 (diff) | |
download | gitlab-ce-7af1ba122fb425214d6b7c9e51ea621a515d6ac0.tar.gz |
Merge branch '54417-graphql-type-authorization' into 'master'
GraphQL Type authorization
Closes #54417
See merge request gitlab-org/gitlab-ce!25724
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/graphql/authorize/authorize_field_service_spec.rb (renamed from spec/lib/gitlab/graphql/authorize/instrumentation_spec.rb) | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/spec/lib/gitlab/graphql/authorize/instrumentation_spec.rb b/spec/lib/gitlab/graphql/authorize/authorize_field_service_spec.rb index cf3a8bcc8b4..ce320a2bdb0 100644 --- a/spec/lib/gitlab/graphql/authorize/instrumentation_spec.rb +++ b/spec/lib/gitlab/graphql/authorize/authorize_field_service_spec.rb @@ -2,13 +2,17 @@ require 'spec_helper' -describe Gitlab::Graphql::Authorize::Instrumentation do +# Also see spec/graphql/features/authorization_spec.rb for +# integration tests of AuthorizeFieldService +describe Gitlab::Graphql::Authorize::AuthorizeFieldService do describe '#build_checker' do let(:current_user) { double(:current_user) } let(:abilities) { [double(:first_ability), double(:last_ability)] } let(:checker) do - described_class.new.__send__(:build_checker, current_user, abilities) + service = described_class.new(double(resolve_proc: proc {})) + allow(service).to receive(:authorizations).and_return(abilities) + service.__send__(:build_checker, current_user) end it 'returns a checker which checks for a single object' do @@ -56,12 +60,14 @@ describe Gitlab::Graphql::Authorize::Instrumentation do .to contain_exactly(allowed) end end + end - def spy_ability_check_for(ability, object, passed: true) - expect(Ability) - .to receive(:allowed?) - .with(current_user, ability, object) - .and_return(passed) - end + private + + def spy_ability_check_for(ability, object, passed: true) + expect(Ability) + .to receive(:allowed?) + .with(current_user, ability, object) + .and_return(passed) end end |