test: Link unit test finished

100% coverage
This commit is contained in:
Juan Rodriguez
2021-06-13 12:28:37 -05:00
parent 38d0aff7f8
commit d27fb94095
3 changed files with 28 additions and 6 deletions
+23 -1
View File
@@ -10,7 +10,29 @@ class LinkTest < ActiveSupport::TestCase
test 'should not save a link with a invalid url' do
link = Link.new
link.url = 'google.com'
link.url = 'test.com'
assert_not link.save, 'Saved the link with invalid url format'
end
test 'should create a link with a valid url' do
link = Link.new
link.url = 'https://test.com'
assert link.save, 'Link with valid url not saved'
end
test 'should generate a slug on save a new link' do
link = links(:one)
assert link.slug, 'Slug not generated on save a new link'
end
test 'should get shorten url of existing url' do
link = links(:one)
url = link.url
assert Link.shorten(url), 'Shorten url not found'
end
test 'should get shorten url and create a link' do
url = 'https://test.com'
assert Link.shorten(url), 'Link not created'
end
end