Skip to content

Commit 6cbb14c

Browse files
committed
Render form on edit rate page
1 parent 3557107 commit 6cbb14c

3 files changed

Lines changed: 48 additions & 0 deletions

File tree

admin/app/components/solidus_admin/tax_rates/edit/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
@@ -6,3 +6,5 @@ en:
66
success: "Tax rate was successfully created."
77
destroy:
88
success: "Tax rates were successfully removed."
9+
update:
10+
success: "Tax rate was successfully updated."

admin/spec/features/tax_rates_spec.rb

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,48 @@
7171
end
7272
end
7373
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
74118
end

0 commit comments

Comments
 (0)