* updating ArtifactUpdate to reflect new mandatory fields
This commit is contained in:
parent
f1ac2a951e
commit
8ca4848d28
4
Gemfile
4
Gemfile
|
|
@ -1,6 +1,8 @@
|
|||
#ruby=1.9.3
|
||||
source 'https://rubygems.org'
|
||||
source 'https://jamjam:blueberryjam@www.jamkazam.com/gems/'
|
||||
unless ENV["LOCAL_DEV"] == "1"
|
||||
source 'https://jamjam:blueberryjam@www.jamkazam.com/gems/'
|
||||
end
|
||||
|
||||
# Look for $WORKSPACE, otherwise use "workspace" as dev path.
|
||||
workspace = ENV["WORKSPACE"] || "~/workspace"
|
||||
|
|
|
|||
|
|
@ -7,12 +7,25 @@ module JamRuby
|
|||
|
||||
self.primary_key = 'id'
|
||||
attr_accessible :version, :uri, :sha1, :environment, :product
|
||||
|
||||
# ORDER MATTERS HERE- before_save for this method must be declared before mount_uploader: https://github.com/jnicklas/carrierwave/wiki/Known-Issues
|
||||
before_save :update_uri_attributes
|
||||
mount_uploader :uri, ArtifactUploader
|
||||
|
||||
validate :version, :presence => true
|
||||
validate :uri, :presence => true
|
||||
validate :sha1, :presence => false
|
||||
validate :environment, presence => true
|
||||
validate :sha1, :presence => true
|
||||
validate :size, :presence => true
|
||||
validate :environment, :presence => true
|
||||
validate :product, :inclusion => {:in => PRODUCTS}
|
||||
|
||||
private
|
||||
|
||||
def update_uri_attributes
|
||||
if uri.present? && uri_changed?
|
||||
self.size = uri.file.size
|
||||
self.sha1 = Digest::MD5.hexdigest(File.read(uri.current_path))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
require 'spec_helper'
|
||||
require 'digest/md5'
|
||||
|
||||
describe ArtifactUpdate do
|
||||
|
||||
|
|
@ -23,15 +24,14 @@ describe ArtifactUpdate do
|
|||
artifact.product = 'JamClient/Win32'
|
||||
artifact.version = '0.1.1'
|
||||
artifact.uri = File.open(ARTIFACT_FILE)
|
||||
artifact.sha1 = 'blahablahblah'
|
||||
|
||||
artifact.save!
|
||||
|
||||
artifact.environment.should == "public"
|
||||
artifact.product.should == "JamClient/Win32"
|
||||
artifact.version.should == "0.1.1"
|
||||
File.basename(artifact.uri.path).should == ARTIFACT_FILE
|
||||
artifact.sha1.should == "blahablahblah"
|
||||
artifact.sha1.should == Digest::MD5.hexdigest(File.read(ARTIFACT_FILE))
|
||||
artifact.size.should == File.size(ARTIFACT_FILE)
|
||||
|
||||
found = ArtifactUpdate.find_by_product_and_version('JamClient/Win32', '0.1.1')
|
||||
artifact.should == found
|
||||
|
|
|
|||
Loading…
Reference in New Issue