Skip to content

Commit

Permalink
Fix sort users by their member_uid
Browse files Browse the repository at this point in the history
This was done with angular in the client side so far. Now fetching the
users list was moved to the backend and so has to be the sorting.
  • Loading branch information
sauloperez committed Jan 30, 2018
1 parent a9f6661 commit 7cc5b58
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class UsersController < ApplicationController

def index
@search = current_organization.users.ransack(params[:q])
@search.sorts = 'members_member_uid asc' if @search.sorts.empty?

@users = @search
.result(distinct: false)
Expand Down
17 changes: 16 additions & 1 deletion spec/controllers/users_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,26 @@
before { set_browser_locale("ca") }

describe "GET #index" do
before { login(user) }

it 'sorts the users by their member_uid' do
member.update_attribute(:member_uid, 100)

get :index

expect(assigns(:users)).to eq([
another_user,
admin_user,
wrong_user,
empty_email_user,
user,
])
end

context 'when a user has many memberships' do
let!(:member_in_another_organization) { Fabricate(:member, user: user) }

before do
login(user)
member.account.update_attribute(
:balance,
Time.parse('13:33').seconds_since_midnight
Expand Down

0 comments on commit 7cc5b58

Please sign in to comment.