2014-01-10 21:02:52 +00:00
|
|
|
require 'spec_helper'
|
2014-01-16 03:29:52 +00:00
|
|
|
require 'stringio'
|
2014-01-10 21:02:52 +00:00
|
|
|
|
2014-01-16 03:29:52 +00:00
|
|
|
=begin
|
|
|
|
|
example output:
|
|
|
|
|
|
|
|
|
|
<directory>
|
|
|
|
|
<yp-url-timeout>15</yp-url-timeout>
|
|
|
|
|
<yp-url>http://dir.xiph.org/cgi-bin/yp-cgi</yp-url>
|
|
|
|
|
</directory>
|
|
|
|
|
=end
|
2014-01-10 21:02:52 +00:00
|
|
|
describe IcecastDirectory do
|
|
|
|
|
|
2014-01-17 04:51:19 +00:00
|
|
|
let(:dir) { IcecastDirectory.new }
|
|
|
|
|
let(:output) { StringIO.new }
|
|
|
|
|
let(:builder) { ::Builder::XmlMarkup.new(:target => output, :indent => 1) }
|
2014-01-10 21:02:52 +00:00
|
|
|
|
2014-01-16 03:29:52 +00:00
|
|
|
before(:each) do
|
2014-01-10 21:02:52 +00:00
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
2014-01-17 04:51:19 +00:00
|
|
|
it "save error" do
|
|
|
|
|
dir.save.should be_false
|
|
|
|
|
dir.errors[:yp_url].length.should == 1
|
|
|
|
|
dir.errors[:yp_url_timeout].length.should == 0
|
|
|
|
|
end
|
|
|
|
|
|
2014-01-10 21:02:52 +00:00
|
|
|
it "save" do
|
2014-01-17 04:51:19 +00:00
|
|
|
dir.yp_url = Faker::Lorem.characters(10)
|
|
|
|
|
dir.yp_url_timeout = 20
|
|
|
|
|
dir.save.should be_true
|
|
|
|
|
dir.dumpXml(builder)
|
2014-01-16 03:29:52 +00:00
|
|
|
|
|
|
|
|
output.rewind
|
2014-01-17 04:51:19 +00:00
|
|
|
xml = Nokogiri::XML(output)
|
|
|
|
|
xml.css('directory yp-url-timeout').text.should == dir.yp_url_timeout.to_s
|
|
|
|
|
xml.css('directory yp-url-timeout').length.should == 1
|
|
|
|
|
xml.css('directory yp-url').text.should == dir.yp_url
|
|
|
|
|
xml.css('directory yp-url').length.should == 1
|
2014-01-10 21:02:52 +00:00
|
|
|
end
|
|
|
|
|
|
2014-01-19 02:20:44 +00:00
|
|
|
describe "poke configs" do
|
|
|
|
|
let(:server) { a = FactoryGirl.create(:icecast_server_with_overrides); a.config_updated; IcecastServer.find(a.id) }
|
|
|
|
|
|
|
|
|
|
before(:each) do
|
|
|
|
|
server.directory = FactoryGirl.create(:icecast_directory)
|
|
|
|
|
server.template.directory = FactoryGirl.create(:icecast_directory)
|
|
|
|
|
server.template.save!
|
|
|
|
|
server.save!
|
|
|
|
|
server.config_updated
|
|
|
|
|
server.reload
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "success via template" do
|
|
|
|
|
server.template.directory.save!
|
|
|
|
|
server.reload
|
|
|
|
|
server.config_changed.should == 1
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "success via server" do
|
|
|
|
|
server.directory.save!
|
|
|
|
|
server.reload
|
|
|
|
|
server.config_changed.should == 1
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2014-01-10 21:02:52 +00:00
|
|
|
end
|