Sha256: b525fb48fcc71f50c8a94463d3a4278176afab3de69840d9cb7fd1d60975793e
Contents?: true
Size: 1.76 KB
Versions: 5
Compression:
Stored size: 1.76 KB
Contents
require 'rails_helper' module Mks module Rate RSpec.describe ServiceBundleService do before(:each) do @service = ServiceBundleService.new end describe '#add_services' do it 'adds new services' do bundle = create(:service_bundle) s1 = create(:chargeable_service) s2 = create(:chargeable_service) s3 = create(:chargeable_service) expect(bundle.chargeable_services.count).to eq 0 @service.add_services(bundle, [s1.id, s2.id, s3.id]) bundle.reload expect(bundle.chargeable_services.count).to eq 3 end it 'removes non selected services' do bundle = create(:service_bundle) s1 = create(:chargeable_service) s2 = create(:chargeable_service) s3 = create(:chargeable_service) bundle.chargeable_services << [s1, s2, s3] expect(bundle.chargeable_services.count).to eq 3 @service.add_services(bundle, [s3.id]) bundle.reload expect(bundle.chargeable_services.count).to eq 1 expect(bundle.chargeable_services[0].id).to eq s3.id end it 'adds newly selected and removes non selected' do bundle = create(:service_bundle) s1 = create(:chargeable_service) s2 = create(:chargeable_service) s3 = create(:chargeable_service) s4 = create(:chargeable_service) bundle.chargeable_services << [s1, s2] expect(bundle.chargeable_services.count).to eq 2 @service.add_services(bundle, [s2.id, s3.id, s4.id]) bundle.reload expect(bundle.chargeable_services.count).to eq 3 expect(bundle.chargeable_services).not_to include s1 end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems