Use prefabricated users in bulk_invite_spec.rb

This commit is contained in:
Daniel Waterworth 2019-05-06 10:09:47 +01:00 committed by Robin Ward
parent 6e11ae06d8
commit 54cfc48975
1 changed files with 2 additions and 6 deletions

View File

@ -21,22 +21,18 @@ describe Jobs::BulkInvite do
end end
it 'raises an error when the filename is missing' do it 'raises an error when the filename is missing' do
user = Fabricate(:user)
expect { Jobs::BulkInvite.new.execute(current_user_id: user.id) } expect { Jobs::BulkInvite.new.execute(current_user_id: user.id) }
.to raise_error(Discourse::InvalidParameters, /filename/) .to raise_error(Discourse::InvalidParameters, /filename/)
end end
it 'raises an error when current_user_id is not valid' do it 'raises an error when current_user_id is not valid' do
user = Fabricate(:user)
expect { Jobs::BulkInvite.new.execute(filename: filename) } expect { Jobs::BulkInvite.new.execute(filename: filename) }
.to raise_error(Discourse::InvalidParameters, /current_user_id/) .to raise_error(Discourse::InvalidParameters, /current_user_id/)
end end
it 'creates the right invites' do it 'creates the right invites' do
described_class.new.execute( described_class.new.execute(
current_user_id: Fabricate(:admin).id, current_user_id: admin.id,
filename: basename, filename: basename,
) )
@ -56,7 +52,7 @@ describe Jobs::BulkInvite do
group2.update!(automatic: true) group2.update!(automatic: true)
described_class.new.execute( described_class.new.execute(
current_user_id: Fabricate(:admin).id, current_user_id: admin.id,
filename: basename, filename: basename,
) )