Welcome to mirror list, hosted at ThFree Co, Russian Federation.

destroy_spec.rb « saved_replies « mutations « graphql « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 84efd9ee0b8c7648911aba1961b232443450377c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Mutations::SavedReplies::Destroy do
  let_it_be(:current_user) { create(:user) }
  let_it_be(:saved_reply) { create(:saved_reply, user: current_user) }

  let(:mutation) { described_class.new(object: nil, context: { current_user: current_user }, field: nil) }

  describe '#resolve' do
    subject(:resolve) do
      mutation.resolve(id: saved_reply.to_global_id)
    end

    context 'when service fails to delete a new saved reply' do
      before do
        saved_reply.destroy!
      end

      it 'raises Gitlab::Graphql::Errors::ResourceNotAvailable' do
        expect { subject }.to raise_error(Gitlab::Graphql::Errors::ResourceNotAvailable)
      end
    end

    context 'when service successfully deletes the saved reply' do
      it { expect(subject[:errors]).to be_empty }
    end
  end
end