mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-11 18:21:04 +08:00
48 lines
1.3 KiB
Ruby
48 lines
1.3 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
describe UserMyModulesController, type: :controller do
|
|
login_user
|
|
|
|
include_context 'reference_project_structure'
|
|
|
|
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: 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
|