Sha256: 601106e51bf158b21cbf0e7c2ec2201d684a55286d21f558f881a1b09bd53260

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

module Spree
  module ControllerRouteFix
    def get(action, parameters = nil, session = nil, flash = nil)
      process_spree_action(action, parameters, session, flash, "GET")
    end

    # Executes a request simulating POST HTTP method and set/volley the response
    def post(action, parameters = nil, session = nil, flash = nil)
      process_spree_action(action, parameters, session, flash, "POST")
    end

    # Executes a request simulating PUT HTTP method and set/volley the response
    def put(action, parameters = nil, session = nil, flash = nil)
      process_spree_action(action, parameters, session, flash, "PUT")
    end

    # Executes a request simulating DELETE HTTP method and set/volley the response
    def delete(action, parameters = nil, session = nil, flash = nil)
      process_spree_action(action, parameters, session, flash, "DELETE")
    end

    private

    def process_spree_action(action, parameters = nil, session = nil, flash = nil, method = "GET")
      parameters ||= {}
      process(action, parameters.merge!(:use_route => :selections), session, flash, method)
    end
  end
end

RSpec.configure do |c|
  c.include Spree::ControllerRouteFix, :type => :controller
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
selections-0.0.1 spec/support/controller_route_fix.rb