Skip to content
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.

Commit

Permalink
Fix configurations controller to correctly display errors on update
Browse files Browse the repository at this point in the history
  • Loading branch information
Flavio Auciello committed Sep 27, 2019
1 parent a384d55 commit de8cb94
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ def update
authorize! :update, SolidusPaypalBraintree::Configuration

params = configurations_params[:configuration_fields]
if SolidusPaypalBraintree::Configuration.update(params.keys, params.values)
results = SolidusPaypalBraintree::Configuration.update(params.keys, params.values)
if results.all? { |r| r.valid? }
flash[:success] = t('update_success', scope: 'solidus_paypal_braintree.configurations')
else
flash[:error] = t('update_error', scope: 'solidus_paypal_braintree.configurations')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,17 @@
end

describe "POST #update" do
let(:paypal_button_color) { 'blue' }
let(:configurations_params) do
{
configurations: {
configuration_fields: {
store_1_config.id.to_s => { paypal: true, apple_pay: true },
store_2_config.id.to_s => { paypal: true, apple_pay: false }
store_2_config.id.to_s => {
paypal: true,
apple_pay: false,
preferred_paypal_button_color: paypal_button_color
}
}
}
}
Expand All @@ -55,7 +60,7 @@
end

context "with invalid parameters" do
before { allow(SolidusPaypalBraintree::Configuration).to receive(:update) { false } }
let(:paypal_button_color) { 'invalid-color'}

it "displays an error message to the user" do
subject
Expand Down

0 comments on commit de8cb94

Please sign in to comment.