Sha256: 86497e9debf9aafdd61d7e6a211a3eb0fa7fb90352113c20c4a1e15bc8754ed1

Contents?: true

Size: 1.04 KB

Versions: 32

Compression:

Stored size: 1.04 KB

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: method,
      params: params.merge(scoping),
      session: session,
      flash: flash,
      format: :json
    )
  end
end

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

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
solidus_api-2.5.2 spec/support/controller_hacks.rb
solidus_api-2.5.1 spec/support/controller_hacks.rb
solidus_api-2.5.0 spec/support/controller_hacks.rb
solidus_api-2.5.0.rc1 spec/support/controller_hacks.rb
solidus_api-2.5.0.beta2 spec/support/controller_hacks.rb
solidus_api-2.5.0.beta1 spec/support/controller_hacks.rb
solidus_api-2.4.2 spec/support/controller_hacks.rb
solidus_api-2.4.1 spec/support/controller_hacks.rb
solidus_api-2.3.1 spec/support/controller_hacks.rb
solidus_api-2.2.2 spec/support/controller_hacks.rb
solidus_api-2.1.1 spec/support/controller_hacks.rb
solidus_api-2.0.3 spec/support/controller_hacks.rb
solidus_api-2.4.0 spec/support/controller_hacks.rb
solidus_api-2.4.0.rc1 spec/support/controller_hacks.rb
solidus_api-2.4.0.beta1 spec/support/controller_hacks.rb
solidus_api-2.3.0 spec/support/controller_hacks.rb
solidus_api-2.3.0.rc3 spec/support/controller_hacks.rb
solidus_api-2.3.0.rc2 spec/support/controller_hacks.rb
solidus_api-2.3.0.rc1 spec/support/controller_hacks.rb
solidus_api-2.3.0.beta1 spec/support/controller_hacks.rb