Skip to content

Commit 2aee7da

Browse files
committed
Add feature specs for shipping methods
- Added feature specs for creating and editing shipping methods.
1 parent 9e69938 commit 2aee7da

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

admin/spec/features/shipping_methods_spec.rb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,42 @@
2727
expect(page).to have_content("Add new")
2828
expect(page).to have_selector(:css, 'a[href="/admin/shipping_methods/new"]')
2929
end
30+
31+
context "when creating a new shipping method" do
32+
before do
33+
create(:shipping_category, name: "Default")
34+
35+
visit "/admin/shipping_methods/new"
36+
end
37+
38+
it "creates the shipping method", :js do
39+
fill_in "Name", with: "Super Saver"
40+
fill_in "Code", with: "super-saver"
41+
fill_in "Carrier", with: "CarrierX"
42+
fill_in "Tracking URL", with: "https://track.example.com/:tracking"
43+
44+
check "Available to all stock locations"
45+
check "Available to users"
46+
solidus_select "Default", from: "Shipping Categories"
47+
48+
click_on "Save"
49+
50+
expect(page).to have_content("Shipping method was successfully created.")
51+
expect(Spree::ShippingMethod.find_by(name: "Super Saver")).to be_present
52+
end
53+
end
54+
55+
context "when editing an existing shipping method" do
56+
let!(:shipping_method) { create(:shipping_method, name: "Old Name") }
57+
58+
before { visit spree.edit_admin_shipping_method_path(shipping_method) }
59+
60+
it "updates the shipping method", :js do
61+
fill_in "Name", with: "New Name"
62+
click_on "Save"
63+
64+
expect(page).to have_content("Shipping method was successfully updated.")
65+
expect(page).to have_content("New Name")
66+
end
67+
end
3068
end

0 commit comments

Comments
 (0)