1 require File.dirname(__FILE__) + '/spec_helper'
3 describe "Creating a slideshow from a single album without specifying prefs" do
6 @controller = Controller.new
8 @album.stub!(:slideshow_album_xml)
11 it "should return a string" do
12 @controller.mono_slideshow_xml(@album).should be_an_instance_of String
15 it "should call slideshow_album_xml on the album once" do
16 @album.should_receive(:slideshow_album_xml).once
17 @controller.mono_slideshow_xml(@album)
20 it "should return expected XML doc with defaults" do
21 @album.should_receive(:slideshow_album_xml).once
22 slideshow = @controller.mono_slideshow_xml(@album)
23 slideshow.should be_an_instance_of String
24 pref_hash = {"imageScaleMode"=>"scaleToFit", "showAlbumsButton" => "false"}
25 Hash.from_xml(slideshow).should == {"slideshow"=>{"preferences"=> pref_hash}}
28 it "should convert each album to xml" do
29 @album.should_receive(:slideshow_album_xml).once
30 @controller.mono_slideshow_xml(@album)
35 describe "Creating a slideshow from multiple albums" do
38 @controller = Controller.new
40 @album.stub!(:slideshow_album_xml)
41 @albums = [@album,@album]
45 it "should return an xml doc" do
46 @album.should_receive(:slideshow_album_xml).twice
47 slideshow = @controller.mono_slideshow_xml(@albums)
48 slideshow.should be_an_instance_of String
49 pref_hash = {"imageScaleMode"=>"scaleToFit"}
50 Hash.from_xml(slideshow).should == {"slideshow"=>{"preferences"=> pref_hash}}
53 it "should convert each album to xml" do
54 @album.should_receive(:slideshow_album_xml).exactly(@albums.size).times
55 @controller.mono_slideshow_xml(@albums)
60 describe "Specifying preferences for a slideshow" do
61 it "should return an XML doc with global prefs" do
62 @controller = Controller.new
64 @album.stub!(:slideshow_album_xml)
65 @albums = [@album,@album]
66 slideshow = @controller.mono_slideshow_xml(@albums, :showThumbnailsButton => :false, :imageScaleMode => :scaleToFill)
67 slideshow.should be_an_instance_of String
68 pref_hash = {"imageScaleMode"=>"scaleToFill", "showThumbnailsButton" => "false"}
69 Hash.from_xml(slideshow).should == {"slideshow"=>{"preferences"=> pref_hash}}