Commit 47c12680 authored by Jarka Kadlecová's avatar Jarka Kadlecová

Fix specs & static-analysis failures

parent 2f950788
......@@ -22,7 +22,7 @@ class RelatedIssuesService {
return Vue.http.put(endpoint, {
epic: {
move_before_id,
move_after_id
move_after_id,
},
});
}
......
......@@ -10,16 +10,12 @@ module RelativePositioning
after_save :save_positionable_neighbours
end
def project_ids
[project.id]
end
def min_relative_position
self.class.in_parent(parent_id).minimum(:relative_position)
self.class.in_parents(parent_ids).minimum(:relative_position)
end
def max_relative_position
self.class.in_parent(parent_id).maximum(:relative_position)
self.class.in_parents(parent_ids).maximum(:relative_position)
end
def prev_relative_position
......@@ -27,7 +23,7 @@ module RelativePositioning
if self.relative_position
prev_pos = self.class
.in_parent([parent_id])
.in_parents(parent_ids)
.where('relative_position < ?', self.relative_position)
.maximum(:relative_position)
end
......@@ -40,7 +36,7 @@ module RelativePositioning
if self.relative_position
next_pos = self.class
.in_parent([parent_id])
.in_parents(parent_ids)
.where('relative_position > ?', self.relative_position)
.minimum(:relative_position)
end
......@@ -67,7 +63,7 @@ module RelativePositioning
pos_after = before.next_relative_position
if before.shift_after?
issue_to_move = self.class.in_parent([parent_id]).find_by!(relative_position: pos_after)
issue_to_move = self.class.in_parents(parent_ids).find_by!(relative_position: pos_after)
issue_to_move.move_after
@positionable_neighbours = [issue_to_move] # rubocop:disable Gitlab/ModuleWithInstanceVariables
......@@ -82,7 +78,7 @@ module RelativePositioning
pos_before = after.prev_relative_position
if after.shift_before?
issue_to_move = self.class.in_parent([parent_id]).find_by!(relative_position: pos_before)
issue_to_move = self.class.in_parents(parent_ids).find_by!(relative_position: pos_before)
issue_to_move.move_before
@positionable_neighbours = [issue_to_move] # rubocop:disable Gitlab/ModuleWithInstanceVariables
......
......@@ -47,7 +47,7 @@ class Issue < ActiveRecord::Base
validates :project, presence: true
alias_attribute :parent_id, :project_id
alias_attribute :parent_ids, :project_id
scope :in_projects, ->(project_ids) { where(project_id: project_ids) }
......@@ -96,10 +96,9 @@ class Issue < ActiveRecord::Base
acts_as_paranoid
class << self
alias_method :in_parent, :in_projects
alias_method :in_parents, :in_projects
end
def self.reference_prefix
'#'
end
......
......@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20171221154744) do
ActiveRecord::Schema.define(version: 20171220191323) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
......
......@@ -11,7 +11,7 @@ module EE
board_group && board_group.boards.any?
end
def project_ids
def parent_ids
return super unless has_group_boards?
board_group.projects.select(:id)
......
......@@ -7,11 +7,11 @@ class EpicIssue < ActiveRecord::Base
belongs_to :epic
belongs_to :issue
alias_attribute :parent_id, :epic_id
alias_attribute :parent_ids, :epic_id
scope :in_epic, ->(epic_id) { where(epic_id: epic_id) }
class << self
alias_method :in_parent, :in_epic
alias_method :in_parents, :in_epic
end
end
......@@ -41,7 +41,7 @@ module API
update_params = {
move_before_id: params[:move_before_id],
move_after_id: params[:move_after_id],
move_after_id: params[:move_after_id]
}
result = ::EpicIssues::UpdateService.new(link, current_user, update_params).execute
......
......@@ -27,7 +27,7 @@ describe Groups::EpicIssuesController do
end
describe 'GET #index' do
let!(:epic_issues) { create(:epic_issue, epic: epic, issue: issue) }
let!(:epic_issue) { create(:epic_issue, epic: epic, issue: issue) }
subject { get :index, group_id: group, epic_id: epic.to_param }
......@@ -52,7 +52,8 @@ describe Groups::EpicIssuesController do
'state' => issue.state,
'reference' => "#{project.full_path}##{issue.iid}",
'path' => "/#{project.full_path}/issues/#{issue.iid}",
'relation_path' => "/groups/#{group.full_path}/-/epics/#{epic.iid}/issues/#{epic_issues.id}"
'relation_path' => "/groups/#{group.full_path}/-/epics/#{epic.iid}/issues/#{epic_issue.id}",
'epic_issue_id' => epic_issue.id
}
]
expect(JSON.parse(response.body)).to eq(expected_result)
......
......@@ -13,8 +13,8 @@ describe 'Epic Issues', :js do
let!(:epic_issues) do
[
create(:epic_issue, epic: epic, issue: public_issue, position: 1),
create(:epic_issue, epic: epic, issue: private_issue, position: 2)
create(:epic_issue, epic: epic, issue: public_issue, relative_position: 1),
create(:epic_issue, epic: epic, issue: private_issue, relative_position: 2)
]
end
......
......@@ -2,6 +2,6 @@ FactoryBot.define do
factory :epic_issue do
epic
issue
relative_position Gitlab::Database::MAX_INT_VALUE / 2
relative_position { Gitlab::Database::MAX_INT_VALUE / 2 }
end
end
......@@ -12,10 +12,10 @@ describe SchedulePopulateMergeRequestMetricsWithEventsData, :migration, :sidekiq
migrate!
expect(described_class::MIGRATION)
.to be_scheduled_migration(10.minutes, mrs.first.id, mrs.second.id)
.to be_scheduled_delayed_migration(10.minutes, mrs.first.id, mrs.second.id)
expect(described_class::MIGRATION)
.to be_scheduled_migration(20.minutes, mrs.third.id, mrs.third.id)
.to be_scheduled_delayed_migration(20.minutes, mrs.third.id, mrs.third.id)
expect(BackgroundMigrationWorker.jobs.size).to eq(2)
end
......
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