1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[dreamhost|dns] added Record model tests, fix Record.save

Record.save was missing attribute merging before returning
This commit is contained in:
Sergio Rubio 2013-01-21 22:16:56 +01:00
parent b4f05f6893
commit 90b5d84c6d
2 changed files with 61 additions and 1 deletions

View file

@ -23,7 +23,8 @@ module Fog
def save
requires :name, :type, :value
data = service.create_record(name, type, value, comment)
data = service.create_record(name, type, value, comment).body
merge_attributes(data)
true
end

View file

@ -0,0 +1,59 @@
Shindo.tests("Fog::DNS[:dreamhost] | record", ['dreamhost', 'dns']) do
service = Fog::DNS[:dreamhost]
record = service.records.first
tests('#attributes') do
tests('should have') do
model_attribute_hash = record.attributes
attributes = [
:name,
:value,
:zone,
:type,
:editable,
:account_id,
:comment,
]
attributes.each do |attribute|
test("#{attribute} method") { record.respond_to? attribute }
end
attributes.each do |attribute|
test("#{attribute} key") { model_attribute_hash.has_key? attribute }
end
end
test('be a kind of Fog::DNS::Dreamhost::Record') do
record.kind_of? Fog::DNS::Dreamhost::Record
end
tests('Write operations') do
name = "test.#{test_domain}"
r = service.records.create :name => name,
:type => 'A',
:value => "8.8.8.8"
tests('#save') do
test('returns Fog::DNS::Dreamhost::Record') do
r.is_a? Fog::DNS::Dreamhost::Record
end
test('value is 8.8.8.8') do
r.value == '8.8.8.8'
end
test("name is #{name}") do
r.name == name
end
end
tests('#destroy') do
test('returns true') { r.destroy == true }
test('destroyed record not listed') do
(service.records.find { |r| r.name == name }).nil?
end
end
end
end
# cleanup
cleanup_records
end