diff --git a/spec/presenters/case_workers/defendant_presenter_spec.rb b/spec/presenters/case_workers/defendant_presenter_spec.rb new file mode 100644 index 0000000000..60bf1d343d --- /dev/null +++ b/spec/presenters/case_workers/defendant_presenter_spec.rb @@ -0,0 +1,20 @@ +RSpec.describe CaseWorkers::DefendantPresenter do + subject(:defendant_presenter) { described_class.new(defendant, view) } + + describe '#representation_orders' do + subject(:representation_orders) { defendant_presenter.representation_orders } + + context 'when there are representation orders' do + let(:defendant) { build(:defendant, representation_orders: build_list(:representation_order, 3)) } + + it { expect(representation_orders.length).to eq 3 } + it { is_expected.to all(be_a(CaseWorkers::RepresentationOrder)) } + end + + context 'when there are no representation orders' do + let(:defendant) { build(:defendant, representation_orders: []) } + + it { is_expected.to be_empty } + end + end +end diff --git a/spec/presenters/external_users/defendant_presenter_spec.rb b/spec/presenters/external_users/defendant_presenter_spec.rb new file mode 100644 index 0000000000..67f43669d6 --- /dev/null +++ b/spec/presenters/external_users/defendant_presenter_spec.rb @@ -0,0 +1,20 @@ +RSpec.describe ExternalUsers::DefendantPresenter do + subject(:defendant_presenter) { described_class.new(defendant, view) } + + describe '#representation_orders' do + subject(:representation_orders) { defendant_presenter.representation_orders } + + context 'when there are representation orders' do + let(:defendant) { build(:defendant, representation_orders: build_list(:representation_order, 3)) } + + it { expect(representation_orders.length).to eq 3 } + it { is_expected.to all(be_a(ExternalUsers::RepresentationOrder)) } + end + + context 'when there are no representation orders' do + let(:defendant) { build(:defendant, representation_orders: []) } + + it { is_expected.to be_empty } + end + end +end