mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-11-11 18:21:04 +08:00
c248e87adb
* Add permission tests for results controller [SCI-6071] * Update results controllers with new permissions [SCI-6071] * Small fixes to results controllers [SCI-6071] * Update result permission helpers [SCI-6071]
56 lines
1.9 KiB
Ruby
56 lines
1.9 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'rails_helper'
|
|
|
|
describe ResultTextsController, type: :controller do
|
|
include PermissionExtends
|
|
|
|
it_behaves_like "a controller with authentication", {
|
|
new: { my_module_id: 1 },
|
|
create: { my_module_id: 1 },
|
|
edit: { id: 1 },
|
|
update: { id: 1 },
|
|
download: { id: 1 }
|
|
}
|
|
|
|
login_user
|
|
|
|
describe 'permissions checking' do
|
|
include_context 'reference_project_structure', {
|
|
team_role: :normal_user,
|
|
result_text: true
|
|
}
|
|
|
|
it_behaves_like "a controller action with permissions checking", :get, :new do
|
|
let(:testable) { my_module }
|
|
let(:permissions) { [MyModulePermissions::RESULTS_MANAGE] }
|
|
let(:action_params) { { my_module_id: my_module.id, format: :json } }
|
|
end
|
|
|
|
it_behaves_like "a controller action with permissions checking", :post, :create do
|
|
let(:testable) { my_module }
|
|
let(:permissions) { [MyModulePermissions::RESULTS_MANAGE] }
|
|
let(:action_params) {
|
|
{ my_module_id: my_module.id, result: { name: 'test', result_text_attributes: { text: 'test' } } }
|
|
}
|
|
end
|
|
|
|
it_behaves_like "a controller action with permissions checking", :get, :edit do
|
|
let(:testable) { my_module }
|
|
let(:permissions) { [MyModulePermissions::RESULTS_MANAGE] }
|
|
let(:action_params) { { id:result_text.id, format: :json } }
|
|
end
|
|
|
|
it_behaves_like "a controller action with permissions checking", :get, :download do
|
|
let(:testable) { my_module }
|
|
let(:permissions) { [MyModulePermissions::READ] }
|
|
let(:action_params) { { id:result_text.id } }
|
|
end
|
|
|
|
it_behaves_like "a controller action with permissions checking", :patch, :update do
|
|
let(:testable) { my_module }
|
|
let(:permissions) { [MyModulePermissions::RESULTS_MANAGE] }
|
|
let(:action_params) { { id:result_text.id, result: { result_text_attributes: { text: 'test1' } } } }
|
|
end
|
|
end
|
|
end
|