debian-mirror-gitlab/spec/services/users/saved_replies/destroy_service_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
901 B
Ruby
Raw Normal View History

2022-06-21 17:19:12 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Users::SavedReplies::DestroyService do
describe '#execute' do
let!(:saved_reply) { create(:saved_reply) }
subject { described_class.new(saved_reply: saved_reply).execute }
context 'when destroy fails' do
before do
allow(saved_reply).to receive(:destroy).and_return(false)
end
it 'does not remove Saved Reply from database' do
expect { subject }.not_to change(::Users::SavedReply, :count)
end
it { is_expected.not_to be_success }
end
context 'when destroy succeeds' do
it { is_expected.to be_success }
it 'removes Saved Reply from database' do
expect { subject }.to change(::Users::SavedReply, :count).by(-1)
end
it 'returns saved reply' do
expect(subject[:saved_reply]).to eq(saved_reply)
end
end
end
end