Skip to content

Commit d8eaee2

Browse files
committed
Reorder and relabel transfer action buttons to Undo (5560)
1 parent 1a15828 commit d8eaee2

3 files changed

Lines changed: 38 additions & 3 deletions

File tree

app/views/transfers/_transfer_row.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<td><%= transfer_row.comment || "none" %></td>
66
<td class="numeric"><%= transfer_row.line_items.total %></td>
77
<td class="text-right">
8-
<%= delete_button_to transfer_path(transfer_row.id), { confirm: "Are you sure you want to permanently remove this transfer?" } %>
98
<%= view_button_to transfer_row %>
9+
<%= delete_button_to transfer_path(transfer_row.id), { text: "Undo", icon: "undo", confirm: "Are you sure you want to undo this transfer?" } %>
1010
</td>
1111
</tr>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
RSpec.describe "Transfers", type: :request do
2+
let(:organization) { create(:organization) }
3+
let(:user) { create(:user, organization: organization) }
4+
5+
before { sign_in(user) }
6+
7+
describe "GET #index" do
8+
let!(:transfer) { create(:transfer, organization: organization) }
9+
10+
it "renders the View button before the Undo button" do
11+
get transfers_path
12+
13+
view_position = response.body.index("fa-search")
14+
undo_position = response.body.index("fa-undo")
15+
16+
expect(view_position).to be_present
17+
expect(undo_position).to be_present
18+
expect(view_position).to be < undo_position
19+
end
20+
21+
it "labels the destructive action as Undo with the undo icon" do
22+
get transfers_path
23+
24+
expect(response.body).to include("Undo")
25+
expect(response.body).to include("fa-undo")
26+
expect(response.body).not_to include("fa-trash")
27+
end
28+
29+
it "asks for confirmation worded as an undo" do
30+
get transfers_path
31+
32+
expect(response.body).to include("Are you sure you want to undo this transfer?")
33+
end
34+
end
35+
end

spec/system/transfer_system_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def create_transfer(amount, from_name, to_name, click_save: true, click_confirm:
8080
expect(inventory.quantity_for(storage_location: to_storage_location.id, item_id: item.id)).to eq(transfer_amount)
8181

8282
accept_confirm do
83-
click_button 'Delete'
83+
click_button 'Undo'
8484
end
8585

8686
expect(page).to have_content(/Successfully deleted Transfer/)
@@ -109,7 +109,7 @@ def create_transfer(amount, from_name, to_name, click_save: true, click_confirm:
109109
allow(TransferDestroyEvent).to receive(:publish).and_raise('OH NOES')
110110

111111
accept_confirm do
112-
click_button 'Delete'
112+
click_button 'Undo'
113113
end
114114

115115
expect(page).to have_content(/OH NOES/)

0 commit comments

Comments
 (0)