Commit 12ea88bd authored by GitLab Bot's avatar GitLab Bot

Automatic merge of gitlab-org/gitlab master

parents 67ba8e77 d7dc9398
...@@ -527,16 +527,6 @@ RSpec/EmptyLineAfterFinalLetItBe: ...@@ -527,16 +527,6 @@ RSpec/EmptyLineAfterFinalLetItBe:
- ee/spec/lib/gitlab/elastic/document_reference_spec.rb - ee/spec/lib/gitlab/elastic/document_reference_spec.rb
- ee/spec/lib/gitlab/elastic/group_search_results_spec.rb - ee/spec/lib/gitlab/elastic/group_search_results_spec.rb
- ee/spec/lib/gitlab/elastic/project_search_results_spec.rb - ee/spec/lib/gitlab/elastic/project_search_results_spec.rb
- ee/spec/lib/gitlab/geo/geo_tasks_spec.rb
- ee/spec/lib/gitlab/geo/log_cursor/daemon_spec.rb
- ee/spec/lib/gitlab/geo/log_cursor/events/container_repository_updated_event_spec.rb
- ee/spec/lib/gitlab/geo/log_cursor/events/design_repository_updated_event_spec.rb
- ee/spec/lib/gitlab/geo/log_cursor/events/repositories_changed_event_spec.rb
- ee/spec/lib/gitlab/geo/log_cursor/events/repository_created_event_spec.rb
- ee/spec/lib/gitlab/geo/log_cursor/events/repository_updated_event_spec.rb
- ee/spec/lib/gitlab/geo/replication/base_transfer_spec.rb
- ee/spec/lib/gitlab/geo/replication/blob_downloader_spec.rb
- ee/spec/lib/gitlab/geo/replication/file_transfer_spec.rb
- ee/spec/lib/gitlab/git_access_spec.rb - ee/spec/lib/gitlab/git_access_spec.rb
- ee/spec/lib/gitlab/git_access_wiki_spec.rb - ee/spec/lib/gitlab/git_access_wiki_spec.rb
- ee/spec/lib/gitlab/graphql/aggregations/vulnerability_statistics/lazy_aggregate_spec.rb - ee/spec/lib/gitlab/graphql/aggregations/vulnerability_statistics/lazy_aggregate_spec.rb
...@@ -607,17 +597,6 @@ RSpec/EmptyLineAfterFinalLetItBe: ...@@ -607,17 +597,6 @@ RSpec/EmptyLineAfterFinalLetItBe:
- ee/spec/requests/callout_spec.rb - ee/spec/requests/callout_spec.rb
- ee/spec/requests/git_http_geo_spec.rb - ee/spec/requests/git_http_geo_spec.rb
- ee/spec/requests/repositories/git_http_controller_spec.rb - ee/spec/requests/repositories/git_http_controller_spec.rb
- ee/spec/serializers/clusters/environment_serializer_spec.rb
- ee/spec/serializers/dependency_entity_spec.rb
- ee/spec/serializers/dependency_list_serializer_spec.rb
- ee/spec/serializers/ee/issue_board_entity_spec.rb
- ee/spec/serializers/ee/issue_entity_spec.rb
- ee/spec/serializers/ee/issue_sidebar_extras_entity_spec.rb
- ee/spec/serializers/member_entity_spec.rb
- ee/spec/serializers/merge_request_poll_widget_entity_spec.rb
- ee/spec/serializers/merge_request_widget_entity_spec.rb
- ee/spec/serializers/status_page/incident_comment_entity_spec.rb
- ee/spec/serializers/vulnerabilities/feedback_entity_spec.rb
- ee/spec/services/alert_management/extract_alert_payload_fields_service_spec.rb - ee/spec/services/alert_management/extract_alert_payload_fields_service_spec.rb
- ee/spec/services/alert_management/process_prometheus_alert_service_spec.rb - ee/spec/services/alert_management/process_prometheus_alert_service_spec.rb
- ee/spec/services/approval_rules/create_service_spec.rb - ee/spec/services/approval_rules/create_service_spec.rb
......
...@@ -69,12 +69,16 @@ module Boards ...@@ -69,12 +69,16 @@ module Boards
if moving_to_list.movable? if moving_to_list.movable?
moving_from_list.label_id moving_from_list.label_id
else else
::Label.ids_on_board(board.id) board_label_ids
end end
Array(label_ids).compact Array(label_ids).compact
end end
def board_label_ids
::Label.ids_on_board(board.id)
end
def move_between_ids(move_params) def move_between_ids(move_params)
ids = [move_params[:move_after_id], move_params[:move_before_id]] ids = [move_params[:move_after_id], move_params[:move_before_id]]
.map(&:to_i) .map(&:to_i)
......
...@@ -13,6 +13,7 @@ module Boards ...@@ -13,6 +13,7 @@ module Boards
enum list_type: { backlog: 0, label: 1, closed: 2 } enum list_type: { backlog: 0, label: 1, closed: 2 }
scope :preload_associated_models, -> { preload(:epic_board, label: :priorities) } scope :preload_associated_models, -> { preload(:epic_board, label: :priorities) }
scope :movable, -> { where(list_type: list_types.slice(*movable_types).values) }
alias_method :preferences, :epic_list_user_preferences alias_method :preferences, :epic_list_user_preferences
......
...@@ -10,6 +10,15 @@ module EE ...@@ -10,6 +10,15 @@ module EE
prepended do prepended do
has_many :epic_board_labels, class_name: 'Boards::EpicBoardLabel', inverse_of: :label has_many :epic_board_labels, class_name: 'Boards::EpicBoardLabel', inverse_of: :label
has_many :epic_lists, class_name: 'Boards::EpicList', inverse_of: :label has_many :epic_lists, class_name: 'Boards::EpicList', inverse_of: :label
scope :on_epic_board, ->(epic_board_id) do
joins(epic_lists: :epic_board).merge(::Boards::EpicList.movable)
.where(boards_epic_boards: { id: epic_board_id })
end
def self.ids_on_epic_board(epic_board_id)
on_epic_board(epic_board_id).pluck(:label_id)
end
end end
def scoped_label? def scoped_label?
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
module Boards module Boards
module Epics module Epics
class MoveService < Boards::BaseItemMoveService class MoveService < Boards::BaseItemMoveService
extend ::Gitlab::Utils::Override
private private
def update(epic, epic_modification_params) def update(epic, epic_modification_params)
...@@ -13,6 +15,11 @@ module Boards ...@@ -13,6 +15,11 @@ module Boards
@board ||= parent.epic_boards.find(params[:board_id]) @board ||= parent.epic_boards.find(params[:board_id])
end end
override :board_label_ids
def board_label_ids
::Label.ids_on_epic_board(board.id)
end
def reposition_parent def reposition_parent
{ board_id: board.id } { board_id: board.id }
end end
......
---
title: Fix removing labels when moving an epic between lists
merge_request: 58145
author:
type: fixed
---
title: Fix RSpec/EmptyLineAfterFinalLetItBe rubocop offenses in ee/spec/lib/gitlab/geo
merge_request: 58380
author: Abdul Wadood @abdulwd
type: fixed
---
title: Fix RSpec/EmptyLineAfterFinalLetItBe rubocop offenses in ee/spec/serializers
merge_request: 58362
author: Abdul Wadood @abdulwd
type: fixed
...@@ -24,6 +24,7 @@ RSpec.describe Gitlab::Geo::GeoTasks do ...@@ -24,6 +24,7 @@ RSpec.describe Gitlab::Geo::GeoTasks do
describe '.set_secondary_as_primary' do describe '.set_secondary_as_primary' do
let_it_be(:primary) { create(:geo_node, :primary) } let_it_be(:primary) { create(:geo_node, :primary) }
let(:secondary) { create(:geo_node) } let(:secondary) { create(:geo_node) }
before do before do
......
...@@ -8,6 +8,7 @@ RSpec.describe Gitlab::Geo::LogCursor::Daemon, :clean_gitlab_redis_shared_state ...@@ -8,6 +8,7 @@ RSpec.describe Gitlab::Geo::LogCursor::Daemon, :clean_gitlab_redis_shared_state
let_it_be(:primary, reload: true) { create(:geo_node, :primary) } let_it_be(:primary, reload: true) { create(:geo_node, :primary) }
let_it_be(:secondary, reload: true) { create(:geo_node) } let_it_be(:secondary, reload: true) { create(:geo_node) }
let(:options) { {} } let(:options) { {} }
subject(:daemon) { described_class.new(options) } subject(:daemon) { described_class.new(options) }
......
...@@ -7,6 +7,7 @@ RSpec.describe Gitlab::Geo::LogCursor::Events::ContainerRepositoryUpdatedEvent, ...@@ -7,6 +7,7 @@ RSpec.describe Gitlab::Geo::LogCursor::Events::ContainerRepositoryUpdatedEvent,
let_it_be(:secondary) { create(:geo_node) } let_it_be(:secondary) { create(:geo_node) }
let_it_be(:secondary_excludes_all_projects) { create(:geo_node, :selective_sync_excludes_all_projects) } let_it_be(:secondary_excludes_all_projects) { create(:geo_node, :selective_sync_excludes_all_projects) }
let(:logger) { Gitlab::Geo::LogCursor::Logger.new(described_class, Logger::INFO) } let(:logger) { Gitlab::Geo::LogCursor::Logger.new(described_class, Logger::INFO) }
let(:event_log) { create(:geo_event_log, :container_repository_updated_event) } let(:event_log) { create(:geo_event_log, :container_repository_updated_event) }
let!(:event_log_state) { create(:geo_event_log_state, event_id: event_log.id - 1) } let!(:event_log_state) { create(:geo_event_log_state, event_id: event_log.id - 1) }
......
...@@ -7,6 +7,7 @@ RSpec.describe Gitlab::Geo::LogCursor::Events::DesignRepositoryUpdatedEvent, :cl ...@@ -7,6 +7,7 @@ RSpec.describe Gitlab::Geo::LogCursor::Events::DesignRepositoryUpdatedEvent, :cl
let_it_be(:secondary) { create(:geo_node) } let_it_be(:secondary) { create(:geo_node) }
let_it_be(:secondary_excludes_all_projects) { create(:geo_node, :selective_sync_excludes_all_projects) } let_it_be(:secondary_excludes_all_projects) { create(:geo_node, :selective_sync_excludes_all_projects) }
let(:logger) { Gitlab::Geo::LogCursor::Logger.new(described_class, Logger::INFO) } let(:logger) { Gitlab::Geo::LogCursor::Logger.new(described_class, Logger::INFO) }
let(:project) { create(:project) } let(:project) { create(:project) }
let(:design_repository_updated_event) { create(:geo_design_repository_updated_event, project: project) } let(:design_repository_updated_event) { create(:geo_design_repository_updated_event, project: project) }
......
...@@ -7,6 +7,7 @@ RSpec.describe Gitlab::Geo::LogCursor::Events::RepositoriesChangedEvent, :clean_ ...@@ -7,6 +7,7 @@ RSpec.describe Gitlab::Geo::LogCursor::Events::RepositoriesChangedEvent, :clean_
let(:logger) { Gitlab::Geo::LogCursor::Logger.new(described_class, Logger::INFO) } let(:logger) { Gitlab::Geo::LogCursor::Logger.new(described_class, Logger::INFO) }
let_it_be(:secondary) { create(:geo_node) } let_it_be(:secondary) { create(:geo_node) }
let(:repositories_changed_event) { create(:geo_repositories_changed_event, geo_node: secondary) } let(:repositories_changed_event) { create(:geo_repositories_changed_event, geo_node: secondary) }
let(:event_log) { create(:geo_event_log, repositories_changed_event: repositories_changed_event) } let(:event_log) { create(:geo_event_log, repositories_changed_event: repositories_changed_event) }
let!(:event_log_state) { create(:geo_event_log_state, event_id: event_log.id - 1) } let!(:event_log_state) { create(:geo_event_log_state, event_id: event_log.id - 1) }
......
...@@ -6,6 +6,7 @@ RSpec.describe Gitlab::Geo::LogCursor::Events::RepositoryCreatedEvent, :clean_gi ...@@ -6,6 +6,7 @@ RSpec.describe Gitlab::Geo::LogCursor::Events::RepositoryCreatedEvent, :clean_gi
include ::EE::GeoHelpers include ::EE::GeoHelpers
let_it_be(:secondary) { create(:geo_node) } let_it_be(:secondary) { create(:geo_node) }
let(:logger) { Gitlab::Geo::LogCursor::Logger.new(described_class, Logger::INFO) } let(:logger) { Gitlab::Geo::LogCursor::Logger.new(described_class, Logger::INFO) }
let(:project) { create(:project) } let(:project) { create(:project) }
let(:repository_created_event) { create(:geo_repository_created_event, project: project) } let(:repository_created_event) { create(:geo_repository_created_event, project: project) }
......
...@@ -7,6 +7,7 @@ RSpec.describe Gitlab::Geo::LogCursor::Events::RepositoryUpdatedEvent, :clean_gi ...@@ -7,6 +7,7 @@ RSpec.describe Gitlab::Geo::LogCursor::Events::RepositoryUpdatedEvent, :clean_gi
let(:logger) { Gitlab::Geo::LogCursor::Logger.new(described_class, Logger::INFO) } let(:logger) { Gitlab::Geo::LogCursor::Logger.new(described_class, Logger::INFO) }
let_it_be(:secondary) { create(:geo_node) } let_it_be(:secondary) { create(:geo_node) }
let(:project) { create(:project) } let(:project) { create(:project) }
let(:repository_updated_event) { create(:geo_repository_updated_event, project: project) } let(:repository_updated_event) { create(:geo_repository_updated_event, project: project) }
let(:event_log) { create(:geo_event_log, repository_updated_event: repository_updated_event) } let(:event_log) { create(:geo_event_log, repository_updated_event: repository_updated_event) }
......
...@@ -97,6 +97,7 @@ RSpec.describe Gitlab::Geo::Replication::BaseTransfer do ...@@ -97,6 +97,7 @@ RSpec.describe Gitlab::Geo::Replication::BaseTransfer do
describe '#stream_from_primary_to_object_storage' do describe '#stream_from_primary_to_object_storage' do
let_it_be(:lfs_object) { create(:lfs_object, :with_file, :correct_oid) } let_it_be(:lfs_object) { create(:lfs_object, :with_file, :correct_oid) }
let(:auth_headers) { { 'Authorization' => 'Bearer 12345' } } let(:auth_headers) { { 'Authorization' => 'Bearer 12345' } }
let(:download_link) { 'http://download.link' } let(:download_link) { 'http://download.link' }
......
...@@ -7,6 +7,7 @@ RSpec.describe Gitlab::Geo::Replication::BlobDownloader do ...@@ -7,6 +7,7 @@ RSpec.describe Gitlab::Geo::Replication::BlobDownloader do
let_it_be(:primary) { create(:geo_node, :primary) } let_it_be(:primary) { create(:geo_node, :primary) }
let_it_be(:secondary) { create(:geo_node) } let_it_be(:secondary) { create(:geo_node) }
let(:model_record) { create(:package_file, :npm) } let(:model_record) { create(:package_file, :npm) }
let(:replicator) { model_record.replicator } let(:replicator) { model_record.replicator }
......
...@@ -7,6 +7,7 @@ RSpec.describe Gitlab::Geo::Replication::FileTransfer do ...@@ -7,6 +7,7 @@ RSpec.describe Gitlab::Geo::Replication::FileTransfer do
let_it_be(:primary_node) { create(:geo_node, :primary) } let_it_be(:primary_node) { create(:geo_node, :primary) }
let_it_be(:secondary_node) { create(:geo_node) } let_it_be(:secondary_node) { create(:geo_node) }
let(:user) { create(:user, :with_avatar) } let(:user) { create(:user, :with_avatar) }
let(:upload) { Upload.find_by(model: user, uploader: 'AvatarUploader') } let(:upload) { Upload.find_by(model: user, uploader: 'AvatarUploader') }
......
...@@ -3,11 +3,35 @@ ...@@ -3,11 +3,35 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Label do RSpec.describe Label do
let_it_be(:group) { create(:group) }
let_it_be(:development) { create(:group_label, group: group, name: 'Development') }
let_it_be(:testing) { create(:group_label, group: group, name: 'Testing') }
let_it_be(:no_board_label) { create(:group_label, group: group, name: 'Feature') }
let_it_be(:board) { create(:epic_board, group: group) }
let_it_be(:list1) { create(:epic_list, epic_board: board, label: development) }
let_it_be(:list2) { create(:epic_list, epic_board: board, label: testing) }
describe 'associations' do describe 'associations' do
it { is_expected.to have_many(:epic_board_labels).inverse_of(:label) } it { is_expected.to have_many(:epic_board_labels).inverse_of(:label) }
it { is_expected.to have_many(:epic_lists).inverse_of(:label) } it { is_expected.to have_many(:epic_lists).inverse_of(:label) }
end end
describe 'scopes' do
describe '.on_epic_board' do
it 'returns only the board labels' do
expect(described_class.on_epic_board(board.id)).to match_array([development, testing])
end
end
end
describe '#ids_on_epic_board' do
it 'returns only the board label ids' do
expect(described_class.ids_on_epic_board(board.id)).to match_array([development.id, testing.id])
end
end
describe '#scoped_label?' do describe '#scoped_label?' do
context 'with scoped_labels available' do context 'with scoped_labels available' do
before do before do
......
...@@ -8,6 +8,7 @@ RSpec.describe Clusters::EnvironmentSerializer do ...@@ -8,6 +8,7 @@ RSpec.describe Clusters::EnvironmentSerializer do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project, namespace: user.namespace) } let_it_be(:project) { create(:project, namespace: user.namespace) }
let_it_be(:cluster) { create(:cluster) } let_it_be(:cluster) { create(:cluster) }
let(:resource) { create(:environment, project: project) } let(:resource) { create(:environment, project: project) }
let(:json_entity) do let(:json_entity) do
......
...@@ -7,6 +7,7 @@ RSpec.describe DependencyEntity do ...@@ -7,6 +7,7 @@ RSpec.describe DependencyEntity do
subject { described_class.represent(dependency, request: request).as_json } subject { described_class.represent(dependency, request: request).as_json }
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let(:project) { create(:project, :repository, :private) } let(:project) { create(:project, :repository, :private) }
let(:request) { double('request') } let(:request) { double('request') }
let(:dependency) { build(:dependency, :with_vulnerabilities, :with_licenses, :indirect) } let(:dependency) { build(:dependency, :with_vulnerabilities, :with_licenses, :indirect) }
......
...@@ -5,6 +5,7 @@ require 'spec_helper' ...@@ -5,6 +5,7 @@ require 'spec_helper'
RSpec.describe DependencyListSerializer do RSpec.describe DependencyListSerializer do
let_it_be(:project) { create(:project, :repository, :private) } let_it_be(:project) { create(:project, :repository, :private) }
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let(:ci_build) { create(:ee_ci_build, :success) } let(:ci_build) { create(:ee_ci_build, :success) }
let(:dependencies) { [build(:dependency, :with_vulnerabilities, :with_licenses)] } let(:dependencies) { [build(:dependency, :with_vulnerabilities, :with_licenses)] }
......
...@@ -6,6 +6,7 @@ RSpec.describe IssueBoardEntity do ...@@ -6,6 +6,7 @@ RSpec.describe IssueBoardEntity do
let_it_be(:project) { create(:project) } let_it_be(:project) { create(:project) }
let_it_be(:issue) { create(:issue, project: project) } let_it_be(:issue) { create(:issue, project: project) }
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let(:request) { double('request', current_user: user) } let(:request) { double('request', current_user: user) }
let(:blocked_ids) { [] } let(:blocked_ids) { [] }
......
...@@ -8,6 +8,7 @@ RSpec.describe IssueEntity do ...@@ -8,6 +8,7 @@ RSpec.describe IssueEntity do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:blocking_issue) { create(:issue, project: project) } let_it_be(:blocking_issue) { create(:issue, project: project) }
let_it_be(:blocked_issue) { create(:issue, project: project) } let_it_be(:blocked_issue) { create(:issue, project: project) }
let(:request) { double('request', current_user: user) } let(:request) { double('request', current_user: user) }
before_all do before_all do
......
...@@ -7,6 +7,7 @@ RSpec.describe IssueSidebarExtrasEntity do ...@@ -7,6 +7,7 @@ RSpec.describe IssueSidebarExtrasEntity do
let_it_be(:project) { create(:project, group: group) } let_it_be(:project) { create(:project, group: group) }
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:issue, reload: true) { create(:issue, :confidential, project: project) } let_it_be(:issue, reload: true) { create(:issue, :confidential, project: project) }
let(:request) { double('request', current_user: user) } let(:request) { double('request', current_user: user) }
subject { described_class.new(issue, request: request).as_json } subject { described_class.new(issue, request: request).as_json }
......
...@@ -4,6 +4,7 @@ require 'spec_helper' ...@@ -4,6 +4,7 @@ require 'spec_helper'
RSpec.describe MemberEntity do RSpec.describe MemberEntity do
let_it_be(:current_user) { create(:user) } let_it_be(:current_user) { create(:user) }
let(:entity) { described_class.new(member, { current_user: current_user, group: group }) } let(:entity) { described_class.new(member, { current_user: current_user, group: group }) }
let(:entity_hash) { entity.as_json } let(:entity_hash) { entity.as_json }
......
...@@ -8,6 +8,7 @@ RSpec.describe MergeRequestPollWidgetEntity do ...@@ -8,6 +8,7 @@ RSpec.describe MergeRequestPollWidgetEntity do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:project) { create :project, :repository } let_it_be(:project) { create :project, :repository }
let_it_be(:merge_request, reload: true) { create(:merge_request, source_project: project, target_project: project) } let_it_be(:merge_request, reload: true) { create(:merge_request, source_project: project, target_project: project) }
let(:request) { double('request', current_user: user) } let(:request) { double('request', current_user: user) }
before do before do
......
...@@ -9,6 +9,7 @@ RSpec.describe MergeRequestWidgetEntity do ...@@ -9,6 +9,7 @@ RSpec.describe MergeRequestWidgetEntity do
let_it_be(:project, reload: true) { create :project, :repository } let_it_be(:project, reload: true) { create :project, :repository }
let_it_be(:merge_request, reload: true) { create(:merge_request, source_project: project, target_project: project) } let_it_be(:merge_request, reload: true) { create(:merge_request, source_project: project, target_project: project) }
let_it_be(:pipeline, reload: true) { create(:ci_empty_pipeline, project: project) } let_it_be(:pipeline, reload: true) { create(:ci_empty_pipeline, project: project) }
let(:request) { double('request', current_user: user) } let(:request) { double('request', current_user: user) }
before do before do
......
...@@ -4,6 +4,7 @@ require 'spec_helper' ...@@ -4,6 +4,7 @@ require 'spec_helper'
RSpec.describe StatusPage::IncidentCommentEntity do RSpec.describe StatusPage::IncidentCommentEntity do
let_it_be(:note, reload: true) { create(:note, note: ':ok:') } let_it_be(:note, reload: true) { create(:note, note: ':ok:') }
let(:json) { subject.as_json } let(:json) { subject.as_json }
let(:issue) { instance_double(Issue, iid: 1) } let(:issue) { instance_double(Issue, iid: 1) }
......
...@@ -5,6 +5,7 @@ require 'spec_helper' ...@@ -5,6 +5,7 @@ require 'spec_helper'
RSpec.describe Vulnerabilities::FeedbackEntity do RSpec.describe Vulnerabilities::FeedbackEntity do
let_it_be(:user) { create(:user) } let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project) } let_it_be(:project) { create(:project) }
let(:request) { double('request') } let(:request) { double('request') }
let(:entity) { described_class.represent(feedback, request: request) } let(:entity) { described_class.represent(feedback, request: request) }
......
...@@ -11,10 +11,11 @@ RSpec.describe Boards::Epics::MoveService do ...@@ -11,10 +11,11 @@ RSpec.describe Boards::Epics::MoveService do
let_it_be(:development) { create(:group_label, group: group, name: 'Development') } let_it_be(:development) { create(:group_label, group: group, name: 'Development') }
let_it_be(:testing) { create(:group_label, group: group, name: 'Testing') } let_it_be(:testing) { create(:group_label, group: group, name: 'Testing') }
let_it_be(:no_board_label) { create(:group_label, group: group, name: 'Feature') }
let_it_be(:backlog) { create(:epic_list, epic_board: board, list_type: :backlog, label: nil) } let_it_be(:backlog) { create(:epic_list, epic_board: board, list_type: :backlog, label: nil) }
let_it_be(:list1) { create(:epic_list, epic_board: board, label: development, position: 0) } let_it_be(:development_list) { create(:epic_list, epic_board: board, label: development, position: 0) }
let_it_be(:list2) { create(:epic_list, epic_board: board, label: testing, position: 1) } let_it_be(:testing_list) { create(:epic_list, epic_board: board, label: testing, position: 1) }
let_it_be(:closed) { create(:epic_list, epic_board: board, list_type: :closed, label: nil) } let_it_be(:closed) { create(:epic_list, epic_board: board, list_type: :closed, label: nil) }
let_it_be(:other_board_list) { create(:epic_list, epic_board: other_board, list_type: :closed, label: nil) } let_it_be(:other_board_list) { create(:epic_list, epic_board: other_board, list_type: :closed, label: nil) }
...@@ -74,7 +75,7 @@ RSpec.describe Boards::Epics::MoveService do ...@@ -74,7 +75,7 @@ RSpec.describe Boards::Epics::MoveService do
context 'when moving an epic between lists' do context 'when moving an epic between lists' do
context 'when moving the epic from backlog' do context 'when moving the epic from backlog' do
context 'to a labeled list' do context 'to a labeled list' do
let(:to_list) { list1 } let(:to_list) { development_list }
it 'keeps the epic opened and adds the labels' do it 'keeps the epic opened and adds the labels' do
expect { subject }.not_to change { epic.state } expect { subject }.not_to change { epic.state }
...@@ -100,16 +101,18 @@ RSpec.describe Boards::Epics::MoveService do ...@@ -100,16 +101,18 @@ RSpec.describe Boards::Epics::MoveService do
context 'when moving the epic from a labeled list' do context 'when moving the epic from a labeled list' do
before do before do
epic.labels = [development] epic.labels = [development, no_board_label]
end end
let(:from_list) { list1 } let(:from_list) { development_list }
context 'to another labeled list' do context 'to another labeled list' do
let(:to_list) { list2 } let(:to_list) { testing_list }
it 'changes the labels' do it 'changes the labels' do
expect { subject }.to change { epic.reload.labels }.from([development]).to([testing]) subject
expect(epic.labels).to match_array([testing, no_board_label])
end end
end end
...@@ -119,6 +122,12 @@ RSpec.describe Boards::Epics::MoveService do ...@@ -119,6 +122,12 @@ RSpec.describe Boards::Epics::MoveService do
it 'closes the epic' do it 'closes the epic' do
expect { subject }.to change { epic.state }.from('opened').to('closed') expect { subject }.to change { epic.state }.from('opened').to('closed')
end end
it 'removes the board labels from the epic' do
subject
expect(epic.labels).to eq([no_board_label])
end
end end
end end
end end
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Label do RSpec.describe Label do
let_it_be(:project) { create(:project) }
describe 'modules' do describe 'modules' do
it { is_expected.to include_module(Referable) } it { is_expected.to include_module(Referable) }
it { is_expected.to include_module(Subscribable) } it { is_expected.to include_module(Subscribable) }
...@@ -44,6 +46,22 @@ RSpec.describe Label do ...@@ -44,6 +46,22 @@ RSpec.describe Label do
end end
end end
describe 'scopes' do
describe '.on_board' do
let(:board) { create(:board, project: project) }
let!(:list1) { create(:list, board: board, label: development) }
let!(:list2) { create(:list, board: board, label: testing) }
let!(:development) { create(:label, project: project, name: 'Development') }
let!(:testing) { create(:label, project: project, name: 'Testing') }
let!(:regression) { create(:label, project: project, name: 'Regression') }
it 'returns only the board labels' do
expect(described_class.on_board(board.id)).to match_array([development, testing])
end
end
end
describe '#color' do describe '#color' do
it 'strips color' do it 'strips color' do
label = described_class.new(color: ' #abcdef ') label = described_class.new(color: ' #abcdef ')
...@@ -92,9 +110,7 @@ RSpec.describe Label do ...@@ -92,9 +110,7 @@ RSpec.describe Label do
end end
describe 'priorization' do describe 'priorization' do
subject(:label) { create(:label) } subject(:label) { create(:label, project: project) }
let(:project) { label.project }
describe '#prioritize!' do describe '#prioritize!' do
context 'when label is not prioritized' do context 'when label is not prioritized' 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