2017-10-02 17:03:30 +02:00
|
|
|
describe AssignTo, type: :model do
|
2018-10-23 11:39:54 +02:00
|
|
|
describe '#procedure_presentation_or_default_and_errors' do
|
2018-10-23 11:03:43 +02:00
|
|
|
let(:procedure) { create(:procedure) }
|
|
|
|
let(:assign_to) { AssignTo.create(procedure: procedure) }
|
|
|
|
|
2018-10-23 11:39:54 +02:00
|
|
|
let(:procedure_presentation_and_errors) { assign_to.procedure_presentation_or_default_and_errors }
|
|
|
|
let(:procedure_presentation_or_default) { procedure_presentation_and_errors.first }
|
|
|
|
let(:errors) { procedure_presentation_and_errors.second }
|
2017-10-02 17:03:30 +02:00
|
|
|
|
2018-10-23 11:03:43 +02:00
|
|
|
context "without a procedure_presentation" do
|
2018-10-23 11:04:21 +02:00
|
|
|
it { expect(procedure_presentation_or_default).not_to be_persisted }
|
2018-10-23 11:39:54 +02:00
|
|
|
it { expect(errors).to be_nil }
|
2017-10-02 17:03:30 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
context "with a procedure_presentation" do
|
|
|
|
let!(:procedure_presentation) { ProcedurePresentation.create(assign_to: assign_to) }
|
|
|
|
|
2018-10-23 11:03:43 +02:00
|
|
|
it { expect(procedure_presentation_or_default).to eq(procedure_presentation) }
|
2018-10-23 11:39:54 +02:00
|
|
|
it { expect(errors).to be_nil }
|
2017-10-02 17:03:30 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|