mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Merge pull request #2519 from mkllnk/more-efficient-login-in-specs
More efficient login in specs
This commit is contained in:
@@ -8,8 +8,8 @@ feature %q{
|
||||
include WebHelper
|
||||
|
||||
describe "listing products" do
|
||||
before :each do
|
||||
login_to_admin_section
|
||||
before do
|
||||
quick_login_as_admin
|
||||
end
|
||||
|
||||
it "displays a list of products" do
|
||||
@@ -102,8 +102,8 @@ feature %q{
|
||||
end
|
||||
|
||||
describe "listing variants" do
|
||||
before :each do
|
||||
login_to_admin_section
|
||||
before do
|
||||
quick_login_as_admin
|
||||
end
|
||||
|
||||
it "displays a list of variants for each product" do
|
||||
@@ -171,8 +171,7 @@ feature %q{
|
||||
d = FactoryBot.create(:distributor_enterprise)
|
||||
taxon = create(:taxon)
|
||||
|
||||
login_to_admin_section
|
||||
|
||||
quick_login_as_admin
|
||||
visit spree.admin_products_path
|
||||
|
||||
find("a", text: "NEW PRODUCT").click
|
||||
@@ -195,7 +194,7 @@ feature %q{
|
||||
scenario "creating new variants" do
|
||||
# Given a product without variants or a unit
|
||||
p = FactoryBot.create(:product, variant_unit: 'weight', variant_unit_scale: 1000)
|
||||
login_to_admin_section
|
||||
quick_login_as_admin
|
||||
visit spree.admin_products_path
|
||||
|
||||
# I should see an add variant button
|
||||
@@ -244,8 +243,7 @@ feature %q{
|
||||
t2 = FactoryBot.create(:taxon)
|
||||
p = FactoryBot.create(:product, supplier: s1, available_on: Date.current, variant_unit: 'volume', variant_unit_scale: 1, primary_taxon: t2, sku: "OLD SKU")
|
||||
|
||||
login_to_admin_section
|
||||
|
||||
quick_login_as_admin
|
||||
visit spree.admin_products_path
|
||||
|
||||
find("div#columns-dropdown", :text => "COLUMNS").click
|
||||
@@ -290,8 +288,7 @@ feature %q{
|
||||
scenario "updating a product with a variant unit of 'items'" do
|
||||
p = FactoryBot.create(:product, variant_unit: 'weight', variant_unit_scale: 1000)
|
||||
|
||||
login_to_admin_section
|
||||
|
||||
quick_login_as_admin
|
||||
visit spree.admin_products_path
|
||||
|
||||
expect(page).to have_select "variant_unit_with_scale", selected: "Weight (kg)"
|
||||
@@ -316,8 +313,7 @@ feature %q{
|
||||
v = p.variants.first
|
||||
v.update_column(:sku, "VARIANTSKU")
|
||||
|
||||
login_to_admin_section
|
||||
|
||||
quick_login_as_admin
|
||||
visit spree.admin_products_path
|
||||
expect(page).to have_selector "a.view-variants", count: 1
|
||||
find("a.view-variants").trigger('click')
|
||||
@@ -355,8 +351,7 @@ feature %q{
|
||||
p = FactoryBot.create(:product)
|
||||
v = FactoryBot.create(:variant, product: p, price: 3.0)
|
||||
|
||||
login_to_admin_section
|
||||
|
||||
quick_login_as_admin
|
||||
visit spree.admin_products_path
|
||||
expect(page).to have_selector "a.view-variants", count: 1
|
||||
find("a.view-variants").trigger('click')
|
||||
@@ -379,7 +374,7 @@ feature %q{
|
||||
|
||||
scenario "updating a product mutiple times without refresh" do
|
||||
p = FactoryBot.create(:product, name: 'original name')
|
||||
login_to_admin_section
|
||||
quick_login_as_admin
|
||||
|
||||
visit spree.admin_products_path
|
||||
|
||||
@@ -412,7 +407,7 @@ feature %q{
|
||||
|
||||
scenario "updating a product after cloning a product" do
|
||||
p = FactoryBot.create(:product, :name => "product 1")
|
||||
login_to_admin_section
|
||||
quick_login_as_admin
|
||||
|
||||
visit spree.admin_products_path
|
||||
|
||||
@@ -435,7 +430,7 @@ feature %q{
|
||||
s2 = create(:supplier_enterprise)
|
||||
p1 = FactoryBot.create(:simple_product, :name => "product1", supplier: s1)
|
||||
p2 = FactoryBot.create(:simple_product, :name => "product2", supplier: s2)
|
||||
login_to_admin_section
|
||||
quick_login_as_admin
|
||||
|
||||
visit spree.admin_products_path
|
||||
|
||||
@@ -541,7 +536,7 @@ feature %q{
|
||||
p1 = FactoryBot.create(:product, :name => "P1")
|
||||
p2 = FactoryBot.create(:product, :name => "P2")
|
||||
p3 = FactoryBot.create(:product, :name => "P3")
|
||||
login_to_admin_section
|
||||
quick_login_as_admin
|
||||
|
||||
visit spree.admin_products_path
|
||||
|
||||
@@ -567,7 +562,7 @@ feature %q{
|
||||
describe "using column display dropdown" do
|
||||
it "shows a column display dropdown, which shows a list of columns when clicked" do
|
||||
FactoryBot.create(:simple_product)
|
||||
login_to_admin_section
|
||||
quick_login_as_admin
|
||||
|
||||
visit spree.admin_products_path
|
||||
|
||||
@@ -599,7 +594,7 @@ feature %q{
|
||||
s2 = create(:supplier_enterprise)
|
||||
p1 = FactoryBot.create(:simple_product, :name => "product1", supplier: s1)
|
||||
p2 = FactoryBot.create(:simple_product, :name => "product2", supplier: s2)
|
||||
login_to_admin_section
|
||||
quick_login_as_admin
|
||||
|
||||
visit spree.admin_products_path
|
||||
|
||||
|
||||
@@ -30,9 +30,8 @@ feature %q{
|
||||
e = create(:supplier_enterprise, name: 'Feedme')
|
||||
|
||||
# When I go to the enterprise fees page
|
||||
login_to_admin_section
|
||||
click_link 'Configuration'
|
||||
click_link 'Enterprise Fees'
|
||||
quick_login_as_admin
|
||||
visit admin_enterprise_fees_path
|
||||
|
||||
# And I fill in the fields for a new enterprise fee and click update
|
||||
select 'Feedme', from: 'enterprise_fee_set_collection_attributes_0_enterprise_id'
|
||||
@@ -60,9 +59,8 @@ feature %q{
|
||||
enterprise = create(:enterprise, name: 'Foo')
|
||||
|
||||
# When I go to the enterprise fees page
|
||||
login_to_admin_section
|
||||
click_link 'Configuration'
|
||||
click_link 'Enterprise Fees'
|
||||
quick_login_as_admin
|
||||
visit admin_enterprise_fees_path
|
||||
|
||||
# And I update the fields for the enterprise fee and click update
|
||||
select 'Foo', from: 'enterprise_fee_set_collection_attributes_0_enterprise_id'
|
||||
@@ -95,11 +93,8 @@ feature %q{
|
||||
fee = create(:enterprise_fee)
|
||||
|
||||
# When I go to the enterprise fees page
|
||||
login_to_admin_section
|
||||
click_link 'Configuration'
|
||||
expect(page).to have_link 'Enterprise Fees'
|
||||
click_link 'Enterprise Fees'
|
||||
expect(page).to have_content 'Enterprise Fees'
|
||||
quick_login_as_admin
|
||||
visit admin_enterprise_fees_path
|
||||
|
||||
# And I click delete
|
||||
find("a.delete-resource").click
|
||||
@@ -117,9 +112,8 @@ feature %q{
|
||||
create(:product_distribution, product: p, distributor: d, enterprise_fee: fee)
|
||||
|
||||
# When I go to the enterprise fees page
|
||||
login_to_admin_section
|
||||
click_link 'Configuration'
|
||||
click_link 'Enterprise Fees'
|
||||
quick_login_as_admin
|
||||
visit admin_enterprise_fees_path
|
||||
|
||||
# And I click delete
|
||||
find("a.delete-resource").click
|
||||
|
||||
@@ -9,7 +9,7 @@ feature %q{
|
||||
|
||||
|
||||
context "as a site administrator" do
|
||||
before { login_to_admin_section }
|
||||
before { quick_login_as_admin }
|
||||
|
||||
scenario "listing relationships" do
|
||||
# Given some enterprises with relationships
|
||||
@@ -19,6 +19,7 @@ feature %q{
|
||||
create(:enterprise_relationship, parent: e3, child: e4, permissions_list: [:add_to_order_cycle, :manage_products])
|
||||
|
||||
# When I go to the relationships page
|
||||
visit spree.admin_path
|
||||
click_link 'Enterprises'
|
||||
click_link 'Permissions'
|
||||
|
||||
@@ -97,7 +98,7 @@ feature %q{
|
||||
let!(:er2) { create(:enterprise_relationship, parent: d2, child: d1) }
|
||||
let!(:er3) { create(:enterprise_relationship, parent: d2, child: d3) }
|
||||
|
||||
before { login_to_admin_as enterprise_user }
|
||||
before { quick_login_as enterprise_user }
|
||||
|
||||
scenario "enterprise user can only see relationships involving their enterprises" do
|
||||
visit admin_enterprise_relationships_path
|
||||
@@ -107,11 +108,10 @@ feature %q{
|
||||
page.should_not have_relationship d2, d3
|
||||
end
|
||||
|
||||
|
||||
scenario "enterprise user can only add their own enterprises as parent" do
|
||||
visit admin_enterprise_relationships_path
|
||||
page.should have_select2 'enterprise_relationship_parent_id', options: ['', d1.name]
|
||||
page.should have_select2 'enterprise_relationship_child_id', options: ['', d1.name, d2.name, d3.name]
|
||||
page.should have_select2 'enterprise_relationship_child_id', with_options: ['', d1.name, d2.name, d3.name]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -33,75 +33,10 @@ feature %q{
|
||||
end
|
||||
end
|
||||
|
||||
# This case no longer exists as anyone with an enterprise can supply into the system.
|
||||
# Or can they?? There is no producer profile anyway.
|
||||
# TODO discuss what parts of this are still necessary in which cases.
|
||||
pending "with only a profile-level enterprise" do
|
||||
before do
|
||||
user.enterprise_roles.create! enterprise: supplier_profile
|
||||
user.enterprise_roles.create! enterprise: distributor_profile
|
||||
login_to_admin_as user
|
||||
end
|
||||
|
||||
it "shows me only menu items for enterprise management" do
|
||||
page.should have_admin_menu_item 'Dashboard'
|
||||
page.should have_admin_menu_item 'Enterprises'
|
||||
|
||||
['Orders', 'Reports', 'Configuration', 'Promotions', 'Users', 'Order Cycles'].each do |menu_item_name|
|
||||
page.should_not have_admin_menu_item menu_item_name
|
||||
end
|
||||
end
|
||||
|
||||
describe "dashboard" do
|
||||
it "shows me enterprise management controls" do
|
||||
within('#enterprises') do
|
||||
page.should have_selector 'h3', text: 'My Enterprises'
|
||||
page.should have_link 'CREATE NEW'
|
||||
page.should have_link supplier_profile.name
|
||||
page.should have_link 'MANAGE MY ENTERPRISES'
|
||||
end
|
||||
end
|
||||
|
||||
it "shows me product management controls, but not order_cycle controls" do
|
||||
page.should have_selector '#products'
|
||||
page.should_not have_selector '#order_cycles'
|
||||
end
|
||||
|
||||
it "shows me enterprise product info but not payment methods, shipping methods or enterprise fees" do
|
||||
# Payment methods, shipping methods, enterprise fees
|
||||
page.should_not have_selector '.hubs_tab span', text: 'Payment Methods'
|
||||
page.should_not have_selector '.hubs_tab span', text: 'Shipping Methods'
|
||||
page.should_not have_selector '.hubs_tab span', text: 'Enterprise Fees'
|
||||
end
|
||||
end
|
||||
|
||||
it "shows me only profile options on the enterprise listing page" do
|
||||
click_link 'Enterprises'
|
||||
|
||||
within "tr.enterprise-#{supplier_profile.id}" do
|
||||
page.should_not have_link 'Enterprise Fees'
|
||||
end
|
||||
|
||||
within "tr.enterprise-#{distributor_profile.id}" do
|
||||
page.should_not have_link 'Payment Methods'
|
||||
page.should_not have_link 'Shipping Methods'
|
||||
page.should_not have_link 'Enterprise Fees'
|
||||
end
|
||||
end
|
||||
|
||||
it "shows me only profile fields on the hub edit page" do
|
||||
click_link distributor_profile.name
|
||||
|
||||
page.should_not have_selector '#payment_methods'
|
||||
page.should_not have_selector '#shipping_methods'
|
||||
page.should_not have_selector '#enterprise_fees'
|
||||
end
|
||||
end
|
||||
|
||||
describe "system management lockdown" do
|
||||
before do
|
||||
user.enterprise_roles.create!(enterprise: supplier1)
|
||||
login_to_admin_as user
|
||||
quick_login_as user
|
||||
end
|
||||
|
||||
scenario "should not be able to see system configuration" do
|
||||
|
||||
@@ -45,8 +45,8 @@ feature 'Enterprises Index' do
|
||||
|
||||
context "without violating rules" do
|
||||
before do
|
||||
login_to_admin_section
|
||||
click_link 'Enterprises'
|
||||
quick_login_as_admin
|
||||
visit admin_enterprises_path
|
||||
end
|
||||
|
||||
it "updates the enterprises" do
|
||||
@@ -72,8 +72,8 @@ feature 'Enterprises Index' do
|
||||
d_manager.enterprise_roles.build(enterprise: second_distributor).save
|
||||
expect(d.owner).to_not eq d_manager
|
||||
|
||||
login_to_admin_section
|
||||
click_link 'Enterprises'
|
||||
quick_login_as_admin
|
||||
visit admin_enterprises_path
|
||||
end
|
||||
|
||||
it "does not update the enterprises and displays errors" do
|
||||
@@ -106,12 +106,12 @@ feature 'Enterprises Index' do
|
||||
enterprise_manager.enterprise_roles.build(enterprise: supplier1).save
|
||||
enterprise_manager.enterprise_roles.build(enterprise: distributor1).save
|
||||
|
||||
login_to_admin_as enterprise_manager
|
||||
quick_login_as enterprise_manager
|
||||
end
|
||||
|
||||
context "listing enterprises", js: true do
|
||||
it "displays enterprises I have permission to manage" do
|
||||
click_link "Enterprises"
|
||||
visit admin_enterprises_path
|
||||
|
||||
within("tbody#e_#{distributor1.id}") do
|
||||
expect(page).to have_content distributor1.name
|
||||
@@ -139,7 +139,7 @@ feature 'Enterprises Index' do
|
||||
|
||||
|
||||
it "does not give me an option to change or update the package and producer properties of enterprises I manage" do
|
||||
click_link "Enterprises"
|
||||
visit admin_enterprises_path
|
||||
|
||||
within("tbody#e_#{distributor1.id}") do
|
||||
find("td.producer").click
|
||||
@@ -162,12 +162,12 @@ feature 'Enterprises Index' do
|
||||
let!(:owned_distributor) { create(:distributor_enterprise, name: 'Owned Distributor', owner: user) }
|
||||
|
||||
before do
|
||||
login_to_admin_as user
|
||||
quick_login_as user
|
||||
end
|
||||
|
||||
context "listing enterprises", js: true do
|
||||
it "allows me to change or update the package and producer properties of enterprises I manage" do
|
||||
click_link "Enterprises"
|
||||
visit admin_enterprises_path
|
||||
|
||||
within("tbody#e_#{owned_distributor.id}") do
|
||||
# Open the producer panel
|
||||
|
||||
@@ -205,8 +205,8 @@ feature %q{
|
||||
s = create(:supplier_enterprise)
|
||||
|
||||
# When I go to its properties page
|
||||
login_to_admin_section
|
||||
click_link 'Enterprises'
|
||||
quick_login_as_admin
|
||||
visit admin_enterprises_path
|
||||
within(".enterprise-#{s.id}") { click_link 'Properties' }
|
||||
|
||||
# And I create a property
|
||||
@@ -229,7 +229,7 @@ feature %q{
|
||||
s.producer_properties.create! property_name: 'Certified Organic', value: 'NASAA 12345'
|
||||
|
||||
# When I go to its properties page
|
||||
login_to_admin_section
|
||||
quick_login_as_admin
|
||||
visit main_app.admin_enterprise_producer_properties_path(s)
|
||||
|
||||
# And I update the property
|
||||
@@ -252,7 +252,7 @@ feature %q{
|
||||
pp = s.producer_properties.create! property_name: 'Certified Organic', value: 'NASAA 12345'
|
||||
|
||||
# When I go to its properties page
|
||||
login_to_admin_section
|
||||
quick_login_as_admin
|
||||
visit main_app.admin_enterprise_producer_properties_path(s)
|
||||
|
||||
# And I remove the property
|
||||
@@ -310,7 +310,7 @@ feature %q{
|
||||
enterprise_user.enterprise_roles.build(enterprise: supplier1).save
|
||||
enterprise_user.enterprise_roles.build(enterprise: distributor1).save
|
||||
|
||||
login_to_admin_as enterprise_user
|
||||
quick_login_as enterprise_user
|
||||
end
|
||||
|
||||
context "when I have reached my enterprise ownership limit" do
|
||||
@@ -318,7 +318,7 @@ feature %q{
|
||||
supplier1.reload
|
||||
enterprise_user.owned_enterprises.push [supplier1]
|
||||
|
||||
click_link "Enterprises"
|
||||
visit admin_enterprises_path
|
||||
|
||||
page.should have_content supplier1.name
|
||||
page.should have_content distributor1.name
|
||||
@@ -335,7 +335,7 @@ feature %q{
|
||||
context "creating an enterprise" do
|
||||
before do
|
||||
# When I create an enterprise
|
||||
click_link 'Enterprises'
|
||||
visit admin_enterprises_path
|
||||
click_link 'New Enterprise'
|
||||
fill_in 'enterprise_name', with: 'zzz'
|
||||
fill_in 'enterprise_email_address', with: 'bob@example.com'
|
||||
@@ -375,7 +375,7 @@ feature %q{
|
||||
end
|
||||
|
||||
scenario "editing enterprises I manage" do
|
||||
click_link 'Enterprises'
|
||||
visit admin_enterprises_path
|
||||
within("tbody#e_#{distributor1.id}") { click_link 'Manage' }
|
||||
|
||||
fill_in 'enterprise_name', :with => 'Eaterprises'
|
||||
@@ -391,7 +391,7 @@ feature %q{
|
||||
|
||||
describe "enterprises I have edit permission for, but do not manage" do
|
||||
it "allows me to edit them" do
|
||||
click_link 'Enterprises'
|
||||
visit admin_enterprises_path
|
||||
within("tbody#e_#{distributor3.id}") { click_link 'Manage' }
|
||||
|
||||
fill_in 'enterprise_name', :with => 'Eaterprises'
|
||||
@@ -406,7 +406,7 @@ feature %q{
|
||||
end
|
||||
|
||||
it "does not show links to manage shipping methods, payment methods or enterprise fees on the edit page" do
|
||||
click_link 'Enterprises'
|
||||
visit admin_enterprises_path
|
||||
within("tbody#e_#{distributor3.id}") { click_link 'Manage' }
|
||||
|
||||
within(".side_menu") do
|
||||
@@ -418,7 +418,7 @@ feature %q{
|
||||
end
|
||||
|
||||
scenario "editing images for an enterprise" do
|
||||
click_link 'Enterprises'
|
||||
visit admin_enterprises_path
|
||||
within("tbody#e_#{distributor1.id}") { click_link 'Manage' }
|
||||
|
||||
within(".side_menu") do
|
||||
@@ -431,7 +431,7 @@ feature %q{
|
||||
|
||||
scenario "managing producer properties" do
|
||||
create(:property, name: "Certified Organic")
|
||||
click_link 'Enterprises'
|
||||
visit admin_enterprises_path
|
||||
within("#e_#{supplier1.id}") { click_link 'Manage' }
|
||||
within(".side_menu") do
|
||||
click_link "Properties"
|
||||
|
||||
@@ -129,7 +129,7 @@ feature %q{
|
||||
|
||||
context 'using datepickers' do
|
||||
it "correctly opens the datepicker and changes the date field" do
|
||||
login_to_admin_section
|
||||
quick_login_as_admin
|
||||
visit admin_order_cycles_path
|
||||
|
||||
within("tr.order-cycle-#{oc_de.id}") do
|
||||
@@ -177,8 +177,8 @@ feature %q{
|
||||
distributor_fee = create(:enterprise_fee, enterprise: distributor, name: 'Distributor fee')
|
||||
|
||||
# When I go to the new order cycle page
|
||||
login_to_admin_section
|
||||
click_link 'Order Cycles'
|
||||
quick_login_as_admin
|
||||
visit admin_order_cycles_path
|
||||
click_link 'New Order Cycle'
|
||||
|
||||
# Select a coordinator since there are two available
|
||||
@@ -304,8 +304,8 @@ feature %q{
|
||||
distributor_fee2 = create(:enterprise_fee, enterprise: distributor, name: 'Distributor fee 2')
|
||||
|
||||
# When I go to its edit page
|
||||
login_to_admin_section
|
||||
click_link 'Order Cycles'
|
||||
quick_login_as_admin
|
||||
visit admin_order_cycles_path
|
||||
click_link oc.name
|
||||
wait_until { page.find('#order_cycle_name').value.present? }
|
||||
|
||||
@@ -429,9 +429,8 @@ feature %q{
|
||||
oc.distributors.last.update_attribute :name, 'ZZZZ'
|
||||
|
||||
# When I edit it
|
||||
login_to_admin_section
|
||||
click_link 'Order Cycles'
|
||||
click_link oc.name
|
||||
quick_login_as_admin
|
||||
visit edit_admin_order_cycle_path(oc)
|
||||
wait_until { page.find('#order_cycle_name').value.present? }
|
||||
|
||||
# Then I should see the basic settings
|
||||
@@ -498,7 +497,6 @@ feature %q{
|
||||
|
||||
scenario "editing an order cycle with an exchange between the same enterprise" do
|
||||
c = create(:distributor_enterprise, is_primary_producer: true)
|
||||
login_to_admin_section
|
||||
|
||||
# Given two order cycles, one with a mono-enterprise incoming exchange...
|
||||
oc_incoming = create(:simple_order_cycle, suppliers: [c], coordinator: c)
|
||||
@@ -507,6 +505,7 @@ feature %q{
|
||||
oc_outgoing = create(:simple_order_cycle, coordinator: c, distributors: [c])
|
||||
|
||||
# When I edit the first order cycle, the exchange should appear as incoming
|
||||
quick_login_as_admin
|
||||
visit edit_admin_order_cycle_path(oc_incoming)
|
||||
page.should have_selector 'table.exchanges tr.supplier'
|
||||
page.should_not have_selector 'table.exchanges tr.distributor'
|
||||
@@ -528,8 +527,8 @@ feature %q{
|
||||
|
||||
|
||||
# When I go to the order cycles page
|
||||
login_to_admin_section
|
||||
click_link 'Order Cycles'
|
||||
quick_login_as_admin
|
||||
visit admin_order_cycles_path
|
||||
|
||||
# And I fill in some new opening/closing times and save them
|
||||
within("tr.order-cycle-#{oc1.id}") do
|
||||
@@ -581,8 +580,8 @@ feature %q{
|
||||
oc = create(:simple_order_cycle)
|
||||
|
||||
# When I clone it
|
||||
login_to_admin_section
|
||||
click_link 'Order Cycles'
|
||||
quick_login_as_admin
|
||||
visit admin_order_cycles_path
|
||||
within "tr.order-cycle-#{oc.id}" do
|
||||
find('a.clone-order-cycle').click
|
||||
end
|
||||
@@ -607,9 +606,8 @@ feature %q{
|
||||
ExchangeVariant.where(exchange_id: exchange_ids, variant_id: p.master.id).should_not be_empty
|
||||
|
||||
# When I go to the order cycle page and remove the obsolete master
|
||||
login_to_admin_section
|
||||
click_link 'Order Cycles'
|
||||
click_link oc.name
|
||||
quick_login_as_admin
|
||||
visit edit_admin_order_cycle_path(oc)
|
||||
within("table.exchanges tbody tr.supplier") { page.find('td.products').click }
|
||||
page.find("#order_cycle_incoming_exchange_0_variants_#{p.master.id}", visible: true).trigger('click') # uncheck
|
||||
click_button "Update"
|
||||
@@ -631,7 +629,7 @@ feature %q{
|
||||
end
|
||||
|
||||
it "displays a warning on the order cycles screen" do
|
||||
login_to_admin_section
|
||||
quick_login_as_admin
|
||||
visit admin_order_cycles_path
|
||||
page.should 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
|
||||
@@ -684,13 +682,14 @@ feature %q{
|
||||
@new_user.enterprise_roles.build(enterprise: supplier_managed).save
|
||||
@new_user.enterprise_roles.build(enterprise: distributor_managed).save
|
||||
|
||||
login_to_admin_as @new_user
|
||||
quick_login_as @new_user
|
||||
end
|
||||
|
||||
scenario "viewing a list of order cycles I am coordinating" do
|
||||
oc_user_coordinating = create(:simple_order_cycle, { suppliers: [supplier_managed, supplier_unmanaged], coordinator: distributor_managed, distributors: [distributor_managed, distributor_unmanaged], name: 'Order Cycle 1' } )
|
||||
oc_for_other_user = create(:simple_order_cycle, { coordinator: supplier_unmanaged, name: 'Order Cycle 2' } )
|
||||
|
||||
visit spree.admin_path
|
||||
click_link "Order Cycles"
|
||||
|
||||
# I should see only the order cycle I am coordinating
|
||||
@@ -715,7 +714,7 @@ feature %q{
|
||||
# Make the page long enough to avoid the save bar overlaying the form
|
||||
page.driver.resize(1280, 2000)
|
||||
|
||||
click_link "Order Cycles"
|
||||
visit admin_order_cycles_path
|
||||
click_link 'New Order Cycle'
|
||||
|
||||
fill_in 'order_cycle_name', with: 'My order cycle'
|
||||
@@ -832,7 +831,7 @@ feature %q{
|
||||
scenario "cloning an order cycle" do
|
||||
oc = create(:simple_order_cycle, coordinator: distributor_managed)
|
||||
|
||||
click_link "Order Cycles"
|
||||
visit admin_order_cycles_path
|
||||
within "tr.order-cycle-#{oc.id}" do
|
||||
find('a.clone-order-cycle').click
|
||||
end
|
||||
@@ -1063,8 +1062,8 @@ feature %q{
|
||||
ex.update_attributes! pickup_time: 'pickup time', pickup_instructions: 'pickup instructions'
|
||||
|
||||
# When I edit it
|
||||
login_to_admin_section
|
||||
click_link 'Order Cycles'
|
||||
quick_login_as_admin
|
||||
visit admin_order_cycles_path
|
||||
click_link oc.name
|
||||
wait_until { page.find('#order_cycle_name').value.present? }
|
||||
|
||||
@@ -1093,7 +1092,7 @@ feature %q{
|
||||
ex.update_attributes! pickup_time: 'pickup time', pickup_instructions: 'pickup instructions'
|
||||
|
||||
# When I edit it
|
||||
login_to_admin_section
|
||||
quick_login_as_admin
|
||||
visit edit_admin_order_cycle_path oc
|
||||
wait_until { page.find('#order_cycle_name').value.present? }
|
||||
|
||||
@@ -1147,8 +1146,8 @@ feature %q{
|
||||
|
||||
scenario "deleting an order cycle" do
|
||||
create(:simple_order_cycle, name: "Translusent Berries")
|
||||
login_to_admin_section
|
||||
click_link 'Order Cycles'
|
||||
quick_login_as_admin
|
||||
visit admin_order_cycles_path
|
||||
page.should have_content("Translusent Berries")
|
||||
first('a.delete-order-cycle').click
|
||||
page.should_not have_content("Translusent Berries")
|
||||
|
||||
@@ -37,7 +37,7 @@ feature %q{
|
||||
create(:simple_order_cycle, name: 'Four', orders_close_at: 4.weeks.from_now)
|
||||
create(:simple_order_cycle, name: 'Three', orders_close_at: 3.weeks.from_now)
|
||||
|
||||
login_to_admin_section
|
||||
quick_login_as_admin
|
||||
visit 'admin/orders'
|
||||
|
||||
open_select2('#s2id_q_order_cycle_id_in')
|
||||
@@ -49,7 +49,7 @@ feature %q{
|
||||
distributor_disabled = create(:distributor_enterprise)
|
||||
create(:simple_order_cycle, name: 'Two')
|
||||
|
||||
login_to_admin_section
|
||||
quick_login_as_admin
|
||||
|
||||
visit '/admin/orders'
|
||||
click_link 'New Order'
|
||||
@@ -85,7 +85,7 @@ feature %q{
|
||||
end
|
||||
|
||||
scenario "can add a product to an existing order", retry: 3 do
|
||||
login_to_admin_section
|
||||
quick_login_as_admin
|
||||
visit '/admin/orders'
|
||||
|
||||
click_edit
|
||||
@@ -106,7 +106,7 @@ feature %q{
|
||||
|
||||
@order.state = 'cart'; @order.completed_at = nil; @order.save
|
||||
|
||||
login_to_admin_section
|
||||
quick_login_as_admin
|
||||
visit '/admin/orders'
|
||||
uncheck 'Only show complete orders'
|
||||
click_button 'Filter Results'
|
||||
@@ -124,7 +124,7 @@ feature %q{
|
||||
scenario "can't add products to an order outside the order's hub and order cycle" do
|
||||
product = create(:simple_product)
|
||||
|
||||
login_to_admin_section
|
||||
quick_login_as_admin
|
||||
visit '/admin/orders'
|
||||
page.find('td.actions a.icon-edit').click
|
||||
|
||||
@@ -134,7 +134,7 @@ feature %q{
|
||||
scenario "can't change distributor or order cycle once order has been finalized" do
|
||||
@order.update_attributes order_cycle_id: nil
|
||||
|
||||
login_to_admin_section
|
||||
quick_login_as_admin
|
||||
visit '/admin/orders'
|
||||
page.find('td.actions a.icon-edit').click
|
||||
|
||||
@@ -173,7 +173,7 @@ feature %q{
|
||||
end
|
||||
|
||||
scenario "capture payment from the orders index page" do
|
||||
login_to_admin_section
|
||||
quick_login_as_admin
|
||||
|
||||
visit spree.admin_orders_path
|
||||
expect(page).to have_current_path spree.admin_orders_path
|
||||
@@ -207,7 +207,7 @@ feature %q{
|
||||
@enterprise_user.enterprise_roles.build(enterprise: coordinator1).save
|
||||
@enterprise_user.enterprise_roles.build(enterprise: distributor1).save
|
||||
|
||||
login_to_admin_as @enterprise_user
|
||||
quick_login_as @enterprise_user
|
||||
end
|
||||
|
||||
feature "viewing the edit page" do
|
||||
|
||||
@@ -47,7 +47,7 @@ feature %q{
|
||||
end
|
||||
|
||||
it "communicates the status of the stripe connection to the user" do
|
||||
login_as user
|
||||
quick_login_as user
|
||||
visit spree.new_admin_payment_method_path
|
||||
|
||||
select2_select "Stripe", from: "payment_method_type"
|
||||
@@ -71,7 +71,7 @@ feature %q{
|
||||
|
||||
scenario "updating a payment method", js: true do
|
||||
pm = create(:payment_method, distributors: [@distributors[0]])
|
||||
login_to_admin_section
|
||||
quick_login_as_admin
|
||||
|
||||
visit spree.edit_admin_payment_method_path pm
|
||||
|
||||
@@ -127,11 +127,11 @@ feature %q{
|
||||
before(:each) do
|
||||
enterprise_user.enterprise_roles.build(enterprise: distributor1).save
|
||||
enterprise_user.enterprise_roles.build(enterprise: distributor2).save
|
||||
login_to_admin_as enterprise_user
|
||||
quick_login_as enterprise_user
|
||||
end
|
||||
|
||||
it "I can get to the new enterprise page" do
|
||||
click_link 'Enterprises'
|
||||
visit admin_enterprises_path
|
||||
within("#e_#{distributor1.id}") { click_link 'Manage' }
|
||||
within(".side_menu") do
|
||||
click_link "Payment Methods"
|
||||
@@ -181,7 +181,7 @@ feature %q{
|
||||
pm1
|
||||
pm2
|
||||
|
||||
click_link 'Enterprises'
|
||||
visit admin_enterprises_path
|
||||
within("#e_#{distributor1.id}") { click_link 'Manage' }
|
||||
within(".side_menu") do
|
||||
click_link "Payment Methods"
|
||||
|
||||
@@ -60,9 +60,9 @@ feature %q{
|
||||
end
|
||||
|
||||
scenario "creating an on-demand product", js: true do
|
||||
login_to_admin_section
|
||||
quick_login_as_admin
|
||||
visit spree.admin_products_path
|
||||
|
||||
click_link 'Products'
|
||||
click_link 'New Product'
|
||||
|
||||
fill_in 'product_name', with: 'Hot Cakes'
|
||||
@@ -100,13 +100,13 @@ feature %q{
|
||||
create(:enterprise_relationship, parent: @supplier_permitted, child: @supplier2,
|
||||
permissions_list: [:manage_products])
|
||||
|
||||
login_to_admin_as @new_user
|
||||
quick_login_as @new_user
|
||||
end
|
||||
|
||||
context "products do not require a tax category" do
|
||||
scenario "creating a new product", js: true do
|
||||
with_products_require_tax_category(false) do
|
||||
click_link 'Products'
|
||||
visit spree.admin_products_path
|
||||
click_link 'New Product'
|
||||
|
||||
fill_in 'product_name', :with => 'A new product !!!'
|
||||
|
||||
@@ -33,9 +33,10 @@ feature %q{
|
||||
|
||||
describe "Customers report" do
|
||||
before do
|
||||
login_to_admin_section
|
||||
click_link "Reports"
|
||||
quick_login_as_admin
|
||||
visit spree.admin_reports_path
|
||||
end
|
||||
|
||||
scenario "customers report" do
|
||||
click_link "Mailing List"
|
||||
expect(page).to have_select('report_type', selected: 'Mailing List')
|
||||
@@ -64,8 +65,8 @@ feature %q{
|
||||
|
||||
describe "Order cycle management report" do
|
||||
before do
|
||||
login_to_admin_section
|
||||
click_link "Reports"
|
||||
quick_login_as_admin
|
||||
visit spree.admin_reports_path
|
||||
end
|
||||
|
||||
scenario "payment method report" do
|
||||
@@ -91,8 +92,8 @@ feature %q{
|
||||
|
||||
describe "Packing reports" do
|
||||
before do
|
||||
login_to_admin_section
|
||||
click_link "Reports"
|
||||
quick_login_as_admin
|
||||
visit spree.admin_reports_path
|
||||
end
|
||||
|
||||
let(:bill_address1) { create(:address, lastname: "Aman") }
|
||||
@@ -150,8 +151,8 @@ feature %q{
|
||||
|
||||
|
||||
scenario "orders and distributors report" do
|
||||
login_to_admin_section
|
||||
click_link 'Reports'
|
||||
quick_login_as_admin
|
||||
visit spree.admin_reports_path
|
||||
click_link 'Orders And Distributors'
|
||||
click_button 'Search'
|
||||
|
||||
@@ -159,8 +160,8 @@ feature %q{
|
||||
end
|
||||
|
||||
scenario "bulk co-op report" do
|
||||
login_to_admin_section
|
||||
click_link 'Reports'
|
||||
quick_login_as_admin
|
||||
visit spree.admin_reports_path
|
||||
click_link 'Bulk Co-Op'
|
||||
click_button 'Search'
|
||||
|
||||
@@ -168,8 +169,8 @@ feature %q{
|
||||
end
|
||||
|
||||
scenario "payments reports" do
|
||||
login_to_admin_section
|
||||
click_link 'Reports'
|
||||
quick_login_as_admin
|
||||
visit spree.admin_reports_path
|
||||
click_link 'Payment Reports'
|
||||
click_button 'Search'
|
||||
|
||||
@@ -204,8 +205,8 @@ feature %q{
|
||||
|
||||
order1.finalize!
|
||||
|
||||
login_to_admin_as user1
|
||||
click_link "Reports"
|
||||
quick_login_as user1
|
||||
visit spree.admin_reports_path
|
||||
click_link "Sales Tax"
|
||||
select("Tax types", from: "report_type")
|
||||
end
|
||||
@@ -239,8 +240,8 @@ feature %q{
|
||||
|
||||
describe "orders & fulfilment reports" do
|
||||
it "loads the report page" do
|
||||
login_to_admin_section
|
||||
click_link 'Reports'
|
||||
quick_login_as_admin
|
||||
visit spree.admin_reports_path
|
||||
click_link 'Orders & Fulfillment Reports'
|
||||
|
||||
expect(page).to have_content 'Supplier'
|
||||
@@ -266,7 +267,7 @@ feature %q{
|
||||
|
||||
it "is precise to time of day, not just date" do
|
||||
# When I generate a customer report with a timeframe that includes one order but not the other
|
||||
login_to_admin_section
|
||||
quick_login_as_admin
|
||||
visit spree.orders_and_fulfillment_admin_reports_path
|
||||
|
||||
fill_in 'q_completed_at_gt', with: '2013-04-25 13:00:00'
|
||||
@@ -284,7 +285,7 @@ feature %q{
|
||||
oc = create(:simple_order_cycle, name: "My Order Cycle", distributors: [distributor], orders_open_at: Time.zone.now, orders_close_at: nil)
|
||||
o = create(:order, order_cycle: oc, distributor: distributor)
|
||||
|
||||
login_to_admin_section
|
||||
quick_login_as_admin
|
||||
visit spree.orders_and_fulfillment_admin_reports_path
|
||||
|
||||
expect(page).to have_content "My Order Cycle"
|
||||
@@ -316,8 +317,8 @@ feature %q{
|
||||
end
|
||||
|
||||
it "shows products and inventory report" do
|
||||
login_to_admin_section
|
||||
click_link 'Reports'
|
||||
quick_login_as_admin
|
||||
visit spree.admin_reports_path
|
||||
|
||||
expect(page).to have_content "All products"
|
||||
expect(page).to have_content "Inventory (on hand)"
|
||||
@@ -331,8 +332,8 @@ feature %q{
|
||||
end
|
||||
|
||||
it "shows the LettuceShare report" do
|
||||
login_to_admin_section
|
||||
click_link 'Reports'
|
||||
quick_login_as_admin
|
||||
visit spree.admin_reports_path
|
||||
click_link 'LettuceShare'
|
||||
click_button "Search"
|
||||
|
||||
@@ -349,8 +350,8 @@ feature %q{
|
||||
before do
|
||||
enterprise3.enterprise_roles.build( user: enterprise1.owner ).save
|
||||
|
||||
login_to_admin_section
|
||||
click_link 'Reports'
|
||||
quick_login_as_admin
|
||||
visit spree.admin_reports_path
|
||||
|
||||
click_link 'Users & Enterprises'
|
||||
end
|
||||
@@ -420,8 +421,8 @@ feature %q{
|
||||
order1.update_attribute :email, 'customer@email.com'
|
||||
Timecop.travel(Time.zone.local(2015, 4, 25, 14, 0, 0)) { order1.finalize! }
|
||||
|
||||
login_to_admin_section
|
||||
click_link 'Reports'
|
||||
quick_login_as_admin
|
||||
visit spree.admin_reports_path
|
||||
|
||||
click_link 'Xero Invoices'
|
||||
end
|
||||
|
||||
@@ -16,10 +16,11 @@ feature 'Schedules', js: true do
|
||||
let!(:oc5) { create(:simple_order_cycle, coordinator: managed_enterprise2, name: 'oc5') }
|
||||
let!(:weekly_schedule) { create(:schedule, name: 'Weekly', order_cycles: [oc1, oc2, oc3, oc4]) }
|
||||
|
||||
before { login_to_admin_as user }
|
||||
before { quick_login_as user }
|
||||
|
||||
describe "Adding a new Schedule" do
|
||||
it "immediately shows the schedule in the order cycle list once created" do
|
||||
visit spree.admin_path
|
||||
click_link 'Order Cycles'
|
||||
expect(page).to have_selector ".order-cycle-#{oc1.id}"
|
||||
find('a', text: 'NEW SCHEDULE').click
|
||||
@@ -65,7 +66,7 @@ feature 'Schedules', js: true do
|
||||
let!(:fortnightly_schedule) { create(:schedule, name: 'Fortnightly', order_cycles: [oc1, oc3]) }
|
||||
|
||||
it "immediately shows updated schedule lists for order cycles" do
|
||||
click_link 'Order Cycles'
|
||||
visit admin_order_cycles_path
|
||||
|
||||
within ".order-cycle-#{oc1.id} td.schedules" do
|
||||
find('a', text: "Weekly").click
|
||||
@@ -100,7 +101,7 @@ feature 'Schedules', js: true do
|
||||
|
||||
describe "deleting a schedule" do
|
||||
it "immediately removes deleted schedules from order cycles" do
|
||||
click_link 'Order Cycles'
|
||||
visit admin_order_cycles_path
|
||||
|
||||
within ".order-cycle-#{oc1.id} td.schedules" do
|
||||
find('a', text: "Weekly").click
|
||||
|
||||
@@ -10,7 +10,7 @@ feature 'shipping methods' do
|
||||
|
||||
context "as a site admin" do
|
||||
before(:each) do
|
||||
login_to_admin_section
|
||||
quick_login_as_admin
|
||||
end
|
||||
|
||||
scenario "creating a shipping method owned by some distributors" do
|
||||
@@ -73,11 +73,11 @@ feature 'shipping methods' do
|
||||
before(:each) do
|
||||
enterprise_user.enterprise_roles.build(enterprise: distributor1).save
|
||||
enterprise_user.enterprise_roles.build(enterprise: distributor2).save
|
||||
login_to_admin_as enterprise_user
|
||||
quick_login_as enterprise_user
|
||||
end
|
||||
|
||||
it "creating a shipping method" do
|
||||
click_link 'Enterprises'
|
||||
visit admin_enterprises_path
|
||||
within("#e_#{distributor1.id}") { click_link 'Manage' }
|
||||
within(".side_menu") do
|
||||
click_link "Shipping Methods"
|
||||
@@ -130,7 +130,7 @@ feature 'shipping methods' do
|
||||
sm1
|
||||
sm2
|
||||
|
||||
click_link 'Enterprises'
|
||||
visit admin_enterprises_path
|
||||
within("#e_#{distributor1.id}") { click_link 'Manage' }
|
||||
within(".side_menu") do
|
||||
click_link "Shipping Methods"
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
feature "Connecting a Stripe Account" do
|
||||
include AuthenticationWorkflow
|
||||
include WebHelper
|
||||
|
||||
let!(:enterprise_user) { create :enterprise_user }
|
||||
before(:each) do
|
||||
login_to_admin_as enterprise_user
|
||||
end
|
||||
end
|
||||
@@ -20,16 +20,7 @@ module AuthenticationWorkflow
|
||||
end
|
||||
|
||||
def login_to_admin_section
|
||||
admin_role = Spree::Role.find_or_create_by_name!('admin')
|
||||
admin_user = create(:user,
|
||||
:password => 'passw0rd',
|
||||
:password_confirmation => 'passw0rd',
|
||||
:remember_me => false,
|
||||
:persistence_token => 'pass',
|
||||
:login => 'admin@ofn.org')
|
||||
|
||||
admin_user.spree_roles << admin_role
|
||||
quick_login_as admin_user
|
||||
quick_login_as_admin
|
||||
visit spree.admin_path
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user