uploadcare-rails 3.2.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/lib/uploadcare/rails/api/rest/base.rb +3 -2
  3. data/lib/uploadcare/rails/api/upload/base.rb +2 -0
  4. data/lib/uploadcare/rails/configuration.rb +3 -1
  5. data/lib/uploadcare/rails/transformations/image_transformations.rb +1 -1
  6. data/lib/uploadcare/rails/version.rb +1 -1
  7. metadata +28 -139
  8. data/spec/fixtures/kitten.jpeg +0 -0
  9. data/spec/fixtures/vcr_cassettes/conversion_api_convert_document.yml +0 -62
  10. data/spec/fixtures/vcr_cassettes/conversion_api_convert_document_with_error.yml +0 -62
  11. data/spec/fixtures/vcr_cassettes/conversion_api_convert_video.yml +0 -62
  12. data/spec/fixtures/vcr_cassettes/conversion_api_convert_video_with_error.yml +0 -62
  13. data/spec/fixtures/vcr_cassettes/conversion_api_get_document_conversion_status.yml +0 -59
  14. data/spec/fixtures/vcr_cassettes/conversion_api_get_video_conversion_status.yml +0 -59
  15. data/spec/fixtures/vcr_cassettes/file_api_copy_file.yml +0 -60
  16. data/spec/fixtures/vcr_cassettes/file_api_delete_file.yml +0 -61
  17. data/spec/fixtures/vcr_cassettes/file_api_delete_files.yml +0 -58
  18. data/spec/fixtures/vcr_cassettes/file_api_get_file.yml +0 -61
  19. data/spec/fixtures/vcr_cassettes/file_api_get_files.yml +0 -61
  20. data/spec/fixtures/vcr_cassettes/file_api_load_file.yml +0 -57
  21. data/spec/fixtures/vcr_cassettes/file_api_store_file.yml +0 -61
  22. data/spec/fixtures/vcr_cassettes/file_api_store_files.yml +0 -57
  23. data/spec/fixtures/vcr_cassettes/group_api_create_group.yml +0 -61
  24. data/spec/fixtures/vcr_cassettes/group_api_get_group.yml +0 -56
  25. data/spec/fixtures/vcr_cassettes/group_api_get_groups.yml +0 -57
  26. data/spec/fixtures/vcr_cassettes/group_api_store_group.yml +0 -177
  27. data/spec/fixtures/vcr_cassettes/project_api_get_project.yml +0 -59
  28. data/spec/fixtures/vcr_cassettes/upload_upload_many_files.yml +0 -59
  29. data/spec/fixtures/vcr_cassettes/upload_upload_one_file.yml +0 -105
  30. data/spec/fixtures/vcr_cassettes/upload_upload_one_file_from_cdn.yml +0 -111
  31. data/spec/fixtures/vcr_cassettes/webhook_api_create_webhook.yml +0 -59
  32. data/spec/fixtures/vcr_cassettes/webhook_api_delete_webhook.yml +0 -59
  33. data/spec/fixtures/vcr_cassettes/webhook_api_get_webhooks.yml +0 -59
  34. data/spec/fixtures/vcr_cassettes/webhook_api_update_webhook.yml +0 -59
  35. data/spec/generators/uploadcare_config_generator_spec.rb +0 -31
  36. data/spec/spec_helper.rb +0 -27
  37. data/spec/support/generators.rb +0 -41
  38. data/spec/support/vcr.rb +0 -14
  39. data/spec/uploadcare/rails/action_view/uploadcare_uploader_tags_spec.rb +0 -40
  40. data/spec/uploadcare/rails/action_view/uploadcare_widget_tags_spec.rb +0 -46
  41. data/spec/uploadcare/rails/active_record/mount_uploadcare_file_spec.rb +0 -33
  42. data/spec/uploadcare/rails/active_record/mount_uploadcare_group_spec.rb +0 -32
  43. data/spec/uploadcare/rails/api/rest/conversion_api_spec.rb +0 -110
  44. data/spec/uploadcare/rails/api/rest/file_api_spec.rb +0 -76
  45. data/spec/uploadcare/rails/api/rest/group_api_spec.rb +0 -61
  46. data/spec/uploadcare/rails/api/rest/project_api_spec.rb +0 -33
  47. data/spec/uploadcare/rails/api/rest/webhook_api_spec.rb +0 -67
  48. data/spec/uploadcare/rails/api/upload/upload_api_spec.rb +0 -82
  49. data/spec/uploadcare/rails/jobs/delete_file_job_spec.rb +0 -15
  50. data/spec/uploadcare/rails/jobs/store_file_job_spec.rb +0 -15
  51. data/spec/uploadcare/rails/jobs/store_group_job_spec.rb +0 -15
  52. data/spec/uploadcare/rails/objects/file_spec.rb +0 -77
  53. data/spec/uploadcare/rails/objects/group_spec.rb +0 -65
  54. data/spec/uploadcare/rails/services/id_extractor_spec.rb +0 -26
  55. data/spec/uploadcare/rails/transformations/image_transformations_spec.rb +0 -120
  56. data/spec/uploadcare/rails_spec.rb +0 -7
@@ -1,111 +0,0 @@
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.7+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.7+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
@@ -1,59 +0,0 @@
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.7+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.7+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
@@ -1,59 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: delete
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.7+json
14
- User-Agent:
15
- - UploadcareRuby/4.1.0/demopublickey (Ruby/3.0.0)
16
- Date:
17
- - Sun, 25 Dec 2022 12:06:29 GMT
18
- Authorization:
19
- - Uploadcare demopublickey:642d9dcfc0f5224025b6f0bfda0e4beb7c175a70
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
- - Sun, 25 Dec 2022 12:06:30 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
- - DELETE, OPTIONS
45
- X-Xss-Protection:
46
- - 1; mode=block
47
- X-Content-Type-Options:
48
- - nosniff
49
- X-Uploadcare-Request-Id:
50
- - fd270a55-41e5-49da-8870-ab5e9308a8a2
51
- X-Frame-Options:
52
- - SAMEORIGIN
53
- X-Robots-Tag:
54
- - noindex, nofollow, nosnippet, noarchive
55
- body:
56
- encoding: ASCII-8BIT
57
- string: ''
58
- recorded_at: Sun, 25 Dec 2022 12:06:30 GMT
59
- recorded_with: VCR 6.1.0
@@ -1,59 +0,0 @@
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.7+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.7+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
@@ -1,59 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: put
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.7+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.7+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, PUT
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,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative '../support/generators'
4
- require 'generators/uploadcare_config_generator'
5
-
6
- RSpec.describe UploadcareConfigGenerator, type: :generator do
7
- destination File.expand_path('../tmp', __dir__)
8
-
9
- let(:config_file_path) { 'spec/tmp/config/initializers/uploadcare.rb' }
10
-
11
- before do
12
- prepare_destination
13
- end
14
-
15
- it 'checks that no config exists before the generator run' do
16
- expect(File.exist?(config_file_path)).to be(false)
17
- end
18
-
19
- context 'when run the generator' do
20
- before { run_generator }
21
-
22
- it 'generates the config file' do
23
- run_generator
24
- expect(File.exist?(config_file_path)).to be(true)
25
- end
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 DELETED
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rspec'
4
- require 'bundler/setup'
5
- require 'uploadcare/rails'
6
- require 'dry/monads/all'
7
- require 'api_struct'
8
- require 'uploadcare'
9
- require 'action_view'
10
-
11
- Dir[File.expand_path(File.join(File.dirname(__FILE__), 'support', '**', '*.rb'))].sort.each { |f| require f }
12
-
13
- RSpec.configure do |config|
14
- # Enable flags like --only-failures and --next-failure
15
- config.example_status_persistence_file_path = '.rspec_status'
16
-
17
- # Disable RSpec exposing methods globally on `Module` and `main`
18
- config.disable_monkey_patching!
19
-
20
- config.expose_dsl_globally = true
21
-
22
- config.expect_with :rspec do |c|
23
- c.syntax = :expect
24
- end
25
-
26
- config.include ActionView::Helpers, type: :helper
27
- end
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rails/generators/test_case'
4
-
5
- module Uploadcare
6
- module Rails
7
- module Generators
8
- extend ActiveSupport::Concern
9
-
10
- included do
11
- cattr_accessor :test_case, :test_case_instance
12
-
13
- self.test_case = Class.new(::Rails::Generators::TestCase) do
14
- def fake_test_case; end
15
-
16
- def add_assertion; end
17
- end
18
- self.test_case_instance = test_case.new(:fake_test_case)
19
- test_case.generator_class = described_class
20
- end
21
-
22
- def prepare_destination
23
- test_case_instance.send :prepare_destination
24
- end
25
-
26
- def run_generator
27
- test_case_instance.run_generator
28
- end
29
-
30
- module ClassMethods
31
- def destination(path)
32
- test_case.destination_root = path
33
- end
34
- end
35
- end
36
- end
37
- end
38
-
39
- RSpec.configure do |c|
40
- c.include Uploadcare::Rails::Generators, type: :generator
41
- end
data/spec/support/vcr.rb DELETED
@@ -1,14 +0,0 @@
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
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'uploadcare/rails/action_view/uploadcare_uploader_tags'
5
-
6
- describe Uploadcare::Rails::ActionView::UploadcareUploaderTags, type: :helper do
7
- it 'includes a hidden field' do
8
- tag = uploadcare_uploader_field(:post, :title)
9
-
10
- [
11
- '<input',
12
- 'role="uploadcare-uploader"',
13
- 'type="hidden"',
14
- 'name="post[title]"',
15
- 'id="post_title"',
16
- '/>'
17
- ].each do |fragment|
18
- expect(tag).to include(fragment)
19
- end
20
- end
21
-
22
- it 'includes a hidden field tag' do
23
- tag = uploadcare_uploader_field_tag(:title)
24
-
25
- [
26
- '<input',
27
- 'role="uploadcare-uploader"',
28
- 'type="hidden"',
29
- 'name="title"',
30
- 'id="title"',
31
- '/>'
32
- ].each do |fragment|
33
- expect(tag).to include(fragment)
34
- end
35
- end
36
- end
37
-
38
- RSpec.configure do |c|
39
- c.include Uploadcare::Rails::ActionView::UploadcareUploaderTags, type: :helper
40
- end
@@ -1,46 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'uploadcare/rails/action_view/uploadcare_include_tags'
5
-
6
- describe Uploadcare::Rails::ActionView::UploadcareWidgetTags, type: :helper do
7
- let(:global_variables) { 'UPLOADCARE_PUBLIC_KEY = demopublickey;' }
8
-
9
- before do
10
- allow(Uploadcare::Rails).to receive_message_chain(:configuration, :uploader_parameters)
11
- .and_return(global_variables)
12
- allow(Uploadcare::Rails).to receive_message_chain(:configuration, :cdn_hostname).and_return('ucarecdn.com')
13
- end
14
-
15
- context 'when including a widget' do
16
- context 'and checking available bundles' do
17
- %w[full default api ie8 lang.en].each do |bundle|
18
- %w[3 3.x 2 1].each do |version|
19
- [true, false].each do |min|
20
- it "includes a widget from cdn with params: vesrion = #{version}, bundle = #{bundle} and min = #{min}" do
21
- tag = uploadcare_include_tag(version: version, bundle: bundle, min: min)
22
-
23
- expect(tag).to match(
24
- [
25
- '<script src="https://ucarecdn.com/libs/widget/',
26
- version,
27
- "/uploadcare#{bundle == 'default' ? '' : ".#{bundle}"}#{min ? '.min' : ''}.js\"></script>"
28
- ].join
29
- )
30
- end
31
- end
32
- end
33
- end
34
-
35
- context 'and checking global variables' do
36
- it 'includes global variables' do
37
- expect(uploadcare_include_tag).to match(global_variables)
38
- end
39
- end
40
- end
41
- end
42
- end
43
-
44
- RSpec.configure do |c|
45
- c.include Uploadcare::Rails::ActionView::UploadcareWidgetTags, type: :helper
46
- end
@@ -1,33 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'uploadcare/rails/active_record/mount_uploadcare_file'
5
- require 'uploadcare/rails/active_record/mount_uploadcare_file_group'
6
-
7
- describe Uploadcare::Rails::ActiveRecord::MountUploadcareFile do
8
- before do
9
- allow(Uploadcare::Rails).to receive(:configuration).and_return(OpenStruct.new)
10
- stub_const 'Post', Class.new
11
- Post.class_eval do
12
- include Uploadcare::Rails::ActiveRecord::MountUploadcareFile
13
- extend ActiveModel::Callbacks
14
-
15
- define_model_callbacks :save, only: :after
16
-
17
- def initialize
18
- @picture = ''
19
- end
20
-
21
- mount_uploadcare_file :picture
22
- end
23
- end
24
-
25
- context 'when checking mount file methods availability' do
26
- it 'checks that a model instance responds to mount file methods', :aggregate_failures do
27
- post = Post.new
28
- %i[uploadcare_store_picture! uploadcare_delete_picture!].each do |method|
29
- expect(post).to respond_to(method)
30
- end
31
- end
32
- end
33
- end
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
- require 'uploadcare/rails/active_record/mount_uploadcare_file'
5
- require 'uploadcare/rails/active_record/mount_uploadcare_file_group'
6
-
7
- describe Uploadcare::Rails::ActiveRecord::MountUploadcareFileGroup do
8
- before do
9
- allow(Uploadcare::Rails).to receive(:configuration).and_return(OpenStruct.new)
10
- stub_const 'Post', Class.new
11
- Post.class_eval do
12
- include Uploadcare::Rails::ActiveRecord::MountUploadcareFileGroup
13
- extend ActiveModel::Callbacks
14
-
15
- define_model_callbacks :save, only: :after
16
-
17
- def initialize
18
- @gallery = ''
19
- end
20
-
21
- mount_uploadcare_file_group :gallery
22
- end
23
- end
24
-
25
- context 'when checking mount file group methods availability' do
26
- it 'checks that a model instance responds to mount file group methods', :aggregate_failures do
27
- post = Post.new
28
- expect(post).to respond_to(:uploadcare_store_gallery!)
29
- expect(Post).to respond_to(:has_uploadcare_file_group_for_gallery?)
30
- end
31
- end
32
- end