Use new spree_paypal_express branch to hide password

This commit is contained in:
Maikel Linke
2016-03-23 16:23:52 +11:00
parent 97bcbb81b9
commit d12c486dd2
5 changed files with 43 additions and 8 deletions

View File

@@ -13,9 +13,10 @@ gem 'spree', github: 'openfoodfoundation/spree', branch: '1-3-stable'
gem 'spree_i18n', github: 'spree/spree_i18n', branch: '1-3-stable'
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '1-3-stable'
# Waiting on merge of PR #117
# https://github.com/spree-contrib/better_spree_paypal_express/pull/117
gem 'spree_paypal_express', :github => "openfoodfoundation/better_spree_paypal_express", :branch => "1-3-stable"
# Our branch contains two changes
# - Pass customer email and phone number to PayPal (merged to upstream master)
# - Change type of password from string to password to hide it in the form
gem 'spree_paypal_express', :github => "openfoodfoundation/better_spree_paypal_express", :branch => "hide-password"
#gem 'spree_paypal_express', :github => "spree-contrib/better_spree_paypal_express", :branch => "1-3-stable"
gem 'delayed_job_active_record'

View File

@@ -14,8 +14,8 @@ GIT
GIT
remote: git://github.com/openfoodfoundation/better_spree_paypal_express.git
revision: cdd61161ccd27cd8d183f9321422c7be113796b8
branch: 1-3-stable
revision: 840d973cd5bd3250b17674a624dad494aeb09eb3
branch: hide-password
specs:
spree_paypal_express (2.0.3)
paypal-sdk-merchant (= 1.106.1)

View File

@@ -0,0 +1,15 @@
class ChangeValueTypeOfPaypalPasswords < ActiveRecord::Migration
def up
Spree::Preference
.where("key like ?", "spree/gateway/pay_pal_express/password/%")
.where(value_type: "string")
.update_all(value_type: "password")
end
def down
Spree::Preference
.where("key like ?", "spree/gateway/pay_pal_express/password/%")
.where(value_type: "password")
.update_all(value_type: "string")
end
end

View File

@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20160316051131) do
ActiveRecord::Schema.define(:version => 20160401043927) do
create_table "account_invoices", :force => true do |t|
t.integer "user_id", :null => false

View File

@@ -30,7 +30,7 @@ feature %q{
payment_method.distributors.should == [@distributors[0]]
end
scenario "updating a payment method", retry: 3 do
scenario "updating a payment method" do
pm = create(:payment_method, distributors: [@distributors[0]])
login_to_admin_section
@@ -42,14 +42,33 @@ feature %q{
check "payment_method_distributor_ids_#{@distributors[1].id}"
check "payment_method_distributor_ids_#{@distributors[2].id}"
select2_select "PayPal Express", from: "payment_method_type"
expect(page).to have_field 'Login'
fill_in 'payment_method_preferred_login', with: 'testlogin'
fill_in 'payment_method_preferred_password', with: 'secret'
fill_in 'payment_method_preferred_signature', with: 'sig'
click_button 'Update'
flash_message.should eq 'Payment Method has been successfully updated!'
expect(flash_message).to eq 'Payment Method has been successfully updated!'
payment_method = Spree::PaymentMethod.find_by_name('New PM Name')
expect(payment_method.distributors).to include @distributors[1], @distributors[2]
expect(payment_method.distributors).not_to include @distributors[0]
expect(payment_method.type).to eq "Spree::Gateway::PayPalExpress"
expect(payment_method.preferences[:login]).to eq 'testlogin'
expect(payment_method.preferences[:password]).to eq 'secret'
expect(payment_method.preferences[:signature]).to eq 'sig'
fill_in 'payment_method_preferred_login', with: 'otherlogin'
click_button 'Update'
expect(flash_message).to eq 'Payment Method has been successfully updated!'
expect(page).to have_field 'Password', with: ''
payment_method = Spree::PaymentMethod.find_by_name('New PM Name')
expect(payment_method.preferences[:login]).to eq 'otherlogin'
expect(payment_method.preferences[:password]).to eq 'secret'
expect(payment_method.preferences[:signature]).to eq 'sig'
end
end