Skip to content

Commit

Permalink
Ajout d'un test unitaire dans 'sygne_spec'
Browse files Browse the repository at this point in the history
  • Loading branch information
tnicolas1 committed Nov 14, 2024
1 parent 1262656 commit a671b39
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions spec/models/student/mappers/sygne_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,30 @@
end
end

context "when processing closed schoolings" do
# rubocop:disable RSpec/MultipleMemoizedHelpers
context "when there is a schooling for that classe that was closed" do
let(:closed_payload) { build_list(:sygne_student, 3, :closed, classe: "1MELEC") }

let(:mapper) { described_class.new(closed_payload, uai) }
let(:student) { Student.find_by(ine: closed_payload.last["ine"]) }

it "sets the end_date for closed schoolings" do
mapper.parse!
let(:ine) { closed_payload.last["ine"] }
let(:student) { Student.find_by(ine: ine) }

before { mapper.parse! }

it "sets the end_date for closed schoolings" do
expect(student.schoolings.last.end_date.to_s).to eq closed_payload.last["dateFinSco"]
end

it "reopens the schooling" do
opened_payload = build_list(:sygne_student, 3, classe: "1MELEC")
opened_payload.last.update(ine: ine)

opened_mapper = described_class.new(opened_payload, uai)
opened_mapper.parse!

expect(student.schoolings.last.open?).to be true
end
end
# rubocop:enable RSpec/MultipleMemoizedHelpers
end
end

0 comments on commit a671b39

Please sign in to comment.