From 1b29d474d0cb75ff56f147deca8576434fb8fe8a Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Sun, 8 Dec 2019 19:44:38 +0000 Subject: [PATCH] Add specs to cover case where updating subscriptions products quantity fails --- spec/features/admin/subscriptions_spec.rb | 27 +++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/spec/features/admin/subscriptions_spec.rb b/spec/features/admin/subscriptions_spec.rb index 42ab7ea2c4..8cbc135348 100644 --- a/spec/features/admin/subscriptions_spec.rb +++ b/spec/features/admin/subscriptions_spec.rb @@ -68,10 +68,7 @@ feature 'Subscriptions' do expect(page).to have_no_content subscription.customer.email # Viewing Products - within "tr#so_#{subscription.id}" do - expect(page).to have_selector "td.items.panel-toggle", text: 3 - page.find("td.items.panel-toggle").click - end + open_subscription_products_panel within "#subscription-line-items" do expect(page).to have_selector "span#order_subtotal", text: "$15.00" # 3 x $5 items @@ -138,6 +135,28 @@ feature 'Subscriptions' do expect(subscription.reload.canceled_at).to be_within(5.seconds).of Time.zone.now end end + + context "editing subscription products quantity" do + it "updates quantity" do + visit admin_subscriptions_path + select2_select shop.name, from: "shop_id" + open_subscription_products_panel + + within "#sli_0" do + fill_in 'quantity', with: "5" + end + + page.find("a.button.update").click + expect(page).to have_content 'SAVED' + end + end + + def open_subscription_products_panel + within "tr#so_#{subscription.id}" do + expect(page).to have_selector "td.items.panel-toggle", text: 3 + page.find("td.items.panel-toggle").click + end + end end context 'creating a new subscription' do