Commit a65ea302 authored by Jarka Košanová's avatar Jarka Košanová

Allow users on premium to delete subepics

- they can see them and should be able to remove them
parent 90fa46e2
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
class Groups::EpicLinksController < Groups::ApplicationController class Groups::EpicLinksController < Groups::ApplicationController
include EpicRelations include EpicRelations
before_action :check_epics_available!, only: :index before_action :check_epics_available!, only: [:index, :destroy]
before_action :check_subepics_available!, only: [:create, :destroy, :update] before_action :check_subepics_available!, only: [:create, :update]
def update def update
result = EpicLinks::UpdateService.new(child_epic, current_user, params[:epic]).execute result = EpicLinks::UpdateService.new(child_epic, current_user, params[:epic]).execute
......
...@@ -26,8 +26,8 @@ module EpicLinks ...@@ -26,8 +26,8 @@ module EpicLinks
def permission_to_remove_relation? def permission_to_remove_relation?
child_epic.present? && child_epic.present? &&
parent_epic.present? && parent_epic.present? &&
can?(current_user, :admin_epic_link, parent_epic) && can?(current_user, :admin_epic, parent_epic) &&
can?(current_user, :admin_epic_link, child_epic) can?(current_user, :admin_epic, child_epic)
end end
def not_found_message def not_found_message
......
...@@ -176,6 +176,8 @@ describe Groups::EpicLinksController do ...@@ -176,6 +176,8 @@ describe Groups::EpicLinksController do
epic1.update(parent: parent_epic) epic1.update(parent: parent_epic)
end end
let(:features_when_forbidden) { { epics: false } }
subject { delete :destroy, params: { group_id: group, epic_id: parent_epic.to_param, id: epic1.id } } subject { delete :destroy, params: { group_id: group, epic_id: parent_epic.to_param, id: epic1.id } }
it_behaves_like 'unlicensed subepics action' it_behaves_like 'unlicensed subepics action'
......
...@@ -45,9 +45,9 @@ describe EpicLinks::DestroyService do ...@@ -45,9 +45,9 @@ describe EpicLinks::DestroyService do
described_class.new(child_epic, user).execute described_class.new(child_epic, user).execute
end end
context 'when subepics feature is disabled' do context 'when epics feature is disabled' do
before do before do
stub_licensed_features(epics: true, subepics: false) stub_licensed_features(epics: false)
end end
subject { remove_epic_relation(child_epic) } subject { remove_epic_relation(child_epic) }
...@@ -55,9 +55,9 @@ describe EpicLinks::DestroyService do ...@@ -55,9 +55,9 @@ describe EpicLinks::DestroyService do
include_examples 'returns not found error' include_examples 'returns not found error'
end end
context 'when subepics feature is enabled' do context 'when epics feature is enabled' do
before do before do
stub_licensed_features(epics: true, subepics: true) stub_licensed_features(epics: true)
end end
context 'when the user has no permissions to remove epic relation' do context 'when the user has no permissions to remove epic relation' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment