2021-09-15 20:39:47 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe ProjectsController, type: :controller do
|
|
|
|
include PermissionExtends
|
|
|
|
|
|
|
|
it_behaves_like "a controller with authentication", {
|
|
|
|
edit: { id: 1 },
|
2024-03-11 20:08:42 +08:00
|
|
|
archive_group: { id: 1 },
|
|
|
|
restore_group: { id: 1 },
|
|
|
|
create: { id: 1 },
|
2021-09-15 20:39:47 +08:00
|
|
|
update: { id: 1 },
|
2023-10-12 22:16:43 +08:00
|
|
|
permissions: { id: 1 },
|
|
|
|
}, [:current_folder, :set_breadcrumbs_items, :create_tag]
|
2021-09-15 20:39:47 +08:00
|
|
|
|
|
|
|
login_user
|
|
|
|
|
|
|
|
describe 'permissions checking' do
|
|
|
|
include_context 'reference_project_structure', {
|
|
|
|
team_role: :normal_user,
|
|
|
|
projects: 5,
|
|
|
|
skip_my_module: true
|
|
|
|
}
|
|
|
|
|
|
|
|
it_behaves_like "a controller action with permissions checking", :put, :update do
|
|
|
|
let(:testable) { project }
|
|
|
|
let(:permissions) { [ProjectPermissions::MANAGE] }
|
|
|
|
let(:action_params) { { id: project.id, project: { name: 'Test' } } }
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like "a controller action with permissions checking", :post, :archive_group do
|
|
|
|
let(:testable) { project }
|
|
|
|
let(:permissions) { [ProjectPermissions::MANAGE] }
|
|
|
|
let(:action_params) { { projects_ids: [project.id] } }
|
|
|
|
let(:custom_response_status) { :unprocessable_entity }
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like "a controller action with permissions checking", :post, :restore_group do
|
|
|
|
let(:testable) { project }
|
|
|
|
let(:permissions) { [ProjectPermissions::MANAGE] }
|
|
|
|
let(:action_params) { { projects_ids: [project.id] } }
|
|
|
|
let(:custom_response_status) { :unprocessable_entity }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|