2019-03-12 14:33:24 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe Users::InvitationsController, type: :controller do
|
|
|
|
login_user
|
|
|
|
|
2022-06-07 00:21:57 +08:00
|
|
|
include_context 'reference_project_structure'
|
2019-03-12 14:33:24 +08:00
|
|
|
|
|
|
|
describe 'POST invite_users' do
|
|
|
|
let(:invited_user) { create :user }
|
|
|
|
let(:params) do
|
|
|
|
{
|
2021-08-03 20:16:22 +08:00
|
|
|
team_ids: [team.id],
|
2019-03-12 14:33:24 +08:00
|
|
|
emails: [invited_user.email],
|
2022-06-07 00:21:57 +08:00
|
|
|
role_id: viewer_role.id
|
2019-03-12 14:33:24 +08:00
|
|
|
}
|
|
|
|
end
|
|
|
|
let(:action) { post :invite_users, params: params, format: :json }
|
|
|
|
|
|
|
|
context 'when inviting existing user not in the team' do
|
|
|
|
it 'calls create activity for inviting user' do
|
|
|
|
expect(Activities::CreateActivityService)
|
|
|
|
.to(receive(:call)
|
|
|
|
.with(hash_including(activity_type: :invite_user_to_team)))
|
|
|
|
|
|
|
|
action
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'adds activity in DB' do
|
|
|
|
expect { action }
|
|
|
|
.to(change { Activity.count })
|
|
|
|
end
|
|
|
|
|
2022-06-07 00:21:57 +08:00
|
|
|
it 'adds user team assignment record in DB' do
|
2019-03-12 14:33:24 +08:00
|
|
|
expect { action }
|
2022-06-07 00:21:57 +08:00
|
|
|
.to(change { UserAssignment.count })
|
2019-03-12 14:33:24 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|