Skip to content

Commit

Permalink
Merge pull request #308 from coopdevs/fix/sort-users-by-member-uid
Browse files Browse the repository at this point in the history
Fix sort users by their member_uid
  • Loading branch information
sauloperez authored Jan 30, 2018
2 parents dcdcac9 + 7cc5b58 commit 3708648
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 3708648

Please sign in to comment.