From c90d30621e042cc3e52ffc87e3491ab110a57e9e Mon Sep 17 00:00:00 2001 From: Azul Date: Mon, 24 Sep 2012 12:16:14 +0200 Subject: ported over proper ways of creating certs Will now use .txt as the extention Returns the actual content on .zipped With tests. --- lib/leap_ca/cert.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/leap_ca/cert.rb b/lib/leap_ca/cert.rb index 80adfbb..1459e01 100644 --- a/lib/leap_ca/cert.rb +++ b/lib/leap_ca/cert.rb @@ -13,7 +13,7 @@ class Cert < CouchRest::Model::Base validates :random, :presence => true, :numericality => {:greater_than => 0, :less_than => 1} - validates :zipped, :presence => true + validates :zip_attachment, :presence => true design do end @@ -23,15 +23,20 @@ class Cert < CouchRest::Model::Base end def attach_zip - self.create_attachment :file => StringIO.new("dummy cert"), :name => zipname + file = File.open File.join(LEAP_CA_ROOT, "config", "cert") + self.create_attachment :file => file, :name => zipname end def zipname - 'cert.zip' + 'cert.txt' end - def zipped + def zip_attachment attachments[zipname] end + def zipped + read_attachment(zipname) + end + end -- cgit v1.2.3