debian-mirror-gitlab/spec/controllers/projects/todos_controller_spec.rb

90 lines
2.3 KiB
Ruby
Raw Permalink Normal View History

2019-07-31 22:56:46 +05:30
# frozen_string_literal: true
2016-06-22 15:30:34 +05:30
require('spec_helper')
2020-06-23 00:09:42 +05:30
RSpec.describe Projects::TodosController do
2020-11-24 15:15:51 +05:30
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project) }
2021-04-29 21:17:54 +05:30
2016-06-22 15:30:34 +05:30
let(:issue) { create(:issue, project: project) }
let(:merge_request) { create(:merge_request, source_project: project) }
2022-06-21 17:19:12 +05:30
let(:design) { create(:design, :with_versions, project: project, issue: issue) }
2018-11-18 11:00:15 +05:30
let(:parent) { project }
2020-11-24 15:15:51 +05:30
shared_examples 'issuable todo actions' do
2018-11-18 11:00:15 +05:30
it_behaves_like 'todos actions'
context 'when not authorized for resource' do
before do
project.update!(visibility_level: Gitlab::VisibilityLevel::PUBLIC)
project.project_feature.update!(issues_access_level: ProjectFeature::PRIVATE)
project.project_feature.update!(merge_requests_access_level: ProjectFeature::PRIVATE)
sign_in(user)
end
it "doesn't create todo" do
expect { post_create }.not_to change { user.todos.count }
2020-03-13 15:44:24 +05:30
expect(response).to have_gitlab_http_status(:not_found)
2018-11-18 11:00:15 +05:30
end
end
end
2016-06-22 15:30:34 +05:30
context 'Issues' do
describe 'POST create' do
2018-11-18 11:00:15 +05:30
def post_create
2016-08-24 12:49:21 +05:30
post :create,
2019-02-15 15:39:39 +05:30
params: {
namespace_id: project.namespace,
project_id: project,
issuable_id: issue.id,
issuable_type: 'issue'
},
2016-08-24 12:49:21 +05:30
format: 'html'
end
2020-11-24 15:15:51 +05:30
it_behaves_like 'issuable todo actions'
2016-06-22 15:30:34 +05:30
end
end
context 'Merge Requests' do
describe 'POST create' do
2018-11-18 11:00:15 +05:30
def post_create
2016-08-24 12:49:21 +05:30
post :create,
2019-02-15 15:39:39 +05:30
params: {
namespace_id: project.namespace,
project_id: project,
issuable_id: merge_request.id,
issuable_type: 'merge_request'
},
2016-08-24 12:49:21 +05:30
format: 'html'
end
2020-11-24 15:15:51 +05:30
it_behaves_like 'issuable todo actions'
end
end
context 'Designs' do
include DesignManagementTestHelpers
before do
enable_design_management
end
describe 'POST create' do
def post_create
post :create,
params: {
namespace_id: project.namespace,
project_id: project,
issue_id: issue.id,
issuable_id: design.id,
issuable_type: 'design'
},
format: 'html'
end
it_behaves_like 'todos actions'
2016-06-22 15:30:34 +05:30
end
end
end