Don't talk to server during tests (ActiveRecord callbacks)

未关闭
#148 6 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
rails, ruby
领域
backend, testing

调研方向

从堆栈跟踪中的 cloudinary/carrier_wave.rb:160 开始,跟踪 ActiveRecord 提交期间调用的删除回调。使用禁用文件存储和处理的测试配置进行复现,然后验证当 enable_processing 为 false 时,销毁模型不会发起任何远程 API 调用。

由索引模型根据 Issue 内容生成。

描述

enhancement

This is related to https://github.com/cloudinary/cloudinary_gem/issues/23

It seems the cloudinary gem still makes remote calls to https://api.cloudinary.com/v1_1/[accountname]/image/destroy when destroy() is invoked on a model, even when CarrierWave is configured to use the file store and enable_processing is false

if Rails.env.test? or Rails.env.cucumber?
  CarrierWave.configure do |config|
    config.storage = :file
    config.enable_processing = false
  end
end

The relevant stack trace is below. We only started to notice this after upgrading to Rails 4.2 and setting config.active_record.raise_in_transactional_callbacks = true in application.rb. Since the remote call is made in an after_commit hook, the tests didn't see the problem.

Can you please update the cloudinary gem to skip the call is enabled_processing==false?

     # /home/vagrant/.rvm/gems/ruby-2.1.6/gems/cloudinary-1.0.75/lib/cloudinary/uploader.rb:284:in `call_api'
     # /home/vagrant/.rvm/gems/ruby-2.1.6/gems/cloudinary-1.0.75/lib/cloudinary/uploader.rb:133:in `destroy'
     # /home/vagrant/.rvm/gems/ruby-2.1.6/gems/cloudinary-1.0.75/lib/cloudinary/carrier_wave.rb:160:in `delete'
     # /home/vagrant/.rvm/gems/ruby-2.1.6/gems/carrierwave-0.10.0/lib/carrierwave/uploader/remove.rb:15:in `block in remove!'
     # /home/vagrant/.rvm/gems/ruby-2.1.6/gems/carrierwave-0.10.0/lib/carrierwave/uploader/callbacks.rb:17:in `with_callbacks'
     # /home/vagrant/.rvm/gems/ruby-2.1.6/gems/carrierwave-0.10.0/lib/carrierwave/uploader/remove.rb:14:in `remove!'
     # /home/vagrant/.rvm/gems/ruby-2.1.6/gems/carrierwave-0.10.0/lib/carrierwave/mount.rb:392:in `remove!'
     # /home/vagrant/.rvm/gems/ruby-2.1.6/gems/carrierwave-0.10.0/lib/carrierwave/mount.rb:195:in `remove_cover_image!'
     # /home/vagrant/.rvm/gems/ruby-2.1.6/gems/carrierwave-0.10.0/lib/carrierwave/orm/activerecord.rb:49:in `remove_cover_image!'
     # /home/vagrant/.rvm/gems/ruby-2.1.6/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:432:in `block in make_lambda'
     # /home/vagrant/.rvm/gems/ruby-2.1.6/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:253:in `call'
     # /home/vagrant/.rvm/gems/ruby-2.1.6/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:253:in `block in conditional'
     # /home/vagrant/.rvm/gems/ruby-2.1.6/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:506:in `call'
     # /home/vagrant/.rvm/gems/ruby-2.1.6/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:506:in `block in call'
     # /home/vagrant/.rvm/gems/ruby-2.1.6/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:506:in `each'
     # /home/vagrant/.rvm/gems/ruby-2.1.6/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:506:in `call'
     # /home/vagrant/.rvm/gems/ruby-2.1.6/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:92:in `_run_callbacks'
     # /home/vagrant/.rvm/gems/ruby-2.1.6/gems/activesupport-4.2.1/lib/active_support/callbacks.rb:776:in `_run_commit_callbacks'
     # /home/vagrant/.rvm/gems/ruby-2.1.6/gems/activerecord-4.2.1/lib/active_record/transactions.rb:314:in `committed!
主要语言
Ruby
星标
420
派生
282
PR 合并指标
30 天内没有已合并 PR

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

cloudinary/cloudinary_gem 的其他 Issue

查看 cloudinary/cloudinary_gem 的全部 Issue

相似的 Issue

更多 Ruby Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。