require File.join( File.dirname(__FILE__), "test_helper") # ralbum require 'ralbum/album_tree/album' require 'ralbum/album_tree/image_pool' require 'ralbum/album_tree/image_file' class TestAlbum < Test::Unit::TestCase def setup @root = Album.new( nil, "key_root", "title_root", "descr_root") @subalbum = Album.new( @root, "key_subalbum", "title_subalbum", "descr_subalbum") @subsubalbum = Album.new( @subalbum, "key_subsubalbum", "title_subsubalbum", "descr_subsubalbum") end def test_breadcrumbs breadcrumbs = @subalbum.breadcrumbs # breadcrumb " (index.html) > (/title_b/index.html)" assert_equal 2, breadcrumbs.length assert_equal "title_root/index.html", breadcrumbs[0][:path] assert_equal "title_root", breadcrumbs[0][:title] assert_equal "title_root/title_subalbum/index.html", breadcrumbs[1][:path] assert_equal "title_subalbum", breadcrumbs[1][:title] @root.prefix_path = "skin" breadcrumbs = @subalbum.breadcrumbs # breadcrumb " (skin/index.html) > (skin/title_b/index.html)" assert_equal 2, breadcrumbs.length # assert_equal "skin/index.html", breadcrumbs[0][:path] # assert_equal "skin/title_subalbum/index.html", breadcrumbs[1][:path] assert_equal "title_subalbum", breadcrumbs[1][:title] end def test_relroot assert_equal 2, @subalbum.depth assert_equal "../../", @subalbum.relroot assert_equal "../../", @subalbum.relroot_with_prefix @subalbum.root.prefix_path = "skin/" assert_equal "../../", @subalbum.relroot assert_equal "skin/../../", @subalbum.relroot_with_prefix end def test_page_url assert_equal 3, @subsubalbum.depth assert_equal "title_subsubalbum/index.html", @subsubalbum.page_url assert_equal "title_root/title_subalbum/title_subsubalbum/index.html", @subsubalbum.page_url_from_root @subalbum.root.prefix_path = "skin/" assert_equal "title_subsubalbum/index.html", @subsubalbum.page_url # assert_equal "title_root/skin/title_subalbum/title_subsubalbum/index.html", @subsubalbum.page_url_from_root end end