2014-01-14 21:22:05 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
|
|
describe IcecastServer do
|
|
|
|
|
|
2014-01-17 04:51:19 +00:00
|
|
|
let(:server) { IcecastServer.new }
|
|
|
|
|
let(:output) { StringIO.new }
|
|
|
|
|
let(:builder) { ::Builder::XmlMarkup.new(:target => output, :indent => 1) }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it "save" do
|
|
|
|
|
server = FactoryGirl.create(:icecast_server_minimal)
|
|
|
|
|
server.save!
|
|
|
|
|
server.reload
|
2014-01-19 02:20:44 +00:00
|
|
|
server.dumpXml(output)
|
2014-01-17 04:51:19 +00:00
|
|
|
|
|
|
|
|
output.rewind
|
2014-01-19 02:20:44 +00:00
|
|
|
|
2014-01-17 04:51:19 +00:00
|
|
|
xml = Nokogiri::XML(output)
|
|
|
|
|
xml.css('icecast hostname').text.should == server.hostname
|
|
|
|
|
xml.css('icecast server-id').text.should == server.server_id
|
2014-01-17 19:55:26 +00:00
|
|
|
xml.css('icecast location').text.should == server.template.location
|
|
|
|
|
xml.css('icecast admin').text.should == server.template.admin_email
|
2014-01-19 02:20:44 +00:00
|
|
|
xml.css('icecast fileserve').text.should == server.template.fileserve.to_s
|
2014-01-17 04:51:19 +00:00
|
|
|
xml.css('icecast limits').length.should == 1
|
|
|
|
|
xml.css('icecast authentication').length.should == 1
|
|
|
|
|
xml.css('icecast directory').length.should == 0
|
|
|
|
|
xml.css('icecast master-server').length.should == 0
|
|
|
|
|
xml.css('icecast paths').length.should == 1
|
|
|
|
|
xml.css('icecast logging').length.should == 1
|
|
|
|
|
xml.css('icecast security').length.should == 1
|
|
|
|
|
xml.css('icecast listen-socket').length.should == 1
|
2014-01-14 21:22:05 +00:00
|
|
|
end
|
2014-01-21 14:51:03 +00:00
|
|
|
|
|
|
|
|
it "xml overrides" do
|
|
|
|
|
server = FactoryGirl.create(:icecast_server_minimal)
|
|
|
|
|
server.save!
|
|
|
|
|
server.reload
|
|
|
|
|
server.dumpXml(output)
|
|
|
|
|
|
|
|
|
|
output.rewind
|
|
|
|
|
|
|
|
|
|
xml = Nokogiri::XML(output)
|
|
|
|
|
xml.css('icecast location').text.should == server.template.location
|
|
|
|
|
xml.css('icecast fileserve').text.should == server.template.fileserve.to_s
|
|
|
|
|
xml.css('icecast limits').length.should == 1
|
|
|
|
|
xml.css('icecast limits queue-size').text.should == server.template.limit.queue_size.to_s
|
|
|
|
|
|
|
|
|
|
server.location = "override"
|
|
|
|
|
server.fileserve = 1
|
|
|
|
|
server.limit = FactoryGirl.create(:icecast_limit, :queue_size => 777)
|
|
|
|
|
server.save!
|
|
|
|
|
|
|
|
|
|
output = StringIO.new
|
|
|
|
|
builder = ::Builder::XmlMarkup.new(:target => output, :indent => 1)
|
|
|
|
|
server.dumpXml(builder)
|
|
|
|
|
output.rewind
|
|
|
|
|
xml = Nokogiri::XML(output)
|
|
|
|
|
xml.css('icecast location').text.should == server.location
|
|
|
|
|
xml.css('icecast fileserve').text.should == server.fileserve.to_s
|
|
|
|
|
xml.css('icecast limits').length.should == 1
|
|
|
|
|
xml.css('icecast limits queue-size').text.should == server.limit.queue_size.to_s
|
|
|
|
|
end
|
2014-01-14 21:22:05 +00:00
|
|
|
end
|