add validator for poll_answers
This commit is contained in:
parent
4953d0c736
commit
8aa353a438
2 changed files with 14 additions and 0 deletions
|
|
@ -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
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue