Allow a project import URL to be blank to prevent false positives

preventing settings from being saved
This commit is contained in:
Stan Hu 2016-07-17 20:12:32 -07:00
parent 1bf57b7511
commit 565b3a1839
2 changed files with 4 additions and 4 deletions

View File

@ -162,7 +162,7 @@ class Project < ActiveRecord::Base
validates :namespace, presence: true
validates_uniqueness_of :name, scope: :namespace_id
validates_uniqueness_of :path, scope: :namespace_id
validates :import_url, addressable_url: true, if: :import_url
validates :import_url, addressable_url: true, if: "import_url.present?"
validates :star_count, numericality: { greater_than_or_equal_to: 0 }
validate :check_limit, on: :create
validate :avatar_type,
@ -482,7 +482,7 @@ class Project < ActiveRecord::Base
end
def create_or_update_import_data(data: nil, credentials: nil)
return unless valid_import_url?
return unless import_url.present? && valid_import_url?
project_import_data = import_data || build_import_data
if data

View File

@ -142,10 +142,10 @@ describe Project, models: true do
expect(project2).to be_valid
end
it 'does not allow to introduce an empty URI' do
it 'allows an empty URI' do
project2 = build(:project, import_url: '')
expect(project2).not_to be_valid
expect(project2).to be_valid
end
it 'does not produce import data on an empty URI' do