Commit ad551e5e 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 40c86cfe
...@@ -9,9 +9,12 @@ ...@@ -9,9 +9,12 @@
.search-holder .search-holder
.search-field-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 = 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") = icon("search", class: "search-icon")
= button_tag 'Search users' if Rails.env.test?
.dropdown.user-sort-dropdown .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' }) = dropdown_toggle(toggle_text, { toggle: 'dropdown' })
%ul.dropdown-menu.dropdown-menu-right %ul.dropdown-menu.dropdown-menu-right
%li.dropdown-header %li.dropdown-header
......
require 'spec_helper' require 'spec_helper'
describe "Admin::Users" do describe "Admin::Users" do
include Spec::Support::Helpers::Features::RowsHelpers include Spec::Support::Helpers::Features::ListRowsHelpers
let!(:user) do let!(:user) do
create(:omniauth_user, provider: 'twitter', extern_uid: '123456') create(:omniauth_user, provider: 'twitter', extern_uid: '123456')
...@@ -39,7 +39,7 @@ describe "Admin::Users" do ...@@ -39,7 +39,7 @@ describe "Admin::Users" do
create(:user, name: 'Dmitriy') create(:user, name: 'Dmitriy')
end end
it 'search users by name' do it 'searches users by name' do
visit admin_users_path(search_query: 'Foo') visit admin_users_path(search_query: 'Foo')
expect(page).to have_content('Foo Bar') expect(page).to have_content('Foo Bar')
...@@ -65,6 +65,16 @@ describe "Admin::Users" do ...@@ -65,6 +65,16 @@ describe "Admin::Users" do
expect(first_row.text).to include('Foo Bar') expect(first_row.text).to include('Foo Bar')
expect(second_row.text).to include('Foo Baz') expect(second_row.text).to include('Foo Baz')
end 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 end
describe 'Two-factor Authentication filters' do describe 'Two-factor Authentication filters' do
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe 'Groups > Members > List members' do describe 'Groups > Members > List members' do
include Select2Helper include Select2Helper
include Spec::Support::Helpers::Features::RowsHelpers include Spec::Support::Helpers::Features::ListRowsHelpers
let(:user1) { create(:user, name: 'John Doe') } let(:user1) { create(:user, name: 'John Doe') }
let(:user2) { create(:user, name: 'Mary Jane') } let(:user2) { create(:user, name: 'Mary Jane') }
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe 'Groups > Members > Manage members' do describe 'Groups > Members > Manage members' do
include Select2Helper include Select2Helper
include Spec::Support::Helpers::Features::RowsHelpers include Spec::Support::Helpers::Features::ListRowsHelpers
let(:user1) { create(:user, name: 'John Doe') } let(:user1) { create(:user, name: 'John Doe') }
let(:user2) { create(:user, name: 'Mary Jane') } let(:user2) { create(:user, name: 'Mary Jane') }
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe 'Project members list' do describe 'Project members list' do
include Select2Helper include Select2Helper
include Spec::Support::Helpers::Features::RowsHelpers include Spec::Support::Helpers::Features::ListRowsHelpers
let(:user1) { create(:user, name: 'John Doe') } let(:user1) { create(:user, name: 'John Doe') }
let(:user2) { create(:user, name: 'Mary Jane') } let(:user2) { create(:user, name: 'Mary Jane') }
......
# frozen_string_literal: true
# These helpers allow you to access rows in the list # These helpers allow you to access rows in the list
# #
# Usage: # Usage:
# describe "..." do # describe "..." do
# include Spec::Support::Helpers::Features::RowsHelpers # include Spec::Support::Helpers::Features::ListRowsHelpers
# ... # ...
# #
# expect(first_row.text).to include("John Doe") # expect(first_row.text).to include("John Doe")
...@@ -12,7 +13,7 @@ module Spec ...@@ -12,7 +13,7 @@ module Spec
module Support module Support
module Helpers module Helpers
module Features module Features
module RowsHelpers module ListRowsHelpers
def first_row def first_row
page.all('ul.content-list > li')[0] page.all('ul.content-list > li')[0]
end 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