Use a button to destroy officials
As mentioned in commits5311daadfandbb958daf0, using links combined with JavaScript to generate POST (or, in this case, DELETE) requests to the server has a few issues.
This commit is contained in:
@@ -3,4 +3,8 @@
|
||||
&[disabled] {
|
||||
@include button-disabled;
|
||||
}
|
||||
|
||||
&.delete {
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,9 +14,17 @@
|
||||
<%= f.text_field :official_position %>
|
||||
<%= f.select :official_level, official_level_options %>
|
||||
<%= f.submit class: "button" %>
|
||||
<% if @user.official? %>
|
||||
<br>
|
||||
<%= link_to t("admin.officials.edit.destroy"), admin_official_path(@user), method: :delete, class: "delete" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if @user.official? %>
|
||||
<br>
|
||||
<%= render Admin::ActionComponent.new(
|
||||
:destroy,
|
||||
@user,
|
||||
text: t("admin.officials.edit.destroy"),
|
||||
path: admin_official_path(@user),
|
||||
method: :delete,
|
||||
class: "delete"
|
||||
) %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -63,7 +63,7 @@ describe "Admin officials", :admin do
|
||||
scenario "Destroy" do
|
||||
visit edit_admin_official_path(official)
|
||||
|
||||
click_link 'Remove "Official" status'
|
||||
click_button 'Remove "Official" status'
|
||||
|
||||
expect(page).to have_content "Details saved: the user is no longer an official"
|
||||
expect(page).to have_current_path(admin_officials_path, ignore_query: true)
|
||||
|
||||
Reference in New Issue
Block a user