PageRenderTime 21ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/amexsbs/railsapp/vendor/plugins/tab_tab/test/view_test.rb

https://bitbucket.org/AcireStudios/social-app-demo
Ruby | 72 lines | 55 code | 17 blank | 0 comment | 0 complexity | fffb5163dd24d369cf33234eb74d3092 MD5 | raw file
Possible License(s): GPL-2.0, MPL-2.0-no-copyleft-exception, MIT
  1. require File.join(File.dirname(__FILE__), 'test_helper')
  2. class ViewTest < Test::Unit::TestCase
  3. def test_tab_scope_helper
  4. view = YeOldeView.new
  5. view.controller = controller = StuffController.new
  6. simple = view.content_tag(:li, :id => 'admin_users_tab') do
  7. view.link_to('Users', '/admin/users/')
  8. end
  9. complex = view.content_tag(:li, :id => 'a_b_c_d_tab') do
  10. view.link_to('D', '/a/b/c/d/')
  11. end
  12. view.tabs_for :admin do |admin|
  13. assert_equal simple, admin.tab('/admin/users/', :users)
  14. end
  15. view.tabs_for :a => :b do |ab|
  16. assert_equal complex, ab.tab('/a/b/c/d/', ['c', 'd'])
  17. end
  18. end
  19. def test_of_builtin_tab_helper
  20. v = YeOldeView.new
  21. v.controller = controller = StuffController.new
  22. minimal = v.content_tag(:li, :id => 'top_tab') do
  23. v.link_to('Top', '/')
  24. end
  25. nested = v.content_tag(:li, :id => 'top_under_lower_tab') do
  26. v.link_to('Lower', '/')
  27. end
  28. with_name = v.content_tag(:li, :id => 'top_tab') do
  29. v.link_to('Back Home', '/')
  30. end
  31. with_id = v.content_tag(:li, :id => 'top_tab', :id => 't7') do
  32. v.link_to('Top', '/')
  33. end
  34. with_class = v.content_tag(:li, :id => 'top_tab', :class => 'nav') do
  35. v.link_to('Top', '/')
  36. end
  37. active = v.content_tag(:li, :id => 'stuff_tab', :class => 'active') do
  38. v.link_to('Stuff', '/')
  39. end
  40. active_nav = v.content_tag(:li, :id => 'stuff_tab',
  41. :class => 'active nav') do
  42. v.link_to('Stuff', '/')
  43. end
  44. assert_equal minimal, v.tab('/', :top)
  45. assert_equal nested, v.tab('/', :top => { :under => :lower })
  46. assert_equal with_name, v.tab('/', :top, :name => 'Back Home')
  47. assert_equal with_id, v.tab('/', :top, :html => { :id => 't7' })
  48. assert_equal with_class, v.tab('/', :top, :html => { :class => 'nav' })
  49. assert_equal active, v.tab('/', :stuff)
  50. assert_equal active_nav, v.tab('/', :stuff, :html => { :class => 'nav' })
  51. assert_raises ArgumentError do
  52. v.tab '/', :top, :invalid_key => 'Kaboom'
  53. end
  54. end
  55. end