mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-08 22:56:06 +00:00
Create login_to_admin_and_visit to avoid loading the admin dashboard unnecessarily
This commit removes 19 unnecessary page loads of the admin dashboard
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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'
|
||||
|
||||
|
||||
@@ -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!'
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user