uploadcare-rails 1.2.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Rakefile +5 -16
- data/lib/generators/templates/uploadcare_config_template.erb +138 -0
- data/lib/generators/uploadcare_config_generator.rb +7 -4
- data/lib/uploadcare/errors/type_error.rb +7 -0
- data/lib/uploadcare/rails/action_view/uploadcare_include_tags.rb +48 -0
- data/lib/uploadcare/rails/action_view/uploadcare_uploader_tags.rb +57 -0
- data/lib/uploadcare/rails/active_record/mount_uploadcare_file.rb +62 -0
- data/lib/uploadcare/rails/active_record/mount_uploadcare_file_group.rb +58 -0
- data/lib/uploadcare/rails/api/rest/base.rb +14 -0
- data/lib/uploadcare/rails/api/rest/conversion_api.rb +42 -0
- data/lib/uploadcare/rails/api/rest/file_api.rb +69 -0
- data/lib/uploadcare/rails/api/rest/group_api.rb +48 -0
- data/lib/uploadcare/rails/api/rest/project_api.rb +27 -0
- data/lib/uploadcare/rails/api/rest/webhook_api.rb +45 -0
- data/lib/uploadcare/rails/api/upload/base.rb +13 -0
- data/lib/uploadcare/rails/api/upload/upload_api.rb +53 -0
- data/lib/uploadcare/rails/configuration.rb +57 -0
- data/lib/uploadcare/rails/engine.rb +13 -17
- data/lib/uploadcare/rails/jobs/delete_file_job.rb +14 -0
- data/lib/uploadcare/rails/jobs/store_file_job.rb +14 -0
- data/lib/uploadcare/rails/jobs/store_group_job.rb +14 -0
- data/lib/uploadcare/rails/objects/concerns/loadable.rb +46 -0
- data/lib/uploadcare/rails/objects/file.rb +40 -20
- data/lib/uploadcare/rails/objects/group.rb +51 -57
- data/lib/uploadcare/rails/services/files_count_extractor.rb +14 -0
- data/lib/uploadcare/rails/services/id_extractor.rb +15 -0
- data/lib/uploadcare/rails/transformations/image_transformations.rb +45 -0
- data/lib/uploadcare/rails/version.rb +3 -1
- data/lib/uploadcare/rails.rb +10 -0
- data/lib/uploadcare-rails.rb +27 -16
- data/spec/fixtures/kitten.jpeg +0 -0
- data/spec/fixtures/vcr_cassettes/conversion_api_convert_document.yml +62 -0
- data/spec/fixtures/vcr_cassettes/conversion_api_convert_document_with_error.yml +62 -0
- data/spec/fixtures/vcr_cassettes/conversion_api_convert_video.yml +62 -0
- data/spec/fixtures/vcr_cassettes/conversion_api_convert_video_with_error.yml +62 -0
- data/spec/fixtures/vcr_cassettes/conversion_api_get_document_conversion_status.yml +59 -0
- data/spec/fixtures/vcr_cassettes/conversion_api_get_video_conversion_status.yml +59 -0
- data/spec/fixtures/vcr_cassettes/file_api_copy_file.yml +60 -0
- data/spec/fixtures/vcr_cassettes/file_api_delete_file.yml +58 -0
- data/spec/fixtures/vcr_cassettes/file_api_delete_files.yml +58 -0
- data/spec/fixtures/vcr_cassettes/file_api_get_file.yml +58 -0
- data/spec/fixtures/vcr_cassettes/file_api_get_files.yml +61 -0
- data/spec/fixtures/vcr_cassettes/file_api_load_file.yml +57 -0
- data/spec/fixtures/vcr_cassettes/file_api_store_file.yml +58 -0
- data/spec/fixtures/vcr_cassettes/file_api_store_files.yml +57 -0
- data/spec/fixtures/vcr_cassettes/group_api_create_group.yml +57 -0
- data/spec/fixtures/vcr_cassettes/group_api_get_group.yml +52 -0
- data/spec/fixtures/vcr_cassettes/group_api_get_groups.yml +57 -0
- data/spec/fixtures/vcr_cassettes/group_api_store_group.yml +57 -0
- data/spec/fixtures/vcr_cassettes/project_api_get_project.yml +59 -0
- data/spec/fixtures/vcr_cassettes/upload_upload_many_files.yml +55 -0
- data/spec/fixtures/vcr_cassettes/upload_upload_one_file.yml +105 -0
- data/spec/fixtures/vcr_cassettes/upload_upload_one_file_from_cdn.yml +111 -0
- data/spec/fixtures/vcr_cassettes/webhook_api_create_webhook.yml +59 -0
- data/spec/fixtures/vcr_cassettes/webhook_api_delete_webhook.yml +57 -0
- data/spec/fixtures/vcr_cassettes/webhook_api_get_webhooks.yml +59 -0
- data/spec/fixtures/vcr_cassettes/webhook_api_update_webhook.yml +59 -0
- data/spec/generators/uploadcare_config_generator_spec.rb +18 -26
- data/spec/spec_helper.rb +17 -69
- data/spec/support/generators.rb +8 -5
- data/spec/support/vcr.rb +14 -0
- data/spec/tmp/config/initializers/uploadcare.rb +138 -0
- data/spec/uploadcare/rails/action_view/uploadcare_uploader_tags_spec.rb +40 -0
- data/spec/uploadcare/rails/action_view/uploadcare_widget_tags_spec.rb +46 -0
- data/spec/uploadcare/rails/active_record/mount_uploadcare_file_spec.rb +33 -0
- data/spec/uploadcare/rails/active_record/mount_uploadcare_group_spec.rb +32 -0
- data/spec/uploadcare/rails/api/rest/conversion_api_spec.rb +110 -0
- data/spec/uploadcare/rails/api/rest/file_api_spec.rb +85 -0
- data/spec/uploadcare/rails/api/rest/group_api_spec.rb +61 -0
- data/spec/uploadcare/rails/api/rest/project_api_spec.rb +33 -0
- data/spec/uploadcare/rails/api/rest/webhook_api_spec.rb +59 -0
- data/spec/uploadcare/rails/api/upload/upload_api_spec.rb +82 -0
- data/spec/uploadcare/rails/jobs/delete_file_job_spec.rb +15 -0
- data/spec/uploadcare/rails/jobs/store_file_job_spec.rb +15 -0
- data/spec/uploadcare/rails/jobs/store_group_job_spec.rb +15 -0
- data/spec/uploadcare/rails/objects/file_spec.rb +77 -0
- data/spec/uploadcare/rails/objects/group_spec.rb +87 -0
- data/spec/uploadcare/rails/services/id_extractor_spec.rb +26 -0
- data/spec/uploadcare/rails/transformations/image_transformations_spec.rb +120 -0
- data/spec/uploadcare/rails_spec.rb +7 -0
- metadata +129 -351
- data/config/initializers/uploadcare.rb +0 -26
- data/config/uploadcare_defaults.yml +0 -12
- data/lib/generators/templates/uploadcare_config_template.yml +0 -67
- data/lib/tasks/uploadcare_rails_tasks.rake +0 -4
- data/lib/uploadcare/rails/action_view/include_tags.rb +0 -47
- data/lib/uploadcare/rails/action_view/uploader_tags.rb +0 -76
- data/lib/uploadcare/rails/active_record/has_file.rb +0 -92
- data/lib/uploadcare/rails/active_record/has_group.rb +0 -89
- data/lib/uploadcare/rails/active_record/has_object.rb +0 -9
- data/lib/uploadcare/rails/formtastic/formtastic.rb +0 -73
- data/lib/uploadcare/rails/operations.rb +0 -57
- data/lib/uploadcare/rails/settings.rb +0 -81
- data/lib/uploadcare/rails/simple_form/simple_form.rb +0 -63
- data/spec/caching/file_caching_spec.rb +0 -26
- data/spec/caching/group_caching_spec.rb +0 -40
- data/spec/dummy/README.rdoc +0 -28
- data/spec/dummy/Rakefile +0 -6
- data/spec/dummy/app/assets/javascripts/application.js +0 -13
- data/spec/dummy/app/assets/javascripts/post_with_collections.js +0 -2
- data/spec/dummy/app/assets/javascripts/posts.js +0 -2
- data/spec/dummy/app/assets/javascripts/posts_with_collection_and_files.js +0 -2
- data/spec/dummy/app/assets/stylesheets/application.css +0 -13
- data/spec/dummy/app/assets/stylesheets/post_with_collections.css +0 -4
- data/spec/dummy/app/assets/stylesheets/posts.css +0 -4
- data/spec/dummy/app/assets/stylesheets/posts_with_collection_and_files.css +0 -4
- data/spec/dummy/app/assets/stylesheets/scaffold.css +0 -56
- data/spec/dummy/app/controllers/application_controller.rb +0 -5
- data/spec/dummy/app/controllers/post_with_collections_controller.rb +0 -58
- data/spec/dummy/app/controllers/posts_controller.rb +0 -58
- data/spec/dummy/app/controllers/posts_with_collection_and_files_controller.rb +0 -58
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/app/helpers/post_with_collections_helper.rb +0 -2
- data/spec/dummy/app/helpers/posts_helper.rb +0 -2
- data/spec/dummy/app/helpers/posts_with_collection_and_files_helper.rb +0 -2
- data/spec/dummy/app/models/post.rb +0 -4
- data/spec/dummy/app/models/post_with_collection.rb +0 -4
- data/spec/dummy/app/models/posts_with_collection_and_file.rb +0 -4
- data/spec/dummy/app/views/layouts/application.html.erb +0 -16
- data/spec/dummy/app/views/post_with_collections/_form.html.erb +0 -25
- data/spec/dummy/app/views/post_with_collections/edit.html.erb +0 -6
- data/spec/dummy/app/views/post_with_collections/index.html.erb +0 -29
- data/spec/dummy/app/views/post_with_collections/new.html.erb +0 -5
- data/spec/dummy/app/views/post_with_collections/show.html.erb +0 -14
- data/spec/dummy/app/views/post_with_collections/show.json.jbuilder +0 -1
- data/spec/dummy/app/views/posts/_form.html.erb +0 -31
- data/spec/dummy/app/views/posts/edit.html.erb +0 -6
- data/spec/dummy/app/views/posts/index.html.erb +0 -37
- data/spec/dummy/app/views/posts/new.html.erb +0 -5
- data/spec/dummy/app/views/posts/post.json.builder +0 -1
- data/spec/dummy/app/views/posts/show.html.erb +0 -15
- data/spec/dummy/app/views/posts_with_collection_and_files/_form.html.erb +0 -27
- data/spec/dummy/app/views/posts_with_collection_and_files/edit.html.erb +0 -6
- data/spec/dummy/app/views/posts_with_collection_and_files/index.html.erb +0 -25
- data/spec/dummy/app/views/posts_with_collection_and_files/new.html.erb +0 -5
- data/spec/dummy/app/views/posts_with_collection_and_files/show.html.erb +0 -4
- data/spec/dummy/app/views/posts_with_collection_and_files/show.json.jbuilder +0 -1
- data/spec/dummy/bin/bundle +0 -3
- data/spec/dummy/bin/rails +0 -4
- data/spec/dummy/bin/rake +0 -4
- data/spec/dummy/config/application.rb +0 -23
- data/spec/dummy/config/boot.rb +0 -4
- data/spec/dummy/config/database.yml +0 -25
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -29
- data/spec/dummy/config/environments/production.rb +0 -80
- data/spec/dummy/config/environments/test.rb +0 -36
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/dummy/config/initializers/formtastic.rb +0 -111
- data/spec/dummy/config/initializers/inflections.rb +0 -16
- data/spec/dummy/config/initializers/mime_types.rb +0 -5
- data/spec/dummy/config/initializers/secret_token.rb +0 -12
- data/spec/dummy/config/initializers/session_store.rb +0 -3
- data/spec/dummy/config/initializers/simple_form.rb +0 -167
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/en.yml +0 -23
- data/spec/dummy/config/locales/simple_form.en.yml +0 -31
- data/spec/dummy/config/routes.rb +0 -63
- data/spec/dummy/config/uploadcare.yml +0 -64
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/db/migrate/20171012001801_create_tables.rb +0 -27
- data/spec/dummy/db/migrate/20181001132710_add_other_file_to_post.rb +0 -8
- data/spec/dummy/db/migrate/20181001141434_add_other_file_to_post_with_collections.rb +0 -8
- data/spec/dummy/db/schema.rb +0 -39
- data/spec/dummy/lib/templates/erb/scaffold/_form.html.erb +0 -13
- data/spec/dummy/public/404.html +0 -58
- data/spec/dummy/public/422.html +0 -58
- data/spec/dummy/public/500.html +0 -57
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/helpers/form_helpers_has_file_spec.rb +0 -30
- data/spec/helpers/form_helpers_has_group_spec.rb +0 -30
- data/spec/helpers/form_helpers_spec.rb +0 -33
- data/spec/helpers/formtastic_spec.rb +0 -25
- data/spec/helpers/include_tags_spec.rb +0 -54
- data/spec/helpers/simple_form_spec.rb +0 -25
- data/spec/helpers/uploader_tags_spec.rb +0 -21
- data/spec/models/has_both_file_and_group_spec.rb +0 -43
- data/spec/models/has_file_spec.rb +0 -46
- data/spec/models/has_group_spec.rb +0 -57
- data/spec/models/has_several_files_spec.rb +0 -55
- data/spec/models/has_several_groups_spec.rb +0 -62
- data/spec/objects/file_spec.rb +0 -27
- data/spec/objects/group_spec.rb +0 -51
- data/spec/operations_spec.rb +0 -28
- data/spec/uploadcare/rails/settings_spec.rb +0 -136
- data/spec/uploadcare_rails_settings_spec.rb +0 -56
- data/spec/view.png +0 -0
- data/spec/view2.jpg +0 -0
@@ -0,0 +1,105 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://upload.uploadcare.com/from_url/
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: "-----------------------fa875849769142918ed86784184269700db9616835\r\nContent-Disposition:
|
9
|
+
form-data; name=\"pub_key\"\r\n\r\ndemopublickey\r\n-----------------------fa875849769142918ed86784184269700db9616835\r\nContent-Disposition:
|
10
|
+
form-data; name=\"source_url\"\r\n\r\nhttps://ucarecdn.com/c3328b8f-1b27-48ca-aebe-591924011efc/thumbnail_0.jpg\r\n-----------------------fa875849769142918ed86784184269700db9616835--\r\n"
|
11
|
+
headers:
|
12
|
+
User-Agent:
|
13
|
+
- UploadcareRuby/3.0.5/demopublickey (Ruby/2.7.2)
|
14
|
+
Content-Type:
|
15
|
+
- multipart/form-data; boundary=---------------------fa875849769142918ed86784184269700db9616835
|
16
|
+
Connection:
|
17
|
+
- close
|
18
|
+
Host:
|
19
|
+
- upload.uploadcare.com
|
20
|
+
response:
|
21
|
+
status:
|
22
|
+
code: 200
|
23
|
+
message: OK
|
24
|
+
headers:
|
25
|
+
Date:
|
26
|
+
- Fri, 23 Jul 2021 09:07:39 GMT
|
27
|
+
Content-Type:
|
28
|
+
- application/json
|
29
|
+
Content-Length:
|
30
|
+
- '63'
|
31
|
+
Connection:
|
32
|
+
- close
|
33
|
+
Server:
|
34
|
+
- nginx
|
35
|
+
Vary:
|
36
|
+
- Accept-Encoding
|
37
|
+
- Origin
|
38
|
+
Access-Control-Allow-Origin:
|
39
|
+
- "*"
|
40
|
+
Access-Control-Allow-Methods:
|
41
|
+
- OPTIONS, GET, POST
|
42
|
+
Access-Control-Allow-Headers:
|
43
|
+
- X-UC-User-Agent, X-PINGOTHER, DNT
|
44
|
+
Access-Control-Max-Age:
|
45
|
+
- '1'
|
46
|
+
Access-Control-Allow-Credentials:
|
47
|
+
- 'true'
|
48
|
+
X-Xss-Protection:
|
49
|
+
- 1; mode=block
|
50
|
+
X-Content-Type-Options:
|
51
|
+
- nosniff
|
52
|
+
body:
|
53
|
+
encoding: ASCII-8BIT
|
54
|
+
string: '{"type":"token","token":"1ebc721a-8c9f-430f-8e9d-e7fad554e9bd"}'
|
55
|
+
recorded_at: Fri, 23 Jul 2021 09:07:39 GMT
|
56
|
+
- request:
|
57
|
+
method: get
|
58
|
+
uri: https://upload.uploadcare.com/from_url/status/?token=1ebc721a-8c9f-430f-8e9d-e7fad554e9bd
|
59
|
+
body:
|
60
|
+
encoding: UTF-8
|
61
|
+
string: ''
|
62
|
+
headers:
|
63
|
+
User-Agent:
|
64
|
+
- UploadcareRuby/3.0.5/demopublickey (Ruby/2.7.2)
|
65
|
+
Connection:
|
66
|
+
- close
|
67
|
+
Host:
|
68
|
+
- upload.uploadcare.com
|
69
|
+
response:
|
70
|
+
status:
|
71
|
+
code: 200
|
72
|
+
message: OK
|
73
|
+
headers:
|
74
|
+
Date:
|
75
|
+
- Fri, 23 Jul 2021 09:07:40 GMT
|
76
|
+
Content-Type:
|
77
|
+
- application/json
|
78
|
+
Content-Length:
|
79
|
+
- '479'
|
80
|
+
Connection:
|
81
|
+
- close
|
82
|
+
Server:
|
83
|
+
- nginx
|
84
|
+
Vary:
|
85
|
+
- Accept-Encoding
|
86
|
+
- Origin
|
87
|
+
Access-Control-Allow-Origin:
|
88
|
+
- "*"
|
89
|
+
Access-Control-Allow-Methods:
|
90
|
+
- GET, POST, HEAD, OPTIONS
|
91
|
+
Access-Control-Allow-Headers:
|
92
|
+
- X-UC-User-Agent, X-PINGOTHER, DNT
|
93
|
+
Access-Control-Max-Age:
|
94
|
+
- '1'
|
95
|
+
Access-Control-Allow-Credentials:
|
96
|
+
- 'true'
|
97
|
+
X-Xss-Protection:
|
98
|
+
- 1; mode=block
|
99
|
+
X-Content-Type-Options:
|
100
|
+
- nosniff
|
101
|
+
body:
|
102
|
+
encoding: ASCII-8BIT
|
103
|
+
string: '{"size":5902,"total":5902,"done":5902,"uuid":"acd4302e-23b9-424a-9a26-9899f2d4e29d","file_id":"acd4302e-23b9-424a-9a26-9899f2d4e29d","original_filename":"thumbnail_0.jpg","is_image":true,"is_stored":false,"image_info":{"width":600,"height":400,"format":"JPEG","color_mode":"RGB","geo_location":null,"orientation":null,"dpi":null,"datetime_original":null,"sequence":false},"video_info":null,"is_ready":true,"filename":"thumbnail_0.jpg","mime_type":"image/jpeg","status":"success"}'
|
104
|
+
recorded_at: Fri, 23 Jul 2021 09:07:40 GMT
|
105
|
+
recorded_with: VCR 6.0.0
|
@@ -0,0 +1,111 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://upload.uploadcare.com/base/
|
6
|
+
body:
|
7
|
+
encoding: ASCII-8BIT
|
8
|
+
string: !binary |-
|
9
|
+
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
|
10
|
+
headers:
|
11
|
+
User-Agent:
|
12
|
+
- UploadcareRuby/3.0.5/demopublickey (Ruby/2.7.2)
|
13
|
+
Content-Type:
|
14
|
+
- multipart/form-data; boundary=---------------------7c58705c4247e04dd044caf908848f6707c795eee4
|
15
|
+
Connection:
|
16
|
+
- close
|
17
|
+
Host:
|
18
|
+
- upload.uploadcare.com
|
19
|
+
response:
|
20
|
+
status:
|
21
|
+
code: 200
|
22
|
+
message: OK
|
23
|
+
headers:
|
24
|
+
Date:
|
25
|
+
- Fri, 23 Jul 2021 09:07:37 GMT
|
26
|
+
Content-Type:
|
27
|
+
- application/json
|
28
|
+
Content-Length:
|
29
|
+
- '54'
|
30
|
+
Connection:
|
31
|
+
- close
|
32
|
+
Server:
|
33
|
+
- nginx
|
34
|
+
Vary:
|
35
|
+
- Accept-Encoding
|
36
|
+
- Origin
|
37
|
+
Access-Control-Allow-Origin:
|
38
|
+
- "*"
|
39
|
+
Access-Control-Allow-Methods:
|
40
|
+
- POST, OPTIONS
|
41
|
+
Access-Control-Allow-Headers:
|
42
|
+
- X-UC-User-Agent, X-PINGOTHER, DNT
|
43
|
+
Access-Control-Max-Age:
|
44
|
+
- '1'
|
45
|
+
Access-Control-Allow-Credentials:
|
46
|
+
- 'true'
|
47
|
+
X-Xss-Protection:
|
48
|
+
- 1; mode=block
|
49
|
+
X-Content-Type-Options:
|
50
|
+
- nosniff
|
51
|
+
body:
|
52
|
+
encoding: ASCII-8BIT
|
53
|
+
string: '{"kitten.jpeg":"f79bb2a1-fdcc-4a02-9691-5c21868e7b84"}'
|
54
|
+
recorded_at: Fri, 23 Jul 2021 09:07:37 GMT
|
55
|
+
- request:
|
56
|
+
method: get
|
57
|
+
uri: https://api.uploadcare.com/files/f79bb2a1-fdcc-4a02-9691-5c21868e7b84/
|
58
|
+
body:
|
59
|
+
encoding: UTF-8
|
60
|
+
string: ''
|
61
|
+
headers:
|
62
|
+
Content-Type:
|
63
|
+
- application/json
|
64
|
+
Accept:
|
65
|
+
- application/vnd.uploadcare-v0.5+json
|
66
|
+
User-Agent:
|
67
|
+
- UploadcareRuby/3.0.5/demopublickey (Ruby/2.7.2)
|
68
|
+
Date:
|
69
|
+
- Fri, 23 Jul 2021 09:07:37 GMT
|
70
|
+
Authorization:
|
71
|
+
- Uploadcare demopublickey:5314d52b4dfa9524e91a721fc9d35864a269b9b7
|
72
|
+
Connection:
|
73
|
+
- close
|
74
|
+
Host:
|
75
|
+
- api.uploadcare.com
|
76
|
+
response:
|
77
|
+
status:
|
78
|
+
code: 200
|
79
|
+
message: OK
|
80
|
+
headers:
|
81
|
+
Date:
|
82
|
+
- Fri, 23 Jul 2021 09:07:38 GMT
|
83
|
+
Content-Type:
|
84
|
+
- application/vnd.uploadcare-v0.5+json
|
85
|
+
Content-Length:
|
86
|
+
- '614'
|
87
|
+
Connection:
|
88
|
+
- close
|
89
|
+
Server:
|
90
|
+
- nginx
|
91
|
+
Warning:
|
92
|
+
- '199 Miscellaneous warning: You are using the demo project'
|
93
|
+
Access-Control-Allow-Origin:
|
94
|
+
- https://uploadcare.com
|
95
|
+
Vary:
|
96
|
+
- Accept
|
97
|
+
Allow:
|
98
|
+
- DELETE, GET, HEAD, OPTIONS
|
99
|
+
X-Xss-Protection:
|
100
|
+
- 1; mode=block
|
101
|
+
X-Content-Type-Options:
|
102
|
+
- nosniff
|
103
|
+
X-Frame-Options:
|
104
|
+
- SAMEORIGIN
|
105
|
+
X-Robots-Tag:
|
106
|
+
- noindex, nofollow, nosnippet, noarchive
|
107
|
+
body:
|
108
|
+
encoding: ASCII-8BIT
|
109
|
+
string: '{"datetime_removed":null,"datetime_stored":null,"datetime_uploaded":"2021-07-23T09:07:37.419795Z","image_info":{"width":50,"height":50,"format":"JPEG","color_mode":"RGB","geo_location":null,"orientation":null,"dpi":[96,96],"datetime_original":null,"sequence":false},"is_image":true,"is_ready":true,"mime_type":"application/octet-stream","original_file_url":"https://ucarecdn.com/f79bb2a1-fdcc-4a02-9691-5c21868e7b84/kitten.jpeg","original_filename":"kitten.jpeg","size":1290,"url":"https://api.uploadcare.com/files/f79bb2a1-fdcc-4a02-9691-5c21868e7b84/","uuid":"f79bb2a1-fdcc-4a02-9691-5c21868e7b84","source":null}'
|
110
|
+
recorded_at: Fri, 23 Jul 2021 09:07:39 GMT
|
111
|
+
recorded_with: VCR 6.0.0
|
@@ -0,0 +1,59 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://api.uploadcare.com/webhooks/
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{"target_url":"https://ucarecdn.com/3542c513-5cf4-4adb-97b0-bfa7fbd31fb5/11.png","event":"file.uploaded","is_active":true}'
|
9
|
+
headers:
|
10
|
+
Content-Type:
|
11
|
+
- application/json
|
12
|
+
Accept:
|
13
|
+
- application/vnd.uploadcare-v0.5+json
|
14
|
+
User-Agent:
|
15
|
+
- UploadcareRuby/3.0.5/demopublickey (Ruby/2.7.0)
|
16
|
+
Date:
|
17
|
+
- Thu, 22 Jul 2021 10:18:34 GMT
|
18
|
+
Authorization:
|
19
|
+
- Uploadcare demopublickey:709d7443bac77a68415330c5786972c57f9ddb16
|
20
|
+
Connection:
|
21
|
+
- close
|
22
|
+
Host:
|
23
|
+
- api.uploadcare.com
|
24
|
+
response:
|
25
|
+
status:
|
26
|
+
code: 201
|
27
|
+
message: Created
|
28
|
+
headers:
|
29
|
+
Date:
|
30
|
+
- Thu, 22 Jul 2021 10:18:35 GMT
|
31
|
+
Content-Type:
|
32
|
+
- application/vnd.uploadcare-v0.5+json
|
33
|
+
Content-Length:
|
34
|
+
- '228'
|
35
|
+
Connection:
|
36
|
+
- close
|
37
|
+
Server:
|
38
|
+
- nginx
|
39
|
+
Warning:
|
40
|
+
- '199 Miscellaneous warning: You are using the demo project'
|
41
|
+
Access-Control-Allow-Origin:
|
42
|
+
- https://uploadcare.com
|
43
|
+
Vary:
|
44
|
+
- Accept
|
45
|
+
Allow:
|
46
|
+
- GET, HEAD, OPTIONS, POST
|
47
|
+
X-Xss-Protection:
|
48
|
+
- 1; mode=block
|
49
|
+
X-Content-Type-Options:
|
50
|
+
- nosniff
|
51
|
+
X-Frame-Options:
|
52
|
+
- SAMEORIGIN
|
53
|
+
X-Robots-Tag:
|
54
|
+
- noindex, nofollow, nosnippet, noarchive
|
55
|
+
body:
|
56
|
+
encoding: ASCII-8BIT
|
57
|
+
string: '{"id":811135,"created":"2021-07-22T10:18:35.149983Z","updated":"2021-07-22T10:18:35.150005Z","event":"file.uploaded","target_url":"https://ucarecdn.com/3542c513-5cf4-4adb-97b0-bfa7fbd31fb5/11.png","project":159,"is_active":true}'
|
58
|
+
recorded_at: Thu, 22 Jul 2021 10:18:35 GMT
|
59
|
+
recorded_with: VCR 6.0.0
|
@@ -0,0 +1,57 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://api.uploadcare.com/webhooks/unsubscribe/
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{"target_url":"https://ucarecdn.com/3542c513-5cf4-4adb-97b0-bfa7fbd31fb5/11.png"}'
|
9
|
+
headers:
|
10
|
+
Content-Type:
|
11
|
+
- application/json
|
12
|
+
Accept:
|
13
|
+
- application/vnd.uploadcare-v0.5+json
|
14
|
+
User-Agent:
|
15
|
+
- UploadcareRuby/3.0.5/demopublickey (Ruby/2.7.0)
|
16
|
+
Date:
|
17
|
+
- Thu, 22 Jul 2021 10:34:48 GMT
|
18
|
+
Authorization:
|
19
|
+
- Uploadcare demopublickey:14eaf922015dd5ccbb791188ee7bc8df64bb3e60
|
20
|
+
Connection:
|
21
|
+
- close
|
22
|
+
Host:
|
23
|
+
- api.uploadcare.com
|
24
|
+
response:
|
25
|
+
status:
|
26
|
+
code: 204
|
27
|
+
message: No Content
|
28
|
+
headers:
|
29
|
+
Date:
|
30
|
+
- Thu, 22 Jul 2021 10:34:49 GMT
|
31
|
+
Content-Length:
|
32
|
+
- '0'
|
33
|
+
Connection:
|
34
|
+
- close
|
35
|
+
Server:
|
36
|
+
- nginx
|
37
|
+
Warning:
|
38
|
+
- '199 Miscellaneous warning: You are using the demo project'
|
39
|
+
Access-Control-Allow-Origin:
|
40
|
+
- https://uploadcare.com
|
41
|
+
Vary:
|
42
|
+
- Accept
|
43
|
+
Allow:
|
44
|
+
- OPTIONS, POST
|
45
|
+
X-Xss-Protection:
|
46
|
+
- 1; mode=block
|
47
|
+
X-Content-Type-Options:
|
48
|
+
- nosniff
|
49
|
+
X-Frame-Options:
|
50
|
+
- SAMEORIGIN
|
51
|
+
X-Robots-Tag:
|
52
|
+
- noindex, nofollow, nosnippet, noarchive
|
53
|
+
body:
|
54
|
+
encoding: ASCII-8BIT
|
55
|
+
string: ''
|
56
|
+
recorded_at: Thu, 22 Jul 2021 10:34:50 GMT
|
57
|
+
recorded_with: VCR 6.0.0
|
@@ -0,0 +1,59 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: https://api.uploadcare.com/webhooks/
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Content-Type:
|
11
|
+
- application/json
|
12
|
+
Accept:
|
13
|
+
- application/vnd.uploadcare-v0.5+json
|
14
|
+
User-Agent:
|
15
|
+
- UploadcareRuby/3.0.5/demopublickey (Ruby/2.7.0)
|
16
|
+
Date:
|
17
|
+
- Thu, 22 Jul 2021 10:18:33 GMT
|
18
|
+
Authorization:
|
19
|
+
- Uploadcare demopublickey:4b73a3f9542c892973c0a85b596da8f305409e60
|
20
|
+
Connection:
|
21
|
+
- close
|
22
|
+
Host:
|
23
|
+
- api.uploadcare.com
|
24
|
+
response:
|
25
|
+
status:
|
26
|
+
code: 200
|
27
|
+
message: OK
|
28
|
+
headers:
|
29
|
+
Date:
|
30
|
+
- Thu, 22 Jul 2021 10:18:34 GMT
|
31
|
+
Content-Type:
|
32
|
+
- application/vnd.uploadcare-v0.5+json
|
33
|
+
Content-Length:
|
34
|
+
- '460'
|
35
|
+
Connection:
|
36
|
+
- close
|
37
|
+
Server:
|
38
|
+
- nginx
|
39
|
+
Warning:
|
40
|
+
- '199 Miscellaneous warning: You are using the demo project'
|
41
|
+
Access-Control-Allow-Origin:
|
42
|
+
- https://uploadcare.com
|
43
|
+
Vary:
|
44
|
+
- Accept
|
45
|
+
Allow:
|
46
|
+
- GET, HEAD, OPTIONS, POST
|
47
|
+
X-Xss-Protection:
|
48
|
+
- 1; mode=block
|
49
|
+
X-Content-Type-Options:
|
50
|
+
- nosniff
|
51
|
+
X-Frame-Options:
|
52
|
+
- SAMEORIGIN
|
53
|
+
X-Robots-Tag:
|
54
|
+
- noindex, nofollow, nosnippet, noarchive
|
55
|
+
body:
|
56
|
+
encoding: ASCII-8BIT
|
57
|
+
string: '[{"id":811133,"created":"2021-07-22T10:13:57.596063Z","updated":"2021-07-22T10:13:57.596135Z","event":"file.uploaded","target_url":"https://ucarecdn.com/3542c513-5cf4-4adb-97b0-bfa7fbd31fb5/170.png","project":159,"is_active":true},{"id":811134,"created":"2021-07-22T10:15:44.309733Z","updated":"2021-07-22T10:15:44.309757Z","event":"file.uploaded","target_url":"https://ucarecdn.com/3542c513-5cf4-4adb-97b0-bfa7fbd31fb5/10.png","project":159,"is_active":true}]'
|
58
|
+
recorded_at: Thu, 22 Jul 2021 10:18:34 GMT
|
59
|
+
recorded_with: VCR 6.0.0
|
@@ -0,0 +1,59 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://api.uploadcare.com/webhooks/811134/
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{"target_url":"https://ucarecdn.com/3542c513-5cf4-4adb-97b0-bfa7fbd31fb5/11.png","is_active":false}'
|
9
|
+
headers:
|
10
|
+
Content-Type:
|
11
|
+
- application/json
|
12
|
+
Accept:
|
13
|
+
- application/vnd.uploadcare-v0.5+json
|
14
|
+
User-Agent:
|
15
|
+
- UploadcareRuby/3.0.5/demopublickey (Ruby/2.7.0)
|
16
|
+
Date:
|
17
|
+
- Thu, 22 Jul 2021 10:30:17 GMT
|
18
|
+
Authorization:
|
19
|
+
- Uploadcare demopublickey:3767a47a86fdf55c296b51b8cf94f18602fc2987
|
20
|
+
Connection:
|
21
|
+
- close
|
22
|
+
Host:
|
23
|
+
- api.uploadcare.com
|
24
|
+
response:
|
25
|
+
status:
|
26
|
+
code: 200
|
27
|
+
message: OK
|
28
|
+
headers:
|
29
|
+
Date:
|
30
|
+
- Thu, 22 Jul 2021 10:30:18 GMT
|
31
|
+
Content-Type:
|
32
|
+
- application/vnd.uploadcare-v0.5+json
|
33
|
+
Content-Length:
|
34
|
+
- '229'
|
35
|
+
Connection:
|
36
|
+
- close
|
37
|
+
Server:
|
38
|
+
- nginx
|
39
|
+
Warning:
|
40
|
+
- '199 Miscellaneous warning: You are using the demo project'
|
41
|
+
Access-Control-Allow-Origin:
|
42
|
+
- https://uploadcare.com
|
43
|
+
Vary:
|
44
|
+
- Accept
|
45
|
+
Allow:
|
46
|
+
- OPTIONS, POST
|
47
|
+
X-Xss-Protection:
|
48
|
+
- 1; mode=block
|
49
|
+
X-Content-Type-Options:
|
50
|
+
- nosniff
|
51
|
+
X-Frame-Options:
|
52
|
+
- SAMEORIGIN
|
53
|
+
X-Robots-Tag:
|
54
|
+
- noindex, nofollow, nosnippet, noarchive
|
55
|
+
body:
|
56
|
+
encoding: ASCII-8BIT
|
57
|
+
string: '{"id":811134,"created":"2021-07-22T10:15:44.309733Z","updated":"2021-07-22T10:30:18.148061Z","event":"file.uploaded","target_url":"https://ucarecdn.com/3542c513-5cf4-4adb-97b0-bfa7fbd31fb5/11.png","project":159,"is_active":false}'
|
58
|
+
recorded_at: Thu, 22 Jul 2021 10:30:18 GMT
|
59
|
+
recorded_with: VCR 6.0.0
|
@@ -1,39 +1,31 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require_relative '../support/generators'
|
3
4
|
require 'generators/uploadcare_config_generator'
|
4
5
|
|
5
|
-
RSpec.describe UploadcareConfigGenerator, :
|
6
|
+
RSpec.describe UploadcareConfigGenerator, type: :generator do
|
6
7
|
destination File.expand_path('../tmp', __dir__)
|
7
|
-
|
8
|
-
let(:
|
9
|
-
{
|
10
|
-
"public_key"=>"demopublickey",
|
11
|
-
"private_key"=>"demoprivatekey",
|
12
|
-
"live"=>true, "cache_files"=>true,
|
13
|
-
"cache_groups"=>true,
|
14
|
-
"store_after_save"=>true,
|
15
|
-
"delete_after_destroy"=>true,
|
16
|
-
}
|
17
|
-
end
|
8
|
+
|
9
|
+
let(:config_file_path) { 'spec/tmp/config/initializers/uploadcare.rb' }
|
18
10
|
|
19
11
|
before do
|
20
12
|
prepare_destination
|
21
|
-
expect(File.exists?(config_file_path)).to be(false)
|
22
|
-
run_generator
|
23
13
|
end
|
24
14
|
|
25
|
-
it
|
26
|
-
expect(File.
|
15
|
+
it 'checks that no config exists before the generator run' do
|
16
|
+
expect(File.exist?(config_file_path)).to be(false)
|
27
17
|
end
|
28
18
|
|
29
|
-
|
30
|
-
|
31
|
-
"defaults" => defaults,
|
32
|
-
"development" => defaults,
|
33
|
-
"production" => defaults,
|
34
|
-
"test" => defaults,
|
35
|
-
)
|
36
|
-
end
|
37
|
-
end
|
19
|
+
context 'when run the generator' do
|
20
|
+
before { run_generator }
|
38
21
|
|
22
|
+
it 'generates the config file' do
|
23
|
+
run_generator
|
24
|
+
expect(File.exist?(config_file_path)).to be(true)
|
25
|
+
end
|
39
26
|
|
27
|
+
it 'checks that the config file contains the :configure method call' do
|
28
|
+
expect(File.open(config_file_path).read).to match(/Uploadcare::Rails.configure do |config|/)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,78 +1,26 @@
|
|
1
|
-
#
|
2
|
-
ENV['RAILS_ENV'] ||= 'test'
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
|
3
|
+
require 'rspec'
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'uploadcare/rails'
|
6
|
+
require 'api_struct'
|
7
|
+
require 'uploadcare'
|
8
|
+
require 'action_view'
|
5
9
|
|
6
|
-
|
7
|
-
require File.expand_path("../dummy/config/environment", __FILE__)
|
8
|
-
require 'rspec/rails'
|
9
|
-
require 'rspec/autorun'
|
10
|
-
require 'vcr'
|
11
|
-
|
12
|
-
# Requires supporting ruby files with custom matchers and macros, etc,
|
13
|
-
# in spec/support/ and its subdirectories.
|
14
|
-
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
|
15
|
-
|
16
|
-
@file = File.open(File.join(File.dirname(__FILE__), 'view.png'))
|
17
|
-
@uploaded_file = UPLOADCARE_SETTINGS.api.upload(@file)
|
18
|
-
@file_cdn_url = @uploaded_file.cdn_url
|
19
|
-
|
20
|
-
@file2 = File.open(File.join(File.dirname(__FILE__), 'view2.jpg'))
|
21
|
-
@uploaded_file2 = UPLOADCARE_SETTINGS.api.upload(@file2)
|
22
|
-
@file2_cdn_url = @uploaded_file2.cdn_url
|
23
|
-
|
24
|
-
@files_ary = [@file, @file2]
|
25
|
-
@files_ary2 = [@file, @file2]
|
26
|
-
@files = UPLOADCARE_SETTINGS.api.upload @files_ary
|
27
|
-
@files2 = UPLOADCARE_SETTINGS.api.upload @files_ary2
|
28
|
-
@uploaded_group = UPLOADCARE_SETTINGS.api.create_group @files
|
29
|
-
@uploaded_group2 = UPLOADCARE_SETTINGS.api.create_group @files2
|
30
|
-
@group_cdn_url = @uploaded_group.cdn_url
|
31
|
-
@group2_cdn_url = @uploaded_group2.cdn_url
|
32
|
-
|
33
|
-
GROUP_CDN_URL = @group_cdn_url
|
34
|
-
GROUP_2_CDN_URL = @group2_cdn_url
|
35
|
-
FILE_CDN_URL = @file_cdn_url
|
36
|
-
FILE_2_CDN_URL = @file2_cdn_url
|
10
|
+
Dir[File.expand_path(File.join(File.dirname(__FILE__), 'support', '**', '*.rb'))].sort.each { |f| require f }
|
37
11
|
|
38
12
|
RSpec.configure do |config|
|
39
|
-
#
|
40
|
-
|
41
|
-
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
42
|
-
#
|
43
|
-
# config.mock_with :mocha
|
44
|
-
# config.mock_with :flexmock
|
45
|
-
# config.mock_with :rr
|
46
|
-
|
47
|
-
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
48
|
-
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
13
|
+
# Enable flags like --only-failures and --next-failure
|
14
|
+
config.example_status_persistence_file_path = '.rspec_status'
|
49
15
|
|
50
|
-
#
|
51
|
-
|
52
|
-
# instead of true.
|
53
|
-
config.use_transactional_fixtures = true
|
16
|
+
# Disable RSpec exposing methods globally on `Module` and `main`
|
17
|
+
config.disable_monkey_patching!
|
54
18
|
|
55
|
-
|
56
|
-
# automatically. This will be the default behavior in future versions of
|
57
|
-
# rspec-rails.
|
58
|
-
config.infer_base_class_for_anonymous_controllers = false
|
59
|
-
config.infer_spec_type_from_file_location!
|
60
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
61
|
-
# Run specs in random order to surface order dependencies. If you find an
|
62
|
-
# order dependency and want to debug it, you can fix the order by providing
|
63
|
-
# the seed, which is printed after each run.
|
64
|
-
# --seed 1234
|
65
|
-
# config.order = "random"
|
19
|
+
config.expose_dsl_globally = true
|
66
20
|
|
67
|
-
|
68
|
-
c.
|
69
|
-
c.hook_into :webmock
|
70
|
-
c.debug_logger = File.open('vcs.log', 'w')
|
71
|
-
c.default_cassette_options = {
|
72
|
-
match_requests_on: %i(method host path)
|
73
|
-
}
|
74
|
-
c.default_cassette_options = { record: :new_episodes }
|
75
|
-
c.configure_rspec_metadata!
|
21
|
+
config.expect_with :rspec do |c|
|
22
|
+
c.syntax = :expect
|
76
23
|
end
|
77
|
-
end
|
78
24
|
|
25
|
+
config.include ActionView::Helpers, type: :helper
|
26
|
+
end
|
data/spec/support/generators.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rails/generators/test_case'
|
2
4
|
|
3
5
|
module Uploadcare
|
@@ -10,23 +12,24 @@ module Uploadcare
|
|
10
12
|
|
11
13
|
self.test_case = Class.new(::Rails::Generators::TestCase) do
|
12
14
|
def fake_test_case; end
|
15
|
+
|
13
16
|
def add_assertion; end
|
14
17
|
end
|
15
|
-
self.test_case_instance =
|
16
|
-
|
18
|
+
self.test_case_instance = test_case.new(:fake_test_case)
|
19
|
+
test_case.generator_class = described_class
|
17
20
|
end
|
18
21
|
|
19
22
|
def prepare_destination
|
20
|
-
|
23
|
+
test_case_instance.send :prepare_destination
|
21
24
|
end
|
22
25
|
|
23
26
|
def run_generator
|
24
|
-
|
27
|
+
test_case_instance.run_generator
|
25
28
|
end
|
26
29
|
|
27
30
|
module ClassMethods
|
28
31
|
def destination(path)
|
29
|
-
|
32
|
+
test_case.destination_root = path
|
30
33
|
end
|
31
34
|
end
|
32
35
|
end
|
data/spec/support/vcr.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'vcr'
|
5
|
+
|
6
|
+
VCR.configure do |config|
|
7
|
+
config.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
|
8
|
+
config.hook_into :webmock
|
9
|
+
config.before_record do |i|
|
10
|
+
if i.request.body && i.request.body.size > 1024 * 1024
|
11
|
+
i.request.body = "Big string (#{i.request.body.size / (1024 * 1024)}) MB"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|