Fix validation error when creating proposals without user verification

We were getting a validation error when skipping user verification and
creating proposals

This was due to the responsible_name being empty for unverified users

As skipping user verification is a temporary setting used until Census
integration is configured, we can safely skip this validation when this
setting is active
This commit is contained in:
rgarcia
2018-07-20 11:53:01 +02:00
parent 0f287ec78d
commit 4cd5bb90d4
2 changed files with 42 additions and 2 deletions

View File

@@ -36,12 +36,12 @@ class Proposal < ActiveRecord::Base
validates :question, presence: true
validates :summary, presence: true
validates :author, presence: true
validates :responsible_name, presence: true
validates :responsible_name, presence: true, unless: :skip_user_verification?
validates :title, length: { in: 4..Proposal.title_max_length }
validates :description, length: { maximum: Proposal.description_max_length }
validates :question, length: { in: 10..Proposal.question_max_length }
validates :responsible_name, length: { in: 6..Proposal.responsible_name_max_length }
validates :responsible_name, length: { in: 6..Proposal.responsible_name_max_length }, unless: :skip_user_verification?
validates :retired_reason, inclusion: { in: RETIRE_OPTIONS, allow_nil: true }
validates :terms_of_service, acceptance: { allow_nil: false }, on: :create
@@ -214,6 +214,10 @@ class Proposal < ActiveRecord::Base
return orders
end
def skip_user_verification?
Setting["feature.user.skip_verification"].present?
end
protected
def set_responsible_name