Skip to content

Commit

Permalink
changing is_international? method to more semantic meaning, like shou…
Browse files Browse the repository at this point in the history
…ld_checkout_with_fastspring? to eliminate ambiguity with the logic seperating the 2 concerns
  • Loading branch information
Timothy Johnson committed Feb 15, 2013
1 parent 57036a5 commit 72624f6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -20,9 +20,9 @@ Or install it yourself as:

the PaymentMethod::Fastspring configurable should be directly available in spree admin payment methods. Be sure to set up your gateway.

Also, be sure in your user model (where current_user reads from) to add an "is_international?" logic block like follows:
Also, be sure in your user model (where current_user reads from) to add an "should_checkout_with_fastspring?" logic block like follows:

def is_international?
def should_checkout_with_fastspring?
return true
end

Expand Down
6 changes: 3 additions & 3 deletions app/controllers/spree/orders_controller_decorator.rb
@@ -1,9 +1,9 @@
module Spree
OrdersController.class_eval do
before_filter :check_for_international, only: :edit
before_filter :allow_fastspring, only: :edit

def check_for_international
@international = true if current_user && current_user.is_international?
def allow_fastspring
@use_fastspring = true if current_user && current_user.should_checkout_with_fastspring?
end

def fastspring_complete
Expand Down
4 changes: 2 additions & 2 deletions app/views/spree/orders/edit.html.erb
Expand Up @@ -10,7 +10,7 @@

<% else %>
<div data-hook="outside_cart_form">
<%= form_for @order, :url => (@international ? PaymentMethod::Fastspring.product_add_url : update_cart_path), :html => {:id => 'update-cart'} do |order_form| %>
<%= form_for @order, :url => (@use_fastspring ? PaymentMethod::Fastspring.product_add_url : update_cart_path), :html => {:id => 'update-cart'} do |order_form| %>
<div data-hook="inside_cart_form">

<div data-hook="cart_items">
Expand All @@ -25,7 +25,7 @@
<%= button_tag :class => 'primary', :id => 'update-button' do %>
<%= t(:update) %>
<% end %>
<% if @international %>
<% if @use_fastspring %>
<input type="hidden" name="operation" value="create"/>
<input type="hidden" name="destination" value="contents"/>
<input type="hidden" name="mode" value="test" />
Expand Down

0 comments on commit 72624f6

Please sign in to comment.