Skip to content
代码片段 群组 项目
未验证 提交 3d6ee09c 编辑于 作者: Mario Celi's avatar Mario Celi
浏览文件

Allow group level issues to set and read weight

issue_weights feature availability was checked only against
an issues's project. We should check against a group
when the issue is directly associated with one
上级 4d68f4ac
No related branches found
No related tags found
无相关合并请求
......@@ -18,7 +18,7 @@ def supports_weight?
end
def weight_available?
supports_weight? && project&.feature_available?(:issue_weights)
supports_weight?
end
def sla_available?
......
......@@ -198,6 +198,11 @@ def supports_weight?
!work_item_type&.incident?
end
override :weight_available?
def weight_available?
super && resource_parent&.licensed_feature_available?(:issue_weights)
end
override :supports_iterations?
def supports_iterations?
!work_item_type&.incident?
......
......@@ -499,6 +499,62 @@
end
end
describe '#weight_available?' do
subject { issue.weight_available? }
context 'when issue belongs to a project' do
let(:issue) { build_stubbed(:issue) }
context 'when weights feature is available' do
before do
stub_licensed_features(issue_weights: true)
end
it { is_expected.to be_truthy }
context 'when issue is of type incident' do
let(:issue) { build_stubbed(:issue, :incident) }
it { is_expected.to be_falsey }
end
end
context 'when weights feature is not available' do
before do
stub_licensed_features(issue_weights: false)
end
it { is_expected.to be_falsey }
end
end
context 'when issue belongs to a group' do
let(:issue) { build_stubbed(:issue, :group_level) }
context 'when weights feature is available' do
before do
stub_licensed_features(issue_weights: true)
end
it { is_expected.to be_truthy }
context 'when issue is of type incident' do
let(:issue) { build_stubbed(:issue, :group_level, :incident) }
it { is_expected.to be_falsey }
end
end
context 'when weights feature is not available' do
before do
stub_licensed_features(issue_weights: false)
end
it { is_expected.to be_falsey }
end
end
end
describe '.simple_sorts' do
it 'includes weight with other base keys' do
expect(described_class.simple_sorts.keys).to match_array(
......
......@@ -7,10 +7,11 @@
let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, group: group) }
let_it_be(:reporter) { create(:user).tap { |user| project.add_reporter(user) } }
let_it_be(:guest) { create(:user).tap { |user| project.add_guest(user) } }
let_it_be(:work_item, refind: true) { create(:work_item, project: project) }
let_it_be(:reporter) { create(:user).tap { |user| group.add_reporter(user) } }
let_it_be(:guest) { create(:user).tap { |user| group.add_guest(user) } }
let_it_be(:project_work_item, refind: true) { create(:work_item, project: project) }
let(:work_item) { project_work_item }
let(:mutation) { graphql_mutation(:workItemUpdate, input.merge('id' => work_item.to_global_id.to_s), fields) }
let(:mutation_response) { graphql_mutation_response(:work_item_update) }
......@@ -223,6 +224,12 @@
it_behaves_like 'work item is not updated'
end
end
context 'when the work item is directly associated with a group' do
let(:work_item) { create(:work_item, :group_level, namespace: group) }
it_behaves_like 'update work item weight widget'
end
end
it_behaves_like 'user without permission to admin work item cannot update the attribute'
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册