Commit 0ad12281 authored by Alex Kalderimis's avatar Alex Kalderimis

Remove unnecessary code

parent b41a151e
......@@ -7,7 +7,6 @@ module Issues
return false if group && !can?(current_user, :read_group, group)
attrs = issue_params(group)
return move_to_end(issue) if params[:placement] == :end
return false if attrs.empty?
update(issue, attrs)
......@@ -15,22 +14,6 @@ module Issues
private
def move_to_end(issue)
issue.move_to_end
return false unless issue.save
rebalance_if_needed(issue)
true
rescue RelativePositioning::NoSpaceLeft
gates = [issue.project, issue.project.group].compact
if gates.any? { |gate| Feature.enabled?(:rebalance_issues, gate) }
IssueRebalancingWorker.perform_async(nil, issue.project_id)
end
issue.update(relative_position: RelativePositioning::MAX_POSITION)
end
def group
return unless params[:group_full_path]
......
......@@ -19,68 +19,6 @@ RSpec.describe Issues::ReorderService do
expect(service(params).execute(issue1)).to be_falsey
end
it 'moves the issue to the end if placement == :end' do
params = { placement: :end }
max_position = project.issues.maximum(:relative_position)
expect do
expect(service(params).execute(issue1)).to be_truthy
end.to change(issue1, :relative_position).to(be > max_position)
end
it 'rebalances if needed' do
params = { placement: :end }
issue3.update!(relative_position: RelativePositioning::MAX_POSITION)
expect(IssueRebalancingWorker).to receive(:perform_async).with(nil, project.id)
expect(service(params).execute(issue1)).to be_truthy
expect(issue1.relative_position).to eq(project.issues.maximum(:relative_position))
end
it 'schedules rebalancing if there is no space left' do
params = { placement: :end }
allow(issue1).to receive(:move_to_end) { raise RelativePositioning::NoSpaceLeft }
expect(IssueRebalancingWorker).to receive(:perform_async).with(nil, project.id)
expect { expect(service(params).execute(issue1)).to be_truthy }
.to change(issue1, :relative_position).to(RelativePositioning::MAX_POSITION)
end
it 'does not schedule rebalancing if there is no space left but the feature flag is off' do
params = { placement: :end }
allow(issue1).to receive(:move_to_end) { raise RelativePositioning::NoSpaceLeft }
stub_feature_flags(rebalance_issues: false)
expect(IssueRebalancingWorker).not_to receive(:perform_async)
expect { service(params).execute(issue1) }
.to change(issue1, :relative_position).to(RelativePositioning::MAX_POSITION)
end
it 'does not rebalance if the rebalance_issues feature flag is disabled' do
params = { placement: :end }
issue3.update!(relative_position: RelativePositioning::MAX_POSITION)
stub_feature_flags(rebalance_issues: false)
expect(IssueRebalancingWorker).not_to receive(:perform_async)
expect(service(params).execute(issue1)).to be_truthy
expect(issue1.relative_position).to eq(project.issues.maximum(:relative_position))
end
it 'rebalances if the rebalance_issues feature flag is enabled for this current project' do
params = { placement: :end }
issue3.update!(relative_position: RelativePositioning::MAX_POSITION)
stub_feature_flags(rebalance_issues: project)
expect(IssueRebalancingWorker).to receive(:perform_async).with(nil, project.id)
expect(service(params).execute(issue1)).to be_truthy
expect(issue1.relative_position).to eq(project.issues.maximum(:relative_position))
end
it 'sorts issues' do
params = { move_after_id: issue2.id, move_before_id: issue3.id }
......
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