feat: ✨ Generate short url view
stimulus links controller, tailwindcss setup, links controller post route, tests updated Generate short links view
This commit is contained in:
@@ -3,9 +3,9 @@
|
||||
require 'test_helper'
|
||||
|
||||
class LinksControllerTest < ActionDispatch::IntegrationTest
|
||||
test 'Should get Home page' do
|
||||
test 'Should get index page' do
|
||||
get '/'
|
||||
assert_response :success, 'Not rendered home page'
|
||||
assert_response :success, 'Not rendered index page'
|
||||
end
|
||||
|
||||
test 'Should return 404 for unavailable slug' do
|
||||
@@ -13,6 +13,20 @@ class LinksControllerTest < ActionDispatch::IntegrationTest
|
||||
assert_response :not_found, 'Not rendered not found'
|
||||
end
|
||||
|
||||
test 'Should create a link' do
|
||||
url = 'https://test.com'
|
||||
post links_url, params: { link: { url: url } }
|
||||
|
||||
assert_response :success, 'Link not created'
|
||||
end
|
||||
|
||||
test 'Should return 422 on create an invalid link' do
|
||||
url = 'test'
|
||||
post links_url, params: { link: { url: url } }
|
||||
|
||||
assert_response :unprocessable_entity, 'Invalid link created'
|
||||
end
|
||||
|
||||
test 'Should redirect from slug to url' do
|
||||
link = links(:one)
|
||||
slug = link.slug
|
||||
|
||||
@@ -24,15 +24,4 @@ class LinkTest < ActiveSupport::TestCase
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user