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:
parent
32a49cc549
commit
b274cc3dad
4 changed files with 4 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue