From d12c486dd2d84f9b0f46fb6a3d8a27b4afe6bc65 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 23 Mar 2016 16:23:52 +1100 Subject: [PATCH] Use new spree_paypal_express branch to hide password --- Gemfile | 7 +++--- Gemfile.lock | 4 ++-- ...7_change_value_type_of_paypal_passwords.rb | 15 ++++++++++++ db/schema.rb | 2 +- spec/features/admin/payment_method_spec.rb | 23 +++++++++++++++++-- 5 files changed, 43 insertions(+), 8 deletions(-) create mode 100644 db/migrate/20160401043927_change_value_type_of_paypal_passwords.rb diff --git a/Gemfile b/Gemfile index 48ff4349cb..d581c8d10b 100644 --- a/Gemfile +++ b/Gemfile @@ -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' diff --git a/Gemfile.lock b/Gemfile.lock index fcd0633483..0e31157d96 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) diff --git a/db/migrate/20160401043927_change_value_type_of_paypal_passwords.rb b/db/migrate/20160401043927_change_value_type_of_paypal_passwords.rb new file mode 100644 index 0000000000..e03ed25f9e --- /dev/null +++ b/db/migrate/20160401043927_change_value_type_of_paypal_passwords.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 9994617a5f..abbd788e58 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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 diff --git a/spec/features/admin/payment_method_spec.rb b/spec/features/admin/payment_method_spec.rb index caf52c08f8..abb5feaf3e 100644 --- a/spec/features/admin/payment_method_spec.rb +++ b/spec/features/admin/payment_method_spec.rb @@ -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