Skip to content

Commit

Permalink
fix tests suite (#709)
Browse files Browse the repository at this point in the history
  • Loading branch information
nflorentin authored Nov 20, 2023
1 parent 787b7dd commit 2b383af
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class User < ApplicationRecord
accepts_nested_attributes_for :members, allow_destroy: true

default_scope { order("users.id ASC") }
scope :actives, -> { references(:members).where(members: { active: true }) }
scope :actives, -> { joins(:members).where(members: { active: true }) }
scope :online_active, -> { where("sign_in_count > 0") }
scope :notifications, -> { where(notifications: true) }

Expand Down
10 changes: 8 additions & 2 deletions spec/controllers/users_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,14 @@
it "populates and array of users" do
get "index"

expected_users = [user, another_user, admin_user, wrong_user, empty_email_user]

expected_users.each_with_index do |user, i|
user.update!(last_sign_in_at: Time.current - i.days)
end

expect(assigns(:members).map(&:user))
.to eq([user, another_user, admin_user, wrong_user, empty_email_user])
.to eq(expected_users)
end
end

Expand Down Expand Up @@ -326,7 +332,7 @@

it 'creates the user' do
expect do
post :create, params: { user: Fabricate.to_params(:user, password: '1234test'), from_signup: 'true' }
post :create, params: { user: Fabricate.to_params(:user, password: '1234test'), from_signup: 'true' }
end.to change(User, :count).by(1)
expect(subject).to redirect_to(terms_path)
end
Expand Down
3 changes: 1 addition & 2 deletions spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@
end

describe ".actives" do
skip "should list users with active members" do
# The join at User.actives is failing
it "should list users with active members" do
user_w_inactive = Fabricate(:user)
user_w_active = Fabricate(:user)
inactive_member = Fabricate(:member, user: user_w_inactive, active: false)
Expand Down

0 comments on commit 2b383af

Please sign in to comment.