jam-cloud/ruby/spec/jam_ruby/models/icecast_admin_authenticatio...

72 lines
2.3 KiB
Ruby
Raw Normal View History

2014-01-07 20:30:06 +00:00
require 'spec_helper'
describe IcecastAdminAuthentication do
let(:admin) { IcecastAdminAuthentication.new }
let(:output) { StringIO.new }
let(:builder) { ::Builder::XmlMarkup.new(:target => output, :indent => 1) }
2014-01-07 20:30:06 +00:00
it "save error" do
admin.save.should be_false
admin.errors[:source_pass].length.should == 2
admin.errors[:admin_user].length.should == 2
admin.errors[:admin_pass].length.should == 2
admin.errors[:relay_user].length.should == 2
admin.errors[:relay_pass].length.should == 2
2014-01-07 20:30:06 +00:00
end
it "save" do
admin.source_pass = Faker::Lorem.characters(10)
admin.admin_user = Faker::Lorem.characters(10)
admin.admin_pass = Faker::Lorem.characters(10)
admin.relay_user = Faker::Lorem.characters(10)
admin.relay_pass = Faker::Lorem.characters(10)
admin.save.should be_true
admin.dumpXml(builder)
2014-01-07 20:30:06 +00:00
output.rewind
xml = Nokogiri::XML(output)
xml.css('authentication source-password').text.should == admin.source_pass
xml.css('authentication source-password').length.should == 1
xml.css('authentication admin-user').text.should == admin.admin_user
xml.css('authentication admin-user').length.should == 1
xml.css('authentication relay-user').text.should == admin.relay_user
xml.css('authentication relay-user').length.should == 1
xml.css('authentication relay-password').text.should == admin.relay_pass
xml.css('authentication relay-password').length.should == 1
xml.css('authentication admin-password').text.should == admin.admin_pass
xml.css('authentication admin-password').length.should == 1
end
2014-01-10 21:02:52 +00:00
describe "poke configs" do
let(:server) { a = FactoryGirl.create(:icecast_server_with_overrides); a.config_updated; IcecastServer.find(a.id) }
it "success via template" do
server.template.admin_auth.save!
server.reload
server.config_changed.should == 1
end
it "success when deleted via template" do
server.template.admin_auth.destroy
server.reload
server.config_changed.should == 1
end
it "success via server" do
server.admin_auth.save!
server.reload
server.config_changed.should == 1
end
it "success when deleted via server" do
server.admin_auth.destroy
server.reload
server.config_changed.should == 1
end
end
2014-01-07 20:30:06 +00:00
end