add validators for empty arrays
This commit is contained in:
parent
28ab54abef
commit
c9d0b978d4
5 changed files with 23 additions and 2 deletions
|
|
@ -6,6 +6,8 @@ module DiasporaFederation
|
|||
|
||||
rule :guid, :guid
|
||||
|
||||
rule :messages, :not_nil
|
||||
|
||||
rule :author, %i(not_empty diaspora_id)
|
||||
|
||||
rule :participants, diaspora_id_count: {maximum: 20}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ module DiasporaFederation
|
|||
|
||||
rule :guid, :guid
|
||||
|
||||
rule :photos, :not_nil
|
||||
|
||||
rule :public, :boolean
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,7 +13,15 @@ module DiasporaFederation
|
|||
let(:property) { :guid }
|
||||
end
|
||||
|
||||
describe "participant_ids" do
|
||||
describe "#messages" do
|
||||
it_behaves_like "a property with a value validation/restriction" do
|
||||
let(:property) { :messages }
|
||||
let(:wrong_values) { [nil] }
|
||||
let(:correct_values) { [[], [FactoryGirl.build(:message_entity)]] }
|
||||
end
|
||||
end
|
||||
|
||||
describe "#participant_ids" do
|
||||
# must not contain more than 20 participant handles
|
||||
it_behaves_like "a property with a value validation/restriction" do
|
||||
let(:property) { :participants }
|
||||
|
|
|
|||
|
|
@ -13,6 +13,14 @@ module DiasporaFederation
|
|||
let(:property) { :guid }
|
||||
end
|
||||
|
||||
describe "#photos" do
|
||||
it_behaves_like "a property with a value validation/restriction" do
|
||||
let(:property) { :photos }
|
||||
let(:wrong_values) { [nil] }
|
||||
let(:correct_values) { [[], [FactoryGirl.build(:photo_entity)]] }
|
||||
end
|
||||
end
|
||||
|
||||
it_behaves_like "a boolean validator" do
|
||||
let(:property) { :public }
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
def entity_stub(entity, data={})
|
||||
OpenStruct.new(FactoryGirl.attributes_for(entity).merge(data))
|
||||
OpenStruct.new(FactoryGirl.factory_by_name(entity).build_class.default_values
|
||||
.merge(FactoryGirl.attributes_for(entity)).merge(data))
|
||||
end
|
||||
|
||||
ALPHANUMERIC_RANGE = [*"0".."9", *"A".."Z", *"a".."z"].freeze
|
||||
|
|
|
|||
Loading…
Reference in a new issue