Skip to content
This repository has been archived by the owner on Nov 20, 2022. It is now read-only.

Commit

Permalink
Update to Crystal 0.29.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sdogruyol committed Jul 15, 2019
1 parent d6178af commit d2ab490
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 29 deletions.
13 changes: 8 additions & 5 deletions spec/s3/bucket_spec.cr
Expand Up @@ -3,25 +3,28 @@ require "../spec_helper"
module Aws::S3
describe Bucket do
it "is equal to another bucket if name and creation time are equal" do
time = Time.now
time = Time.utc
bucket = Bucket.new("test", time)
Bucket.new("test", time).should eq(bucket)
end

it "not equal to another bucket if name and creation time differ" do
time = Time.now
time = Time.utc
bucket = Bucket.new("test2", time)
(Bucket.new("test", Time.epoch(Time.now.epoch + 123)) == bucket).should eq(false)
new_bucket_time = Time.utc + 2.minutes
new_bucket = Bucket.new("test", new_bucket_time)

(new_bucket == bucket).should eq(false)
end

it "has a name" do
bucket = Bucket.new("name", Time.now)
bucket = Bucket.new("name", Time.utc)

bucket.name.should eq("name")
end

it "has a creation_time" do
time = Time.now
time = Time.utc
bucket = Bucket.new("name", time)

bucket.creation_time.should eq(time)
Expand Down
7 changes: 3 additions & 4 deletions spec/s3/content_type_spec.cr
@@ -1,5 +1,4 @@
require "../../spec_helper"
require "tempfile"
require "../spec_helper"

module Aws::S3
describe ContentType do
Expand All @@ -13,7 +12,7 @@ module Aws::S3
describe "when the io is a file" do
it "returns the correct Content-Type" do
ContentType::TYPES.keys.each do |ext|
tempfile = Tempfile.new("foo", ext)
tempfile = File.tempfile(ext)
file = File.open(tempfile.path)
ContentType.get(file).should be(ContentType::TYPES[ext])
tempfile.delete
Expand All @@ -23,7 +22,7 @@ module Aws::S3

describe "when the io is a file and the extension is unknown" do
it "returns the default Content-Type" do
tempfile = Tempfile.new("foo", ".spicy")
tempfile = File.tempfile(".spicy")
file = File.open(tempfile.path)
ContentType.get(file).should be(ContentType::DEFAULT)
tempfile.delete
Expand Down
7 changes: 3 additions & 4 deletions spec/s3/file_uploader_spec.cr
@@ -1,5 +1,4 @@
require "../../spec_helper"
require "tempfile"
require "../spec_helper"

module Aws::S3
describe FileUploader do
Expand Down Expand Up @@ -96,7 +95,7 @@ module Aws::S3
client = Client.new(REGION, "key", "secret")
uploader = FileUploader.new(client)

tempfile = Tempfile.new("foo", ".svg")
tempfile = File.tempfile(".svg")
file = File.open(tempfile.path)

uploader.upload("bucket", "object", file).should be_true
Expand All @@ -117,7 +116,7 @@ module Aws::S3
options = FileUploader::Options.new(with_content_types: false)
uploader = FileUploader.new(client, options)

tempfile = Tempfile.new("foo", ".svg")
tempfile = File.tempfile(".svg")
file = File.open(tempfile.path)

uploader.upload("bucket", "object", file).should be_true
Expand Down
4 changes: 2 additions & 2 deletions spec/s3/presigned/form_spec.cr
Expand Up @@ -59,7 +59,7 @@ module Aws

describe "submit" do
it "sends a reasonable request over http for v2" do
time = Time.epoch(1)
time = Time.unix(1)
Timecop.freeze(time)

post = Post.new(
Expand Down Expand Up @@ -91,7 +91,7 @@ module Aws
end

it "sends a reasonable request over http for v4" do
time = Time.epoch(1)
time = Time.unix(1)
Timecop.freeze(time)

post = Post.new(
Expand Down
6 changes: 3 additions & 3 deletions spec/s3/presigned/html_printer_spec.cr
Expand Up @@ -5,15 +5,15 @@ module Aws
module Presigned
describe HtmlPrinter do
Spec.before_each do
Timecop.freeze(Time.epoch(1))
Timecop.freeze(Time.unix(1))
end

Spec.after_each do
Timecop.reset
end

it "generates the same html each call" do
time = Time.epoch(1)
time = Time.unix(1)
post = Post.new(
region: "us-east-1",
aws_access_key: "test",
Expand All @@ -32,7 +32,7 @@ module Aws
end

it "prints html" do
time = Time.epoch(1)
time = Time.unix(1)

post = Post.new(
region: "region",
Expand Down
4 changes: 2 additions & 2 deletions spec/s3/presigned/post_policy_spec.cr
Expand Up @@ -39,7 +39,7 @@ module Aws
describe "to_s" do
it "returns policy as base64 encoded json" do
policy = Policy.new
policy.expiration(Time.epoch(1_483_859_302))
policy.expiration(Time.unix(1_483_859_302))
policy.condition("test", "test")

policy.to_s.should eq("eyJleHBpcmF0aW9uIjoiMjAxNy0wMS0wOFQwNzowODoyMi4wMDBaIiwiY29uZGl0aW9ucyI6W3sidGVzdCI6InRlc3QifV19")
Expand All @@ -54,7 +54,7 @@ module Aws

it "can be a hash" do
policy = Policy.new
policy.expiration(Time.epoch(1_483_859_302))
policy.expiration(Time.unix(1_483_859_302))
policy.condition("test", "test")

policy.to_hash.should eq({
Expand Down
14 changes: 7 additions & 7 deletions spec/s3/presigned/post_spec.cr
Expand Up @@ -5,7 +5,7 @@ module Aws
module Presigned
describe Post do
Spec.before_each do
Timecop.freeze(Time.epoch(1))
Timecop.freeze(Time.unix(1))
end

Spec.after_each do
Expand Down Expand Up @@ -49,7 +49,7 @@ module Aws

describe "fields" do
it "generates the same fields each time" do
time = Time.epoch(1)
time = Time.unix(1)
post = Post.new(
region: "us-east-1",
aws_access_key: "test",
Expand All @@ -61,7 +61,7 @@ module Aws
end

it "contains the policy field" do
time = Time.epoch(1)
time = Time.unix(1)
post = Post.new(
region: "us-east-1",
aws_access_key: "test",
Expand All @@ -75,7 +75,7 @@ module Aws
end

it "contains the signature field" do
time = Time.epoch(1)
time = Time.unix(1)
post = Post.new(
region: "us-east-1",
aws_access_key: "test",
Expand All @@ -89,7 +89,7 @@ module Aws
end

it "contains the credential field" do
time = Time.epoch(1)
time = Time.unix(1)
post = Post.new(
region: "us-east-1",
aws_access_key: "test",
Expand All @@ -103,7 +103,7 @@ module Aws
end

it "contains the algorithm field" do
time = Time.epoch(1)
time = Time.unix(1)
post = Post.new(
region: "us-east-1",
aws_access_key: "test",
Expand All @@ -117,7 +117,7 @@ module Aws
end

it "contains the date field" do
time = Time.epoch(1)
time = Time.unix(1)
post = Post.new(
region: "us-east-1",
aws_access_key: "test",
Expand Down
2 changes: 1 addition & 1 deletion spec/s3/presigned/url_spec.cr
Expand Up @@ -59,7 +59,7 @@ module Aws

describe "get" do
it "generates correct url for v2" do
time = Time.epoch(1)
time = Time.unix(1)
Timecop.freeze(time)
options = Url::Options.new(
region: "us-east-1",
Expand Down
2 changes: 1 addition & 1 deletion src/aws/s3/presigned/url.cr
Expand Up @@ -56,7 +56,7 @@ module Aws
if @options.signer_version == :v4
request.query_params.add("X-Amz-Expires", @options.expires.to_s)
else
request.query_params.add("Expires", (Time.utc_now.epoch + @options.expires).to_s)
request.query_params.add("Expires", (Time.utc_now.to_unix + Time.unix(@options.expires).to_unix).to_s)
end

request
Expand Down

0 comments on commit d2ab490

Please sign in to comment.