Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/views/transfers/_transfer_row.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<td><%= transfer_row.comment || "none" %></td>
<td class="numeric"><%= transfer_row.line_items.total %></td>
<td class="text-right">
<%= delete_button_to transfer_path(transfer_row.id), { confirm: "Are you sure you want to permanently remove this transfer?" } %>
<%= view_button_to transfer_row %>
<%= delete_button_to transfer_path(transfer_row.id), { text: "Undo", icon: "undo", confirm: "Are you sure you want to undo this transfer?" } %>
</td>
</tr>
35 changes: 35 additions & 0 deletions spec/requests/transfers_request_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
RSpec.describe "Transfers", type: :request do
let(:organization) { create(:organization) }
let(:user) { create(:user, organization: organization) }

before { sign_in(user) }

describe "GET #index" do
let!(:transfer) { create(:transfer, organization: organization) }

it "renders the View button before the Undo button" do
get transfers_path

view_position = response.body.index("fa-search")
undo_position = response.body.index("fa-undo")

expect(view_position).to be_present
expect(undo_position).to be_present
expect(view_position).to be < undo_position
end

it "labels the destructive action as Undo with the undo icon" do
get transfers_path

expect(response.body).to include("Undo")
expect(response.body).to include("fa-undo")
expect(response.body).not_to include("fa-trash")
end

it "asks for confirmation worded as an undo" do
get transfers_path

expect(response.body).to include("Are you sure you want to undo this transfer?")
end
end
end
4 changes: 2 additions & 2 deletions spec/system/transfer_system_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def create_transfer(amount, from_name, to_name, click_save: true, click_confirm:
expect(inventory.quantity_for(storage_location: to_storage_location.id, item_id: item.id)).to eq(transfer_amount)

accept_confirm do
click_button 'Delete'
click_button 'Undo'
end

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

accept_confirm do
click_button 'Delete'
click_button 'Undo'
end

expect(page).to have_content(/OH NOES/)
Expand Down
Loading