2019-03-14 02:05:29 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe ResultsController, type: :controller do
|
|
|
|
login_user
|
|
|
|
|
2019-03-21 04:34:47 +08:00
|
|
|
let(:user) { subject.current_user }
|
2019-03-14 02:05:29 +08:00
|
|
|
let!(:team) { create :team, :with_members }
|
2021-05-29 23:25:20 +08:00
|
|
|
let!(:user_project) { create :user_project, user: user }
|
2019-03-14 02:05:29 +08:00
|
|
|
let(:project) do
|
|
|
|
create :project, team: team, user_projects: [user_project]
|
|
|
|
end
|
2021-05-29 23:25:20 +08:00
|
|
|
let(:owner_user_role) { create :owner_role }
|
|
|
|
let!(:user_assignment) do
|
|
|
|
create :user_assignment,
|
|
|
|
assignable: project,
|
|
|
|
user: user,
|
|
|
|
user_role: owner_user_role,
|
|
|
|
assigned_by: user
|
|
|
|
end
|
2019-03-14 02:05:29 +08:00
|
|
|
let(:experiment) { create :experiment, project: project }
|
|
|
|
let(:task) { create :my_module, name: 'test task', experiment: experiment }
|
|
|
|
let(:result) do
|
2021-01-20 16:01:26 +08:00
|
|
|
create :result, :archived, name: 'test result', my_module: task, user: user
|
2019-03-14 02:05:29 +08:00
|
|
|
end
|
|
|
|
let!(:result_text) do
|
|
|
|
create :result_text, text: 'test text result', result: result
|
|
|
|
end
|
|
|
|
|
2019-03-27 18:24:44 +08:00
|
|
|
describe 'DELETE destroy' do
|
|
|
|
let(:action) { delete :destroy, params: params }
|
2019-03-14 02:05:29 +08:00
|
|
|
let(:params) do
|
|
|
|
{ id: result.id }
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'calls create activity service' do
|
|
|
|
expect(Activities::CreateActivityService).to receive(:call)
|
|
|
|
.with(hash_including(activity_type: :destroy_result))
|
2019-03-27 18:24:44 +08:00
|
|
|
action
|
|
|
|
end
|
2019-03-14 02:05:29 +08:00
|
|
|
|
2019-03-27 18:24:44 +08:00
|
|
|
it 'adds activity in DB' do
|
|
|
|
expect { action }
|
|
|
|
.to(change { Activity.count })
|
2019-03-14 02:05:29 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|