diff options
Diffstat (limited to 'spec/graphql/mutations/todos/create_spec.rb')
-rw-r--r-- | spec/graphql/mutations/todos/create_spec.rb | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/spec/graphql/mutations/todos/create_spec.rb b/spec/graphql/mutations/todos/create_spec.rb new file mode 100644 index 00000000000..bbb033e2f33 --- /dev/null +++ b/spec/graphql/mutations/todos/create_spec.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Mutations::Todos::Create do + include GraphqlHelpers + include DesignManagementTestHelpers + + describe '#resolve' do + context 'when target does not support todos' do + it 'raises error' do + current_user = create(:user) + mutation = described_class.new(object: nil, context: { current_user: current_user }, field: nil) + + target = create(:milestone) + + expect { mutation.resolve(target_id: global_id_of(target)) } + .to raise_error(GraphQL::CoercionError) + end + end + + context 'with issue as target' do + it_behaves_like 'create todo mutation' do + let_it_be(:target) { create(:issue) } + end + end + + context 'with merge request as target' do + it_behaves_like 'create todo mutation' do + let_it_be(:target) { create(:merge_request) } + end + end + + context 'with design as target' do + before do + enable_design_management + end + + it_behaves_like 'create todo mutation' do + let_it_be(:target) { create(:design) } + end + end + end +end |