diff --git a/spec/features/admin/adjustments_spec.rb b/spec/features/admin/adjustments_spec.rb index fcd0a0bb39..61646be708 100644 --- a/spec/features/admin/adjustments_spec.rb +++ b/spec/features/admin/adjustments_spec.rb @@ -21,8 +21,7 @@ feature ' scenario "adding taxed adjustments to an order" do # When I go to the adjustments page for the order - login_to_admin_section - visit spree.admin_orders_path + login_to_admin_and_visit spree.admin_orders_path page.find('td.actions a.icon-edit').click click_link 'Adjustments' @@ -44,8 +43,7 @@ feature ' adjustment = create(:adjustment, label: "Extra Adjustment", adjustable: order, amount: 110, included_tax: 10) # When I go to the adjustments page for the order - login_to_admin_section - visit spree.admin_orders_path + login_to_admin_and_visit spree.admin_orders_path page.find('td.actions a.icon-edit').click click_link 'Adjustments' page.find('tr', text: 'Extra Adjustment').find('a.icon-edit').click @@ -68,8 +66,7 @@ feature ' adjustment = create(:adjustment, label: "Extra Adjustment", adjustable: order, amount: 110, included_tax: 0) # When I go to the adjustments page for the order - login_to_admin_section - visit spree.admin_orders_path + login_to_admin_and_visit spree.admin_orders_path page.find('td.actions a.icon-edit').click click_link 'Adjustments' page.find('tr', text: 'Extra Adjustment').find('a.icon-edit').click diff --git a/spec/features/admin/content_spec.rb b/spec/features/admin/content_spec.rb index 75dd4ad656..1194f4af34 100644 --- a/spec/features/admin/content_spec.rb +++ b/spec/features/admin/content_spec.rb @@ -8,8 +8,7 @@ feature ' include WebHelper before do - login_to_admin_section - click_link 'Configuration' + login_to_admin_and_visit spree.admin_general_settings_path click_link 'Content' end diff --git a/spec/features/admin/enterprise_fees_spec.rb b/spec/features/admin/enterprise_fees_spec.rb index 5129953df6..a99c3b0d1a 100644 --- a/spec/features/admin/enterprise_fees_spec.rb +++ b/spec/features/admin/enterprise_fees_spec.rb @@ -13,8 +13,7 @@ feature ' fee = create(:enterprise_fee, name: '$0.50 / kg', fee_type: 'packing', tax_category: tax_category_gst) amount = fee.calculator.preferred_amount - login_to_admin_section - click_link 'Configuration' + login_to_admin_and_visit spree.admin_general_settings_path click_link 'Enterprise Fees' expect(page).to have_select "enterprise_fee_set_collection_attributes_0_enterprise_id" diff --git a/spec/features/admin/enterprise_user_spec.rb b/spec/features/admin/enterprise_user_spec.rb index d62322bc14..8e5170130d 100644 --- a/spec/features/admin/enterprise_user_spec.rb +++ b/spec/features/admin/enterprise_user_spec.rb @@ -19,8 +19,7 @@ feature ' context "with a limitted number of owned enterprises" do scenario "setting the enterprise ownership limit" do expect(user.enterprise_limit).to eq 5 - login_to_admin_section - click_link 'Users' + login_to_admin_and_visit spree.admin_users_path click_link user.email fill_in "user_enterprise_limit", with: 2 diff --git a/spec/features/admin/enterprises/index_spec.rb b/spec/features/admin/enterprises/index_spec.rb index 78b348fcd9..a55a7ee373 100644 --- a/spec/features/admin/enterprises/index_spec.rb +++ b/spec/features/admin/enterprises/index_spec.rb @@ -9,8 +9,7 @@ feature 'Enterprises Index' do s = create(:supplier_enterprise) d = create(:distributor_enterprise) - login_to_admin_section - click_link 'Enterprises' + login_to_admin_and_visit admin_enterprises_path within("tr.enterprise-#{s.id}") do expect(page).to have_content s.name diff --git a/spec/features/admin/image_settings_spec.rb b/spec/features/admin/image_settings_spec.rb index 9ef2860cd4..d23e4c5952 100644 --- a/spec/features/admin/image_settings_spec.rb +++ b/spec/features/admin/image_settings_spec.rb @@ -20,8 +20,7 @@ feature ' scenario "setting the image format for a paperclip style" do # When I go to the image settings page - login_to_admin_section - visit spree.edit_admin_image_settings_path + login_to_admin_and_visit spree.edit_admin_image_settings_path # All the styles should default to "Unchanged" expect(page).to have_select 'attachment_styles_format_mini', selected: 'Unchanged' diff --git a/spec/features/admin/order_cycles/list_spec.rb b/spec/features/admin/order_cycles/list_spec.rb index d675984dd8..3dc5626986 100644 --- a/spec/features/admin/order_cycles/list_spec.rb +++ b/spec/features/admin/order_cycles/list_spec.rb @@ -30,8 +30,7 @@ feature ' create(:proxy_order, subscription: create(:subscription, schedule: schedule1), order_cycle: oc1) # When I go to the admin order cycles page - login_to_admin_section - click_link 'Order Cycles' + login_to_admin_and_visit admin_order_cycles_path # Then the order cycles should be ordered correctly expect(page).to have_selector "#listing_order_cycles tr td:first-child", count: 7 diff --git a/spec/features/admin/order_cycles/simple_spec.rb b/spec/features/admin/order_cycles/simple_spec.rb index b946eefae8..903857cfae 100644 --- a/spec/features/admin/order_cycles/simple_spec.rb +++ b/spec/features/admin/order_cycles/simple_spec.rb @@ -100,8 +100,7 @@ feature ' end it "displays a warning on the order cycles screen" do - quick_login_as_admin - visit admin_order_cycles_path + login_to_admin_and_visit admin_order_cycles_path expect(page).to have_content "The hub #{hub.name} is listed in an active order cycle, but does not have valid shipping and payment methods. Until you set these up, customers will not be able to shop at this hub." end end diff --git a/spec/features/admin/payment_method_spec.rb b/spec/features/admin/payment_method_spec.rb index 6ca99e8c85..f46262b5af 100644 --- a/spec/features/admin/payment_method_spec.rb +++ b/spec/features/admin/payment_method_spec.rb @@ -13,9 +13,7 @@ feature ' describe "creating a payment method", js: true do scenario "assigning a distributor to the payment method" do - login_to_admin_section - - click_link 'Configuration' + login_to_admin_and_visit spree.admin_general_settings_path click_link 'Payment Methods' click_link 'New Payment Method' diff --git a/spec/features/admin/properties_spec.rb b/spec/features/admin/properties_spec.rb index 905810039e..52a573509a 100644 --- a/spec/features/admin/properties_spec.rb +++ b/spec/features/admin/properties_spec.rb @@ -9,8 +9,7 @@ feature ' include AuthenticationWorkflow scenario "creating and editing a property" do - login_to_admin_section - visit spree.admin_properties_path + login_to_admin_and_visit spree.admin_properties_path click_link 'New Property' fill_in 'property_name', with: 'New property!' diff --git a/spec/features/admin/tag_rules_spec.rb b/spec/features/admin/tag_rules_spec.rb index ca53fb68a9..3867a0f006 100644 --- a/spec/features/admin/tag_rules_spec.rb +++ b/spec/features/admin/tag_rules_spec.rb @@ -242,8 +242,7 @@ feature 'Tag Rules', js: true do end def visit_tag_rules - login_to_admin_section - visit main_app.edit_admin_enterprise_path(enterprise) + login_to_admin_and_visit main_app.edit_admin_enterprise_path(enterprise) expect(page).to have_content "PRIMARY DETAILS" click_link "Tag Rules" end diff --git a/spec/features/admin/variant_overrides_spec.rb b/spec/features/admin/variant_overrides_spec.rb index e631b546b1..24a5135904 100644 --- a/spec/features/admin/variant_overrides_spec.rb +++ b/spec/features/admin/variant_overrides_spec.rb @@ -401,9 +401,7 @@ feature " let(:product) { order_cycle.products.first } before do - login_to_admin_section - - visit 'admin/orders/new' + login_to_admin_and_visit 'admin/orders/new' select2_select distributor.name, from: 'order_distributor_id' select2_select order_cycle.name, from: 'order_order_cycle_id' click_button 'Next' diff --git a/spec/features/admin/variants_spec.rb b/spec/features/admin/variants_spec.rb index 700c375954..b22a322486 100644 --- a/spec/features/admin/variants_spec.rb +++ b/spec/features/admin/variants_spec.rb @@ -12,8 +12,7 @@ feature ' product = create(:simple_product, variant_unit: "weight", variant_unit_scale: "1") # When I create a variant on the product - login_to_admin_section - visit spree.admin_product_variants_path product + login_to_admin_and_visit spree.admin_product_variants_path product click_link 'New Variant' fill_in 'unit_value_human', with: '1' @@ -35,8 +34,7 @@ feature ' product.option_types << variant.option_values.first.option_type # When I view the variant - login_to_admin_section - visit spree.admin_product_variants_path product + login_to_admin_and_visit spree.admin_product_variants_path product page.find('table.index .icon-edit').click # Then I should not see a traditional option value field for the unit-related option value @@ -62,8 +60,7 @@ feature ' variant = product.variants.first variant.update(unit_description: 'foo') - login_to_admin_section - visit spree.edit_admin_product_variant_path(product, variant) + login_to_admin_and_visit spree.edit_admin_product_variant_path(product, variant) expect(page).to_not have_field "unit_value_human" expect(page).to have_field "variant_unit_description", with: "foo" @@ -120,8 +117,7 @@ feature ' product = create(:simple_product) variant = create(:variant, product: product) - login_to_admin_section - visit spree.admin_product_variants_path product + login_to_admin_and_visit spree.admin_product_variants_path product within "tr#spree_variant_#{variant.id}" do accept_alert do @@ -138,8 +134,7 @@ feature ' variant = product.variants.first # When I view the variant - login_to_admin_section - visit spree.admin_product_variants_path product + login_to_admin_and_visit spree.admin_product_variants_path product page.find('table.index .icon-edit').click # It should allow the display name to be changed diff --git a/spec/support/request/authentication_workflow.rb b/spec/support/request/authentication_workflow.rb index 7d84dc9c5f..43106a66bb 100644 --- a/spec/support/request/authentication_workflow.rb +++ b/spec/support/request/authentication_workflow.rb @@ -19,9 +19,13 @@ module AuthenticationWorkflow admin_user end - def login_to_admin_section + def login_to_admin_and_visit(path_visit) quick_login_as_admin - visit spree.admin_dashboard_path + visit path_visit + end + + def login_to_admin_section + login_to_admin__and_visit(spree.admin_dashboard_path) end def login_to_admin_as(user)