Fix deleting searched managers/moderators/admins

We were deleting managers, moderators and administrators based on their
user ID, instead of their manager/moderator/administrator ID.
This commit is contained in:
Javi Martín
2020-06-11 17:53:24 +02:00
parent 99dc861d45
commit 5d10afdf26
6 changed files with 33 additions and 3 deletions

View File

@@ -20,7 +20,7 @@
<td class="text-right"> <td class="text-right">
<% if user.administrator? && user.administrator.persisted? %> <% if user.administrator? && user.administrator.persisted? %>
<%= link_to t("admin.administrators.administrator.delete"), <%= link_to t("admin.administrators.administrator.delete"),
admin_administrator_path(user), admin_administrator_path(user.administrator),
method: :delete, method: :delete,
class: "button hollow alert expanded" %> class: "button hollow alert expanded" %>
<% else %> <% else %>

View File

@@ -20,7 +20,7 @@
<td> <td>
<% if user.manager? && user.manager.persisted? %> <% if user.manager? && user.manager.persisted? %>
<%= link_to t("admin.managers.manager.delete"), <%= link_to t("admin.managers.manager.delete"),
admin_manager_path(user), admin_manager_path(user.manager),
method: :delete, method: :delete,
class: "button hollow alert expanded" %> class: "button hollow alert expanded" %>
<% else %> <% else %>

View File

@@ -20,7 +20,7 @@
<td> <td>
<% if user.moderator? && user.moderator.persisted? %> <% if user.moderator? && user.moderator.persisted? %>
<%= link_to t("admin.moderators.moderator.delete"), <%= link_to t("admin.moderators.moderator.delete"),
admin_moderator_path(user), admin_moderator_path(user.moderator),
method: :delete, method: :delete,
class: "button hollow alert expanded" %> class: "button hollow alert expanded" %>
<% else %> <% else %>

View File

@@ -98,6 +98,16 @@ describe "Admin administrators" do
expect(page).to have_content(administrator2.email) expect(page).to have_content(administrator2.email)
expect(page).not_to have_content(administrator1.email) expect(page).not_to have_content(administrator1.email)
end end
scenario "Delete after searching" do
fill_in "Search user by name or email", with: administrator2.email
click_button "Search"
click_link "Delete"
expect(page).to have_content(administrator1.email)
expect(page).not_to have_content(administrator2.email)
end
end end
context "Edit" do context "Edit" do

View File

@@ -80,5 +80,15 @@ describe "Admin managers" do
expect(page).to have_content(manager2.email) expect(page).to have_content(manager2.email)
expect(page).not_to have_content(manager1.email) expect(page).not_to have_content(manager1.email)
end end
scenario "Delete after searching" do
fill_in "Search user by name or email", with: manager2.email
click_button "Search"
click_link "Delete"
expect(page).to have_content(manager1.email)
expect(page).not_to have_content(manager2.email)
end
end end
end end

View File

@@ -80,5 +80,15 @@ describe "Admin moderators" do
expect(page).to have_content(moderator2.email) expect(page).to have_content(moderator2.email)
expect(page).not_to have_content(moderator1.email) expect(page).not_to have_content(moderator1.email)
end end
scenario "Delete after searching" do
fill_in "Search user by name or email", with: moderator2.email
click_button "Search"
click_link "Delete"
expect(page).to have_content(moderator1.email)
expect(page).not_to have_content(moderator2.email)
end
end end
end end