2013-02-06 05:14:07 +00:00
|
|
|
require 'spec_helper'
|
2013-04-10 06:16:04 +00:00
|
|
|
require 'digest/md5'
|
2013-02-06 05:14:07 +00:00
|
|
|
|
|
|
|
|
describe ArtifactUpdate do
|
|
|
|
|
|
2013-02-13 01:56:40 +00:00
|
|
|
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
|
|
|
|
|
|
2013-02-06 05:14:07 +00:00
|
|
|
it "return empty" do
|
2016-07-17 15:16:27 +00:00
|
|
|
ArtifactUpdate.count.should == 0
|
2013-02-06 05:14:07 +00:00
|
|
|
end
|
|
|
|
|
|
2013-02-13 01:56:40 +00:00
|
|
|
|
2013-02-06 05:14:07 +00:00
|
|
|
it "should allow insertion" do
|
2013-02-13 01:56:40 +00:00
|
|
|
|
2013-02-06 05:14:07 +00:00
|
|
|
artifact = ArtifactUpdate.new
|
|
|
|
|
artifact.product = 'JamClient/Win32'
|
|
|
|
|
artifact.version = '0.1.1'
|
2013-02-13 01:56:40 +00:00
|
|
|
artifact.uri = File.open(ARTIFACT_FILE)
|
2013-02-06 05:14:07 +00:00
|
|
|
artifact.save!
|
|
|
|
|
|
|
|
|
|
artifact.environment.should == "public"
|
|
|
|
|
artifact.product.should == "JamClient/Win32"
|
|
|
|
|
artifact.version.should == "0.1.1"
|
2013-02-13 01:56:40 +00:00
|
|
|
File.basename(artifact.uri.path).should == ARTIFACT_FILE
|
2013-04-10 06:16:04 +00:00
|
|
|
artifact.sha1.should == Digest::MD5.hexdigest(File.read(ARTIFACT_FILE))
|
|
|
|
|
artifact.size.should == File.size(ARTIFACT_FILE)
|
2013-02-06 05:14:07 +00:00
|
|
|
|
|
|
|
|
found = ArtifactUpdate.find_by_product_and_version('JamClient/Win32', '0.1.1')
|
|
|
|
|
artifact.should == found
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|