time_accounting_spec.rb 945 B

123456789101112131415161718192021222324252627
  1. require 'rails_helper'
  2. RSpec.describe Ticket::TimeAccounting, type: :model do
  3. subject(:time_accounting) { create(:'ticket/time_accounting') }
  4. describe 'Associations:' do
  5. describe '#ticket_article' do
  6. subject!(:time_accounting) { create(:'ticket/time_accounting', :for_article) }
  7. context 'when destroyed' do
  8. it 'destroys self' do
  9. expect { time_accounting.ticket_article.destroy }
  10. .to change(time_accounting, :persisted?).to(false)
  11. .and change(described_class, :count).by(-1)
  12. end
  13. it 'does not destroy other TimeAccountings for same ticket' do
  14. create(:'ticket/time_accounting', ticket: time_accounting.ticket)
  15. create(:'ticket/time_accounting', :for_article, ticket: time_accounting.ticket)
  16. expect { time_accounting.ticket_article.destroy }
  17. .to change(described_class, :count).by(-1)
  18. end
  19. end
  20. end
  21. end
  22. end