Initial work in Poll::Question
This commit is contained in:
27
spec/models/poll/question_spec.rb
Normal file
27
spec/models/poll/question_spec.rb
Normal file
@@ -0,0 +1,27 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Poll::Question, type: :model do
|
||||
|
||||
describe "#valid_answers" do
|
||||
it "gets a comma-separated string, but returns an array" do
|
||||
q = create(:poll_question, valid_answers: "Yes, No")
|
||||
expect(q.valid_answers).to eq(["Yes", "No"])
|
||||
end
|
||||
end
|
||||
|
||||
describe "#copy_attributes_from_proposal" do
|
||||
it "copies the attributes from the proposal" do
|
||||
create_list(:geozone, 3)
|
||||
p = create(:proposal)
|
||||
q = create(:poll_question)
|
||||
q.copy_attributes_from_proposal(p)
|
||||
expect(q.author).to eq(p.author)
|
||||
expect(q.author_visible_name).to eq(p.author.name)
|
||||
expect(q.proposal_id).to eq(p.id)
|
||||
expect(q.title).to eq(p.title)
|
||||
expect(q.question).to eq(p.question)
|
||||
expect(q.geozones).to eq(Geozone.all)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user