Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deleting searched managers/moderators/admins #4038

Merged
merged 2 commits into from
Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 7 additions & 15 deletions app/views/admin/administrators/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,13 @@
<%= administrator.description %>
</td>
<td>
<% if administrator.persisted? %>
<%= link_to t("admin.actions.edit"),
edit_admin_administrator_path(administrator),
class: "button hollow" %>
<%= link_to t("admin.administrators.administrator.delete"),
admin_administrator_path(administrator),
method: :delete,
class: "button hollow alert" %>
<% else %>
<%= link_to t("admin.administrators.administrator.add"),
{ controller: "admin/administrators", action: :create,
user_id: administrator.user_id },
method: :post,
class: "button success expanded" %>
<% end %>
<%= link_to t("admin.actions.edit"),
edit_admin_administrator_path(administrator),
class: "button hollow" %>
<%= link_to t("admin.administrators.administrator.delete"),
admin_administrator_path(administrator),
method: :delete,
class: "button hollow alert" %>
</td>
</tr>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/administrators/search.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<td class="text-right">
<% if user.administrator? && user.administrator.persisted? %>
<%= link_to t("admin.administrators.administrator.delete"),
admin_administrator_path(user),
admin_administrator_path(user.administrator),
method: :delete,
class: "button hollow alert expanded" %>
<% else %>
Expand Down
18 changes: 4 additions & 14 deletions app/views/admin/managers/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,10 @@
<%= manager.email %>
</td>
<td>
<% if manager.persisted? %>
<%= link_to t("admin.managers.manager.delete"),
admin_manager_path(manager),
method: :delete,
class: "button hollow alert expanded"
%>
<% else %>
<%= link_to t("admin.managers.manager.add"),
{ controller: "admin/managers",
action: :create,
user_id: manager.user_id },
method: :post,
class: "button success expanded" %>
<% end %>
<%= link_to t("admin.managers.manager.delete"),
admin_manager_path(manager),
method: :delete,
class: "button hollow alert expanded" %>
</td>
</tr>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/managers/search.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<td>
<% if user.manager? && user.manager.persisted? %>
<%= link_to t("admin.managers.manager.delete"),
admin_manager_path(user),
admin_manager_path(user.manager),
method: :delete,
class: "button hollow alert expanded" %>
<% else %>
Expand Down
17 changes: 4 additions & 13 deletions app/views/admin/moderators/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,10 @@
<%= moderator.email %>
</td>
<td>
<% if moderator.persisted? %>
<%= link_to t("admin.moderators.moderator.delete"),
admin_moderator_path(moderator),
method: :delete,
class: "button hollow alert expanded"
%>
<% else %>
<%= link_to t("admin.moderators.moderator.add"),
{ controller: "admin/moderators", action: :create,
user_id: moderator.user_id },
method: :post,
class: "button success expanded" %>
<% end %>
<%= link_to t("admin.moderators.moderator.delete"),
admin_moderator_path(moderator),
method: :delete,
class: "button hollow alert expanded" %>
</td>
</tr>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/moderators/search.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<td>
<% if user.moderator? && user.moderator.persisted? %>
<%= link_to t("admin.moderators.moderator.delete"),
admin_moderator_path(user),
admin_moderator_path(user.moderator),
method: :delete,
class: "button hollow alert expanded" %>
<% else %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/officials/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<%= t("admin.officials.level_#{official.official_level}") %>
</td>
<td>
<%= link_to official.official? ? t("admin.officials.search.edit_official") : t("admin.officials.search.make_official"),
<%= link_to t("admin.officials.search.edit_official"),
edit_admin_official_path(official), class: "button hollow expanded" %>
</td>
</tr>
Expand Down
10 changes: 10 additions & 0 deletions spec/system/admin/administrators_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@
expect(page).to have_content(administrator2.email)
expect(page).not_to have_content(administrator1.email)
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

context "Edit" do
Expand Down
10 changes: 10 additions & 0 deletions spec/system/admin/managers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,15 @@
expect(page).to have_content(manager2.email)
expect(page).not_to have_content(manager1.email)
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
10 changes: 10 additions & 0 deletions spec/system/admin/moderators_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,15 @@
expect(page).to have_content(moderator2.email)
expect(page).not_to have_content(moderator1.email)
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