Skip to content
Snippets Groups Projects
Commit e094759e authored by Brett Walker's avatar Brett Walker
Browse files

Update some specs that raise an error

parent 95a1b98f
No related branches found
No related tags found
No related merge requests found
......@@ -74,7 +74,8 @@ def object_from_id(global_id, ctx = {})
end
def resolve_type(type, object, ctx = :__undefined__)
tc = type.metadata[:type_class]
# TODO: check if we needed both conditions
tc = type.respond_to?(:metadata) ? type.metadata[:type_class] : type
return if tc.respond_to?(:assignable?) && !tc.assignable?(object)
super
......@@ -132,27 +133,6 @@ def parse_gid(global_id, ctx = {})
gid
end
# This hook is called when an object fails an `authorized?` check.
# You might report to your bug tracker here, so you can correct
# the field resolvers not to return unauthorized objects.
#
# By default, this hook just replaces the unauthorized object with `nil`.
#
# Whatever value is returned from this method will be used instead of the
# unauthorized object (accessible as `unauthorized_error.object`). If an
# error is raised, then `nil` will be used.
#
# If you want to add an error to the `"errors"` key, raise a {GraphQL::ExecutionError}
# in this hook.
#
# @param unauthorized_error [GraphQL::UnauthorizedError]
# @return [Object] The returned object will be put in the GraphQL response
def unauthorized_object(unauthorized_error)
# certain exceptions are captured, so here we're re-raising it.
# TODO: is this needed? This is more of a hcak at the moment
raise unauthorized_error
end
private
def max_query_complexity(ctx)
......
......@@ -43,11 +43,9 @@
context "when we only pass #{arg_name}" do
let(:move_params) { { arg_name => list1.id } }
it 'raises an error' do
expect { subject }.to raise_error(
Gitlab::Graphql::Errors::ArgumentError,
'Both fromListId and toListId must be present'
)
it 'propagates an error' do
expect(subject).to be_instance_of(Gitlab::Graphql::Errors::ArgumentError)
expect(subject.message).to eq 'Both fromListId and toListId must be present'
end
end
end
......@@ -55,11 +53,9 @@
context 'when required arguments are missing' do
let(:move_params) { {} }
it 'raises an error' do
expect { subject }.to raise_error(
Gitlab::Graphql::Errors::ArgumentError,
"At least one of the arguments fromListId, toListId, afterId or beforeId is required"
)
it 'propagates an error' do
expect(subject).to be_instance_of(Gitlab::Graphql::Errors::ArgumentError)
expect(subject.message).to eq 'At least one of the arguments fromListId, toListId, afterId or beforeId is required'
end
end
......
......@@ -24,8 +24,8 @@
end
context 'when the user cannot admin the runner' do
it 'raises an error' do
expect { subject }.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable)
it 'propagates an error' do
expect(subject).to be_instance_of(Gitlab::Graphql::Errors::ResourceNotAvailable)
end
end
......
......@@ -26,8 +26,8 @@
end
context 'when the user cannot admin the runner' do
it 'raises an error' do
expect { subject }.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable)
it 'propagates an error' do
expect(subject).to be_instance_of(Gitlab::Graphql::Errors::ResourceNotAvailable)
end
end
......
......@@ -64,7 +64,7 @@
let!(:protected_tag) { create(:protected_tag, :maintainers_can_create, name: '*', project: project) }
it 'has an access error' do
expect { subject }.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable)
expect(subject).to be_instance_of(Gitlab::Graphql::Errors::ResourceNotAvailable)
end
end
end
......@@ -72,16 +72,16 @@
context "when the user doesn't have access to the project" do
let(:current_user) { reporter }
it 'raises an error' do
expect { subject }.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable)
it 'propagates an error' do
expect(subject).to be_instance_of(Gitlab::Graphql::Errors::ResourceNotAvailable)
end
end
context "when the project doesn't exist" do
let(:project_path) { 'project/that/does/not/exist' }
it 'raises an error' do
expect { subject }.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable)
it 'propagates an error' do
expect(subject).to be_instance_of(Gitlab::Graphql::Errors::ResourceNotAvailable)
end
end
......
......@@ -29,8 +29,8 @@
describe '#resolve' do
let(:result) { subject }
it 'raises an error if the resource is not accessible to the user' do
expect { subject }.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable)
it 'propagates an error if the resource is not accessible to the user' do
expect(subject).to be_instance_of(Gitlab::Graphql::Errors::ResourceNotAvailable)
end
context 'when user does not have enough permissions' do
......@@ -38,8 +38,8 @@
project.add_guest(user)
end
it 'raises an error' do
expect { subject }.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable)
it 'propagates an error' do
expect(subject).to be_instance_of(Gitlab::Graphql::Errors::ResourceNotAvailable)
end
end
......@@ -48,8 +48,8 @@
create(:project_empty_repo).add_maintainer(user)
end
it 'raises an error' do
expect { subject }.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable)
it 'propagates an error' do
expect(subject).to be_instance_of(Gitlab::Graphql::Errors::ResourceNotAvailable)
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment