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

Already on GitHub? Sign in to your account

AO3-5249 Add basic search of invitation queue #3164

Merged
merged 7 commits into from Nov 18, 2017
@@ -40,6 +40,12 @@ def create
def manage
@invite_requests = InviteRequest.order(:position).page(params[:page])
+ if params[:query].present?
+ @invite_requests = InviteRequest.where("simplified_email LIKE ?",
+ "%#{params[:query]}%")
+ .order(:position)
@houndci-bot

houndci-bot Nov 17, 2017

Place the . on the previous line, together with the method call receiver.

+ .page(params[:page])
@houndci-bot

houndci-bot Nov 17, 2017

Place the . on the previous line, together with the method call receiver.

+ end
end
def reorder
@@ -60,15 +66,15 @@ def destroy
ts("Request for %{email} was removed from the queue.", email: @invite_request.email)
end
respond_to do |format|
- format.html { redirect_to manage_invite_requests_path(page: params[:page]), notice: success_message }
+ format.html { redirect_to manage_invite_requests_path(page: params[:page], query: params[:query]), notice: success_message }
format.json { render json: { item_success_message: success_message }, status: :ok }
end
else
error_message = ts("Request could not be removed. Please try again.")
respond_to do |format|
format.html do
flash.keep
- redirect_to manage_invite_requests_path(page: params[:page]), flash: { error: error_message }
+ redirect_to manage_invite_requests_path(page: params[:page], query: params[:query]), flash: { error: error_message }
end
format.json { render json: { errors: error_message }, status: :unprocessable_entity }
end
@@ -83,7 +89,7 @@ def status
def invite_request_params
params.require(:invite_request).permit(
- :email
+ :email, :query
)
end
end
@@ -3,11 +3,27 @@
<h2 class="heading"><%= ts("Manage the Invitation Queue") %></h2>
<!--/descriptions-->
-<!--main content-->
- <%= form_tag reorder_invite_requests_url do %>
- <p><%= submit_tag ts("Reorder Queue") %></p>
- <% end %>
+<!--subnav-->
+ <ul class="navigation actions" role="navigation">
+ <li>
+ <%= form_tag reorder_invite_requests_url do %>
+ <p><%= submit_tag ts("Reorder Queue") %></p>
+ <% end %>
+ </li>
+ <li class="search" role="search">
+ <%= form_tag manage_invite_requests_path, method: :get,
+ id: "invite-request-search", class: "simple search" do %>
+ <fieldset>
+ <%= text_field_tag :query, params[:query],
+ title: ts("Find invitation requests from") %>
+ <%= submit_tag ts("Search Queue") %>
+ </fieldset>
+ <% end %>
+ </li>
+ </ul>
+<!--/subnav-->
+<!--main content-->
<table summary="<%= ts("Lists each request/email and its current place in the queue. You can also delete each request.") %>">
<caption><%= ts("Manage the Invitation Queue") %></caption>
<thead>
@@ -23,7 +39,7 @@
<td><%= request.position %></td>
<td><%= request.email %></td>
<td>
- <%= form_tag invite_request_path(request, page: params[:page]), method: "delete", class: "ajax-remove" do |f| %>
+ <%= form_tag invite_request_path(request, page: params[:page], query: params[:query]), method: "delete", class: "ajax-remove" do |f| %>
<%= submit_tag ts("Delete") %>
<% end %>
</td>
@@ -350,3 +350,24 @@ Feature: Admin Actions to Manage Invitations
When I fill in "invitation_invitee_email" with "[email protected]"
And I press "Update Invitation"
Then I should see "[email protected]" in the "invitation_invitee_email" input
+
+ Scenario: An admin can search the invitation queue, and search parameters are
+ kept even if deleting without JavaScript
+ Given I am logged in as an admin
+ And an invitation request for "[email protected]"
+ And an invitation request for "[email protected]"
+ And an invitation request for "[email protected]"
+ And an invitation request for "[email protected]"
+ And an invitation request for "[email protected]"
+ When I am on the manage invite queue page
+ And I fill in "query" with "stream"
+ And I press "Search Queue"
+ Then I should see "[email protected]"
+ And I should see "[email protected]"
+ And I should see "[email protected]"
+ But I should not see "[email protected]"
+ And I should not see "[email protected]"
+ When I press "Delete"
+ Then the "query" field should contain "stream"
+ And I should not see "[email protected]"
+ And I should not see "[email protected]"