2014-01-10 21:02:52 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
|
|
describe IcecastMount do
|
|
|
|
|
|
2014-01-19 02:20:44 +00:00
|
|
|
let(:icecast_mount) { FactoryGirl.create(:icecast_mount) }
|
2014-01-17 04:51:19 +00:00
|
|
|
let(:output) { StringIO.new }
|
|
|
|
|
let(:builder) { ::Builder::XmlMarkup.new(:target => output, :indent => 1) }
|
2014-01-10 21:02:52 +00:00
|
|
|
|
2014-01-17 04:51:19 +00:00
|
|
|
it "save error" do
|
2014-01-19 02:20:44 +00:00
|
|
|
mount = IcecastMount.new
|
2014-01-17 04:51:19 +00:00
|
|
|
mount.save.should be_false
|
2014-01-19 02:20:44 +00:00
|
|
|
mount.errors[:name].should == ["can't be blank", "must start with /"]
|
2014-01-17 04:51:19 +00:00
|
|
|
mount.errors[:stream_name].should == ["can't be blank"]
|
|
|
|
|
mount.errors[:stream_description].should == ["can't be blank"]
|
|
|
|
|
mount.errors[:stream_url].should == ["can't be blank"]
|
|
|
|
|
mount.errors[:genre].should == ["can't be blank"]
|
2014-01-10 21:02:52 +00:00
|
|
|
end
|
|
|
|
|
|
2014-01-14 21:22:05 +00:00
|
|
|
|
2014-01-10 21:02:52 +00:00
|
|
|
it "save" do
|
2014-01-19 02:20:44 +00:00
|
|
|
mount = IcecastMount.new
|
|
|
|
|
mount.name = "/" + Faker::Lorem.characters(10)
|
2014-01-17 04:51:19 +00:00
|
|
|
mount.stream_name = Faker::Lorem.characters(10)
|
|
|
|
|
mount.stream_description = Faker::Lorem.characters(10)
|
|
|
|
|
mount.stream_url = Faker::Lorem.characters(10)
|
|
|
|
|
mount.genre = Faker::Lorem.characters(10)
|
2014-01-19 02:20:44 +00:00
|
|
|
mount.source_username = Faker::Lorem.characters(10)
|
|
|
|
|
mount.source_pass = Faker::Lorem.characters(10)
|
2014-01-17 04:51:19 +00:00
|
|
|
mount.intro = Faker::Lorem.characters(10)
|
|
|
|
|
mount.fallback_mount = Faker::Lorem.characters(10)
|
|
|
|
|
mount.on_connect = Faker::Lorem.characters(10)
|
|
|
|
|
mount.on_disconnect = Faker::Lorem.characters(10)
|
|
|
|
|
mount.fallback_override = true
|
|
|
|
|
mount.fallback_when_full = true
|
|
|
|
|
mount.max_listeners = 1000
|
|
|
|
|
mount.max_listener_duration = 3600
|
|
|
|
|
mount.authentication = FactoryGirl.create(:icecast_user_authentication)
|
2014-01-14 21:22:05 +00:00
|
|
|
|
2014-01-17 04:51:19 +00:00
|
|
|
mount.save!
|
2014-01-14 21:22:05 +00:00
|
|
|
|
2014-01-17 04:51:19 +00:00
|
|
|
mount.dumpXml(builder)
|
2014-01-14 21:22:05 +00:00
|
|
|
|
2014-01-17 04:51:19 +00:00
|
|
|
output.rewind
|
2014-01-14 21:22:05 +00:00
|
|
|
|
2014-01-17 04:51:19 +00:00
|
|
|
xml = Nokogiri::XML(output)
|
2014-01-19 02:20:44 +00:00
|
|
|
xml.css('mount mount-name').text.should == mount.name
|
|
|
|
|
xml.css('mount username').text.should == mount.source_username
|
|
|
|
|
xml.css('mount password').text.should == mount.source_pass
|
2014-01-17 04:51:19 +00:00
|
|
|
xml.css('mount max-listeners').text.should == mount.max_listeners.to_s
|
|
|
|
|
xml.css('mount max-listener-duration').text.should == mount.max_listener_duration.to_s
|
|
|
|
|
xml.css('mount intro').text.should == mount.intro
|
|
|
|
|
xml.css('mount fallback-mount').text.should == mount.fallback_mount
|
2014-01-19 02:20:44 +00:00
|
|
|
xml.css('mount fallback-override').text.should == mount.fallback_override.to_s
|
|
|
|
|
xml.css('mount fallback-when-full').text.should == mount.fallback_when_full.to_s
|
2014-01-17 04:51:19 +00:00
|
|
|
xml.css('mount stream-name').text.should == mount.stream_name
|
|
|
|
|
xml.css('mount stream-description').text.should == mount.stream_description
|
|
|
|
|
xml.css('mount stream-url').text.should == mount.stream_url
|
|
|
|
|
xml.css('mount genre').text.should == mount.genre
|
|
|
|
|
xml.css('mount bitrate').length.should == 0
|
|
|
|
|
xml.css('mount charset').text == mount.charset
|
|
|
|
|
xml.css('mount public').text == mount.is_public.to_s
|
|
|
|
|
xml.css('mount type').text == mount.mime_type
|
|
|
|
|
xml.css('mount subtype').text == mount.subtype
|
|
|
|
|
xml.css('mount burst-size').length.should == 0
|
|
|
|
|
xml.css('mount mp3-metadata-interval').length.should == 0
|
2014-01-19 02:20:44 +00:00
|
|
|
xml.css('mount hidden').text.should == mount.hidden.to_s
|
2014-01-17 04:51:19 +00:00
|
|
|
xml.css('mount on-connect').text.should == mount.on_connect
|
|
|
|
|
xml.css('mount on-disconnect').text.should == mount.on_disconnect
|
|
|
|
|
xml.css('mount dump-file').length.should == 0
|
|
|
|
|
xml.css('mount authentication').length.should == 1 # no reason to test futher; it's tested in that model
|
2014-01-19 02:20:44 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe "poke configs" do
|
|
|
|
|
let(:server) { a = FactoryGirl.create(:icecast_server_with_overrides); a.config_updated; IcecastServer.find(a.id) }
|
2014-01-14 21:22:05 +00:00
|
|
|
|
2014-01-19 02:20:44 +00:00
|
|
|
before(:each) do
|
|
|
|
|
server.mounts << FactoryGirl.create(:icecast_mount)
|
|
|
|
|
server.save!
|
|
|
|
|
server.config_updated
|
|
|
|
|
server.reload
|
|
|
|
|
server.config_changed.should == 0
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "success via server" do
|
|
|
|
|
server.mounts.first.save!
|
|
|
|
|
server.reload
|
|
|
|
|
server.config_changed.should == 1
|
|
|
|
|
end
|
2014-01-10 21:02:52 +00:00
|
|
|
end
|
2014-01-14 21:22:05 +00:00
|
|
|
|
2014-01-19 02:20:44 +00:00
|
|
|
describe "icecast server callbacks" do
|
|
|
|
|
it "source up" do
|
|
|
|
|
icecast_mount.source_up
|
|
|
|
|
end
|
|
|
|
|
end
|
2014-01-10 21:02:52 +00:00
|
|
|
end
|