Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature into system specs #8179

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions spec/features/admin/adjustments_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "spec_helper"

feature '
describe '
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can't have specs using spec_helper with describe, as they will be run as system specs, but will break because they are not calling the necessary helper (system_helper).

Copy link
Contributor Author

@filipefurtad0 filipefurtad0 Sep 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm noticing this as the build is failing here, on background:

https://github.com/openfoodfoundation/openfoodnetwork/pull/8179/files#diff-0f3532dd56c5ea48814fa945b58cd9a5851a2ddc631cd91020d85e25d783f1e8R319

Which passes on feature specs but breaks system specs -> replacing with before fixes it.

This seems to prevent the build from running:
image

As an administrator
I want to manage adjustments on orders
', js: true do
Expand All @@ -28,7 +28,7 @@
create(:check_payment, order: order, amount: order.total)
end

scenario "adding taxed adjustments to an order" do
it "adding taxed adjustments to an order" do
# When I go to the adjustments page for the order
login_as_admin_and_visit spree.admin_orders_path
page.find('td.actions a.icon-edit').click
Expand All @@ -47,7 +47,7 @@
expect(page).to have_selector 'td.tax', text: '10.00'
end

scenario "modifying taxed adjustments on an order" do
it "modifying taxed adjustments on an order" do
# Given a taxed adjustment
adjustment = create(:adjustment, label: "Extra Adjustment", adjustable: order,
amount: 110, tax_category: tax_category, order: order)
Expand All @@ -69,7 +69,7 @@
expect(page).to have_selector 'td.tax', text: '0.00'
end

scenario "modifying an untaxed adjustment on an order" do
it "modifying an untaxed adjustment on an order" do
# Given an untaxed adjustment
adjustment = create(:adjustment, label: "Extra Adjustment", adjustable: order,
amount: 110, tax_category: nil, order: order)
Expand All @@ -91,7 +91,7 @@
expect(page).to have_selector 'td.tax', text: '10.00'
end

scenario "viewing adjustments on a canceled order" do
it "viewing adjustments on a canceled order" do
# Given a taxed adjustment
adjustment = create(:adjustment, label: "Extra Adjustment", adjustable: order,
amount: 110, tax_category: tax_category, order: order)
Expand Down
6 changes: 3 additions & 3 deletions spec/features/admin/authentication_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

require 'spec_helper'

feature "Authentication", js: true do
describe "Authentication", js: true do
include UIComponentHelper
include AuthenticationHelper
include WebHelper

let(:user) { create(:user, password: "password", password_confirmation: "password") }
let!(:enterprise) { create(:enterprise, owner: user) } # Required for access to admin

scenario "logging into admin redirects home, then back to admin" do
it "logging into admin redirects home, then back to admin" do
visit spree.admin_dashboard_path

fill_in "Email", with: user.email
Expand All @@ -21,7 +21,7 @@
expect(page).to have_no_content "CONFIGURATION"
end

scenario "viewing my account" do
it "viewing my account" do
login_to_admin_section
click_link "Account"
expect(page).to have_current_path spree.account_path
Expand Down
2 changes: 1 addition & 1 deletion spec/features/admin/bulk_order_management_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'spec_helper'

feature '
describe '
As an Administrator
I want to be able to manage orders in bulk
', js: true do
Expand Down
20 changes: 10 additions & 10 deletions spec/features/admin/bulk_product_update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'spec_helper'

feature '
describe '
As an Administrator
I want to be able to manage products in bulk
', js: true do
Expand Down Expand Up @@ -200,7 +200,7 @@
end
end

scenario "creating a new product" do
it "creating a new product" do
create(:stock_location, backorderable_default: false)

supplier = create(:supplier_enterprise)
Expand All @@ -227,7 +227,7 @@
expect(page).to have_field "product_name", with: 'Big Bag Of Apples'
end

scenario "creating new variants" do
it "creating new variants" do
# Given a product without variants or a unit
p = FactoryBot.create(:product, variant_unit: 'weight', variant_unit_scale: 1000)
login_as_admin
Expand Down Expand Up @@ -274,7 +274,7 @@
expect(page).to have_selector "a.edit-variant", visible: true
end

scenario "updating product attributes" do
it "updating product attributes" do
s1 = FactoryBot.create(:supplier_enterprise)
s2 = FactoryBot.create(:supplier_enterprise)
t1 = FactoryBot.create(:taxon)
Expand Down Expand Up @@ -319,7 +319,7 @@
expect(p.sku).to eq "NEW SKU"
end

scenario "updating a product with a variant unit of 'items'" do
it "updating a product with a variant unit of 'items'" do
p = FactoryBot.create(:product, variant_unit: 'weight', variant_unit_scale: 1000)

login_as_admin
Expand All @@ -339,7 +339,7 @@
expect(p.variant_unit_name).to eq "loaf"
end

scenario "updating a product with variants" do
it "updating a product with variants" do
s1 = FactoryBot.create(:supplier_enterprise)
s2 = FactoryBot.create(:supplier_enterprise)
p = FactoryBot.create(:product, supplier: s1, available_on: Date.current, variant_unit: 'volume', variant_unit_scale: 0.001,
Expand Down Expand Up @@ -381,7 +381,7 @@
expect(v.unit_description).to eq "(8x250 mL bottles)"
end

scenario "updating delegated attributes of variants in isolation" do
it "updating delegated attributes of variants in isolation" do
p = FactoryBot.create(:product)
v = FactoryBot.create(:variant, product: p, price: 3.0)

Expand All @@ -406,7 +406,7 @@
expect(v.price).to eq 10.0
end

scenario "updating a product mutiple times without refresh" do
it "updating a product mutiple times without refresh" do
p = FactoryBot.create(:product, name: 'original name')
login_as_admin

Expand Down Expand Up @@ -439,7 +439,7 @@
expect(p.name).to eq "original name"
end

scenario "updating a product after cloning a product" do
it "updating a product after cloning a product" do
p = FactoryBot.create(:product, name: "product 1")
login_as_admin

Expand All @@ -462,7 +462,7 @@
expect(p.name).to eq "new product name"
end

scenario "updating when a filter has been applied" do
it "updating when a filter has been applied" do
s1 = create(:supplier_enterprise)
s2 = create(:supplier_enterprise)
p1 = FactoryBot.create(:simple_product, name: "product1", supplier: s1)
Expand Down
6 changes: 3 additions & 3 deletions spec/features/admin/configuration/zones_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Spree::Zone.delete_all
end

scenario "list existing zones" do
it "list existing zones" do
visit spree.edit_admin_general_settings_path
create(:zone, name: "eastern", description: "zone is eastern")
create(:zone, name: "western", description: "cool san fran")
Expand All @@ -27,7 +27,7 @@
within_row(2) { expect(page).to have_content("eastern") }
end

scenario "create a new zone" do
it "create a new zone" do
visit spree.admin_zones_path
click_link "admin_new_zone_link"
expect(page).to have_content("New Zone")
Expand All @@ -39,7 +39,7 @@
expect(page).to have_content("successfully created!")
end

scenario "edit existing zone" do
it "edit existing zone" do
zone = create(:zone_with_member)
visit spree.edit_admin_zone_path(zone.id)

Expand Down
2 changes: 1 addition & 1 deletion spec/features/admin/customers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'spec_helper'

feature 'Customers' do
describe 'Customers' do
include AdminHelper
include AuthenticationHelper
include WebHelper
Expand Down
10 changes: 5 additions & 5 deletions spec/features/admin/enterprise_fees_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'spec_helper'

feature '
describe '
As an administrator
I want to manage enterprise fees
', js: true do
Expand All @@ -11,7 +11,7 @@

let!(:tax_category_gst) { create(:tax_category, name: 'GST') }

scenario "listing enterprise fees" do
it "listing enterprise fees" do
fee = create(:enterprise_fee, name: '$0.50 / kg', fee_type: 'packing',
tax_category: tax_category_gst)
amount = fee.calculator.preferred_amount
Expand All @@ -30,7 +30,7 @@
expect(page).to have_selector "input[value='#{amount}']"
end

scenario "creating an enterprise fee" do
it "creating an enterprise fee" do
# Given an enterprise
e = create(:supplier_enterprise, name: 'Feedme')

Expand Down Expand Up @@ -58,7 +58,7 @@
expect(page).to have_selector "#sets_enterprise_fee_set_collection_attributes_0_calculator_attributes_preferred_flat_percent[value='12.34']"
end

scenario "editing an enterprise fee" do
it "editing an enterprise fee" do
# Given an enterprise fee
fee = create(:enterprise_fee)
enterprise = create(:enterprise, name: 'Foo')
Expand Down Expand Up @@ -96,7 +96,7 @@
expect(fee.inherits_tax_category).to eq(true)
end

scenario "deleting an enterprise fee" do
it "deleting an enterprise fee" do
# Given an enterprise fee
fee = create(:enterprise_fee)

Expand Down
12 changes: 6 additions & 6 deletions spec/features/admin/enterprise_groups_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'spec_helper'

feature '
describe '
As an administrator
I want to manage enterprise groups
' do
Expand All @@ -13,7 +13,7 @@
login_to_admin_section
end

scenario "listing enterprise groups" do
it "listing enterprise groups" do
e = create(:enterprise)
group = create(:enterprise_group, enterprises: [e], on_front_page: true)

Expand All @@ -24,7 +24,7 @@
expect(page).to have_selector 'td', text: e.name
end

scenario "creating a new enterprise group", js: true do
it "creating a new enterprise group", js: true do
e1 = create(:enterprise)
e2 = create(:enterprise)
e3 = create(:enterprise)
Expand Down Expand Up @@ -55,7 +55,7 @@
expect(eg.enterprises).to match_array [e1, e2]
end

scenario "editing an enterprise group" do
it "editing an enterprise group" do
e1 = create(:enterprise)
e2 = create(:enterprise)
eg = create(:enterprise_group, name: 'EGEGEG', on_front_page: true, enterprises: [e1, e2])
Expand All @@ -82,7 +82,7 @@
expect(eg.enterprises).to eq([e2])
end

scenario "re-ordering enterprise groups" do
it "re-ordering enterprise groups" do
eg1 = create(:enterprise_group, name: 'A')
eg2 = create(:enterprise_group, name: 'B')

Expand All @@ -95,7 +95,7 @@
expect(page.all('td.name').map(&:text)).to eq(['A', 'B'])
end

scenario "deleting an enterprise group", js: true do
it "deleting an enterprise group", js: true do
eg = create(:enterprise_group, name: 'EGEGEG')

click_link 'Groups'
Expand Down
14 changes: 7 additions & 7 deletions spec/features/admin/enterprise_relationships_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'spec_helper'

feature '
describe '
As an Administrator
I want to manage relationships between enterprises
', js: true do
Expand All @@ -12,7 +12,7 @@
context "as a site administrator" do
before { login_as_admin }

scenario "listing relationships" do
it "listing relationships" do
# Given some enterprises with relationships
e1, e2, e3, e4 = create(:enterprise), create(:enterprise), create(:enterprise),
create(:enterprise)
Expand All @@ -35,7 +35,7 @@
end
end

scenario "creating a relationship" do
it "creating a relationship" do
e1 = create(:enterprise, name: 'One')
e2 = create(:enterprise, name: 'Two')

Expand All @@ -60,7 +60,7 @@
'create_variant_overrides']
end

scenario "attempting to create a relationship with invalid data" do
it "attempting to create a relationship with invalid data" do
e1 = create(:enterprise, name: 'One')
e2 = create(:enterprise, name: 'Two')
create(:enterprise_relationship, parent: e1, child: e2)
Expand All @@ -77,7 +77,7 @@
end.to change(EnterpriseRelationship, :count).by(0)
end

scenario "deleting a relationship" do
it "deleting a relationship" do
e1 = create(:enterprise, name: 'One')
e2 = create(:enterprise, name: 'Two')
er = create(:enterprise_relationship, parent: e1, child: e2,
Expand Down Expand Up @@ -107,15 +107,15 @@

before { login_as enterprise_user }

scenario "enterprise user can only see relationships involving their enterprises" do
it "enterprise user can only see relationships involving their enterprises" do
visit admin_enterprise_relationships_path

expect(page).to have_relationship d1, d2
expect(page).to have_relationship d2, d1
expect(page).not_to have_relationship d2, d3
end

scenario "enterprise user can only add their own enterprises as parent" do
it "enterprise user can only add their own enterprises as parent" do
visit admin_enterprise_relationships_path
expect(page).to have_select2 'enterprise_relationship_parent_id', options: ['', d1.name]
expect(page).to have_select2 'enterprise_relationship_child_id',
Expand Down
Loading