Add helper function for speaker selection

The line '@users = User.all.order(:name)' is replicated a lot of times
in EventsController and ProposalsController.
So, this commit removes it and adds a helper function
'speaker_selector_input' that generates the field where the @users
variable was used.
Also, it makes the query more specific.

Fix #1455

Other changes:
* Include the username in the drop down menu
* Add .active scope to User and corresponding tests
* Add :disabled trait to User factory
This commit is contained in:
AEtherC0r3 2017-04-22 09:40:08 +03:00 committed by Stella Rouzi
parent 36b8088726
commit fa56ff7f6d
7 changed files with 25 additions and 9 deletions

View file

@ -10,6 +10,7 @@ describe User do
let(:volunteers_coordinator_role) { Role.find_by(name: 'volunteers_coordinator', resource: conference) }
let(:organizer) { create(:user, role_ids: [organizer_role.id]) }
let(:user) { create(:user) }
let(:user_disabled) { create(:user, :disabled) }
let(:event1) { create(:event, program: conference.program) }
let(:another_conference) { create(:conference) }
@ -75,6 +76,16 @@ describe User do
end
end
describe '.active' do
it 'includes users without is_disabled flag' do
expect(User.active).to include(user)
end
it 'excludes users with is_disabled flag' do
expect(User.active).not_to include(user_disabled)
end
end
describe '.comment_notifiable' do
let(:cfp_user) { create(:user, role_ids: [cfp_role.id]) }