40 lines
972 B
Ruby
40 lines
972 B
Ruby
require 'spec_helper'
|
|
require 'digest/md5'
|
|
|
|
describe ArtifactUpdate do
|
|
|
|
include UsesTempFiles
|
|
|
|
ARTIFACT_FILE='jkclient-0.1.1.exe'
|
|
|
|
in_directory_with_file(ARTIFACT_FILE)
|
|
|
|
before do
|
|
content_for_file("exe binary globby goo")
|
|
end
|
|
|
|
it "return empty" do
|
|
ArtifactUpdate.find(:all).length.should == 0
|
|
end
|
|
|
|
|
|
it "should allow insertion" do
|
|
|
|
artifact = ArtifactUpdate.new
|
|
artifact.product = 'JamClient/Win32'
|
|
artifact.version = '0.1.1'
|
|
artifact.uri = File.open(ARTIFACT_FILE)
|
|
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 == 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
|
|
end
|
|
|
|
end |