Sha256: 2963de1e6de9c04bd53681993bcabd3efd70e424232a23eb5a6048130a8ff5de

Contents?: true

Size: 971 Bytes

Versions: 31

Compression:

Stored size: 971 Bytes

Contents

require 'active_support/all'
module ControllerHacks
  extend ActiveSupport::Concern

  included do
    routes { Spree::Core::Engine.routes }
  end

  def api_get(action, params={}, session=nil, flash=nil)
    api_process(action, params, session, flash, "GET")
  end

  def api_post(action, params={}, session=nil, flash=nil)
    api_process(action, params, session, flash, "POST")
  end

  def api_put(action, params={}, session=nil, flash=nil)
    api_process(action, params, session, flash, "PUT")
  end

  def api_delete(action, params={}, session=nil, flash=nil)
    api_process(action, params, session, flash, "DELETE")
  end

  def api_process(action, params={}, session=nil, flash=nil, method="get")
    scoping = respond_to?(:resource_scoping) ? resource_scoping : {}
    process(action, method, params.merge(scoping).reverse_merge!(:format => :json), session, flash)
  end
end

RSpec.configure do |config|
  config.include ControllerHacks, type: :controller
end

Version data entries

31 entries across 31 versions & 3 rubygems

Version Path
spree_api-3.1.5 spec/support/controller_hacks.rb
spree_api-3.1.4 spec/support/controller_hacks.rb
spree_api-3.1.3 spec/support/controller_hacks.rb
spree_api-3.1.2 spec/support/controller_hacks.rb
spree_api-3.0.10 spec/support/controller_hacks.rb
spree_api-3.1.1 spec/support/controller_hacks.rb
spree_api-3.1.0 spec/support/controller_hacks.rb
spree_api-3.1.0.rc4 spec/support/controller_hacks.rb
spree_api-3.0.9 spec/support/controller_hacks.rb
spree_api-3.1.0.rc3 spec/support/controller_hacks.rb
spree_api-3.1.0.rc2 spec/support/controller_hacks.rb
spree_api-3.1.0.rc1 spec/support/controller_hacks.rb
spree_api-3.0.8 spec/support/controller_hacks.rb
spree_api-3.0.7 spec/support/controller_hacks.rb
spree_api-3.0.6.1 spec/support/controller_hacks.rb
spree_api-3.0.6 spec/support/controller_hacks.rb
spree_api-3.0.5 spec/support/controller_hacks.rb
solidus_br_common-1.1.3 spec/support/controller_hacks.rb
solidus_br_common-1.1.2 spec/support/controller_hacks.rb
solidus_br_common-1.1.1 spec/support/controller_hacks.rb