-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1540 from gevann/payment-methods-display-on-boolean
Payment methods display on boolean
- Loading branch information
Showing
13 changed files
with
313 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...ate/20161014221052_add_available_to_columns_and_remove_display_on_from_payment_methods.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
class AddAvailableToColumnsAndRemoveDisplayOnFromPaymentMethods < ActiveRecord::Migration[5.0] | ||
def up | ||
add_column(:spree_payment_methods, :available_to_users, :boolean, default: true) | ||
add_column(:spree_payment_methods, :available_to_admin, :boolean, default: true) | ||
execute("UPDATE spree_payment_methods "\ | ||
"SET available_to_users=#{quoted_false} "\ | ||
"WHERE NOT (display_on='front_end' OR display_on='' OR display_on IS NULL)") | ||
execute("UPDATE spree_payment_methods "\ | ||
"SET available_to_admin=#{quoted_false} "\ | ||
"WHERE NOT (display_on='back_end' OR display_on='' OR display_on IS NULL)") | ||
remove_column(:spree_payment_methods, :display_on) | ||
end | ||
|
||
def down | ||
add_column(:spree_payment_methods, :display_on, :string) | ||
execute("UPDATE spree_payment_methods "\ | ||
"SET display_on='' "\ | ||
"WHERE (available_to_users=#{quoted_true} AND available_to_admin=#{quoted_true})") | ||
execute("UPDATE spree_payment_methods "\ | ||
"SET display_on='front_end' "\ | ||
"WHERE (available_to_users=#{quoted_true} AND NOT available_to_admin=#{quoted_true})") | ||
execute("UPDATE spree_payment_methods "\ | ||
"SET display_on='back_end' "\ | ||
"WHERE (available_to_admin=#{quoted_true} AND NOT available_to_users=#{quoted_true})") | ||
remove_column(:spree_payment_methods, :available_to_users) | ||
remove_column(:spree_payment_methods, :available_to_admin) | ||
end | ||
end |
9 changes: 8 additions & 1 deletion
9
core/lib/spree/testing_support/factories/payment_method_factory.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,30 @@ | ||
FactoryGirl.define do | ||
factory :payment_method, aliases: [:credit_card_payment_method], class: Spree::Gateway::Bogus do | ||
name 'Credit Card' | ||
available_to_admin true | ||
available_to_users true | ||
end | ||
|
||
factory :check_payment_method, class: Spree::PaymentMethod::Check do | ||
name 'Check' | ||
available_to_admin true | ||
available_to_users true | ||
end | ||
|
||
# authorize.net was moved to spree_gateway. | ||
# Leaving this factory in place with bogus in case anyone is using it. | ||
factory :simple_credit_card_payment_method, class: Spree::Gateway::BogusSimple do | ||
name 'Credit Card' | ||
available_to_admin true | ||
available_to_users true | ||
end | ||
|
||
factory :store_credit_payment_method, class: Spree::PaymentMethod::StoreCredit do | ||
name "Store Credit" | ||
description "Store Credit" | ||
active true | ||
display_on 'none' | ||
available_to_admin false | ||
available_to_users false | ||
auto_capture true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.