FEATURE: Add topic invitation support to Bulk Invite

This commit is contained in:
Arpit Jalan
2014-06-26 20:46:53 +05:30
parent 00910679ad
commit 52f9984804
3 changed files with 77 additions and 42 deletions

View File

@@ -24,35 +24,61 @@ describe Jobs::BulkInvite do
it 'reads csv file' do
bulk_invite.current_user = user
bulk_invite.read_csv_file(csv_file)
Invite.where(email: 'robin@outlook.com').exists?.should be_true
Invite.where(email: "robin@outlook.com").exists?.should be_true
end
end
context '.send_invite_with_groups' do
context '.send_invite' do
let(:bulk_invite) { Jobs::BulkInvite.new }
let(:user) { Fabricate(:user) }
let(:group) { Fabricate(:group) }
let(:topic) { Fabricate(:topic) }
let(:email) { "evil@trout.com" }
let(:csv_info) { [] }
it 'creates an invite' do
csv_info[0] = email
it 'creates an invite to the group' do
bulk_invite.current_user = user
bulk_invite.send_invite_with_groups(email, group.name, 1)
bulk_invite.send_invite(csv_info, 1)
Invite.where(email: email).exists?.should be_true
end
it 'creates an invite with group' do
csv_info[0] = email
csv_info[1] = group.name
bulk_invite.current_user = user
bulk_invite.send_invite(csv_info, 1)
invite = Invite.where(email: email).first
invite.should be_present
InvitedGroup.where(invite_id: invite.id, group_id: group.id).exists?.should be_true
end
end
context '.send_invite_without_group' do
let(:bulk_invite) { Jobs::BulkInvite.new }
let(:user) { Fabricate(:user) }
let(:email) { "evil@trout.com" }
it 'creates an invite with topic' do
csv_info[0] = email
csv_info[2] = topic
it 'creates an invite' do
bulk_invite.current_user = user
bulk_invite.send_invite_without_group(email)
Invite.where(email: email).exists?.should be_true
bulk_invite.send_invite(csv_info, 1)
invite = Invite.where(email: email).first
invite.should be_present
TopicInvite.where(invite_id: invite.id, topic_id: topic.id).exists?.should be_true
end
it 'creates an invite with group and topic' do
csv_info[0] = email
csv_info[1] = group.name
csv_info[2] = topic
bulk_invite.current_user = user
bulk_invite.send_invite(csv_info, 1)
invite = Invite.where(email: email).first
invite.should be_present
InvitedGroup.where(invite_id: invite.id, group_id: group.id).exists?.should be_true
TopicInvite.where(invite_id: invite.id, topic_id: topic.id).exists?.should be_true
end
end
end