Files
grecia/spec/models/poll/question_spec.rb
Javi Martín af7c37634d Remove poll votation types
Unfortunately this feature wasn't properly reviewed and tested, and it
had many bugs, some of them critical and hard to fix, like validations
being skipped in concurrent requests.

So we're removing it before releasing version 1.1. We might add it back
in the future if we manage to solve the critical issues.

This commit reverts commit 836f9ba7.
2019-10-30 18:48:55 +01:00

49 lines
1.5 KiB
Ruby

require "rails_helper"
RSpec.describe Poll::Question, type: :model do
let(:poll_question) { build(:poll_question) }
describe "Concerns" do
it_behaves_like "acts as paranoid", :poll_question
it_behaves_like "globalizable", :poll_question
end
describe "#poll_question_id" do
it "is invalid if a poll is not selected" do
poll_question.poll_id = nil
expect(poll_question).not_to be_valid
end
it "is valid if a poll is selected" do
poll_question.poll_id = 1
expect(poll_question).to be_valid
end
end
describe "#copy_attributes_from_proposal" do
before { create_list(:geozone, 3) }
let(:proposal) { create(:proposal) }
it "copies the attributes from the proposal" do
poll_question.copy_attributes_from_proposal(proposal)
expect(poll_question.author).to eq(proposal.author)
expect(poll_question.author_visible_name).to eq(proposal.author.name)
expect(poll_question.proposal_id).to eq(proposal.id)
expect(poll_question.title).to eq(proposal.title)
end
context "locale with non-underscored name" do
before { I18n.locale = :"pt-BR" }
it "correctly creates a translation" do
poll_question.copy_attributes_from_proposal(proposal)
translation = poll_question.translations.first
expect(poll_question.title).to eq(proposal.title)
expect(translation.title).to eq(proposal.title)
expect(translation.locale).to eq(:"pt-BR")
end
end
end
end