Sha256: 7dced2858e2f39b1d23aabc1b3640ef3573fbed184387752ad4d09d0fa4c2581
Contents?: true
Size: 992 Bytes
Versions: 4
Compression:
Stored size: 992 Bytes
Contents
require 'test_helper' module MongoidShortener class ShortenedUrlsControllerTest < ActionController::TestCase test "get non-existence unique key" do get :translate, {unique_key: "~123"} assert_response :redirect assert_redirected_to "http://localhost:3000" end test "get valid unique key" do short_url = MongoidShortener.generate("http://google.com") unique_key = short_url[short_url.index("~")..-1] get :translate, {unique_key: unique_key} assert_response :redirect assert_redirected_to "http://google.com" end test "changing redirect root_url" do MongoidShortener.root_url = "http://google.com" get :translate, {unique_key: "~123"} assert_response :redirect assert_redirected_to "http://google.com" end test "redirect to non-valid key should raise exception" do assert_raise(ActionController::RoutingError) { get :translate, {unique_key: "123"} } end end end
Version data entries
4 entries across 4 versions & 1 rubygems