|
71 | 71 | end |
72 | 72 | end |
73 | 73 | end |
| 74 | + |
| 75 | + context "updating tax rate" do |
| 76 | + before do |
| 77 | + create(:tax_rate, |
| 78 | + name: "Clothing", |
| 79 | + zone: create(:zone, name: "US"), |
| 80 | + tax_categories: [create(:tax_category, name: "Default")], |
| 81 | + amount: 0.3) |
| 82 | + create(:zone, name: "EU") |
| 83 | + create(:tax_category, name: "Specific") |
| 84 | + end |
| 85 | + |
| 86 | + it "updates tax rate" do |
| 87 | + visit "/admin/tax_rates" |
| 88 | + click_on "Clothing" |
| 89 | + |
| 90 | + fill_in "Name", with: "Food" |
| 91 | + solidus_select "EU", from: "Zone" |
| 92 | + solidus_select "Specific", from: "Tax Categories" |
| 93 | + fill_in "Rate", with: "0.18" |
| 94 | + |
| 95 | + within("header") { click_on "Save" } |
| 96 | + |
| 97 | + expect(page).to have_content("Tax rate was successfully updated.") |
| 98 | + expect(page).to have_content("EU") |
| 99 | + expect(page).to have_content("Food") |
| 100 | + expect(page).to have_content("Default, Specific") |
| 101 | + expect(page).to have_content("18.0%") |
| 102 | + end |
| 103 | + |
| 104 | + context "with invalid attributes" do |
| 105 | + it "shows validation errors" do |
| 106 | + visit "/admin/tax_rates" |
| 107 | + click_on "Clothing" |
| 108 | + |
| 109 | + fill_in "Rate", with: "" |
| 110 | + |
| 111 | + within("header") { click_on "Save" } |
| 112 | + |
| 113 | + expect(page).to have_content("can't be blank") |
| 114 | + expect(page).to have_content("is not a number") |
| 115 | + end |
| 116 | + end |
| 117 | + end |
74 | 118 | end |
0 commit comments