impress/spec/models/swf_asset_spec.rb

39 lines
1.2 KiB
Ruby
Raw Normal View History

require 'spec_helper'
describe SwfAsset do
it "belongs to a zone" do
zone = Factory.create :zone, :label => 'foo'
asset = Factory.create :swf_asset, :zone_id => 1
asset.zone_id.should == 1
asset.zone.id.should == 1
asset.zone.label.should == 'foo'
end
it "delegates depth to zone" do
zone = Factory.create :zone, :depth => 12
asset = Factory.create :swf_asset, :zone_id => 1
asset.depth.should == 12
end
it "converts neopets URL to impress URL" do
asset = Factory.create :swf_asset, :url => 'http://images.neopets.com/cp/items/swf/000/000/012/12211_9969430b3a.swf'
asset.local_url.should == 'http://impress.openneo.net/assets/swf/outfit/items/000/000/012/12211_9969430b3a.swf'
end
2010-06-07 16:50:49 -07:00
it "should contain id, depth, zone ID, and local_url as JSON" do
zone = Factory.create :zone, :depth => 12
asset = Factory.create :swf_asset,
:id => 123,
:zone_id => 1,
2010-05-20 17:25:36 -07:00
:body_id => 234,
:url => 'http://images.neopets.com/cp/items/swf/000/000/012/12211_9969430b3a.swf'
asset.as_json.should == {
:id => 123,
:depth => 12,
2010-05-20 17:25:36 -07:00
:body_id => 234,
2010-06-07 16:50:49 -07:00
:local_url => 'http://impress.openneo.net/assets/swf/outfit/items/000/000/012/12211_9969430b3a.swf',
:zone_id => 1
}
end
end