mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
FIX: wasn't able to update category's settings
This commit is contained in:
parent
28a12510dd
commit
282f9948cb
2 changed files with 3 additions and 2 deletions
|
@ -3,7 +3,7 @@ class UploadUrlValidator < ActiveModel::EachValidator
|
|||
if value.present?
|
||||
uri = URI.parse(value) rescue nil
|
||||
|
||||
unless uri && Upload.exists?(url: value)
|
||||
unless uri && Discourse.store.has_been_uploaded?(value)
|
||||
record.errors[attribute] << (options[:message] || I18n.t('errors.messages.invalid'))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,19 +14,20 @@ describe Category do
|
|||
|
||||
context "url validation" do
|
||||
let(:user) { Fabricate(:user) }
|
||||
|
||||
let(:upload) { Fabricate(:upload) }
|
||||
|
||||
it "ensures logo_url is valid" do
|
||||
expect(Fabricate.build(:category, user: user, logo_url: "---%")).not_to be_valid
|
||||
expect(Fabricate.build(:category, user: user, logo_url: "http://example.com/made-up.jpg")).not_to be_valid
|
||||
expect(Fabricate.build(:category, user: user, logo_url: upload.url)).to be_valid
|
||||
expect(Fabricate.build(:category, user: user, logo_url: UrlHelper.schemaless(UrlHelper.absolute(upload.url)))).to be_valid
|
||||
end
|
||||
|
||||
it "ensures background_url is valid" do
|
||||
expect(Fabricate.build(:category, user: user, background_url: ";test")).not_to be_valid
|
||||
expect(Fabricate.build(:category, user: user, background_url: "http://example.com/no.jpg")).not_to be_valid
|
||||
expect(Fabricate.build(:category, user: user, background_url: upload.url)).to be_valid
|
||||
expect(Fabricate.build(:category, user: user, background_url: UrlHelper.schemaless(UrlHelper.absolute(upload.url)))).to be_valid
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue