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] {
|
&[disabled] {
|
||||||
@include button-disabled;
|
@include button-disabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.delete {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,17 @@
|
|||||||
<%= f.text_field :official_position %>
|
<%= f.text_field :official_position %>
|
||||||
<%= f.select :official_level, official_level_options %>
|
<%= f.select :official_level, official_level_options %>
|
||||||
<%= f.submit class: "button" %>
|
<%= f.submit class: "button" %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<% if @user.official? %>
|
<% if @user.official? %>
|
||||||
<br>
|
<br>
|
||||||
<%= link_to t("admin.officials.edit.destroy"), admin_official_path(@user), method: :delete, class: "delete" %>
|
<%= render Admin::ActionComponent.new(
|
||||||
<% end %>
|
:destroy,
|
||||||
|
@user,
|
||||||
|
text: t("admin.officials.edit.destroy"),
|
||||||
|
path: admin_official_path(@user),
|
||||||
|
method: :delete,
|
||||||
|
class: "delete"
|
||||||
|
) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ describe "Admin officials", :admin do
|
|||||||
scenario "Destroy" do
|
scenario "Destroy" do
|
||||||
visit edit_admin_official_path(official)
|
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_content "Details saved: the user is no longer an official"
|
||||||
expect(page).to have_current_path(admin_officials_path, ignore_query: true)
|
expect(page).to have_current_path(admin_officials_path, ignore_query: true)
|
||||||
|
|||||||
Reference in New Issue
Block a user