Commit eb2ac7de authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Keep sorting selection when search users on admin panel

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent ace07a8e
......@@ -9,9 +9,12 @@
.search-holder
.search-field-holder
= search_field_tag :search_query, params[:search_query], placeholder: 'Search by name, email or username', class: 'form-control search-text-input js-search-input', spellcheck: false
- if @sort.present?
= hidden_field_tag :sort, @sort
= icon("search", class: "search-icon")
= button_tag 'Search users' if Rails.env.test?
.dropdown.user-sort-dropdown
- toggle_text = if @sort.present? then sort_options_hash[@sort] else sort_title_name end
- toggle_text = if @sort.present? then users_sort_options_hash[@sort] else sort_title_name end
= dropdown_toggle(toggle_text, { toggle: 'dropdown' })
%ul.dropdown-menu.dropdown-menu-right
%li.dropdown-header
......
require 'spec_helper'
describe "Admin::Users" do
include Spec::Support::Helpers::Features::RowsHelpers
include Spec::Support::Helpers::Features::ListRowsHelpers
let!(:user) do
create(:omniauth_user, provider: 'twitter', extern_uid: '123456')
......@@ -39,7 +39,7 @@ describe "Admin::Users" do
create(:user, name: 'Dmitriy')
end
it 'search users by name' do
it 'searches users by name' do
visit admin_users_path(search_query: 'Foo')
expect(page).to have_content('Foo Bar')
......@@ -65,6 +65,16 @@ describe "Admin::Users" do
expect(first_row.text).to include('Foo Bar')
expect(second_row.text).to include('Foo Baz')
end
it 'searches with respect of sorting' do
visit admin_users_path(sort: 'Name')
fill_in :search_query, with: 'Foo'
click_button('Search users')
expect(first_row.text).to include('Foo Bar')
expect(second_row.text).to include('Foo Baz')
end
end
describe 'Two-factor Authentication filters' do
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe 'Groups > Members > List members' do
include Select2Helper
include Spec::Support::Helpers::Features::RowsHelpers
include Spec::Support::Helpers::Features::ListRowsHelpers
let(:user1) { create(:user, name: 'John Doe') }
let(:user2) { create(:user, name: 'Mary Jane') }
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe 'Groups > Members > Manage members' do
include Select2Helper
include Spec::Support::Helpers::Features::RowsHelpers
include Spec::Support::Helpers::Features::ListRowsHelpers
let(:user1) { create(:user, name: 'John Doe') }
let(:user2) { create(:user, name: 'Mary Jane') }
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe 'Project members list' do
include Select2Helper
include Spec::Support::Helpers::Features::RowsHelpers
include Spec::Support::Helpers::Features::ListRowsHelpers
let(:user1) { create(:user, name: 'John Doe') }
let(:user2) { create(:user, name: 'Mary Jane') }
......
# frozen_string_literal: true
# These helpers allow you to access rows in the list
#
# Usage:
# describe "..." do
# include Spec::Support::Helpers::Features::RowsHelpers
# include Spec::Support::Helpers::Features::ListRowsHelpers
# ...
#
# expect(first_row.text).to include("John Doe")
......@@ -12,7 +13,7 @@ module Spec
module Support
module Helpers
module Features
module RowsHelpers
module ListRowsHelpers
def first_row
page.all('ul.content-list > li')[0]
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment