forked from decidim/decidim
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pagination and search on conflicts page (decidim#13154)
* Included conflicts pagination and search * Added test * Lint * Completed test * Fixed view and lint * Improved test * Lint * Deleted partials
- Loading branch information
Showing
5 changed files
with
133 additions
and
11 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
decidim-admin/app/controllers/concerns/decidim/admin/verification_conflicts/filterable.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
require "active_support/concern" | ||
|
||
module Decidim | ||
module Admin | ||
module VerificationConflicts | ||
module Filterable | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
include Decidim::Admin::Filterable | ||
|
||
private | ||
|
||
def base_query | ||
collection | ||
end | ||
|
||
def search_field_predicate | ||
:current_user_name_or_current_user_nickname_or_current_user_email_cont | ||
end | ||
|
||
def filters | ||
[] | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# frozen_string_literal: true | ||
|
||
require "spec_helper" | ||
|
||
describe "Admin checks conflicts" do | ||
let(:organization) { create(:organization) } | ||
let(:resource_controller) { Decidim::Admin::ConflictsController } | ||
|
||
let!(:user) { create(:user, :admin, :confirmed, organization:) } | ||
let!(:first_conflictive_user) { create(:user, :admin, :confirmed, organization:) } | ||
let!(:second_conflictive_user) { create(:user, :admin, :confirmed, organization:) } | ||
|
||
let!(:first_user_conflicts) { create_list(:conflict, 15, current_user: first_conflictive_user) } | ||
let!(:second_user_conflicts) { create_list(:conflict, 15, current_user: second_conflictive_user) } | ||
|
||
before do | ||
switch_to_host(organization.host) | ||
login_as user, scope: :user | ||
visit decidim_admin.root_path | ||
click_on "Participants" | ||
click_on "Verification conflicts" | ||
end | ||
|
||
include_context "with filterable context" | ||
|
||
context "when listing conflicts" do | ||
before { visit current_path } | ||
|
||
it_behaves_like "paginating a collection" do | ||
let!(:collection) { create_list(:conflict, 50, current_user: first_conflictive_user) } | ||
end | ||
end | ||
|
||
context "when searching by current user name, nickname or email" do | ||
before { visit current_path } | ||
|
||
it "can be searched by name" do | ||
search_by_text(first_conflictive_user.name) | ||
|
||
expect(page).to have_content(first_conflictive_user.name) | ||
expect(page).to have_no_content(second_conflictive_user.name) | ||
end | ||
|
||
it "can be searched by nickname" do | ||
search_by_text(first_conflictive_user.nickname) | ||
|
||
expect(page).to have_content(first_conflictive_user.name) | ||
expect(page).to have_no_content(second_conflictive_user.name) | ||
end | ||
|
||
it "can be searched by email" do | ||
search_by_text(first_conflictive_user.email) | ||
|
||
expect(page).to have_content(first_conflictive_user.name) | ||
expect(page).to have_no_content(second_conflictive_user.name) | ||
end | ||
end | ||
end |