-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only allow HTTP(S) URLs in example app
- Loading branch information
Showing
2 changed files
with
28 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe Product do | ||
describe "validations" do | ||
it { should allow_value("http://example.com/foo/bar").for(:image_url) } | ||
it { should allow_value("https://example.com/foo/bar").for(:image_url) } | ||
it { should_not allow_value("ftp://example.com/foo/bar").for(:image_url) } | ||
end | ||
|
||
describe "#image_url" do | ||
it "is trimmed on save" do | ||
product = FactoryBot.create( | ||
:product, | ||
image_url: "\n https://example.com/foo/bar \n", | ||
) | ||
expect(product.image_url).to eq("https://example.com/foo/bar") | ||
end | ||
end | ||
end |