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 摘要。