|
27 | 27 | expect(page).to have_content("Add new") |
28 | 28 | expect(page).to have_selector(:css, 'a[href="/admin/shipping_methods/new"]') |
29 | 29 | 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 |
30 | 68 | end |
0 commit comments