Skip to content

Commit

Permalink
ajout spec
Browse files Browse the repository at this point in the history
  • Loading branch information
adipasquale committed Jan 27, 2025
1 parent c98bf2c commit 12fd437
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions spec/models/concerns/participation/creatable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,29 @@
expect(rdv.reload.participations).to eq([participation_relative])
end
end

describe "l’usager ajouté n’appartient pas encore à l’organisation" do
let!(:organisation) { create(:organisation, rdvs: [rdv]) }
let(:participation) { build(:participation, rdv:, user:) }

it "ajoute l’orga à l’usager" do
expect(user.organisations).to be_empty
participation.create_and_notify!(user)
expect(user.organisations).to contain_exactly(organisation)
end
end

describe "l’usager ajouté appartient déjà à l’organisation" do
let!(:organisation) { create(:organisation, rdvs: [rdv]) }
let!(:user) { create(:user, organisations: [organisation]) }
let(:participation) { build(:participation, rdv:, user:) }

it "ne ré-ajoute pas l’orga à l’usager" do
expect(user.organisations).to contain_exactly(organisation)
participation.create_and_notify!(user)
expect(user.organisations).to contain_exactly(organisation)
expect(user.organisations.count).to eq(1)
end
end
end
end

0 comments on commit 12fd437

Please sign in to comment.