Fix some validators for nil values

Using the real entities for the tests also uncovered some bugs where for
example empty strings are converted to nil and the validation wasn't
invalid in this case, but should be.
This commit is contained in:
Benjamin Neff 2018-02-14 01:38:23 +01:00
parent 32a49cc549
commit b274cc3dad
No known key found for this signature in database
GPG key ID: 971464C3F1A90194
4 changed files with 4 additions and 4 deletions

View file

@ -43,7 +43,7 @@ module DiasporaFederation
# Returns diaspora* ID of the new person identity.
# @return [String] diaspora* ID of the new person identity
def new_identity
profile.author
profile.author if profile
end
# @return [String] string representation of this object

View file

@ -9,7 +9,7 @@ module DiasporaFederation
rule :subject, [:not_empty, length: {maximum: 255}]
rule :participants, diaspora_id_list: {minimum: 2}
rule :participants, [:not_empty, diaspora_id_list: {minimum: 2}]
rule :messages, :not_nil
end
end

View file

@ -6,7 +6,7 @@ module DiasporaFederation
include RelayableValidator
rule :status, regular_expression: {regex: /\A(accepted|declined|tentative)\z/}
rule :status, [:not_empty, regular_expression: {regex: /\A(accepted|declined|tentative)\z/}]
end
end
end

View file

@ -27,7 +27,7 @@ module DiasporaFederation
describe "##{prop}" do
it_behaves_like "a property with a value validation/restriction" do
let(:property) { prop }
let(:wrong_values) { ["", "https://asdf$%.com", "example.com"] }
let(:wrong_values) { %w[https://asdf$.com example.com] }
let(:correct_values) { [nil] }
end