Skip to content

Commit

Permalink
Set environment for payment methods unless admin
Browse files Browse the repository at this point in the history
  • Loading branch information
oeoeaio committed Oct 24, 2014
1 parent 8385bff commit 6155600
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Spree
module Admin
PaymentMethodsController.class_eval do
before_filter :force_environment, only: [:create, :update]
skip_before_filter :load_resource, only: [:show_provider_preferences]
before_filter :load_hubs, only: [:new, :edit, :update]
create.before :load_hubs
Expand Down Expand Up @@ -46,6 +47,10 @@ def show_provider_preferences

private

def force_environment
params[:payment_method][:environment] = Rails.env unless spree_current_user.admin?
end

def load_data
if spree_current_user.admin? || Rails.env.test?
@providers = Gateway.providers.sort{|p1, p2| p1.name <=> p2.name }
Expand Down

0 comments on commit 6155600

Please sign in to comment.