Skip to content

Commit

Permalink
OTWO-7207 Remove enlistments only on project deletion (#1771)
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-sig authored Mar 7, 2024
1 parent 32ca50f commit 30ba479
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/controllers/autocompletes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class AutocompletesController < ApplicationController
before_action :set_projects_to_ignore, only: :projects_for_stack

def account
accounts = params[:term].blank? ? [] : Account.simple_search(params[:term])
accounts = params[:term].blank? ? [] : Account.in_good_standing.simple_search(params[:term])
render json: accounts.map { |a| { login: a.login, name: a.name, value: a.login, id: a.id } }
end

Expand Down
2 changes: 1 addition & 1 deletion app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def badges_summary
end

def after_undo(current_user)
remove_enlistments(current_user)
remove_enlistments(current_user) if deleted?
end

class << self
Expand Down
8 changes: 6 additions & 2 deletions test/controllers/autocompletes_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
class AutocompletesControllerTest < ActionController::TestCase
describe 'account' do
it 'should return account hash' do
account = create(:account)
get :account, params: { term: account.login }, xhr: true
account = create(:account, login: 'good-user')
create(:account, level: Account::Access::SPAM, login: 'bad-user-1')
create(:account, level: Account::Access::DISABLED, login: 'bad-user-2')

get :account, params: { term: '-user' }, xhr: true
assert_response :ok

result = JSON.parse(response.body)
_(result.count).must_equal 1
_(result.first['login']).must_equal account.login
_(result.first['value']).must_equal account.login
_(result.first['name']).must_equal account.name
Expand Down

0 comments on commit 30ba479

Please sign in to comment.