add validator for poll_answers

This commit is contained in:
Benjamin Neff 2016-04-29 01:32:49 +02:00
parent 4953d0c736
commit 8aa353a438
2 changed files with 14 additions and 0 deletions

View file

@ -6,6 +6,7 @@ module DiasporaFederation
rule :guid, :guid rule :guid, :guid
rule :question, [:not_empty, length: {maximum: 255}] rule :question, [:not_empty, length: {maximum: 255}]
rule :poll_answers, length: {minimum: 2}
end end
end end
end end

View file

@ -17,5 +17,18 @@ module DiasporaFederation
let(:correct_values) { ["a" * 255] } let(:correct_values) { ["a" * 255] }
end end
end end
describe "#poll_answers" do
it_behaves_like "a property with a value validation/restriction" do
let(:property) { :poll_answers }
let(:wrong_values) { [nil, [FactoryGirl.attributes_for(:poll_answer_entity)]] }
let(:correct_values) {
[
Array.new(2) { FactoryGirl.build(:poll_answer_entity) },
Array.new(5) { FactoryGirl.build(:poll_answer_entity) }
]
}
end
end
end end
end end