diff --git a/app/models/poll/booth.rb b/app/models/poll/booth.rb index d10270064..4c45b9d1a 100644 --- a/app/models/poll/booth.rb +++ b/app/models/poll/booth.rb @@ -12,7 +12,7 @@ class Poll end def self.available - where(polls: { id: Poll.current_or_recounting }).joins(polls: :translations) + where(polls: { id: Poll.current_or_recounting }).joins(:polls) end def assignment_on_poll(poll) diff --git a/spec/models/poll/booth_spec.rb b/spec/models/poll/booth_spec.rb index 8cde2263b..2a90d23c6 100644 --- a/spec/models/poll/booth_spec.rb +++ b/spec/models/poll/booth_spec.rb @@ -24,7 +24,7 @@ describe Poll::Booth do end end - describe "#available" do + describe ".available" do it "returns booths associated to current polls" do booth_for_current_poll = create(:poll_booth) @@ -40,5 +40,10 @@ describe Poll::Booth do expect(described_class.available).not_to include(booth_for_expired_poll) end + it "returns polls with multiple translations only once" do + create(:poll_booth, polls: [create(:poll, :current, name: "English", name_es: "Spanish")]) + + expect(Poll::Booth.available.count).to eq 1 + end end end