require 'test_helper' class HelperTest < ActionView::TestCase test 'link_to_new' do assert_equal "New My User", link_to_new(User) end test 'link_to_new nested' do assert_equal "New My Comment", link_to_new([@user, Comment]) end test 'link_to_index' do assert_equal "My Users", link_to_index(User) end test 'link_to_index when icons and classes enabled' do swap LinkToAction, use_icons: true, use_classes: true do assert_equal "My Users", link_to_index(User) end end test 'link_to_show' do assert_equal "#{@user.name}", link_to_show(@user) end test 'link_to_show using custom method' do assert_equal "#{@user.login}", link_to_show(@user, send: :login) end test 'link_to_show using custom method raw' do user = @user user.login = 'example' assert_equal "#{user.login}", link_to_show(user, raw: :login) end test 'link_to_edit' do assert_equal "Edit My User", link_to_edit(@user) end test 'link_to_destroy' do assert_equal "Delete My User", link_to_destroy(@user) end test 'link_to_destroy with skip_pjax' do swap LinkToAction, destroy_skip_pjax: true do assert_equal "Delete My User", link_to_destroy(@user) end end test 'link_to_destroy without confirm' do swap LinkToAction, destroy_confirm: false do assert_equal "Delete My User", link_to_destroy(@user) end end test 'link_to_destroy with per-link confirm' do swap LinkToAction, destroy_confirm: false do assert_equal "Delete My User", link_to_destroy(@user, confirm: true) end end test 'link_to_destroy with per-link confirm and specific text' do swap LinkToAction, destroy_confirm: false do assert_equal "Delete My User", link_to_destroy(@user, confirm: 'Are you really sure?') end end test 'link_to_destroy without per-link confirm' do assert_equal "Delete My User", link_to_destroy(@user, confirm: false) end test 'link_to_destroy with cancan disallowed' do swap LinkToAction, use_cancan: true do assert_equal nil, link_to_destroy(@user) end end test 'link_to_back first time' do assert_equal "Back", link_to_back end test 'link_to_back with size' do assert_equal "Back", link_to_back(size: :mini) end test 'link_to_back using icons' do swap LinkToAction, use_icons: true do assert_equal " Back", link_to_back end end test 'link_to_back with icon on the right side' do swap LinkToAction, use_icons: true, icons_place_left: false do assert_equal "Back ", link_to_back end end test 'link_to_back swapping icon_position' do swap LinkToAction, use_icons: true do assert_equal "Back ", link_to_back(icon_swap: true) end end test 'link_to_back specifying icon' do swap LinkToAction, use_icons: true do assert_equal " Back", link_to_back(icon: 'chevron-left') end end test 'link_to_back specifying icon size' do swap LinkToAction, use_icons: true do assert_equal " Back", link_to_back(icon_size: :small) end end test 'link_to_back specifying default icon size' do swap LinkToAction, use_icons: true do assert_equal " Back", link_to_back(icon_size: :default) end end test 'link_to_back first time with classes' do swap LinkToAction, use_classes: true do assert_equal "Back", link_to_back end end test 'link_to_back drop classes' do swap LinkToAction, use_classes: true do assert_equal "Back", link_to_back(class: '') end end test 'link_to_back append classes' do swap LinkToAction, use_classes: true, classes_append: true do assert_equal "Back", link_to_back(class: 'btn-warning') end end end