Skip to content

Commit f0fb9a8

Browse files
committed
Add user store credit: Load modal with turbo frame
1 parent 3d15725 commit f0fb9a8

File tree

5 files changed

+15
-13
lines changed

5 files changed

+15
-13
lines changed

admin/app/components/solidus_admin/users/store_credits/index/component.html.erb

+7-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,14 @@
55

66
<%= page_header_actions do %>
77
<%= render component("ui/button").new(
8-
"data-action": "click->#{stimulus_id}#actionButtonClicked",
9-
"data-#{stimulus_id}-url-param": solidus_admin.new_user_store_credit_path(user_id: @user.id, _turbo_frame: :new_store_credit_modal),
8+
tag: :a,
9+
href: solidus_admin.new_user_store_credit_path(user_id: @user.id),
10+
data: {
11+
turbo_frame: :new_store_credit_modal,
12+
turbo_prefetch: false
13+
},
1014
text: t(".add_store_credit"),
15+
icon: "add-line"
1116
)%>
1217
<% end %>
1318
<% end %>

admin/app/components/solidus_admin/users/store_credits/new/component.html.erb

-1
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,3 @@
2828
<% end %>
2929
<% end %>
3030
<% end %>
31-
<%= render component("users/store_credits/index").new(user: @user, store_credits: @store_credits) %>

admin/app/components/solidus_admin/users/store_credits/new/component.rb

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ def initialize(user:, store_credit:, categories:)
55
@user = user
66
@store_credit = store_credit
77
@store_credit_categories = categories
8-
@store_credits = Spree::StoreCredit.where(user_id: @user.id).order(id: :desc)
98
end
109

1110
def form_id

admin/spec/features/store_credits_spec.rb

+8-8
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
it "allows creation of a new store credit" do
3535
click_on "Create One"
3636

37-
expect(page).to have_selector("dialog", wait: 5)
37+
expect(page).to have_selector("dialog")
3838
expect(page).to have_content("New Store Credit")
3939

4040
within("dialog") do
@@ -47,7 +47,7 @@
4747

4848
click_on "Create One"
4949

50-
expect(page).to have_selector("dialog", wait: 5)
50+
expect(page).to have_selector("dialog")
5151
expect(page).to have_content("New Store Credit")
5252

5353
within("dialog") do
@@ -109,7 +109,7 @@
109109
context "with invalid amount" do
110110
it "shows the appropriate error message" do
111111
click_on "Edit Amount"
112-
expect(page).to have_selector("dialog", wait: 5)
112+
expect(page).to have_selector("dialog")
113113
expect(page).to have_content("Edit Store Credit Amount")
114114

115115
within("dialog") do
@@ -124,7 +124,7 @@
124124
context "without a valid reason" do
125125
it "shows the appropriate error message" do
126126
click_on "Edit Amount"
127-
expect(page).to have_selector("dialog", wait: 5)
127+
expect(page).to have_selector("dialog")
128128
expect(page).to have_content("Edit Store Credit Amount")
129129

130130
within("dialog") do
@@ -139,7 +139,7 @@
139139
context "with valid params" do
140140
it "allows editing of the store credit amount" do
141141
click_on "Edit Amount"
142-
expect(page).to have_selector("dialog", wait: 5)
142+
expect(page).to have_selector("dialog")
143143
expect(page).to have_content("Edit Store Credit Amount")
144144

145145
within("dialog") do
@@ -159,7 +159,7 @@
159159
context "without a valid reason" do
160160
it "shows the appropriate error message" do
161161
click_on "Invalidate"
162-
expect(page).to have_selector("dialog", wait: 5)
162+
expect(page).to have_selector("dialog")
163163
expect(page).to have_content("Invalidate Store Credit")
164164

165165
within("dialog") do
@@ -173,7 +173,7 @@
173173
context "with a valid reason" do
174174
it "invalidates the store credit" do
175175
click_on "Invalidate"
176-
expect(page).to have_selector("dialog", wait: 5)
176+
expect(page).to have_selector("dialog")
177177
expect(page).to have_content("Invalidate Store Credit")
178178

179179
within("dialog") do
@@ -192,7 +192,7 @@
192192
context "when editing the store credit memo" do
193193
it "allows editing of the store credit memo" do
194194
click_on "Edit Memo"
195-
expect(page).to have_selector("dialog", wait: 5)
195+
expect(page).to have_selector("dialog")
196196
expect(page).to have_content("Edit Store Credit Memo")
197197

198198
within("dialog") do

admin/spec/requests/solidus_admin/store_credits_spec.rb

-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
it "renders the new store credit template with a 200 OK status" do
6161
get solidus_admin.new_user_store_credit_path(user)
6262
expect(response).to have_http_status(:ok)
63-
expect(response.body).to include(store_credit.amount.to_s)
6463
end
6564
end
6665

0 commit comments

Comments
 (0)