Skip to content

Commit 3557107

Browse files
committed
Render form on new rate page
1 parent 7a1c093 commit 3557107

3 files changed

Lines changed: 54 additions & 0 deletions

File tree

admin/app/components/solidus_admin/tax_rates/new/component.html.erb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,6 @@
1414
<%= render component("ui/button").new(tag: :button, text: t(".save"), form: form_id) %>
1515
<% end %>
1616
<% end %>
17+
18+
<%= render component("tax_rates/form").new(tax_rate: @tax_rate, form_url:, form_id:) %>
1719
<% end %>

admin/config/locales/tax_rates.en.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@ en:
22
solidus_admin:
33
tax_rates:
44
title: "Tax Rates"
5+
create:
6+
success: "Tax rate was successfully created."
57
destroy:
68
success: "Tax rates were successfully removed."

admin/spec/features/tax_rates_spec.rb

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,54 @@
2121
expect(Spree::TaxRate.count).to eq(1)
2222
expect(page).to be_axe_clean
2323
end
24+
25+
context "creating new tax rate" do
26+
before do
27+
create(:zone, name: "EU")
28+
create(:tax_category, name: "Default")
29+
create(:tax_category, name: "Specific")
30+
end
31+
32+
it "creates new tax rate" do
33+
visit "/admin/tax_rates"
34+
click_on "Add new"
35+
expect(page).to have_current_path("/admin/tax_rates/new")
36+
expect(page).to be_axe_clean
37+
38+
fill_in "Name", with: "Clothing"
39+
solidus_select "EU", from: "Zone"
40+
solidus_select %w[Default Specific], from: "Tax Categories"
41+
switch "Show Rate in Label"
42+
solidus_select "Default Tax", from: "Calculator"
43+
fill_in "Rate", with: "0.18"
44+
solidus_select "Item level", from: "Tax Rate Level"
45+
switch "Included in Price"
46+
fill_in "Start Date", with: "20/06/2024"
47+
fill_in "Expiration Date", with: "20/06/2026"
48+
49+
within("header") { click_on "Save" }
50+
51+
expect(page).to have_current_path("/admin/tax_rates")
52+
expect(page).to have_content("Tax rate was successfully created.")
53+
expect(page).to have_content("EU")
54+
expect(page).to have_content("Clothing")
55+
expect(page).to have_content("Default, Specific")
56+
expect(page).to have_content("18.0%")
57+
expect(page).to have_content("2026-06-20")
58+
expect(page).to have_content("Default Tax")
59+
end
60+
61+
context "with invalid attributes" do
62+
it "shows validation errors" do
63+
visit "/admin/tax_rates"
64+
click_on "Add new"
65+
66+
within("header") { click_on "Save" }
67+
68+
expect(page).to have_current_path("/admin/tax_rates/new")
69+
expect(page).to have_content("can't be blank")
70+
expect(page).to have_content("is not a number")
71+
end
72+
end
73+
end
2474
end

0 commit comments

Comments
 (0)