Sha256: 5ae400fbb5d5896956516652423554cf79c428538bb7c35802dd2d235fd0a670

Contents?: true

Size: 1.31 KB

Versions: 21

Compression:

Stored size: 1.31 KB

Contents

# Based on spree commerce controller hacks.
# https://github.com/spree/spree/blob/master/core/spec/support/controller_hacks.rb
# Thanks!

module Alchemy
  module TestSupport
    module ControllerRequests

      def get(action, parameters = nil, session = nil, flash = nil)
        process_alchemy_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_alchemy_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_alchemy_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_alchemy_action(action, parameters, session, flash, "DELETE")
      end

      private

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

    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
alchemy_cms-3.1.3 lib/alchemy/test_support/controller_requests.rb
alchemy_cms-3.1.1 lib/alchemy/test_support/controller_requests.rb
alchemy_cms-3.0.4 lib/alchemy/test_support/controller_requests.rb
alchemy_cms-3.1.0 lib/alchemy/test_support/controller_requests.rb
alchemy_cms-3.1.0.rc3 lib/alchemy/test_support/controller_requests.rb
alchemy_cms-3.1.0.rc2 lib/alchemy/test_support/controller_requests.rb
alchemy_cms-3.1.0.rc1 lib/alchemy/test_support/controller_requests.rb
alchemy_cms-3.1.0.beta6 lib/alchemy/test_support/controller_requests.rb
alchemy_cms-3.1.0.beta5 lib/alchemy/test_support/controller_requests.rb
alchemy_cms-3.1.0.beta4 lib/alchemy/test_support/controller_requests.rb
alchemy_cms-3.0.3 lib/alchemy/test_support/controller_requests.rb
alchemy_cms-3.1.0.beta3 lib/alchemy/test_support/controller_requests.rb
alchemy_cms-3.1.0.beta2 lib/alchemy/test_support/controller_requests.rb
alchemy_cms-3.1.0.beta1 lib/alchemy/test_support/controller_requests.rb
alchemy_cms-3.0.2 lib/alchemy/test_support/controller_requests.rb
alchemy_cms-3.0.1 lib/alchemy/test_support/controller_requests.rb
alchemy_cms-3.0.0 lib/alchemy/test_support/controller_requests.rb
alchemy_cms-3.0.0.rc8 lib/alchemy/test_support/controller_requests.rb
alchemy_cms-3.0.0.rc7 lib/alchemy/test_support/controller_requests.rb
alchemy_cms-3.0.0.rc6 lib/alchemy/test_support/controller_requests.rb