scinote-web/spec/controllers/user_my_modules_controller_spec.rb

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