uploadcare-rails 1.2.0.pre.alpha3 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (209) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +5 -16
  3. data/lib/generators/templates/uploadcare_config_template.erb +138 -0
  4. data/lib/generators/uploadcare_config_generator.rb +7 -4
  5. data/lib/uploadcare/errors/type_error.rb +7 -0
  6. data/lib/uploadcare/rails/action_view/uploadcare_include_tags.rb +48 -0
  7. data/lib/uploadcare/rails/action_view/uploadcare_uploader_tags.rb +57 -0
  8. data/lib/uploadcare/rails/active_record/mount_uploadcare_file.rb +62 -0
  9. data/lib/uploadcare/rails/active_record/mount_uploadcare_file_group.rb +58 -0
  10. data/lib/uploadcare/rails/api/rest/base.rb +14 -0
  11. data/lib/uploadcare/rails/api/rest/conversion_api.rb +42 -0
  12. data/lib/uploadcare/rails/api/rest/file_api.rb +69 -0
  13. data/lib/uploadcare/rails/api/rest/group_api.rb +48 -0
  14. data/lib/uploadcare/rails/api/rest/project_api.rb +27 -0
  15. data/lib/uploadcare/rails/api/rest/webhook_api.rb +45 -0
  16. data/lib/uploadcare/rails/api/upload/base.rb +13 -0
  17. data/lib/uploadcare/rails/api/upload/upload_api.rb +53 -0
  18. data/lib/uploadcare/rails/configuration.rb +57 -0
  19. data/lib/uploadcare/rails/engine.rb +13 -17
  20. data/lib/uploadcare/rails/jobs/delete_file_job.rb +14 -0
  21. data/lib/uploadcare/rails/jobs/store_file_job.rb +14 -0
  22. data/lib/uploadcare/rails/jobs/store_group_job.rb +14 -0
  23. data/lib/uploadcare/rails/objects/concerns/loadable.rb +46 -0
  24. data/lib/uploadcare/rails/objects/file.rb +40 -20
  25. data/lib/uploadcare/rails/objects/group.rb +51 -57
  26. data/lib/uploadcare/rails/services/files_count_extractor.rb +14 -0
  27. data/lib/uploadcare/rails/services/id_extractor.rb +15 -0
  28. data/lib/uploadcare/rails/transformations/image_transformations.rb +45 -0
  29. data/lib/uploadcare/rails/version.rb +3 -1
  30. data/lib/uploadcare/rails.rb +10 -0
  31. data/lib/uploadcare-rails.rb +27 -16
  32. data/spec/fixtures/kitten.jpeg +0 -0
  33. data/spec/fixtures/vcr_cassettes/conversion_api_convert_document.yml +62 -0
  34. data/spec/fixtures/vcr_cassettes/conversion_api_convert_document_with_error.yml +62 -0
  35. data/spec/fixtures/vcr_cassettes/conversion_api_convert_video.yml +62 -0
  36. data/spec/fixtures/vcr_cassettes/conversion_api_convert_video_with_error.yml +62 -0
  37. data/spec/fixtures/vcr_cassettes/conversion_api_get_document_conversion_status.yml +59 -0
  38. data/spec/fixtures/vcr_cassettes/conversion_api_get_video_conversion_status.yml +59 -0
  39. data/spec/fixtures/vcr_cassettes/file_api_copy_file.yml +60 -0
  40. data/spec/fixtures/vcr_cassettes/file_api_delete_file.yml +58 -0
  41. data/spec/fixtures/vcr_cassettes/file_api_delete_files.yml +58 -0
  42. data/spec/fixtures/vcr_cassettes/file_api_get_file.yml +58 -0
  43. data/spec/fixtures/vcr_cassettes/file_api_get_files.yml +61 -0
  44. data/spec/fixtures/vcr_cassettes/file_api_load_file.yml +57 -0
  45. data/spec/fixtures/vcr_cassettes/file_api_store_file.yml +58 -0
  46. data/spec/fixtures/vcr_cassettes/file_api_store_files.yml +57 -0
  47. data/spec/fixtures/vcr_cassettes/group_api_create_group.yml +57 -0
  48. data/spec/fixtures/vcr_cassettes/group_api_get_group.yml +52 -0
  49. data/spec/fixtures/vcr_cassettes/group_api_get_groups.yml +57 -0
  50. data/spec/fixtures/vcr_cassettes/group_api_store_group.yml +57 -0
  51. data/spec/fixtures/vcr_cassettes/project_api_get_project.yml +59 -0
  52. data/spec/fixtures/vcr_cassettes/upload_upload_many_files.yml +55 -0
  53. data/spec/fixtures/vcr_cassettes/upload_upload_one_file.yml +105 -0
  54. data/spec/fixtures/vcr_cassettes/upload_upload_one_file_from_cdn.yml +111 -0
  55. data/spec/fixtures/vcr_cassettes/webhook_api_create_webhook.yml +59 -0
  56. data/spec/fixtures/vcr_cassettes/webhook_api_delete_webhook.yml +57 -0
  57. data/spec/fixtures/vcr_cassettes/webhook_api_get_webhooks.yml +59 -0
  58. data/spec/fixtures/vcr_cassettes/webhook_api_update_webhook.yml +59 -0
  59. data/spec/generators/uploadcare_config_generator_spec.rb +18 -26
  60. data/spec/spec_helper.rb +17 -62
  61. data/spec/support/generators.rb +8 -5
  62. data/spec/support/vcr.rb +14 -0
  63. data/spec/uploadcare/rails/action_view/uploadcare_uploader_tags_spec.rb +40 -0
  64. data/spec/uploadcare/rails/action_view/uploadcare_widget_tags_spec.rb +46 -0
  65. data/spec/uploadcare/rails/active_record/mount_uploadcare_file_spec.rb +33 -0
  66. data/spec/uploadcare/rails/active_record/mount_uploadcare_group_spec.rb +32 -0
  67. data/spec/uploadcare/rails/api/rest/conversion_api_spec.rb +110 -0
  68. data/spec/uploadcare/rails/api/rest/file_api_spec.rb +85 -0
  69. data/spec/uploadcare/rails/api/rest/group_api_spec.rb +61 -0
  70. data/spec/uploadcare/rails/api/rest/project_api_spec.rb +33 -0
  71. data/spec/uploadcare/rails/api/rest/webhook_api_spec.rb +67 -0
  72. data/spec/uploadcare/rails/api/upload/upload_api_spec.rb +82 -0
  73. data/spec/uploadcare/rails/jobs/delete_file_job_spec.rb +15 -0
  74. data/spec/uploadcare/rails/jobs/store_file_job_spec.rb +15 -0
  75. data/spec/uploadcare/rails/jobs/store_group_job_spec.rb +15 -0
  76. data/spec/uploadcare/rails/objects/file_spec.rb +77 -0
  77. data/spec/uploadcare/rails/objects/group_spec.rb +87 -0
  78. data/spec/uploadcare/rails/services/id_extractor_spec.rb +26 -0
  79. data/spec/uploadcare/rails/transformations/image_transformations_spec.rb +120 -0
  80. data/spec/uploadcare/rails_spec.rb +7 -0
  81. metadata +129 -393
  82. data/config/initializers/uploadcare.rb +0 -26
  83. data/config/uploadcare_defaults.yml +0 -12
  84. data/lib/generators/templates/uploadcare_config_template.yml +0 -71
  85. data/lib/tasks/uploadcare_rails_tasks.rake +0 -4
  86. data/lib/uploadcare/rails/action_view/include_tags.rb +0 -47
  87. data/lib/uploadcare/rails/action_view/uploader_tags.rb +0 -76
  88. data/lib/uploadcare/rails/active_record/has_file.rb +0 -89
  89. data/lib/uploadcare/rails/active_record/has_group.rb +0 -84
  90. data/lib/uploadcare/rails/active_record/has_object.rb +0 -9
  91. data/lib/uploadcare/rails/formtastic/formtastic.rb +0 -73
  92. data/lib/uploadcare/rails/operations.rb +0 -57
  93. data/lib/uploadcare/rails/settings.rb +0 -81
  94. data/lib/uploadcare/rails/simple_form/simple_form.rb +0 -63
  95. data/spec/caching/file_caching_spec.rb +0 -26
  96. data/spec/caching/group_caching_spec.rb +0 -40
  97. data/spec/cassettes/Uploadcare_Rails_File/should_load_itself.yml +0 -263
  98. data/spec/cassettes/Uploadcare_Rails_Group/group_should_stay_loaded.yml +0 -263
  99. data/spec/cassettes/Uploadcare_Rails_Group/rails_cache_should_updates_after_load_call.yml +0 -263
  100. data/spec/cassettes/group_cahsing_file_load.yml +0 -263
  101. data/spec/cassettes/has_uploadcare_file/object_with_uploadcare_file/deletes_file_after_destroy.yml +0 -1763
  102. data/spec/cassettes/has_uploadcare_file/object_with_uploadcare_file/stores_file_after_save.yml +0 -543
  103. data/spec/cassettes/has_uploadcare_group/object_attachment/contains_files_inside.yml +0 -679
  104. data/spec/cassettes/has_uploadcare_group_save.yml +0 -705
  105. data/spec/cassettes/load_group.yml +0 -263
  106. data/spec/dummy/README.rdoc +0 -28
  107. data/spec/dummy/Rakefile +0 -6
  108. data/spec/dummy/app/assets/javascripts/application.js +0 -13
  109. data/spec/dummy/app/assets/javascripts/post_with_collections.js +0 -2
  110. data/spec/dummy/app/assets/javascripts/posts.js +0 -2
  111. data/spec/dummy/app/assets/javascripts/posts_with_collection_and_files.js +0 -2
  112. data/spec/dummy/app/assets/stylesheets/application.css +0 -13
  113. data/spec/dummy/app/assets/stylesheets/post_with_collections.css +0 -4
  114. data/spec/dummy/app/assets/stylesheets/posts.css +0 -4
  115. data/spec/dummy/app/assets/stylesheets/posts_with_collection_and_files.css +0 -4
  116. data/spec/dummy/app/assets/stylesheets/scaffold.css +0 -56
  117. data/spec/dummy/app/controllers/application_controller.rb +0 -5
  118. data/spec/dummy/app/controllers/post_with_collections_controller.rb +0 -58
  119. data/spec/dummy/app/controllers/posts_controller.rb +0 -58
  120. data/spec/dummy/app/controllers/posts_with_collection_and_files_controller.rb +0 -58
  121. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  122. data/spec/dummy/app/helpers/post_with_collections_helper.rb +0 -2
  123. data/spec/dummy/app/helpers/posts_helper.rb +0 -2
  124. data/spec/dummy/app/helpers/posts_with_collection_and_files_helper.rb +0 -2
  125. data/spec/dummy/app/models/post.rb +0 -3
  126. data/spec/dummy/app/models/post_with_collection.rb +0 -3
  127. data/spec/dummy/app/models/posts_with_collection_and_file.rb +0 -4
  128. data/spec/dummy/app/views/layouts/application.html.erb +0 -16
  129. data/spec/dummy/app/views/post_with_collections/_form.html.erb +0 -25
  130. data/spec/dummy/app/views/post_with_collections/edit.html.erb +0 -6
  131. data/spec/dummy/app/views/post_with_collections/index.html.erb +0 -29
  132. data/spec/dummy/app/views/post_with_collections/new.html.erb +0 -5
  133. data/spec/dummy/app/views/post_with_collections/show.html.erb +0 -14
  134. data/spec/dummy/app/views/post_with_collections/show.json.jbuilder +0 -1
  135. data/spec/dummy/app/views/posts/_form.html.erb +0 -31
  136. data/spec/dummy/app/views/posts/edit.html.erb +0 -6
  137. data/spec/dummy/app/views/posts/index.html.erb +0 -37
  138. data/spec/dummy/app/views/posts/new.html.erb +0 -5
  139. data/spec/dummy/app/views/posts/post.json.builder +0 -1
  140. data/spec/dummy/app/views/posts/show.html.erb +0 -15
  141. data/spec/dummy/app/views/posts_with_collection_and_files/_form.html.erb +0 -27
  142. data/spec/dummy/app/views/posts_with_collection_and_files/edit.html.erb +0 -6
  143. data/spec/dummy/app/views/posts_with_collection_and_files/index.html.erb +0 -25
  144. data/spec/dummy/app/views/posts_with_collection_and_files/new.html.erb +0 -5
  145. data/spec/dummy/app/views/posts_with_collection_and_files/show.html.erb +0 -4
  146. data/spec/dummy/app/views/posts_with_collection_and_files/show.json.jbuilder +0 -1
  147. data/spec/dummy/bin/bundle +0 -3
  148. data/spec/dummy/bin/rails +0 -4
  149. data/spec/dummy/bin/rake +0 -4
  150. data/spec/dummy/config/application.rb +0 -23
  151. data/spec/dummy/config/boot.rb +0 -5
  152. data/spec/dummy/config/database.yml +0 -25
  153. data/spec/dummy/config/environment.rb +0 -5
  154. data/spec/dummy/config/environments/development.rb +0 -29
  155. data/spec/dummy/config/environments/production.rb +0 -80
  156. data/spec/dummy/config/environments/test.rb +0 -36
  157. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  158. data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  159. data/spec/dummy/config/initializers/formtastic.rb +0 -111
  160. data/spec/dummy/config/initializers/inflections.rb +0 -16
  161. data/spec/dummy/config/initializers/mime_types.rb +0 -5
  162. data/spec/dummy/config/initializers/secret_token.rb +0 -12
  163. data/spec/dummy/config/initializers/session_store.rb +0 -3
  164. data/spec/dummy/config/initializers/simple_form.rb +0 -167
  165. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  166. data/spec/dummy/config/locales/en.yml +0 -23
  167. data/spec/dummy/config/locales/simple_form.en.yml +0 -31
  168. data/spec/dummy/config/routes.rb +0 -63
  169. data/spec/dummy/config/uploadcare.yml +0 -68
  170. data/spec/dummy/config.ru +0 -4
  171. data/spec/dummy/db/migrate/20171012001801_create_tables.rb +0 -27
  172. data/spec/dummy/db/schema.rb +0 -37
  173. data/spec/dummy/db/test.sqlite3 +0 -0
  174. data/spec/dummy/lib/templates/erb/scaffold/_form.html.erb +0 -13
  175. data/spec/dummy/log/development.log +0 -0
  176. data/spec/dummy/log/test.log +0 -3276
  177. data/spec/dummy/public/404.html +0 -58
  178. data/spec/dummy/public/422.html +0 -58
  179. data/spec/dummy/public/500.html +0 -57
  180. data/spec/dummy/public/favicon.ico +0 -0
  181. data/spec/dummy/tmp/cache/293/091/https%3A%2F%2Fucarecdn.com%2F19073296-2315-4726-817b-46398b2c7431%7E2%2F +0 -0
  182. data/spec/dummy/tmp/cache/2AF/761/https%3A%2F%2Fucarecdn.com%2F595319d0-a113-459f-91bd-b29c7183467b%2F +0 -0
  183. data/spec/dummy/tmp/cache/301/D41/https%3A%2F%2Fucarecdn.com%2F81332043-fa2c-452f-936b-737d87ab2ae2%2F +0 -0
  184. data/spec/dummy/tmp/cache/30A/7C1/https%3A%2F%2Fucarecdn.com%2F39b34128-a001-46fd-9773-1b6ad46e6b9e%2F +0 -0
  185. data/spec/dummy/tmp/cache/340/A41/https%3A%2F%2Fucarecdn.com%2F090bcb5f-6d19-456c-b4a3-d753e690926f%2F +0 -0
  186. data/spec/dummy/tmp/cache/3AB/5A1/https%3A%2F%2Fucarecdn.com%2F7eb0161b-cebe-4316-946b-694de6f77ef9%2F +0 -0
  187. data/spec/dummy/tmp/cache/3FC/5C1/https%3A%2F%2Fucarecdn.com%2Fc3f0464b-ce9a-4281-8eaa-5c55783ccedf%2F +0 -0
  188. data/spec/dummy/tmp/cache/431/5C1/https%3A%2F%2Fucarecdn.com%2Fa1b1bb40-bd89-4f9c-b809-e84920f24a01%7E2%2F +0 -0
  189. data/spec/dummy/tmp/cache/44B/7A1/https%3A%2F%2Fucarecdn.com%2Fd6c785a8-9761-4602-88de-65ddb04ddc6a%7E2%2F +0 -0
  190. data/spec/dummy/tmp/cache/45B/F31/https%3A%2F%2Fucarecdn.com%2F73e3cdbc-6495-4cf2-bbd1-413e6cb70004%7E2%2F +0 -0
  191. data/spec/dummy/tmp/cache/461/AA1/https%3A%2F%2Fucarecdn.com%2Fc50e9a53-0b95-48ac-a4a9-6744052dbdab%7E2%2F +0 -0
  192. data/spec/helpers/form_helpers_has_file_spec.rb +0 -30
  193. data/spec/helpers/form_helpers_has_group_spec.rb +0 -30
  194. data/spec/helpers/form_helpers_spec.rb +0 -33
  195. data/spec/helpers/formtastic_spec.rb +0 -25
  196. data/spec/helpers/include_tags_spec.rb +0 -54
  197. data/spec/helpers/simple_form_spec.rb +0 -25
  198. data/spec/helpers/uploader_tags_spec.rb +0 -21
  199. data/spec/models/has_both_file_and_group_spec.rb +0 -43
  200. data/spec/models/has_file_spec.rb +0 -46
  201. data/spec/models/has_group_spec.rb +0 -57
  202. data/spec/objects/file_spec.rb +0 -27
  203. data/spec/objects/group_spec.rb +0 -51
  204. data/spec/operations_spec.rb +0 -28
  205. data/spec/tmp/config/uploadcare.yml +0 -71
  206. data/spec/uploadcare/rails/settings_spec.rb +0 -136
  207. data/spec/uploadcare_rails_settings_spec.rb +0 -56
  208. data/spec/view.png +0 -0
  209. data/spec/view2.jpg +0 -0
@@ -1,28 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Uploadcare::Rails do
4
- let(:operations) do
5
- {
6
- format: :jpeg,
7
- quality: :normal,
8
- progressive: :yes,
9
- preview: '200x150',
10
- resize: '150x',
11
- inline: '//overlay/:uuid/50%x50%/center/'
12
- }
13
- end
14
-
15
- let(:subject) { Uploadcare::Rails::Operations.new(operations).to_s }
16
-
17
- it { is_expected.to include('format/jpeg') }
18
- it { is_expected.to include('quality/normal') }
19
- it { is_expected.to include('progressive/yes') }
20
- it { is_expected.to include('preview/200x150') }
21
- it { is_expected.to include('resize/150x') }
22
- it { is_expected.to include('/overlay/:uuid/50%x50%/center/') }
23
-
24
- it do
25
- is_expected.
26
- to eq('-/format/jpeg/-/quality/normal/-/progressive/yes/-/preview/200x150/-/resize/150x/-/overlay/:uuid/50%x50%/center/')
27
- end
28
- end
@@ -1,71 +0,0 @@
1
- defaults: &defaults
2
- public_key: "demopublickey" # replace it with your public key
3
- private_key: "demoprivatekey" # replace it with your private key
4
-
5
- # instances of widget initialized for you on page load
6
- live: true
7
-
8
- # cache files json dumps to prevent calling to server if it posible
9
- cache_files: true
10
-
11
- # cache groups json dumps to prevent calling to server if it posible
12
- cache_groups: true
13
-
14
- # store file or group after model is created or updated
15
- store_after_save: true
16
-
17
- # deletes file or group after model object is deleted
18
- delete_after_destroy: true
19
-
20
- # Avaliable options are listed at https://uploadcare.com/documentation/widget/#advanced-configuration
21
- # please note, that for options marker as Global: N/A - there is no practical meaning
22
- # of putting this option here, as it will not have any effect.
23
- # But it also will not break anything.
24
-
25
- # for preview step use:
26
- # preview_step: false # true or false
27
-
28
- # for clearable option (allows user to remove uploaded file from widget) use:
29
- # clearable: false # true or false
30
-
31
- # for setting tabs use tabs option:
32
- # tabs: "url file facebook" # etc
33
- # read more here: https://uploadcare.com/documentation/widget/#tabs
34
- #
35
- # Full list of tabs:
36
- # |----------------------------------------|
37
- # | Code | File Source | Default |
38
- # |------------|-----------------|---------|
39
- # | url | Any URL | On |
40
- # | file | Local disk | On |
41
- # | facebook | Facebook | On |
42
- # | dropbox | Dropbox | Off |
43
- # | gdrive | Google Drive | On |
44
- # | box | Box | On |
45
- # | skydrive | SkyDrive | On |
46
- # | instagram | Instagram | On |
47
- # | evernote | Evernote | On |
48
- # | vk | VK | Off |
49
- # |________________________________________|
50
-
51
- # for locale option use:
52
- # locale: "en"
53
-
54
- # for autostore option use:
55
- # autostore: true #true or false
56
-
57
- # for manual start (which means you will need to initialize uploaders yourself) use:
58
- # manual_start: false # true or false
59
-
60
- # for path value use:
61
- # path_value: true # true or false
62
- # (important for input values - see https://uploadcare.com/documentation/widget/#input-value)
63
-
64
- development:
65
- <<: *defaults
66
-
67
- test:
68
- <<: *defaults
69
-
70
- production:
71
- <<: *defaults
@@ -1,136 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Uploadcare::Rails::Settings do
4
- subject(:settings) { described_class.new(test: config) }
5
-
6
- let(:full_config) do
7
- {
8
- widget_version: '3.x',
9
- upload_url_base: 'http://example.com/',
10
- api_url_base: 'http://example.com/',
11
- static_url_base: 'http://example.com/',
12
- api_version: '0.3',
13
- public_key: 'test_public_key',
14
- private_key: 'test_private_key',
15
- auth_scheme: :secure,
16
- cache_files: true,
17
- cache_groups: true,
18
- delete_after_destroy: true,
19
- store_after_save: true,
20
- locale: 'en',
21
- images_only: true,
22
- multiple: true,
23
- multiple_min: 2,
24
- multiple_max: 3,
25
- preview_step: true,
26
- crop: true,
27
- clearable: true,
28
- tabs: "url file facebook",
29
- autostore: true,
30
- live: true,
31
- manual_start: true,
32
- path_value: true,
33
- }
34
- end
35
- let(:config) { full_config }
36
-
37
- it { is_expected.to respond_to(:widget_version) }
38
- it { is_expected.to respond_to(:upload_url_base) }
39
- it { is_expected.to respond_to(:api_url_base) }
40
- it { is_expected.to respond_to(:static_url_base) }
41
- it { is_expected.to respond_to(:api_version) }
42
- it { is_expected.to respond_to(:cache_files) }
43
- it { is_expected.to respond_to(:cache_groups) }
44
- it { is_expected.to respond_to(:public_key) }
45
- it { is_expected.to respond_to(:private_key) }
46
- it { is_expected.to respond_to(:auth_scheme) }
47
- it { is_expected.to respond_to(:delete_after_destroy) }
48
- it { is_expected.to respond_to(:store_after_save) }
49
- it { is_expected.to respond_to(:locale) }
50
- it { is_expected.to respond_to(:images_only) }
51
- it { is_expected.to respond_to(:multiple) }
52
- it { is_expected.to respond_to(:multiple_min) }
53
- it { is_expected.to respond_to(:multiple_max) }
54
- it { is_expected.to respond_to(:preview_step) }
55
- it { is_expected.to respond_to(:crop) }
56
- it { is_expected.to respond_to(:clearable) }
57
- it { is_expected.to respond_to(:tabs) }
58
- it { is_expected.to respond_to(:autostore) }
59
- it { is_expected.to respond_to(:live) }
60
- it { is_expected.to respond_to(:manual_start) }
61
- it { is_expected.to respond_to(:path_value) }
62
-
63
- it { is_expected.to have_attributes(full_config) }
64
-
65
- it { is_expected.to respond_to(:api) }
66
- it { expect(settings.api).to be_a(Uploadcare::Api) }
67
-
68
- it { is_expected.to respond_to(:api_settings) }
69
- it { expect(settings.api_settings).to eq(settings.to_h) }
70
-
71
- it { is_expected.to respond_to(:widget_settings) }
72
- it 'filters private settings' do
73
- expect(settings.widget_settings).to eq(
74
- public_key: "test_public_key",
75
- locale: 'en',
76
- images_only: true,
77
- multiple: true,
78
- multiple_min: 2,
79
- multiple_max: 3,
80
- preview_step: true,
81
- crop: true,
82
- clearable: true,
83
- tabs: "url file facebook",
84
- autostore: true,
85
- live: true,
86
- manual_start: true,
87
- path_value: true,
88
- )
89
- end
90
-
91
- context 'when no config for the current rails env given' do
92
- subject(:settings) { described_class.new(development: config) }
93
- it { expect { settings }.to raise_error(ArgumentError) }
94
- end
95
-
96
- context 'works with both symbols and strings in a config' do
97
- subject(:settings) { described_class.new('test' => config.stringify_keys) }
98
- it { is_expected.to have_attributes(full_config) }
99
- end
100
-
101
- context 'when some settings are missing in the config' do
102
- context 'if missing settings are some of uploadcare-ruby defaults' do
103
- let(:uploadcare_ruby_defaults) do
104
- Uploadcare::DEFAULT_SETTINGS.except(:public_key, :private_key)
105
- end
106
- let(:config) { full_config.except(*uploadcare_ruby_defaults.keys) }
107
-
108
- it 'sets missing settings from uploadcare-ruby defaults' do
109
- uploadcare_ruby_defaults.each do |k, v|
110
- expect(settings).to have_attributes(k => v)
111
- end
112
- end
113
- end
114
-
115
- context 'if public key is missing' do
116
- let(:config) { full_config.except(:public_key) }
117
- it { expect { settings }.to raise_error(ArgumentError) }
118
- end
119
-
120
- context 'if private key is missing' do
121
- let(:config) { full_config.except(:private_key) }
122
- it { expect { settings }.to raise_error(ArgumentError) }
123
- end
124
-
125
- context 'if missing settings are some of uploadcare-rails defaults' do
126
- let(:uploadcare_rails_defaults) { Uploadcare::Rails::DEFAULT_SETTINGS }
127
- let(:config) { full_config.except(uploadcare_rails_defaults.keys) }
128
-
129
- it 'sets missing settings from uploadcare-rails defaults' do
130
- uploadcare_rails_defaults.each do |k, v|
131
- expect(settings).to have_attributes(k => v)
132
- end
133
- end
134
- end
135
- end
136
- end
@@ -1,56 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Uploadcare::Rails do
4
- it "should load settings" do
5
- UPLOADCARE_SETTINGS.should_not be_nil
6
- UPLOADCARE_SETTINGS.should be_kind_of(Uploadcare::Rails::Settings)
7
- end
8
-
9
- it "settings should respond to all defined methods" do
10
- UPLOADCARE_SETTINGS.should respond_to(:widget_version)
11
- UPLOADCARE_SETTINGS.should respond_to(:upload_url_base)
12
- UPLOADCARE_SETTINGS.should respond_to(:api_url_base)
13
- UPLOADCARE_SETTINGS.should respond_to(:static_url_base)
14
- UPLOADCARE_SETTINGS.should respond_to(:api_version)
15
- UPLOADCARE_SETTINGS.should respond_to(:cache_files)
16
- UPLOADCARE_SETTINGS.should respond_to(:public_key)
17
- UPLOADCARE_SETTINGS.should respond_to(:private_key)
18
- end
19
-
20
- it "should have private and public keys as not empty strings" do
21
- UPLOADCARE_SETTINGS.private_key.should be_kind_of(String)
22
- UPLOADCARE_SETTINGS.public_key.should be_kind_of(String)
23
-
24
- UPLOADCARE_SETTINGS.private_key.should_not be_empty
25
- UPLOADCARE_SETTINGS.public_key.should_not be_empty
26
- end
27
-
28
- it "pub and private keys should be loaded from config file" do
29
- config_file = "#{Rails.root}/config/uploadcare.yml"
30
- config = YAML.load_file(config_file)
31
-
32
- UPLOADCARE_SETTINGS.private_key.should == config["test"]["private_key"]
33
- UPLOADCARE_SETTINGS.public_key.should == config["test"]["public_key"]
34
- end
35
-
36
- # TODO: test api settings and widget settings
37
- it "should build instanse of UC api" do
38
- UPLOADCARE_SETTINGS.api.should be_kind_of(Uploadcare::Api)
39
- end
40
-
41
- it "should build api settings hash" do
42
- UPLOADCARE_SETTINGS.api_settings.should be_a_kind_of(Hash)
43
- UPLOADCARE_SETTINGS.api_settings.should_not be_empty
44
- end
45
-
46
- it "should build widget settings hash" do
47
- UPLOADCARE_SETTINGS.widget_settings.should be_a_kind_of(Hash)
48
- UPLOADCARE_SETTINGS.widget_settings.should_not be_empty
49
- end
50
-
51
- it 'should include user agent environment config' do
52
- expect(UPLOADCARE_SETTINGS.user_agent_environment.keys).to include(
53
- :framework_name, :framework_version, :extension_name, :extension_version
54
- )
55
- end
56
- end
data/spec/view.png DELETED
Binary file
data/spec/view2.jpg DELETED
Binary file