card 1.19.0 → 1.19.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/card.gemspec +3 -3
- data/config/initializers/{02_extensions → 02_patches}/kaminari.rb +16 -5
- data/config/initializers/patches.rb +7 -0
- data/config/locales/en.yml +15 -6
- data/db/migrate_core_cards/20150724123438_update_file_and_image_cards.rb +11 -11
- data/db/migrate_core_cards/data/themes/bootstrap_default/_variables.scss +2 -1
- data/db/seed/new/card_actions.yml +915 -443
- data/db/seed/new/card_acts.yml +348 -186
- data/db/seed/new/card_changes.yml +4409 -3329
- data/db/seed/new/card_references.yml +220 -3
- data/db/seed/new/cards.yml +6687 -3445
- data/db/seed/test/fixtures/card_actions.yml +1953 -1513
- data/db/seed/test/fixtures/card_acts.yml +615 -453
- data/db/seed/test/fixtures/card_changes.yml +7596 -6516
- data/db/seed/test/fixtures/card_references.yml +892 -675
- data/db/seed/test/fixtures/cards.yml +8803 -5561
- data/db/seeds.rb +8 -0
- data/lib/card.rb +10 -0
- data/lib/card/auth/setup.rb +6 -6
- data/lib/card/mod/dirs.rb +13 -3
- data/lib/card/set/advanced_api.rb +5 -4
- data/lib/cardio.rb +7 -3
- data/mod/Modfile +2 -2
- data/mod/admin/set/self/admin.rb +47 -30
- data/mod/admin/set/self/admin_info.rb +11 -11
- data/mod/basic_formats/set/self/head.rb +1 -1
- data/mod/{basic_types → basic_formats}/spec/set/all/all_css_spec.rb +0 -0
- data/mod/{basic_types → basic_formats}/spec/set/all/all_csv_spec.rb +0 -0
- data/mod/{basic_types → basic_formats}/spec/set/all/base_spec.rb +0 -0
- data/mod/{basic_types → basic_formats}/spec/set/all/file_spec.rb +0 -0
- data/mod/{basic_types → basic_formats}/spec/set/all/json_spec.rb +0 -0
- data/mod/{basic_types → basic_formats}/spec/set/all/rss_spec.rb +0 -0
- data/mod/{basic_types → basic_formats}/spec/set/all/text_spec.rb +0 -0
- data/mod/bootstrap/lib/stylesheets/bootstrap/_variables.scss +1 -1
- data/mod/bootstrap/set/all/bootstrap/table.rb +1 -1
- data/mod/bootstrap/set/self/bootswatch_shared.rb +1 -1
- data/mod/carrierwave/Gemfile +4 -0
- data/mod/carrierwave/lib/carrier_wave/cardmount.rb +24 -13
- data/mod/carrierwave/lib/carrier_wave/file_card_uploader.rb +189 -57
- data/mod/carrierwave/lib/carrier_wave/image_card_uploader.rb +5 -0
- data/mod/carrierwave/set/abstract/attachment.rb +26 -190
- data/mod/carrierwave/set/abstract/attachment/paths.rb +50 -0
- data/mod/carrierwave/set/abstract/attachment/storage_type.rb +319 -0
- data/mod/carrierwave/set/abstract/attachment/upload_cache.rb +77 -0
- data/mod/carrierwave/set/all/file_utils.rb +28 -0
- data/mod/carrierwave/set/self/admin.rb +23 -0
- data/mod/carrierwave/set/type/file.rb +26 -23
- data/mod/carrierwave/set/type/image.rb +1 -0
- data/mod/carrierwave/spec/lib/carrier_wave/file_card_uploader_spec.rb +67 -0
- data/mod/carrierwave/spec/set/type/file_spec.rb +557 -0
- data/mod/{standard → carrierwave}/spec/set/type/image_spec.rb +22 -4
- data/mod/core/set/abstract/code_file.rb +3 -3
- data/mod/core/set/all/debug.rb +23 -0
- data/mod/core/set/all/name.rb +1 -1
- data/mod/core/set/all/permissions.rb +22 -12
- data/mod/core/set/all/tracked_attributes.rb +0 -76
- data/mod/core/set/all/trash.rb +50 -0
- data/mod/core/set/all/update_read_rules.rb +84 -0
- data/mod/core/set/all/utils.rb +1 -75
- data/mod/email/set/type_plus_right/user/follow.rb +4 -8
- data/mod/history/lib/card/act.rb +3 -1
- data/mod/history/lib/card/action.rb +3 -1
- data/mod/history/lib/card/action/differ.rb +12 -1
- data/mod/history/set/all/history.rb +2 -1
- data/mod/machines/file/all_script_machine_output/file.js +211 -0
- data/mod/machines/file/all_style_machine_output/file.css +19 -0
- data/mod/machines/set/abstract/machine.rb +270 -0
- data/mod/machines/set/abstract/machine_input.rb +76 -0
- data/mod/machines/set/right/machine_output.rb +9 -1
- data/mod/machines/set/type/coffee_script.rb +2 -6
- data/mod/machines/set/type/css.rb +2 -2
- data/mod/machines/set/type/java_script.rb +2 -2
- data/mod/machines/set/type/skin.rb +2 -2
- data/mod/machines/spec/set/abstract/machine_spec.rb +10 -0
- data/mod/{basic_types → pointer}/spec/set/type/pointer_spec.rb +10 -26
- data/mod/settings/set/right/script.rb +1 -1
- data/mod/settings/set/right/style.rb +1 -1
- data/mod/solid_cache/set/all/solid_cache.rb +1 -1
- data/mod/standard/file/credit_image/image-icon.png +0 -0
- data/mod/standard/file/credit_image/image-large.png +0 -0
- data/mod/standard/file/credit_image/image-medium.png +0 -0
- data/mod/standard/file/credit_image/image-small.png +0 -0
- data/mod/standard/file/favicon/image-icon.png +0 -0
- data/mod/standard/file/favicon/image-large.png +0 -0
- data/mod/standard/file/favicon/image-medium.png +0 -0
- data/mod/standard/file/favicon/image-small.png +0 -0
- data/mod/standard/file/logo/image-icon.png +0 -0
- data/mod/standard/file/logo/image-large.png +0 -0
- data/mod/standard/file/logo/image-medium.png +0 -0
- data/mod/standard/file/logo/image-small.png +0 -0
- data/mod/standard/set/all/links.rb +2 -2
- data/spec/spec_helper.rb +15 -3
- data/tmpsets/set/{mod014-admin → mod001-admin}/self/admin.rb +47 -30
- data/tmpsets/set/{mod014-admin → mod001-admin}/self/admin_info.rb +11 -11
- data/tmpsets/set/{mod014-admin → mod001-admin}/self/version.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/abstract/code_file.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/actify.rb +6 -5
- data/tmpsets/set/{mod001-core → mod002-core}/all/active_card.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/collection.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/content.rb +0 -0
- data/tmpsets/set/mod002-core/all/debug.rb +30 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/erb.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/event.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/export.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/fetch.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/haml.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/initialize.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/location_history.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/name.rb +1 -1
- data/tmpsets/set/{mod001-core → mod002-core}/all/name_validations.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/pattern.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/permissions.rb +22 -12
- data/tmpsets/set/{mod001-core → mod002-core}/all/phases.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/references.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/rules.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/stages.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/states.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/subcards.rb +0 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/templating.rb +0 -0
- data/tmpsets/set/mod002-core/all/tracked_attributes.rb +78 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/trash.rb +50 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/type.rb +0 -0
- data/tmpsets/set/mod002-core/all/update_read_rules.rb +91 -0
- data/tmpsets/set/mod002-core/all/utils.rb +62 -0
- data/tmpsets/set/{mod001-core → mod002-core}/all/view_cache.rb +0 -0
- data/tmpsets/set/{mod002-history → mod003-history}/all/actions.rb +0 -0
- data/tmpsets/set/{mod002-history → mod003-history}/all/content_history.rb +0 -0
- data/tmpsets/set/{mod002-history → mod003-history}/all/history.rb +2 -1
- data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/all/all_css.rb +0 -0
- data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/all/all_csv.rb +0 -0
- data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/all/all_js.rb +0 -0
- data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/all/base.rb +0 -0
- data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/all/file.rb +0 -0
- data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/all/json.rb +0 -0
- data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/all/rss.rb +0 -0
- data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/all/text.rb +0 -0
- data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/self/01_head/javascript.rb +0 -0
- data/tmpsets/set/{mod003-basic_formats → mod004-basic_formats}/self/head.rb +1 -1
- data/tmpsets/set/{mod004-pointer → mod005-pointer}/abstract/01_pointer.rb +0 -0
- data/tmpsets/set/{mod004-pointer → mod005-pointer}/abstract/01_pointer/edit.rb +0 -0
- data/tmpsets/set/{mod004-pointer → mod005-pointer}/abstract/code_pointer.rb +0 -0
- data/tmpsets/set/{mod004-pointer → mod005-pointer}/self/script_editors.rb +0 -0
- data/tmpsets/set/{mod004-pointer → mod005-pointer}/self/script_mods.rb +0 -0
- data/tmpsets/set/{mod004-pointer → mod005-pointer}/self/script_pointer_config.rb +0 -0
- data/tmpsets/set/{mod004-pointer → mod005-pointer}/type/pointer.rb +0 -0
- data/tmpsets/set/{mod005-ace_editor → mod006-ace_editor}/abstract/ace_editor.rb +0 -0
- data/tmpsets/set/{mod005-ace_editor → mod006-ace_editor}/self/script_ace.rb +0 -0
- data/tmpsets/set/{mod005-ace_editor → mod006-ace_editor}/self/script_ace_config.rb +0 -0
- data/tmpsets/set/{mod006-prosemirror_editor → mod007-prosemirror_editor}/abstract/prosemirror_editor.rb +0 -0
- data/tmpsets/set/{mod006-prosemirror_editor → mod007-prosemirror_editor}/self/script_prosemirror.rb +0 -0
- data/tmpsets/set/{mod006-prosemirror_editor → mod007-prosemirror_editor}/self/script_prosemirror_config.rb +0 -0
- data/tmpsets/set/{mod008-solid_cache → mod009-solid_cache}/abstract/solid_cache.rb +0 -0
- data/tmpsets/set/{mod008-solid_cache → mod009-solid_cache}/all/solid_cache.rb +0 -0
- data/tmpsets/set/{mod008-solid_cache → mod009-solid_cache}/right/solid_cache.rb +0 -0
- data/tmpsets/set/{mod009-basic_types → mod010-basic_types}/type/html.rb +0 -0
- data/tmpsets/set/{mod009-basic_types → mod010-basic_types}/type/plain_text.rb +0 -0
- data/tmpsets/set/mod011-machines/abstract/machine.rb +277 -0
- data/tmpsets/set/mod011-machines/abstract/machine_input.rb +83 -0
- data/tmpsets/set/{mod010-machines → mod011-machines}/abstract/script.rb +0 -0
- data/tmpsets/set/{mod010-machines → mod011-machines}/all/reset_machines.rb +0 -0
- data/tmpsets/set/{mod010-machines → mod011-machines}/right/machine_cache.rb +0 -0
- data/tmpsets/set/{mod010-machines → mod011-machines}/right/machine_input.rb +0 -0
- data/tmpsets/set/{mod010-machines → mod011-machines}/right/machine_output.rb +9 -1
- data/tmpsets/set/{mod010-machines → mod011-machines}/self/script_card_menu.rb +0 -0
- data/tmpsets/set/{mod010-machines → mod011-machines}/self/script_html5shiv_printshiv.rb +0 -0
- data/tmpsets/set/{mod010-machines → mod011-machines}/self/script_jquery.rb +0 -0
- data/tmpsets/set/{mod010-machines → mod011-machines}/self/script_jquery_helper.rb +0 -0
- data/tmpsets/set/{mod010-machines → mod011-machines}/self/script_slot.rb +0 -0
- data/tmpsets/set/{mod010-machines → mod011-machines}/self/style_bootstrap_compatible.rb +0 -0
- data/tmpsets/set/{mod010-machines → mod011-machines}/self/style_cards.rb +0 -0
- data/tmpsets/set/{mod010-machines → mod011-machines}/self/style_jquery_ui_smoothness.rb +0 -0
- data/tmpsets/set/{mod010-machines → mod011-machines}/type/coffee_script.rb +2 -6
- data/tmpsets/set/{mod010-machines → mod011-machines}/type/css.rb +2 -2
- data/tmpsets/set/{mod010-machines → mod011-machines}/type/java_script.rb +2 -2
- data/tmpsets/set/{mod010-machines → mod011-machines}/type/scss.rb +0 -0
- data/tmpsets/set/{mod010-machines → mod011-machines}/type/skin.rb +2 -2
- data/tmpsets/set/{mod011-settings → mod012-settings}/abstract/permission.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/right/add_help.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/right/comment.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/right/create.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/right/default.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/right/delete.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/right/help.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/right/read.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/right/script.rb +1 -1
- data/tmpsets/set/{mod011-settings → mod012-settings}/right/structure.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/right/style.rb +1 -1
- data/tmpsets/set/{mod011-settings → mod012-settings}/right/update.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/accountable.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/add_help.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/autoname.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/captcha.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/create.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/default.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/default_html_view.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/delete.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/follow_fields.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/help.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/input.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/layout.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/on_create.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/on_delete.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/on_update.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/options.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/options_label.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/read.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/recent_settings.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/script.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/structure.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/style.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/table_of_contents.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/thanks.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/self/update.rb +0 -0
- data/tmpsets/set/{mod011-settings → mod012-settings}/type/setting.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/all/email_html.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/all/email_text.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/all/follow.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/all/notify.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/all/observer.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/right/bcc.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/right/cc.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/right/follow.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/right/follow_fields.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/right/followers.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/right/following.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/right/from.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/right/html_message.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/right/to.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/self/always.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/self/created.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/self/edited.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/self/follow.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/self/follow_defaults.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/self/never.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/type/email_template.rb +0 -0
- data/tmpsets/set/{mod012-email → mod013-email}/type_plus_right/user/follow.rb +4 -8
- data/tmpsets/set/{mod015-developer → mod014-developer}/all/event_viz.rb +0 -0
- data/tmpsets/set/{mod015-developer → mod014-developer}/all/view_viz.rb +0 -0
- data/tmpsets/set/{mod015-developer → mod014-developer}/right/debug.rb +0 -0
- data/tmpsets/set/mod015-carrierwave/abstract/attachment.rb +118 -0
- data/tmpsets/set/mod015-carrierwave/abstract/attachment/paths.rb +57 -0
- data/tmpsets/set/mod015-carrierwave/abstract/attachment/storage_type.rb +326 -0
- data/tmpsets/set/mod015-carrierwave/abstract/attachment/upload_cache.rb +84 -0
- data/tmpsets/set/mod015-carrierwave/all/file_utils.rb +35 -0
- data/tmpsets/set/mod015-carrierwave/self/admin.rb +30 -0
- data/tmpsets/set/{mod013-carrierwave → mod015-carrierwave}/type/file.rb +27 -24
- data/tmpsets/set/{mod013-carrierwave → mod015-carrierwave}/type/image.rb +1 -0
- data/tmpsets/set/mod016-standard/all/links.rb +2 -2
- data/tmpsets/set/mod018-bootstrap/all/bootstrap/table.rb +1 -1
- data/tmpsets/set/mod018-bootstrap/self/bootswatch_shared.rb +1 -1
- data/vendor/carrierwave/.gitignore +19 -0
- data/vendor/carrierwave/.rubocop.yml +262 -0
- data/vendor/carrierwave/.travis.yml +58 -0
- data/vendor/carrierwave/CHANGELOG.md +81 -0
- data/vendor/carrierwave/CONTRIBUTING.md +37 -0
- data/vendor/carrierwave/Gemfile +5 -0
- data/vendor/carrierwave/README.md +995 -0
- data/vendor/carrierwave/Rakefile +26 -0
- data/vendor/carrierwave/carrierwave.gemspec +45 -0
- data/vendor/carrierwave/cucumber.yml +2 -0
- data/vendor/carrierwave/features/caching.feature +28 -0
- data/vendor/carrierwave/features/download.feature +20 -0
- data/vendor/carrierwave/features/file_storage.feature +37 -0
- data/vendor/carrierwave/features/file_storage_overridden_filename.feature +38 -0
- data/vendor/carrierwave/features/file_storage_overridden_store_dir.feature +38 -0
- data/vendor/carrierwave/features/file_storage_reversing_processor.feature +43 -0
- data/vendor/carrierwave/features/fixtures/bork.txt +1 -0
- data/vendor/carrierwave/features/fixtures/monkey.txt +1 -0
- data/vendor/carrierwave/features/fixtures/upcased_bork.txt +1 -0
- data/vendor/carrierwave/features/mount_activerecord.feature +46 -0
- data/vendor/carrierwave/features/step_definitions/activerecord_steps.rb +20 -0
- data/vendor/carrierwave/features/step_definitions/caching_steps.rb +12 -0
- data/vendor/carrierwave/features/step_definitions/datamapper_steps.rb +27 -0
- data/vendor/carrierwave/features/step_definitions/download_steps.rb +8 -0
- data/vendor/carrierwave/features/step_definitions/file_steps.rb +51 -0
- data/vendor/carrierwave/features/step_definitions/general_steps.rb +102 -0
- data/vendor/carrierwave/features/step_definitions/mount_steps.rb +17 -0
- data/vendor/carrierwave/features/step_definitions/store_steps.rb +16 -0
- data/vendor/carrierwave/features/support/activerecord.rb +18 -0
- data/vendor/carrierwave/features/support/env.rb +19 -0
- data/vendor/carrierwave/features/versions_basics.feature +50 -0
- data/vendor/carrierwave/features/versions_caching_from_versions.feature +32 -0
- data/vendor/carrierwave/features/versions_nested_versions.feature +70 -0
- data/vendor/carrierwave/features/versions_overridden_filename.feature +51 -0
- data/vendor/carrierwave/features/versions_overriden_store_dir.feature +41 -0
- data/vendor/carrierwave/gemfiles/rails-4-0-stable.gemfile +5 -0
- data/vendor/carrierwave/gemfiles/rails-4-1-stable.gemfile +5 -0
- data/vendor/carrierwave/gemfiles/rails-4-2-stable.gemfile +5 -0
- data/vendor/carrierwave/gemfiles/rails-master.gemfile +11 -0
- data/vendor/carrierwave/lib/carrierwave.rb +93 -0
- data/vendor/carrierwave/lib/carrierwave/compatibility/paperclip.rb +103 -0
- data/vendor/carrierwave/lib/carrierwave/error.rb +8 -0
- data/vendor/carrierwave/lib/carrierwave/locale/cs.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/locale/de.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/locale/el.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/locale/en.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/locale/es.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/locale/fr-CA.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/locale/fr.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/locale/id.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/locale/ja.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/locale/nb.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/locale/nl.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/locale/pl.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/locale/pt-BR.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/locale/pt-PT.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/locale/ru.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/locale/sk.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/locale/tr.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/locale/zh-CN.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/locale/zh-TW.yml +14 -0
- data/vendor/carrierwave/lib/carrierwave/mount.rb +444 -0
- data/vendor/carrierwave/lib/carrierwave/mounter.rb +163 -0
- data/vendor/carrierwave/lib/carrierwave/orm/activerecord.rb +103 -0
- data/vendor/carrierwave/lib/carrierwave/processing.rb +2 -0
- data/vendor/carrierwave/lib/carrierwave/processing/mini_magick.rb +328 -0
- data/vendor/carrierwave/lib/carrierwave/processing/rmagick.rb +379 -0
- data/vendor/carrierwave/lib/carrierwave/sanitized_file.rb +348 -0
- data/vendor/carrierwave/lib/carrierwave/storage.rb +2 -0
- data/vendor/carrierwave/lib/carrierwave/storage/abstract.rb +43 -0
- data/vendor/carrierwave/lib/carrierwave/storage/file.rb +118 -0
- data/vendor/carrierwave/lib/carrierwave/storage/fog.rb +462 -0
- data/vendor/carrierwave/lib/carrierwave/test/matchers.rb +394 -0
- data/vendor/carrierwave/lib/carrierwave/uploader.rb +67 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/cache.rb +207 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/callbacks.rb +33 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/configuration.rb +203 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/content_type_blacklist.rb +48 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/content_type_whitelist.rb +48 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/default_url.rb +17 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/download.rb +92 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/extension_blacklist.rb +51 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/extension_whitelist.rb +51 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/file_size.rb +41 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/magic_mime_blacklist.rb +94 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/magic_mime_whitelist.rb +94 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/mountable.rb +38 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/processing.rb +88 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/proxy.rb +86 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/remove.rb +21 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/serialization.rb +28 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/store.rb +93 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/url.rb +41 -0
- data/vendor/carrierwave/lib/carrierwave/uploader/versions.rb +295 -0
- data/vendor/carrierwave/lib/carrierwave/utilities.rb +6 -0
- data/vendor/carrierwave/lib/carrierwave/utilities/uri.rb +21 -0
- data/vendor/carrierwave/lib/carrierwave/validations/active_model.rb +78 -0
- data/vendor/carrierwave/lib/carrierwave/version.rb +3 -0
- data/vendor/carrierwave/lib/generators/templates/uploader.rb +49 -0
- data/vendor/carrierwave/lib/generators/uploader_generator.rb +7 -0
- data/vendor/carrierwave/script/console +10 -0
- data/vendor/carrierwave/script/destroy +14 -0
- data/vendor/carrierwave/script/generate +14 -0
- data/vendor/carrierwave/spec/compatibility/paperclip_spec.rb +138 -0
- data/vendor/carrierwave/spec/fixtures/Uppercase.jpg +1 -0
- data/vendor/carrierwave/spec/fixtures/bork.ttxt +1 -0
- data/vendor/carrierwave/spec/fixtures/bork.txt +1 -0
- data/vendor/carrierwave/spec/fixtures/bork.txtt +1 -0
- data/vendor/carrierwave/spec/fixtures/case.JPG +1 -0
- data/vendor/carrierwave/spec/fixtures/landscape.jpg +0 -0
- data/vendor/carrierwave/spec/fixtures/multi_page.pdf +0 -0
- data/vendor/carrierwave/spec/fixtures/new.jpeg +1 -0
- data/vendor/carrierwave/spec/fixtures/new.txt +1 -0
- data/vendor/carrierwave/spec/fixtures/old.jpeg +1 -0
- data/vendor/carrierwave/spec/fixtures/old.txt +1 -0
- data/vendor/carrierwave/spec/fixtures/portrait.jpg +0 -0
- data/vendor/carrierwave/spec/fixtures/ruby.gif +0 -0
- data/vendor/carrierwave/spec/fixtures/sponsored.doc +1 -0
- data/vendor/carrierwave/spec/fixtures/test+.jpg +1 -0
- data/vendor/carrierwave/spec/fixtures/test.jpeg +1 -0
- data/vendor/carrierwave/spec/fixtures/test.jpg +1 -0
- data/vendor/carrierwave/spec/generators/uploader_generator_spec.rb +19 -0
- data/vendor/carrierwave/spec/mount_multiple_spec.rb +913 -0
- data/vendor/carrierwave/spec/mount_single_spec.rb +793 -0
- data/vendor/carrierwave/spec/orm/activerecord_spec.rb +1556 -0
- data/vendor/carrierwave/spec/processing/mini_magick_spec.rb +210 -0
- data/vendor/carrierwave/spec/processing/rmagick_spec.rb +250 -0
- data/vendor/carrierwave/spec/sanitized_file_spec.rb +805 -0
- data/vendor/carrierwave/spec/spec_helper.rb +105 -0
- data/vendor/carrierwave/spec/storage/file_spec.rb +82 -0
- data/vendor/carrierwave/spec/storage/fog_credentials.rb +46 -0
- data/vendor/carrierwave/spec/storage/fog_helper.rb +428 -0
- data/vendor/carrierwave/spec/storage/fog_spec.rb +48 -0
- data/vendor/carrierwave/spec/support/activerecord.rb +31 -0
- data/vendor/carrierwave/spec/support/file_utils_helper.rb +15 -0
- data/vendor/carrierwave/spec/uploader/cache_spec.rb +324 -0
- data/vendor/carrierwave/spec/uploader/callback_spec.rb +30 -0
- data/vendor/carrierwave/spec/uploader/configuration_spec.rb +133 -0
- data/vendor/carrierwave/spec/uploader/content_type_blacklist_spec.rb +61 -0
- data/vendor/carrierwave/spec/uploader/content_type_whitelist_spec.rb +63 -0
- data/vendor/carrierwave/spec/uploader/default_url_spec.rb +77 -0
- data/vendor/carrierwave/spec/uploader/download_spec.rb +204 -0
- data/vendor/carrierwave/spec/uploader/extension_blacklist_spec.rb +112 -0
- data/vendor/carrierwave/spec/uploader/extension_whitelist_spec.rb +102 -0
- data/vendor/carrierwave/spec/uploader/file_size_spec.rb +52 -0
- data/vendor/carrierwave/spec/uploader/mountable_spec.rb +26 -0
- data/vendor/carrierwave/spec/uploader/overrides_spec.rb +71 -0
- data/vendor/carrierwave/spec/uploader/paths_spec.rb +18 -0
- data/vendor/carrierwave/spec/uploader/processing_spec.rb +159 -0
- data/vendor/carrierwave/spec/uploader/proxy_spec.rb +79 -0
- data/vendor/carrierwave/spec/uploader/remove_spec.rb +71 -0
- data/vendor/carrierwave/spec/uploader/store_spec.rb +400 -0
- data/vendor/carrierwave/spec/uploader/url_spec.rb +273 -0
- data/vendor/carrierwave/spec/uploader/versions_spec.rb +633 -0
- metadata +339 -187
- data/config/initializers/extensions.rb +0 -3
- data/mod/05_standard/file/favicon/image-icon.png +0 -0
- data/mod/05_standard/file/favicon/image-large.png +0 -0
- data/mod/05_standard/file/favicon/image-medium.png +0 -0
- data/mod/05_standard/file/favicon/image-original.png +0 -0
- data/mod/05_standard/file/favicon/image-small.png +0 -0
- data/mod/machines/lib/card/machine.rb +0 -261
- data/mod/machines/lib/card/machine_input.rb +0 -80
- data/mod/standard/file/credit/icon-image.png +0 -0
- data/mod/standard/file/credit/large-image.png +0 -0
- data/mod/standard/file/credit/medium-image.png +0 -0
- data/mod/standard/file/credit/original-image.png +0 -0
- data/mod/standard/file/credit/small-image.png +0 -0
- data/mod/standard/spec/set/type/file_spec.rb +0 -99
- data/tmpsets/set/mod001-core/all/tracked_attributes.rb +0 -154
- data/tmpsets/set/mod001-core/all/utils.rb +0 -132
- data/tmpsets/set/mod013-carrierwave/abstract/attachment.rb +0 -282
@@ -0,0 +1,793 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe CarrierWave::Mount do
|
4
|
+
|
5
|
+
after do
|
6
|
+
FileUtils.rm_rf(public_path)
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '.mount_uploader' do
|
10
|
+
|
11
|
+
before do
|
12
|
+
@class = Class.new
|
13
|
+
@class.send(:extend, CarrierWave::Mount)
|
14
|
+
|
15
|
+
@uploader = Class.new(CarrierWave::Uploader::Base)
|
16
|
+
|
17
|
+
@class.mount_uploader(:image, @uploader)
|
18
|
+
@instance = @class.new
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should maintain the ability to super" do
|
22
|
+
@class.class_eval do
|
23
|
+
def image_uploader
|
24
|
+
super
|
25
|
+
end
|
26
|
+
|
27
|
+
def image=(val)
|
28
|
+
super
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
@instance.image = stub_file('test.jpg')
|
33
|
+
expect(@instance.image).to be_an_instance_of(@uploader)
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should inherit uploaders to subclasses" do
|
37
|
+
@subclass = Class.new(@class)
|
38
|
+
@subclass_instance = @subclass.new
|
39
|
+
@subclass_instance.image = stub_file('test.jpg')
|
40
|
+
expect(@subclass_instance.image).to be_an_instance_of(@uploader)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should allow marshalling uploaders and versions" do
|
44
|
+
Object.const_set("MyClass#{@class.object_id}".tr('-', '_'), @class)
|
45
|
+
Object.const_set("Uploader#{@uploader.object_id}".tr('-', '_'), @uploader)
|
46
|
+
@uploader.class_eval do
|
47
|
+
def rotate
|
48
|
+
end
|
49
|
+
end
|
50
|
+
@uploader.version :thumb do
|
51
|
+
process :rotate
|
52
|
+
end
|
53
|
+
@instance.image = stub_file('test.jpg')
|
54
|
+
expect { Marshal.dump @instance.image }.not_to raise_error
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "expected behavior with subclassed uploaders" do
|
58
|
+
before do
|
59
|
+
@class = Class.new
|
60
|
+
@class.send(:extend, CarrierWave::Mount)
|
61
|
+
@uploader1 = Class.new(CarrierWave::Uploader::Base)
|
62
|
+
@uploader1.process :rotate
|
63
|
+
@uploader1.version :thumb do
|
64
|
+
process :compress
|
65
|
+
end
|
66
|
+
@uploader2 = Class.new(@uploader1)
|
67
|
+
@uploader2.process :shrink
|
68
|
+
@uploader2.version :secret do
|
69
|
+
process :encrypt
|
70
|
+
end
|
71
|
+
@class.mount_uploader(:image1, @uploader1)
|
72
|
+
@class.mount_uploader(:image2, @uploader2)
|
73
|
+
@instance = @class.new
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should inherit defined versions" do
|
77
|
+
expect(@instance.image1).to respond_to(:thumb)
|
78
|
+
expect(@instance.image2).to respond_to(:thumb)
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should not inherit versions defined in subclasses" do
|
82
|
+
expect(@instance.image1).not_to respond_to(:secret)
|
83
|
+
expect(@instance.image2).to respond_to(:secret)
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should inherit defined processors properly" do
|
87
|
+
expect(@uploader1.processors).to eq([[:rotate, [], nil]])
|
88
|
+
expect(@uploader2.processors).to eq([[:rotate, [], nil], [:shrink, [], nil]])
|
89
|
+
expect(@uploader1.versions[:thumb].processors).to eq([[:compress, [], nil]])
|
90
|
+
expect(@uploader2.versions[:thumb].processors).to eq([[:compress, [], nil]])
|
91
|
+
expect(@uploader2.versions[:secret].processors).to eq([[:encrypt, [], nil]])
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
describe '#image' do
|
96
|
+
|
97
|
+
it "should return a blank uploader when nothing has been assigned" do
|
98
|
+
expect(@instance).to receive(:read_uploader).with(:image).and_return(nil)
|
99
|
+
expect(@instance.image).to be_an_instance_of(@uploader)
|
100
|
+
expect(@instance.image).to be_blank
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should return the same object every time when nothing has been assigned" do
|
104
|
+
expect(@instance).to receive(:read_uploader).with(:image).and_return(nil)
|
105
|
+
expect(@instance.image.object_id).to eq @instance.image.object_id
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should return a blank uploader when an empty string has been assigned" do
|
109
|
+
expect(@instance).to receive(:read_uploader).with(:image).and_return('')
|
110
|
+
expect(@instance.image).to be_an_instance_of(@uploader)
|
111
|
+
expect(@instance.image).to be_blank
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should retrieve a file from the storage if a value is stored in the database" do
|
115
|
+
expect(@instance).to receive(:read_uploader).with(:image).at_least(:once).and_return('test.jpg')
|
116
|
+
expect(@instance.image).to be_an_instance_of(@uploader)
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should set the path to the store dir" do
|
120
|
+
expect(@instance).to receive(:read_uploader).with(:image).at_least(:once).and_return('test.jpg')
|
121
|
+
expect(@instance.image.current_path).to eq(public_path('uploads/test.jpg'))
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
|
126
|
+
describe '#image=' do
|
127
|
+
|
128
|
+
it "should cache a file" do
|
129
|
+
@instance.image = stub_file('test.jpg')
|
130
|
+
expect(@instance.image).to be_an_instance_of(@uploader)
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should copy a file into into the cache directory" do
|
134
|
+
@instance.image = stub_file('test.jpg')
|
135
|
+
expect(@instance.image.current_path).to match(/^#{public_path('uploads/tmp')}/)
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should do nothing when nil is assigned" do
|
139
|
+
expect(@instance).not_to receive(:write_uploader)
|
140
|
+
@instance.image = nil
|
141
|
+
end
|
142
|
+
|
143
|
+
it "should do nothing when an empty string is assigned" do
|
144
|
+
expect(@instance).not_to receive(:write_uploader)
|
145
|
+
@instance.image = stub_file('test.jpg')
|
146
|
+
end
|
147
|
+
|
148
|
+
it "should fail silently if the image fails a white list integrity check" do
|
149
|
+
@uploader.class_eval do
|
150
|
+
def extension_whitelist
|
151
|
+
%w(txt)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
@instance.image = stub_file('test.jpg')
|
155
|
+
expect(@instance.image).to be_blank
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should fail silently if the image fails a black list integrity check" do
|
159
|
+
@uploader.class_eval do
|
160
|
+
def extension_blacklist
|
161
|
+
%w(jpg)
|
162
|
+
end
|
163
|
+
end
|
164
|
+
@instance.image = stub_file('test.jpg')
|
165
|
+
expect(@instance.image).to be_blank
|
166
|
+
end
|
167
|
+
|
168
|
+
it "should fail silently if the image fails to be processed" do
|
169
|
+
@uploader.class_eval do
|
170
|
+
process :monkey
|
171
|
+
def monkey
|
172
|
+
raise CarrierWave::ProcessingError, "Ohh noez!"
|
173
|
+
end
|
174
|
+
end
|
175
|
+
@instance.image = stub_file('test.jpg')
|
176
|
+
end
|
177
|
+
|
178
|
+
end
|
179
|
+
|
180
|
+
describe '#image?' do
|
181
|
+
|
182
|
+
it "should be false when nothing has been assigned" do
|
183
|
+
@instance.image = nil
|
184
|
+
expect(@instance.image?).to be_falsey
|
185
|
+
end
|
186
|
+
|
187
|
+
it "should be false when an empty string has been assigned" do
|
188
|
+
@instance.image = ''
|
189
|
+
expect(@instance.image?).to be_falsey
|
190
|
+
end
|
191
|
+
|
192
|
+
it "should be true when a file has been cached" do
|
193
|
+
@instance.image = stub_file('test.jpg')
|
194
|
+
expect(@instance.image?).to be_truthy
|
195
|
+
end
|
196
|
+
|
197
|
+
end
|
198
|
+
|
199
|
+
describe '#image_url' do
|
200
|
+
|
201
|
+
it "should return nil when nothing has been assigned" do
|
202
|
+
expect(@instance).to receive(:read_uploader).with(:image).and_return(nil)
|
203
|
+
expect(@instance.image_url).to be_nil
|
204
|
+
end
|
205
|
+
|
206
|
+
it "should return fallback url when nothing has been assigned" do
|
207
|
+
@uploader.class_eval do
|
208
|
+
def default_url
|
209
|
+
"foo/bar.jpg"
|
210
|
+
end
|
211
|
+
end
|
212
|
+
expect(@instance).to receive(:read_uploader).with(:image).and_return(nil)
|
213
|
+
expect(@instance.image_url).to eq("foo/bar.jpg")
|
214
|
+
end
|
215
|
+
|
216
|
+
it "should return nil when an empty string has been assigned" do
|
217
|
+
expect(@instance).to receive(:read_uploader).with(:image).and_return('')
|
218
|
+
expect(@instance.image_url).to be_nil
|
219
|
+
end
|
220
|
+
|
221
|
+
it "should get the url from a retrieved file" do
|
222
|
+
expect(@instance).to receive(:read_uploader).at_least(:once).with(:image).and_return('test.jpg')
|
223
|
+
expect(@instance.image_url).to eq('/uploads/test.jpg')
|
224
|
+
end
|
225
|
+
|
226
|
+
it "should get the url from a cached file" do
|
227
|
+
@instance.image = stub_file('test.jpg')
|
228
|
+
expect(@instance.image_url).to match(%r{uploads/tmp/[\d\-]+/test.jpg})
|
229
|
+
end
|
230
|
+
|
231
|
+
it "should get the url from a cached file's version" do
|
232
|
+
@uploader.version(:thumb)
|
233
|
+
@instance.image = stub_file('test.jpg')
|
234
|
+
expect(@instance.image_url(:thumb)).to match(%r{uploads/tmp/[\d\-]+/thumb_test.jpg})
|
235
|
+
end
|
236
|
+
|
237
|
+
end
|
238
|
+
|
239
|
+
describe '#image_cache' do
|
240
|
+
|
241
|
+
before do
|
242
|
+
allow(@instance).to receive(:write_uploader)
|
243
|
+
allow(@instance).to receive(:read_uploader).and_return(nil)
|
244
|
+
end
|
245
|
+
|
246
|
+
it "should return nil when nothing has been assigned" do
|
247
|
+
expect(@instance.image_cache).to be_nil
|
248
|
+
end
|
249
|
+
|
250
|
+
it "should be nil when a file has been stored" do
|
251
|
+
@instance.image = stub_file('test.jpg')
|
252
|
+
@instance.image.store!
|
253
|
+
expect(@instance.image_cache).to be_nil
|
254
|
+
end
|
255
|
+
|
256
|
+
it "should be the cache name when a file has been cached" do
|
257
|
+
@instance.image = stub_file('test.jpg')
|
258
|
+
expect(@instance.image_cache).to match(%r(^[\d]+\-[\d]+\-[\d]{4}\-[\d]{4}/test\.jpg$))
|
259
|
+
end
|
260
|
+
|
261
|
+
end
|
262
|
+
|
263
|
+
describe '#image_cache=' do
|
264
|
+
|
265
|
+
before do
|
266
|
+
allow(@instance).to receive(:write_uploader)
|
267
|
+
allow(@instance).to receive(:read_uploader).and_return(nil)
|
268
|
+
CarrierWave::SanitizedFile.new(file_path('test.jpg')).copy_to(public_path('uploads/tmp/1369894322-123-0123-1234/test.jpg'))
|
269
|
+
end
|
270
|
+
|
271
|
+
it "should do nothing when nil is assigned" do
|
272
|
+
@instance.image_cache = nil
|
273
|
+
expect(@instance.image).to be_blank
|
274
|
+
end
|
275
|
+
|
276
|
+
it "should do nothing when an empty string is assigned" do
|
277
|
+
@instance.image_cache = ''
|
278
|
+
expect(@instance.image).to be_blank
|
279
|
+
end
|
280
|
+
|
281
|
+
it "retrieve from cache when a cache name is assigned" do
|
282
|
+
@instance.image_cache = '1369894322-123-0123-1234/test.jpg'
|
283
|
+
expect(@instance.image.current_path).to eq(public_path('uploads/tmp/1369894322-123-0123-1234/test.jpg'))
|
284
|
+
end
|
285
|
+
|
286
|
+
it "should not write over a previously assigned file" do
|
287
|
+
@instance.image = stub_file('test.jpg')
|
288
|
+
@instance.image_cache = '1369894322-123-0123-1234/monkey.jpg'
|
289
|
+
expect(@instance.image.current_path).to match(/test.jpg$/)
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
describe "#remote_image_url" do
|
294
|
+
before do
|
295
|
+
stub_request(:get, "www.example.com/test.jpg").to_return(body: File.read(file_path("test.jpg")))
|
296
|
+
end
|
297
|
+
|
298
|
+
it "returns nil" do
|
299
|
+
expect(@instance.remote_image_url).to be_nil
|
300
|
+
end
|
301
|
+
|
302
|
+
it "returns previously cached URL" do
|
303
|
+
@instance.remote_image_url = "http://www.example.com/test.jpg"
|
304
|
+
|
305
|
+
expect(@instance.remote_image_url).to eq("http://www.example.com/test.jpg")
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
describe "#remote_image_url=" do
|
310
|
+
before do
|
311
|
+
stub_request(:get, "www.example.com/test.jpg").to_return(body: File.read(file_path("test.jpg")))
|
312
|
+
end
|
313
|
+
|
314
|
+
it "does nothing when nil is assigned" do
|
315
|
+
@instance.remote_image_url = nil
|
316
|
+
|
317
|
+
expect(@instance.image).to be_blank
|
318
|
+
end
|
319
|
+
|
320
|
+
it "does nothing when an empty string is assigned" do
|
321
|
+
@instance.remote_image_url = ""
|
322
|
+
|
323
|
+
expect(@instance.image).to be_blank
|
324
|
+
end
|
325
|
+
|
326
|
+
it "retrieves from cache when a cache name is assigned" do
|
327
|
+
@instance.remote_image_url = "http://www.example.com/test.jpg"
|
328
|
+
|
329
|
+
expect(@instance.image.current_path).to match(/test.jpg$/)
|
330
|
+
end
|
331
|
+
|
332
|
+
it "writes over a previously assigned file" do
|
333
|
+
@instance.image = stub_file("portrait.jpg")
|
334
|
+
@instance.remote_image_url = "http://www.example.com/test.jpg"
|
335
|
+
|
336
|
+
expect(@instance.image.current_path).to match(/test.jpg$/)
|
337
|
+
end
|
338
|
+
end
|
339
|
+
|
340
|
+
describe '#store_image!' do
|
341
|
+
|
342
|
+
before do
|
343
|
+
allow(@instance).to receive(:write_uploader)
|
344
|
+
allow(@instance).to receive(:read_uploader).and_return(nil)
|
345
|
+
end
|
346
|
+
|
347
|
+
it "should do nothing when no file has been uploaded" do
|
348
|
+
@instance.store_image!
|
349
|
+
expect(@instance.image).to be_blank
|
350
|
+
end
|
351
|
+
|
352
|
+
it "store an assigned file" do
|
353
|
+
@instance.image = stub_file('test.jpg')
|
354
|
+
@instance.store_image!
|
355
|
+
expect(@instance.image.current_path).to eq(public_path('uploads/test.jpg'))
|
356
|
+
end
|
357
|
+
|
358
|
+
it "should remove an uploaded file when remove_image? returns true" do
|
359
|
+
@instance.image = stub_file('test.jpg')
|
360
|
+
path = @instance.image.current_path
|
361
|
+
@instance.remove_image = true
|
362
|
+
@instance.store_image!
|
363
|
+
expect(@instance.image).to be_blank
|
364
|
+
expect(File.exist?(path)).to be_falsey
|
365
|
+
end
|
366
|
+
end
|
367
|
+
|
368
|
+
describe '#remove_image!' do
|
369
|
+
|
370
|
+
before do
|
371
|
+
allow(@instance).to receive(:write_uploader)
|
372
|
+
allow(@instance).to receive(:read_uploader).and_return(nil)
|
373
|
+
end
|
374
|
+
|
375
|
+
it "should do nothing when no file has been uploaded" do
|
376
|
+
@instance.remove_image!
|
377
|
+
expect(@instance.image).to be_blank
|
378
|
+
end
|
379
|
+
|
380
|
+
it "should remove an uploaded file" do
|
381
|
+
@instance.image = stub_file('test.jpg')
|
382
|
+
path = @instance.image.current_path
|
383
|
+
@instance.remove_image!
|
384
|
+
expect(@instance.image).to be_blank
|
385
|
+
expect(File.exist?(path)).to be_falsey
|
386
|
+
end
|
387
|
+
end
|
388
|
+
|
389
|
+
describe '#remove_image' do
|
390
|
+
|
391
|
+
it "should store a value" do
|
392
|
+
@instance.remove_image = true
|
393
|
+
expect(@instance.remove_image).to be_truthy
|
394
|
+
end
|
395
|
+
|
396
|
+
end
|
397
|
+
|
398
|
+
describe '#remove_image?' do
|
399
|
+
|
400
|
+
it "should be true when the value is truthy" do
|
401
|
+
@instance.remove_image = true
|
402
|
+
expect(@instance.remove_image?).to be_truthy
|
403
|
+
end
|
404
|
+
|
405
|
+
it "should be false when the value is falsey" do
|
406
|
+
@instance.remove_image = false
|
407
|
+
expect(@instance.remove_image?).to be_falsey
|
408
|
+
end
|
409
|
+
|
410
|
+
it "should be false when the value is ''" do
|
411
|
+
@instance.remove_image = ''
|
412
|
+
expect(@instance.remove_image?).to be_falsey
|
413
|
+
end
|
414
|
+
|
415
|
+
it "should be false when the value is '0'" do
|
416
|
+
@instance.remove_image = '0'
|
417
|
+
expect(@instance.remove_image?).to be_falsey
|
418
|
+
end
|
419
|
+
|
420
|
+
it "should be false when the value is 'false'" do
|
421
|
+
@instance.remove_image = 'false'
|
422
|
+
expect(@instance.remove_image?).to be_falsey
|
423
|
+
end
|
424
|
+
|
425
|
+
end
|
426
|
+
|
427
|
+
describe '#image_integrity_error' do
|
428
|
+
|
429
|
+
it "should be nil by default" do
|
430
|
+
expect(@instance.image_integrity_error).to be_nil
|
431
|
+
end
|
432
|
+
|
433
|
+
it "should be nil after a file is cached" do
|
434
|
+
@instance.image = stub_file('test.jpg')
|
435
|
+
expect(@instance.image_integrity_error).to be_nil
|
436
|
+
end
|
437
|
+
|
438
|
+
describe "when an integrity check fails" do
|
439
|
+
before do
|
440
|
+
@uploader.class_eval do
|
441
|
+
def extension_whitelist
|
442
|
+
%w(txt)
|
443
|
+
end
|
444
|
+
end
|
445
|
+
end
|
446
|
+
|
447
|
+
it "should be an error instance if file was cached" do
|
448
|
+
@instance.image = stub_file('test.jpg')
|
449
|
+
e = @instance.image_integrity_error
|
450
|
+
expect(e).to be_an_instance_of(CarrierWave::IntegrityError)
|
451
|
+
expect(e.message.lines.grep(/^You are not allowed to upload/)).to be_truthy
|
452
|
+
end
|
453
|
+
|
454
|
+
it "should be an error instance if file was downloaded" do
|
455
|
+
stub_request(:get, "www.example.com/test.jpg").to_return(body: File.read(file_path("test.jpg")))
|
456
|
+
@instance.remote_image_url = "http://www.example.com/test.jpg"
|
457
|
+
e = @instance.image_integrity_error
|
458
|
+
|
459
|
+
expect(e).to be_an_instance_of(CarrierWave::IntegrityError)
|
460
|
+
expect(e.message.lines.grep(/^You are not allowed to upload/)).to be_truthy
|
461
|
+
end
|
462
|
+
|
463
|
+
it "should be an error instance when image file is assigned and remote_image_url is blank" do
|
464
|
+
@instance.image = stub_file('test.jpg')
|
465
|
+
@instance.remote_image_url = ""
|
466
|
+
e = @instance.image_integrity_error
|
467
|
+
expect(e).to be_an_instance_of(CarrierWave::IntegrityError)
|
468
|
+
expect(e.message.lines.grep(/^You are not allowed to upload/)).to be_truthy
|
469
|
+
end
|
470
|
+
end
|
471
|
+
end
|
472
|
+
|
473
|
+
describe '#image_processing_error' do
|
474
|
+
|
475
|
+
it "should be nil by default" do
|
476
|
+
expect(@instance.image_processing_error).to be_nil
|
477
|
+
end
|
478
|
+
|
479
|
+
it "should be nil after a file is cached" do
|
480
|
+
@instance.image = stub_file('test.jpg')
|
481
|
+
expect(@instance.image_processing_error).to be_nil
|
482
|
+
end
|
483
|
+
|
484
|
+
describe "when an processing error occurs" do
|
485
|
+
before do
|
486
|
+
@uploader.class_eval do
|
487
|
+
process :monkey
|
488
|
+
def monkey
|
489
|
+
raise CarrierWave::ProcessingError, "Ohh noez!"
|
490
|
+
end
|
491
|
+
end
|
492
|
+
end
|
493
|
+
|
494
|
+
it "should be an error instance if file was cached" do
|
495
|
+
@instance.image = stub_file('test.jpg')
|
496
|
+
expect(@instance.image_processing_error).to be_an_instance_of(CarrierWave::ProcessingError)
|
497
|
+
end
|
498
|
+
|
499
|
+
it "should be an error instance if file was downloaded" do
|
500
|
+
stub_request(:get, "www.example.com/test.jpg").to_return(body: File.read(file_path("test.jpg")))
|
501
|
+
@instance.remote_image_url = "http://www.example.com/test.jpg"
|
502
|
+
|
503
|
+
expect(@instance.image_processing_error).to be_an_instance_of(CarrierWave::ProcessingError)
|
504
|
+
end
|
505
|
+
end
|
506
|
+
end
|
507
|
+
|
508
|
+
describe '#image_download_error' do
|
509
|
+
before do
|
510
|
+
stub_request(:get, "www.example.com/test.jpg").to_return(body: File.read(file_path("test.jpg")))
|
511
|
+
stub_request(:get, "www.example.com/missing.jpg").to_return(status: 404)
|
512
|
+
end
|
513
|
+
|
514
|
+
it "should be nil by default" do
|
515
|
+
expect(@instance.image_download_error).to be_nil
|
516
|
+
end
|
517
|
+
|
518
|
+
it "should be nil if file download was successful" do
|
519
|
+
@instance.remote_image_url = "http://www.example.com/test.jpg"
|
520
|
+
expect(@instance.image_download_error).to be_nil
|
521
|
+
end
|
522
|
+
|
523
|
+
it "should be an error instance if file could not be found" do
|
524
|
+
@instance.remote_image_url = "http://www.example.com/missing.jpg"
|
525
|
+
expect(@instance.image_download_error).to be_an_instance_of(CarrierWave::DownloadError)
|
526
|
+
end
|
527
|
+
end
|
528
|
+
|
529
|
+
describe '#image_download_error' do
|
530
|
+
before do
|
531
|
+
stub_request(:get, "www.example.com/test.jpg").to_return(body: File.read(file_path("test.jpg")))
|
532
|
+
stub_request(:get, "www.example.com/missing.jpg").to_return(status: 404)
|
533
|
+
end
|
534
|
+
|
535
|
+
it "should be nil by default" do
|
536
|
+
expect(@instance.image_download_error).to be_nil
|
537
|
+
end
|
538
|
+
|
539
|
+
it "should be nil if file download was successful" do
|
540
|
+
@instance.remote_image_url = "http://www.example.com/test.jpg"
|
541
|
+
expect(@instance.image_download_error).to be_nil
|
542
|
+
end
|
543
|
+
|
544
|
+
it "should be an error instance if file could not be found" do
|
545
|
+
@instance.remote_image_url = "http://www.example.com/missing.jpg"
|
546
|
+
expect(@instance.image_download_error).to be_an_instance_of(CarrierWave::DownloadError)
|
547
|
+
end
|
548
|
+
end
|
549
|
+
|
550
|
+
describe '#write_image_identifier' do
|
551
|
+
it "should write to the column" do
|
552
|
+
expect(@instance).to receive(:write_uploader).with(:image, "test.jpg")
|
553
|
+
@instance.image = stub_file('test.jpg')
|
554
|
+
@instance.write_image_identifier
|
555
|
+
end
|
556
|
+
|
557
|
+
it "should remove from the column when remove_image is true" do
|
558
|
+
@instance.image = stub_file('test.jpg')
|
559
|
+
@instance.store_image!
|
560
|
+
@instance.remove_image = true
|
561
|
+
expect(@instance).to receive(:write_uploader).with(:image, nil)
|
562
|
+
@instance.write_image_identifier
|
563
|
+
end
|
564
|
+
end
|
565
|
+
|
566
|
+
describe '#image_identifier' do
|
567
|
+
it "should return the identifier from the mounted column" do
|
568
|
+
expect(@instance).to receive(:read_uploader).with(:image).and_return("test.jpg")
|
569
|
+
expect(@instance.image_identifier).to eq('test.jpg')
|
570
|
+
end
|
571
|
+
end
|
572
|
+
|
573
|
+
end
|
574
|
+
|
575
|
+
describe '#mount_uploader without an uploader' do
|
576
|
+
|
577
|
+
before do
|
578
|
+
@class = Class.new
|
579
|
+
@class.send(:extend, CarrierWave::Mount)
|
580
|
+
@class.mount_uploader(:image)
|
581
|
+
@instance = @class.new
|
582
|
+
end
|
583
|
+
|
584
|
+
describe '#image' do
|
585
|
+
|
586
|
+
before do
|
587
|
+
allow(@instance).to receive(:read_uploader).and_return('test.jpg')
|
588
|
+
end
|
589
|
+
|
590
|
+
it "should return an instance of a subclass of CarrierWave::Uploader::Base" do
|
591
|
+
expect(@instance.image).to be_a(CarrierWave::Uploader::Base)
|
592
|
+
end
|
593
|
+
|
594
|
+
it "should set the path to the store dir" do
|
595
|
+
expect(@instance.image.current_path).to eq(public_path('uploads/test.jpg'))
|
596
|
+
end
|
597
|
+
|
598
|
+
end
|
599
|
+
|
600
|
+
end
|
601
|
+
|
602
|
+
describe '#mount_uploader with a block' do
|
603
|
+
describe 'and no uploader given' do
|
604
|
+
before do
|
605
|
+
@class = Class.new
|
606
|
+
@class.send(:extend, CarrierWave::Mount)
|
607
|
+
@class.mount_uploader(:image) do
|
608
|
+
def monkey
|
609
|
+
'blah'
|
610
|
+
end
|
611
|
+
end
|
612
|
+
@instance = @class.new
|
613
|
+
end
|
614
|
+
|
615
|
+
it "should return an instance of a subclass of CarrierWave::Uploader::Base" do
|
616
|
+
expect(@instance.image).to be_a(CarrierWave::Uploader::Base)
|
617
|
+
end
|
618
|
+
|
619
|
+
it "should apply any custom modifications" do
|
620
|
+
expect(@instance.image.monkey).to eq("blah")
|
621
|
+
end
|
622
|
+
end
|
623
|
+
|
624
|
+
describe 'and an uploader given' do
|
625
|
+
before do
|
626
|
+
@class = Class.new
|
627
|
+
@class.send(:extend, CarrierWave::Mount)
|
628
|
+
@uploader = Class.new(CarrierWave::Uploader::Base)
|
629
|
+
@uploader.version :thumb do
|
630
|
+
version :mini
|
631
|
+
version :maxi
|
632
|
+
end
|
633
|
+
@class.mount_uploader(:image, @uploader) do
|
634
|
+
def fish
|
635
|
+
'blub'
|
636
|
+
end
|
637
|
+
end
|
638
|
+
@instance = @class.new
|
639
|
+
end
|
640
|
+
|
641
|
+
it "should return an instance of the uploader specified" do
|
642
|
+
expect(@instance.image).to be_a_kind_of(@uploader)
|
643
|
+
end
|
644
|
+
|
645
|
+
it "should apply any custom modifications to the instance" do
|
646
|
+
expect(@instance.image.fish).to eq("blub")
|
647
|
+
end
|
648
|
+
|
649
|
+
it "should apply any custom modifications to all defined versions" do
|
650
|
+
expect(@instance.image.thumb.fish).to eq("blub")
|
651
|
+
expect(@instance.image.thumb.mini.fish).to eq("blub")
|
652
|
+
expect(@instance.image.thumb.maxi.fish).to eq("blub")
|
653
|
+
end
|
654
|
+
|
655
|
+
it "should not apply any custom modifications to the uploader class" do
|
656
|
+
expect(@uploader.new).not_to respond_to(:fish)
|
657
|
+
end
|
658
|
+
end
|
659
|
+
end
|
660
|
+
|
661
|
+
describe '#mount_uploader with :ignore_integrity_errors => false' do
|
662
|
+
|
663
|
+
before do
|
664
|
+
@class = Class.new
|
665
|
+
@class.send(:extend, CarrierWave::Mount)
|
666
|
+
|
667
|
+
@uploader = Class.new(CarrierWave::Uploader::Base)
|
668
|
+
|
669
|
+
@class.mount_uploader(:image, @uploader, :ignore_integrity_errors => false)
|
670
|
+
@instance = @class.new
|
671
|
+
|
672
|
+
@uploader.class_eval do
|
673
|
+
def extension_whitelist
|
674
|
+
%w(txt)
|
675
|
+
end
|
676
|
+
end
|
677
|
+
end
|
678
|
+
|
679
|
+
it "should raise an error if the image fails an integrity check when cached" do
|
680
|
+
expect(running {
|
681
|
+
@instance.image = stub_file('test.jpg')
|
682
|
+
}).to raise_error(CarrierWave::IntegrityError)
|
683
|
+
end
|
684
|
+
|
685
|
+
it "should raise an error if the image fails an integrity check when downloaded" do
|
686
|
+
stub_request(:get, "www.example.com/test.jpg").to_return(body: File.read(file_path("test.jpg")))
|
687
|
+
|
688
|
+
expect(running {
|
689
|
+
@instance.remote_image_url = "http://www.example.com/test.jpg"
|
690
|
+
}).to raise_error(CarrierWave::IntegrityError)
|
691
|
+
end
|
692
|
+
end
|
693
|
+
|
694
|
+
describe '#mount_uploader with :ignore_processing_errors => false' do
|
695
|
+
|
696
|
+
before do
|
697
|
+
@class = Class.new
|
698
|
+
@class.send(:extend, CarrierWave::Mount)
|
699
|
+
|
700
|
+
@uploader = Class.new(CarrierWave::Uploader::Base)
|
701
|
+
|
702
|
+
@class.mount_uploader(:image, @uploader, :ignore_processing_errors => false)
|
703
|
+
@instance = @class.new
|
704
|
+
|
705
|
+
@uploader.class_eval do
|
706
|
+
process :monkey
|
707
|
+
def monkey
|
708
|
+
raise CarrierWave::ProcessingError, "Ohh noez!"
|
709
|
+
end
|
710
|
+
end
|
711
|
+
end
|
712
|
+
|
713
|
+
it "should raise an error if the image fails to be processed when cached" do
|
714
|
+
expect(running {
|
715
|
+
@instance.image = stub_file('test.jpg')
|
716
|
+
}).to raise_error(CarrierWave::ProcessingError)
|
717
|
+
end
|
718
|
+
|
719
|
+
it "should raise an error if the image fails to be processed when downloaded" do
|
720
|
+
stub_request(:get, "www.example.com/test.jpg").to_return(body: File.read(file_path("test.jpg")))
|
721
|
+
|
722
|
+
expect(running {
|
723
|
+
@instance.remote_image_url = "http://www.example.com/test.jpg"
|
724
|
+
}).to raise_error(CarrierWave::ProcessingError)
|
725
|
+
end
|
726
|
+
|
727
|
+
end
|
728
|
+
|
729
|
+
describe '#mount_uploader with :ignore_download_errors => false' do
|
730
|
+
|
731
|
+
before do
|
732
|
+
@class = Class.new
|
733
|
+
@class.send(:extend, CarrierWave::Mount)
|
734
|
+
|
735
|
+
@uploader = Class.new(CarrierWave::Uploader::Base)
|
736
|
+
|
737
|
+
@class.mount_uploader(:image, @uploader, :ignore_download_errors => false)
|
738
|
+
@instance = @class.new
|
739
|
+
end
|
740
|
+
|
741
|
+
it "should raise an error if the image fails to be processed" do
|
742
|
+
@uploader.class_eval do
|
743
|
+
def download! uri
|
744
|
+
raise CarrierWave::DownloadError
|
745
|
+
end
|
746
|
+
end
|
747
|
+
|
748
|
+
expect(running {
|
749
|
+
@instance.remote_image_url = "http://www.example.com/test.jpg"
|
750
|
+
}).to raise_error(CarrierWave::DownloadError)
|
751
|
+
end
|
752
|
+
|
753
|
+
end
|
754
|
+
|
755
|
+
describe '#mount_uploader with :mount_on => :monkey' do
|
756
|
+
|
757
|
+
before do
|
758
|
+
@class = Class.new
|
759
|
+
@class.send(:extend, CarrierWave::Mount)
|
760
|
+
|
761
|
+
@uploader = Class.new(CarrierWave::Uploader::Base)
|
762
|
+
|
763
|
+
@class.mount_uploader(:image, @uploader, :mount_on => :monkey)
|
764
|
+
@instance = @class.new
|
765
|
+
end
|
766
|
+
|
767
|
+
describe '#image' do
|
768
|
+
it "should retrieve a file from the storage if a value is stored in the database" do
|
769
|
+
expect(@instance).to receive(:read_uploader).at_least(:once).with(:monkey).and_return('test.jpg')
|
770
|
+
expect(@instance.image).to be_an_instance_of(@uploader)
|
771
|
+
expect(@instance.image.current_path).to eq(public_path('uploads/test.jpg'))
|
772
|
+
end
|
773
|
+
end
|
774
|
+
|
775
|
+
describe '#write_image_identifier' do
|
776
|
+
it "should write to the given column" do
|
777
|
+
expect(@instance).to receive(:write_uploader).with(:monkey, "test.jpg")
|
778
|
+
@instance.image = stub_file('test.jpg')
|
779
|
+
@instance.write_image_identifier
|
780
|
+
end
|
781
|
+
|
782
|
+
it "should remove from the given column when remove_image is true" do
|
783
|
+
@instance.image = stub_file('test.jpg')
|
784
|
+
@instance.store_image!
|
785
|
+
@instance.remove_image = true
|
786
|
+
expect(@instance).to receive(:write_uploader).with(:monkey, nil)
|
787
|
+
@instance.write_image_identifier
|
788
|
+
end
|
789
|
+
end
|
790
|
+
|
791
|
+
end
|
792
|
+
|
793
|
+
end
|