Fix accidental translations join

We added the code thinking we were ordering by the name of the poll, but
here we're actually ordering by the name of the booth.
This commit is contained in:
Javi Martín
2019-05-31 13:48:27 +02:00
parent dadbf873ba
commit 481184e7f3
2 changed files with 7 additions and 2 deletions

View File

@@ -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)

View File

@@ -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