Skip to content

Commit

Permalink
Merge pull request #12898 from dacook/buu-producer-specs
Browse files Browse the repository at this point in the history
[BUU] Add missing specs
  • Loading branch information
rioug authored Oct 15, 2024
2 parents 8c4cc05 + d5b2408 commit c1c2811
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 17 deletions.
58 changes: 41 additions & 17 deletions spec/system/admin/products_v3/index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,6 @@
end
end

it "displays a select box for suppliers, with the appropriate supplier selected" do
pending( "[BUU] Change producer, unit type, category and tax category #11060" )
s1 = FactoryBot.create(:supplier_enterprise)
s2 = FactoryBot.create(:supplier_enterprise)
s3 = FactoryBot.create(:supplier_enterprise)
p1 = FactoryBot.create(:product, supplier_id: s2.id)
p2 = FactoryBot.create(:product, supplier_id: s3.id)

visit spree.admin_products_path

expect(page).to have_select "producer_id", with_options: [s1.name, s2.name, s3.name],
selected: s2.name
expect(page).to have_select "producer_id", with_options: [s1.name, s2.name, s3.name],
selected: s3.name
end

context "with several variants" do
let!(:variant1) { p1.variants.first }
let!(:variant2a) { p2.variants.first }
Expand Down Expand Up @@ -91,6 +75,38 @@
expect(page).to have_content "4"
end
end

describe "Producer column" do
it "when I have one enterprise" do
visit spree.admin_products_path

expect(page).not_to have_select "Producer"
end

context "when I have multiple enterprises" do
let(:user) { create(:user, enterprises: [producer2, producer1]) }
let(:producer1) { create(:supplier_enterprise, name: "Producer A") }
let(:producer2) { create(:supplier_enterprise, name: "Producer B") }

it "displays a select box for suppliers, with the appropriate supplier selected" do
create(:supplier_enterprise, name: "Producer C")
variant1.update!(supplier: producer1)
variant2a.update!(supplier: producer2)

visit spree.admin_products_path

within row_containing_name "Variant1" do
expect(page).to have_select "Producer", with_options: ["Producer A", "Producer B"],
selected: "Producer A"
end

within row_containing_name "Variant2a" do
expect(page).to have_select "Producer", with_options: ["Producer A", "Producer B"],
selected: "Producer B"
end
end
end
end
end

it "displays a select box for the unit of measure for the product's variants" do
Expand Down Expand Up @@ -296,7 +312,7 @@
end
end

context "product has producer" do
context "User has multiple producers" do
before { create_products 1 }

# create a product with a different supplier
Expand Down Expand Up @@ -334,6 +350,14 @@
end
end

context "User has single producer" do
it "producer filter does not show" do
visit admin_products_url

expect(page).not_to have_select "Producers"
end
end

context "product has category" do
before { create_products 1 }

Expand Down
10 changes: 10 additions & 0 deletions spec/system/admin/products_v3/update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@
end
end

# it "can select only the producers that I manage"

it "discards changes and reloads latest data" do
within row_containing_name("Apples") do
fill_in "Name", with: "Pommes"
Expand Down Expand Up @@ -437,6 +439,14 @@
expect(page).not_to have_css('form.disabled-section#filters')
end

xdescribe "producer" do
it "can select only the producers that I manage"

context " when I manage only one producer" do
it "producer select doesn't show, and is saved correctly"
end
end

context "With 2 products" do
before do
variant_b1
Expand Down

0 comments on commit c1c2811

Please sign in to comment.