mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-28 11:14:24 +08:00
49 lines
1.4 KiB
Ruby
49 lines
1.4 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
describe UserMyModulesController, type: :controller do
|
|
login_user
|
|
|
|
include_context 'reference_project_structure'
|
|
let(:other_user) { create :user }
|
|
|
|
describe 'POST create' do
|
|
let(:action) { post :create, params: params, format: :json }
|
|
let(:params) do
|
|
{ my_module_id: my_module.id, user_my_module: { user_id: other_user.id } }
|
|
end
|
|
|
|
it 'calls create activity for assigning user to task' do
|
|
expect(Activities::CreateActivityService)
|
|
.to(receive(:call)
|
|
.with(hash_including(activity_type: :designate_user_to_my_module)))
|
|
action
|
|
end
|
|
|
|
it 'adds activity in DB' do
|
|
expect { action }
|
|
.to(change { Activity.count })
|
|
end
|
|
end
|
|
|
|
describe 'DELETE destroy' do
|
|
let(:user_task) { create :user_my_module, user: user, my_module: my_module }
|
|
let(:action) { delete :destroy, params: params, format: :json }
|
|
let(:params) do
|
|
{ my_module_id: my_module.id, id: user_task.id }
|
|
end
|
|
|
|
it 'calls create activity for unassigning user to task' do
|
|
expect(Activities::CreateActivityService)
|
|
.to(receive(:call)
|
|
.with(hash_including(activity_type: :undesignate_user_from_my_module)))
|
|
action
|
|
end
|
|
|
|
it 'adds activity in DB' do
|
|
expect { action }
|
|
.to(change { Activity.count })
|
|
end
|
|
end
|
|
end
|