Adds test to check permissions when creating a new product

This commit is contained in:
filipefurtad0
2024-06-11 14:28:14 -06:00
parent 8e2419040e
commit 417fd21470

View File

@@ -1446,6 +1446,34 @@ RSpec.describe 'As an enterprise user, I can manage my products', feature: :admi
expect(page).to have_selector row_containing_name(product_supplied_inactive.name)
end
it "allows me to create a product" do
taxon = create(:taxon, name: 'Fruit')
shipping_category = create(:shipping_category)
visit spree.admin_products_path
click_link "New Product"
expect(page).to have_content "New Product"
expect(page).to have_select 'product_supplier_id',
with_options: [supplier_managed1.name, supplier_managed2.name,
supplier_permitted.name]
within 'fieldset#new_product' do
fill_in 'product_name', with: 'Big Bag Of Apples'
select supplier_permitted.name, from: 'product_supplier_id'
select 'Weight (g)', from: 'product_variant_unit_with_scale'
fill_in 'product_unit_value', with: '100'
fill_in 'product_price', with: '10.00'
select taxon.name, from: 'product_primary_taxon_id'
select shipping_category.name, from: 'product_shipping_category_id'
end
click_button 'Create'
expect(URI.parse(current_url).path).to eq spree.admin_products_path
expect(flash_message).to eq 'Product "Big Bag Of Apples" has been successfully created!'
expect(page).to have_selector row_containing_name('Big Bag Of Apples')
end
end
def create_products(amount)