s3_relay 0.5.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +3 -19
- data/app/assets/javascripts/s3_relay.coffee +4 -4
- data/app/controllers/s3_relay/uploads_controller.rb +8 -2
- data/app/models/s3_relay/upload.rb +1 -1
- data/db/migrate/20141009000804_create_s3_relay_uploads.rb +1 -1
- data/lib/s3_relay/base.rb +1 -1
- data/lib/s3_relay/engine.rb +1 -1
- data/lib/s3_relay/private_url.rb +1 -1
- data/lib/s3_relay/version.rb +1 -1
- data/test/controllers/s3_relay/uploads_controller_test.rb +28 -22
- data/test/dummy/{README.rdoc → README.md} +1 -5
- data/test/dummy/Rakefile +1 -1
- data/test/dummy/app/assets/config/manifest.js +3 -0
- data/test/dummy/app/assets/javascripts/application.js +6 -4
- data/test/dummy/app/assets/javascripts/cable.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +5 -5
- data/test/dummy/app/channels/application_cable/channel.rb +4 -0
- data/test/dummy/app/channels/application_cable/connection.rb +4 -0
- data/test/dummy/app/controllers/application_controller.rb +0 -2
- data/test/dummy/app/jobs/application_job.rb +2 -0
- data/test/dummy/app/mailers/application_mailer.rb +4 -0
- data/test/dummy/app/models/application_record.rb +3 -0
- data/test/dummy/app/models/product.rb +1 -1
- data/test/dummy/app/views/layouts/application.html.erb +9 -9
- data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/test/dummy/bin/rails +6 -1
- data/test/dummy/bin/rake +5 -0
- data/test/dummy/bin/setup +38 -0
- data/test/dummy/bin/spring +17 -0
- data/test/dummy/bin/update +29 -0
- data/test/dummy/bin/yarn +11 -0
- data/test/dummy/config.ru +2 -1
- data/test/dummy/config/application.rb +7 -11
- data/test/dummy/config/boot.rb +2 -4
- data/test/dummy/config/cable.yml +10 -0
- data/test/dummy/config/environment.rb +1 -1
- data/test/dummy/config/environments/development.rb +24 -7
- data/test/dummy/config/environments/production.rb +36 -23
- data/test/dummy/config/environments/test.rb +6 -3
- data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/test/dummy/config/initializers/assets.rb +8 -2
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -1
- data/test/dummy/config/initializers/wrap_parameters.rb +2 -2
- data/test/dummy/config/locales/en.yml +10 -0
- data/test/dummy/config/puma.rb +56 -0
- data/test/dummy/config/secrets.yml +15 -5
- data/test/dummy/config/spring.rb +6 -0
- data/test/dummy/db/migrate/20141021002149_create_products.rb +1 -1
- data/test/dummy/db/schema.rb +13 -14
- data/test/dummy/db/seeds.rb +7 -0
- data/test/dummy/log/development.log +60 -20
- data/test/dummy/log/test.log +10958 -856
- data/test/dummy/package.json +5 -0
- data/test/dummy/public/404.html +6 -6
- data/test/dummy/public/422.html +6 -6
- data/test/dummy/public/500.html +6 -6
- data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/test/dummy/public/apple-touch-icon.png +0 -0
- data/test/dummy/public/robots.txt +1 -0
- data/test/dummy/test/application_system_test_case.rb +5 -0
- data/test/dummy/test/test_helper.rb +9 -0
- data/test/factories/products.rb +2 -2
- data/test/factories/uploads.rb +14 -7
- data/test/helpers/s3_relay/uploads_helper_test.rb +7 -4
- data/test/lib/s3_relay/model_test.rb +15 -15
- data/test/lib/s3_relay/private_url_test.rb +1 -1
- data/test/lib/s3_relay/upload_presigner_test.rb +9 -9
- data/test/models/s3_relay/upload_test.rb +25 -24
- data/test/test_helper.rb +2 -4
- metadata +110 -72
- data/test/dummy/config/initializers/session_store.rb +0 -3
data/test/dummy/public/404.html
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
<title>The page you were looking for doesn't exist (404)</title>
|
5
5
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
6
|
<style>
|
7
|
-
|
7
|
+
.rails-default-error-page {
|
8
8
|
background-color: #EFEFEF;
|
9
9
|
color: #2E2F30;
|
10
10
|
text-align: center;
|
@@ -12,13 +12,13 @@
|
|
12
12
|
margin: 0;
|
13
13
|
}
|
14
14
|
|
15
|
-
div.dialog {
|
15
|
+
.rails-default-error-page div.dialog {
|
16
16
|
width: 95%;
|
17
17
|
max-width: 33em;
|
18
18
|
margin: 4em auto 0;
|
19
19
|
}
|
20
20
|
|
21
|
-
div.dialog > div {
|
21
|
+
.rails-default-error-page div.dialog > div {
|
22
22
|
border: 1px solid #CCC;
|
23
23
|
border-right-color: #999;
|
24
24
|
border-left-color: #999;
|
@@ -31,13 +31,13 @@
|
|
31
31
|
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
32
|
}
|
33
33
|
|
34
|
-
h1 {
|
34
|
+
.rails-default-error-page h1 {
|
35
35
|
font-size: 100%;
|
36
36
|
color: #730E15;
|
37
37
|
line-height: 1.5em;
|
38
38
|
}
|
39
39
|
|
40
|
-
div.dialog > p {
|
40
|
+
.rails-default-error-page div.dialog > p {
|
41
41
|
margin: 0 0 1em;
|
42
42
|
padding: 1em;
|
43
43
|
background-color: #F7F7F7;
|
@@ -54,7 +54,7 @@
|
|
54
54
|
</style>
|
55
55
|
</head>
|
56
56
|
|
57
|
-
<body>
|
57
|
+
<body class="rails-default-error-page">
|
58
58
|
<!-- This file lives in public/404.html -->
|
59
59
|
<div class="dialog">
|
60
60
|
<div>
|
data/test/dummy/public/422.html
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
<title>The change you wanted was rejected (422)</title>
|
5
5
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
6
|
<style>
|
7
|
-
|
7
|
+
.rails-default-error-page {
|
8
8
|
background-color: #EFEFEF;
|
9
9
|
color: #2E2F30;
|
10
10
|
text-align: center;
|
@@ -12,13 +12,13 @@
|
|
12
12
|
margin: 0;
|
13
13
|
}
|
14
14
|
|
15
|
-
div.dialog {
|
15
|
+
.rails-default-error-page div.dialog {
|
16
16
|
width: 95%;
|
17
17
|
max-width: 33em;
|
18
18
|
margin: 4em auto 0;
|
19
19
|
}
|
20
20
|
|
21
|
-
div.dialog > div {
|
21
|
+
.rails-default-error-page div.dialog > div {
|
22
22
|
border: 1px solid #CCC;
|
23
23
|
border-right-color: #999;
|
24
24
|
border-left-color: #999;
|
@@ -31,13 +31,13 @@
|
|
31
31
|
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
32
|
}
|
33
33
|
|
34
|
-
h1 {
|
34
|
+
.rails-default-error-page h1 {
|
35
35
|
font-size: 100%;
|
36
36
|
color: #730E15;
|
37
37
|
line-height: 1.5em;
|
38
38
|
}
|
39
39
|
|
40
|
-
div.dialog > p {
|
40
|
+
.rails-default-error-page div.dialog > p {
|
41
41
|
margin: 0 0 1em;
|
42
42
|
padding: 1em;
|
43
43
|
background-color: #F7F7F7;
|
@@ -54,7 +54,7 @@
|
|
54
54
|
</style>
|
55
55
|
</head>
|
56
56
|
|
57
|
-
<body>
|
57
|
+
<body class="rails-default-error-page">
|
58
58
|
<!-- This file lives in public/422.html -->
|
59
59
|
<div class="dialog">
|
60
60
|
<div>
|
data/test/dummy/public/500.html
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
<title>We're sorry, but something went wrong (500)</title>
|
5
5
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
6
|
<style>
|
7
|
-
|
7
|
+
.rails-default-error-page {
|
8
8
|
background-color: #EFEFEF;
|
9
9
|
color: #2E2F30;
|
10
10
|
text-align: center;
|
@@ -12,13 +12,13 @@
|
|
12
12
|
margin: 0;
|
13
13
|
}
|
14
14
|
|
15
|
-
div.dialog {
|
15
|
+
.rails-default-error-page div.dialog {
|
16
16
|
width: 95%;
|
17
17
|
max-width: 33em;
|
18
18
|
margin: 4em auto 0;
|
19
19
|
}
|
20
20
|
|
21
|
-
div.dialog > div {
|
21
|
+
.rails-default-error-page div.dialog > div {
|
22
22
|
border: 1px solid #CCC;
|
23
23
|
border-right-color: #999;
|
24
24
|
border-left-color: #999;
|
@@ -31,13 +31,13 @@
|
|
31
31
|
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
32
32
|
}
|
33
33
|
|
34
|
-
h1 {
|
34
|
+
.rails-default-error-page h1 {
|
35
35
|
font-size: 100%;
|
36
36
|
color: #730E15;
|
37
37
|
line-height: 1.5em;
|
38
38
|
}
|
39
39
|
|
40
|
-
div.dialog > p {
|
40
|
+
.rails-default-error-page div.dialog > p {
|
41
41
|
margin: 0 0 1em;
|
42
42
|
padding: 1em;
|
43
43
|
background-color: #F7F7F7;
|
@@ -54,7 +54,7 @@
|
|
54
54
|
</style>
|
55
55
|
</head>
|
56
56
|
|
57
|
-
<body>
|
57
|
+
<body class="rails-default-error-page">
|
58
58
|
<!-- This file lives in public/500.html -->
|
59
59
|
<div class="dialog">
|
60
60
|
<div>
|
File without changes
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
# See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require File.expand_path('../../config/environment', __FILE__)
|
2
|
+
require 'rails/test_help'
|
3
|
+
|
4
|
+
class ActiveSupport::TestCase
|
5
|
+
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
|
6
|
+
fixtures :all
|
7
|
+
|
8
|
+
# Add more helper methods to be used by all tests here...
|
9
|
+
end
|
data/test/factories/products.rb
CHANGED
data/test/factories/uploads.rb
CHANGED
@@ -1,16 +1,23 @@
|
|
1
|
-
|
1
|
+
FactoryBot.define do
|
2
2
|
factory :upload, class: "S3Relay::Upload" do
|
3
|
-
uuid
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
uuid { SecureRandom.uuid }
|
4
|
+
end
|
5
|
+
|
6
|
+
factory :file_upload, parent: :upload do
|
7
|
+
filename { "cat.png" }
|
8
|
+
content_type { "image/png" }
|
9
|
+
upload_type { "FileUpload" }
|
7
10
|
end
|
8
11
|
|
9
12
|
factory :icon_upload, parent: :upload do
|
10
|
-
|
13
|
+
filename { "cat.png" }
|
14
|
+
content_type { "image/png" }
|
15
|
+
upload_type { "IconUpload" }
|
11
16
|
end
|
12
17
|
|
13
18
|
factory :photo_upload, parent: :upload do
|
14
|
-
|
19
|
+
filename { "cat.png" }
|
20
|
+
content_type { "image/png" }
|
21
|
+
upload_type { "PhotoUpload" }
|
15
22
|
end
|
16
23
|
end
|
@@ -1,27 +1,30 @@
|
|
1
1
|
require "test_helper"
|
2
2
|
|
3
|
+
include ActionView::Helpers::FormTagHelper
|
4
|
+
include S3Relay::UploadsHelper
|
5
|
+
|
3
6
|
describe S3Relay::UploadsHelper do
|
4
|
-
before { @product =
|
7
|
+
before { @product = FactoryBot.create(:product) }
|
5
8
|
|
6
9
|
describe "#s3_relay_field" do
|
7
10
|
describe "without options" do
|
8
11
|
it do
|
9
12
|
s3_relay_field(@product, :photo_uploads)
|
10
|
-
.must_equal %Q{<div class="s3r-container" data-
|
13
|
+
.must_equal %Q{<div class="s3r-container" data-parent-type="product" data-parent-id="#{@product.id}" data-association="photo_uploads" data-disposition=\"inline\"><input type="file" name="file" id="file" class="s3r-field" /><table class="s3r-upload-list"></table></div>}
|
11
14
|
end
|
12
15
|
end
|
13
16
|
|
14
17
|
describe "with multiple: true" do
|
15
18
|
it do
|
16
19
|
s3_relay_field(@product, :photo_uploads, multiple: true)
|
17
|
-
.must_equal %Q{<div class="s3r-container" data-
|
20
|
+
.must_equal %Q{<div class="s3r-container" data-parent-type="product" data-parent-id="#{@product.id}" data-association="photo_uploads" data-disposition=\"inline\"><input type="file" name="file" id="file" multiple="multiple" class="s3r-field" /><table class="s3r-upload-list"></table></div>}
|
18
21
|
end
|
19
22
|
end
|
20
23
|
|
21
24
|
describe "with disposition: attachment" do
|
22
25
|
it do
|
23
26
|
s3_relay_field(@product, :photo_uploads, disposition: :attachment)
|
24
|
-
.must_equal %Q{<div class="s3r-container" data-
|
27
|
+
.must_equal %Q{<div class="s3r-container" data-parent-type="product" data-parent-id="#{@product.id}" data-association="photo_uploads" data-disposition=\"attachment\"><input type="file" name="file" id="file" disposition=\"attachment\" class="s3r-field" /><table class="s3r-upload-list"></table></div>}
|
25
28
|
end
|
26
29
|
end
|
27
30
|
end
|
@@ -2,19 +2,19 @@ require "test_helper"
|
|
2
2
|
|
3
3
|
describe S3Relay::Model do
|
4
4
|
before do
|
5
|
-
@product =
|
5
|
+
@product = FactoryBot.build(:product)
|
6
6
|
end
|
7
7
|
|
8
8
|
describe "#s3_relay" do
|
9
9
|
|
10
10
|
describe "associations" do
|
11
11
|
it "has_one" do
|
12
|
-
Product.reflect_on_association(:icon_upload).macro
|
12
|
+
_(Product.reflect_on_association(:icon_upload).macro)
|
13
13
|
.must_equal(:has_one)
|
14
14
|
end
|
15
15
|
|
16
16
|
it "has_many" do
|
17
|
-
Product.reflect_on_association(:photo_uploads).macro
|
17
|
+
_(Product.reflect_on_association(:photo_uploads).macro)
|
18
18
|
.must_equal(:has_many)
|
19
19
|
end
|
20
20
|
end
|
@@ -22,41 +22,41 @@ describe S3Relay::Model do
|
|
22
22
|
describe "scopes" do
|
23
23
|
before do
|
24
24
|
@product.save
|
25
|
-
@icon =
|
26
|
-
@photo_1 =
|
27
|
-
@photo_2 =
|
25
|
+
@icon = FactoryBot.create(:icon_upload, parent: @product)
|
26
|
+
@photo_1 = FactoryBot.create(:photo_upload, parent: @product)
|
27
|
+
@photo_2 = FactoryBot.create(:photo_upload, parent: @product)
|
28
28
|
end
|
29
29
|
|
30
30
|
describe "has_one" do
|
31
|
-
it { @product.icon_upload.must_equal @icon }
|
31
|
+
it { _(@product.icon_upload).must_equal @icon }
|
32
32
|
end
|
33
33
|
|
34
34
|
describe "has_many" do
|
35
35
|
it do
|
36
|
-
@product.photo_uploads.pluck(:id).sort
|
36
|
+
_(@product.photo_uploads.pluck(:id).sort)
|
37
37
|
.must_equal [@photo_1.id, @photo_2.id]
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
describe "virtual attribute for UUID assignment" do
|
43
|
-
it { @product.must_respond_to :new_photo_uploads_uuids= }
|
43
|
+
it { _(@product).must_respond_to :new_photo_uploads_uuids= }
|
44
44
|
end
|
45
45
|
|
46
46
|
describe "association method" do
|
47
47
|
before do
|
48
|
-
@product =
|
49
|
-
@icon =
|
50
|
-
@photo_1 =
|
51
|
-
@photo_2 =
|
48
|
+
@product = FactoryBot.create(:product)
|
49
|
+
@icon = FactoryBot.create(:icon_upload)
|
50
|
+
@photo_1 = FactoryBot.create(:photo_upload)
|
51
|
+
@photo_2 = FactoryBot.create(:photo_upload)
|
52
52
|
end
|
53
53
|
|
54
54
|
describe "has_many" do
|
55
55
|
it do
|
56
|
-
@product.photo_uploads.must_equal []
|
56
|
+
_(@product.photo_uploads).must_equal []
|
57
57
|
@product.new_photo_uploads_uuids = [@photo_1.uuid, @photo_2.uuid]
|
58
58
|
@product.associate_photo_uploads
|
59
|
-
@product.photo_uploads.must_equal [@photo_1, @photo_2]
|
59
|
+
_(@product.photo_uploads).must_equal [@photo_1, @photo_2]
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
@@ -21,7 +21,7 @@ describe S3Relay::PrivateUrl do
|
|
21
21
|
time = Time.parse("2014-01-01 12:00am")
|
22
22
|
url = S3Relay::PrivateUrl.new(uuid, file, expires: time).generate
|
23
23
|
|
24
|
-
url.must_equal "https://
|
24
|
+
_(url).must_equal "https://s3.region.amazonaws.com/bucket/123-456-789/Crazy%20%2B%20c@t%20picture.png?AWSAccessKeyId=access-key-id&Expires=1388563200&Signature=8Kp5NL77iycg4CFFwxboo905t%2Fs%3D"
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -23,15 +23,15 @@ describe S3Relay::UploadPresigner do
|
|
23
23
|
|
24
24
|
data = S3Relay::UploadPresigner.new(expires: time).form_data
|
25
25
|
|
26
|
-
data["awsaccesskeyid"].must_equal "access-key-id"
|
27
|
-
data["x_amz_server_side_encryption"].must_equal "AES256"
|
28
|
-
data["key"].must_equal "#{uuid}/${filename}"
|
29
|
-
data["success_action_status"].must_equal "201"
|
30
|
-
data["acl"].must_equal "acl"
|
31
|
-
data["endpoint"].must_equal "https://
|
32
|
-
data["policy"].length.must_equal 400 # TODO: Improve this
|
33
|
-
data["signature"].length.must_equal 28 # TODO: Improve this
|
34
|
-
data["uuid"].must_equal uuid
|
26
|
+
_(data["awsaccesskeyid"]).must_equal "access-key-id"
|
27
|
+
_(data["x_amz_server_side_encryption"]).must_equal "AES256"
|
28
|
+
_(data["key"]).must_equal "#{uuid}/${filename}"
|
29
|
+
_(data["success_action_status"]).must_equal "201"
|
30
|
+
_(data["acl"]).must_equal "acl"
|
31
|
+
_(data["endpoint"]).must_equal "https://s3.region.amazonaws.com/bucket"
|
32
|
+
_(data["policy"].length).must_equal 400 # TODO: Improve this
|
33
|
+
_(data["signature"].length).must_equal 28 # TODO: Improve this
|
34
|
+
_(data["uuid"]).must_equal uuid
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -2,13 +2,13 @@ require "test_helper"
|
|
2
2
|
|
3
3
|
describe S3Relay::Upload do
|
4
4
|
before do
|
5
|
-
@upload =
|
5
|
+
@upload = FactoryBot.build(:upload)
|
6
6
|
end
|
7
7
|
|
8
8
|
describe "associations" do
|
9
9
|
describe "parent" do
|
10
10
|
it do
|
11
|
-
S3Relay::Upload.reflect_on_association(:parent).macro
|
11
|
+
_(S3Relay::Upload.reflect_on_association(:parent).macro)
|
12
12
|
.must_equal :belongs_to
|
13
13
|
end
|
14
14
|
end
|
@@ -17,35 +17,36 @@ describe S3Relay::Upload do
|
|
17
17
|
describe "validations" do
|
18
18
|
describe "uuid" do
|
19
19
|
it "validates presence" do
|
20
|
+
@upload.uuid = nil
|
20
21
|
@upload.valid?
|
21
|
-
@upload.errors[:uuid].must_include("can't be blank")
|
22
|
+
_(@upload.errors[:uuid]).must_include("can't be blank")
|
22
23
|
end
|
23
24
|
|
24
25
|
it "validates uniqueness" do
|
25
|
-
|
26
|
+
FactoryBot.create(:file_upload, uuid: @upload.uuid)
|
26
27
|
@upload.valid?
|
27
|
-
@upload.errors[:uuid].must_include("has already been taken")
|
28
|
+
_(@upload.errors[:uuid]).must_include("has already been taken")
|
28
29
|
end
|
29
30
|
end
|
30
31
|
|
31
32
|
describe "upload_type" do
|
32
33
|
it "validates presence" do
|
33
34
|
@upload.valid?
|
34
|
-
@upload.errors[:upload_type].must_include("can't be blank")
|
35
|
+
_(@upload.errors[:upload_type]).must_include("can't be blank")
|
35
36
|
end
|
36
37
|
end
|
37
38
|
|
38
39
|
describe "filename" do
|
39
40
|
it "validates presence" do
|
40
41
|
@upload.valid?
|
41
|
-
@upload.errors[:filename].must_include("can't be blank")
|
42
|
+
_(@upload.errors[:filename]).must_include("can't be blank")
|
42
43
|
end
|
43
44
|
end
|
44
45
|
|
45
46
|
describe "content_type" do
|
46
47
|
it "validates presence" do
|
47
48
|
@upload.valid?
|
48
|
-
@upload.errors[:content_type].must_include("can't be blank")
|
49
|
+
_(@upload.errors[:content_type]).must_include("can't be blank")
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
@@ -53,68 +54,68 @@ describe S3Relay::Upload do
|
|
53
54
|
it "validates presence" do
|
54
55
|
@upload.pending_at = nil
|
55
56
|
@upload.valid?
|
56
|
-
@upload.errors[:pending_at].must_include("can't be blank")
|
57
|
+
_(@upload.errors[:pending_at]).must_include("can't be blank")
|
57
58
|
end
|
58
59
|
end
|
59
60
|
end
|
60
61
|
|
61
62
|
describe "scopes" do
|
62
63
|
before do
|
63
|
-
@pending =
|
64
|
+
@pending = FactoryBot.build(:file_upload)
|
64
65
|
.tap { |u| u.save(validate: false) }
|
65
|
-
@imported =
|
66
|
+
@imported = FactoryBot.build(:upload, state: "imported")
|
66
67
|
.tap { |u| u.save(validate: false) }
|
67
68
|
end
|
68
69
|
|
69
70
|
describe "pending" do
|
70
71
|
it do
|
71
72
|
results = S3Relay::Upload.pending.all
|
72
|
-
results.must_include @pending
|
73
|
-
results.wont_include @imported
|
73
|
+
_(results).must_include @pending
|
74
|
+
_(results).wont_include @imported
|
74
75
|
end
|
75
76
|
end
|
76
77
|
|
77
78
|
describe "imported" do
|
78
79
|
it do
|
79
80
|
results = S3Relay::Upload.imported.all
|
80
|
-
results.wont_include @pending
|
81
|
-
results.must_include @imported
|
81
|
+
_(results).wont_include @pending
|
82
|
+
_(results).must_include @imported
|
82
83
|
end
|
83
84
|
end
|
84
85
|
end
|
85
86
|
|
86
87
|
describe "upon finalization" do
|
87
88
|
it do
|
88
|
-
@upload.state.must_equal "pending"
|
89
|
-
@upload.pending_at.wont_equal nil
|
89
|
+
_(@upload.state).must_equal "pending"
|
90
|
+
_(@upload.pending_at).wont_equal nil
|
90
91
|
end
|
91
92
|
end
|
92
93
|
|
93
94
|
describe "#pending?" do
|
94
|
-
it { @upload.pending
|
95
|
+
it { _(@upload.pending?).must_equal true }
|
95
96
|
end
|
96
97
|
|
97
98
|
describe "#imported" do
|
98
99
|
it do
|
99
100
|
@upload.state = "imported"
|
100
|
-
@upload.imported
|
101
|
+
_(@upload.imported?).must_equal true
|
101
102
|
end
|
102
103
|
end
|
103
104
|
|
104
105
|
describe "#mark_imported!" do
|
105
106
|
it do
|
106
107
|
@upload.mark_imported!
|
107
|
-
@upload.state.must_equal "imported"
|
108
|
-
@upload.imported_at.wont_equal nil
|
108
|
+
_(@upload.state).must_equal "imported"
|
109
|
+
_(@upload.imported_at).wont_equal nil
|
109
110
|
end
|
110
111
|
end
|
111
112
|
|
112
113
|
describe "#notify_parent" do
|
113
|
-
before { @upload =
|
114
|
+
before { @upload = FactoryBot.build(:file_upload) }
|
114
115
|
|
115
116
|
describe "when the parent is associated" do
|
116
117
|
it do
|
117
|
-
@product =
|
118
|
+
@product = FactoryBot.create(:product)
|
118
119
|
@upload.parent = @product
|
119
120
|
@product.expects(:import_upload)
|
120
121
|
@upload.save
|
@@ -134,7 +135,7 @@ describe S3Relay::Upload do
|
|
134
135
|
S3Relay::PrivateUrl.expects(:new).with(uuid, filename).returns(klass)
|
135
136
|
klass.expects(:generate).returns(url)
|
136
137
|
|
137
|
-
@upload.private_url.must_equal url
|
138
|
+
_(@upload.private_url).must_equal url
|
138
139
|
end
|
139
140
|
end
|
140
141
|
|