Sha256: 08857e30b81268952e15bc6a688a60867fdf85cebe17c76f81a01e7e3788c769

Contents?: true

Size: 1.39 KB

Versions: 29

Compression:

Stored size: 1.39 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 Specs
    module ControllerHacks

      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, parameters.merge!(:use_route => :alchemy), session, flash, method)
      end

    end
  end
end

RSpec.configure do |c|
  c.include Alchemy::Specs::ControllerHacks, :type => :controller
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
alchemy_cms-2.5.0.b9 spec/support/alchemy/controller_hacks.rb
alchemy_cms-2.3.2 spec/support/alchemy/controller_hacks.rb
alchemy_cms-2.2.4 spec/support/alchemy/controller_hacks.rb
alchemy_cms-2.4.1 spec/support/alchemy/controller_hacks.rb
alchemy_cms-2.5.0.b5 spec/support/alchemy/controller_hacks.rb
alchemy_cms-2.5.0.b2 spec/support/alchemy/controller_hacks.rb
alchemy_cms-2.4.0 spec/support/alchemy/controller_hacks.rb
alchemy_cms-2.4.rc4 spec/support/alchemy/controller_hacks.rb
alchemy_cms-2.4.rc2 spec/support/alchemy/controller_hacks.rb
alchemy_cms-2.4.rc1 spec/support/alchemy/controller_hacks.rb
alchemy_cms-2.3.1 spec/support/alchemy/controller_hacks.rb
alchemy_cms-2.4.beta2 spec/support/alchemy/controller_hacks.rb
alchemy_cms-2.2.3.2 spec/support/alchemy/controller_hacks.rb
alchemy_cms-2.2.3.1 spec/support/alchemy/controller_hacks.rb
alchemy_cms-2.3.0 spec/support/alchemy/controller_hacks.rb
alchemy_cms-2.3.rc5 spec/support/alchemy/controller_hacks.rb
alchemy_cms-2.2.2 spec/support/alchemy/controller_hacks.rb
alchemy_cms-2.2.1 spec/support/alchemy/controller_hacks.rb
alchemy_cms-2.2.0 spec/support/alchemy/controller_hacks.rb
alchemy_cms-2.2.rc15 spec/support/alchemy/controller_hacks.rb