Commit b840cc6a authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'sh-bump-shoulda-matcher-ee' into 'master'

[EE] Upgrade shoulda-matchers to 4.0.1

See merge request gitlab-org/gitlab-ee!13111
parents 9637d0e7 fe78eff3
......@@ -394,7 +394,7 @@ group :development, :test do
end
group :test do
gem 'shoulda-matchers', '~> 3.1.2', require: false
gem 'shoulda-matchers', '~> 4.0.1', require: false
gem 'email_spec', '~> 2.2.0'
gem 'json-schema', '~> 2.8.0'
gem 'webmock', '~> 3.5.1'
......
......@@ -888,8 +888,8 @@ GEM
sexp_processor (4.12.0)
sham_rack (1.3.6)
rack
shoulda-matchers (3.1.2)
activesupport (>= 4.0.0)
shoulda-matchers (4.0.1)
activesupport (>= 4.2.0)
sidekiq (5.2.7)
connection_pool (~> 2.2, >= 2.2.2)
rack (>= 1.5.0)
......@@ -1241,7 +1241,7 @@ DEPENDENCIES
sentry-raven (~> 2.7)
settingslogic (~> 2.0.9)
sham_rack (~> 1.3.6)
shoulda-matchers (~> 3.1.2)
shoulda-matchers (~> 4.0.1)
sidekiq (~> 5.2.7)
sidekiq-cron (~> 1.0)
simple_po_parser (~> 1.1.2)
......
......@@ -583,6 +583,8 @@ class MergeRequest < ApplicationRecord
end
def validate_branches
return unless target_project && source_project
if target_project == source_project && target_branch == source_branch
errors.add :branch_conflict, "You can't use same project/branch for source and target"
return
......
......@@ -35,7 +35,7 @@ module EE
end
def milestone
return unless parent.feature_available?(:scoped_issue_board)
return unless parent&.feature_available?(:scoped_issue_board)
case milestone_id
when ::Milestone::Upcoming.id
......
......@@ -7,7 +7,10 @@ describe Group do
describe 'associations' do
it { is_expected.to have_many(:audit_events).dependent(false) }
it { is_expected.to belong_to(:file_template_project) }
# shoulda-matchers attempts to set the association to nil to ensure
# the presence check works, but since this is a private method that
# method can't be called with a public_send.
it { is_expected.to belong_to(:file_template_project).class_name('Project').without_validating_presence }
it { is_expected.to have_many(:dependency_proxy_blobs) }
it { is_expected.to have_one(:dependency_proxy_setting) }
end
......
......@@ -7,7 +7,7 @@ describe PrometheusAlertEvent do
let(:alert) { subject.prometheus_alert }
describe 'associations' do
it { is_expected.to belong_to(:prometheus_alert) }
it { is_expected.to belong_to(:prometheus_alert).required }
end
describe 'validations' do
......
......@@ -24,8 +24,8 @@ describe PrometheusAlert do
end
describe 'associations' do
it { is_expected.to belong_to(:project) }
it { is_expected.to belong_to(:environment) }
it { is_expected.to belong_to(:project).required }
it { is_expected.to belong_to(:environment).required }
end
describe 'project validations' do
......
......@@ -3,6 +3,8 @@
require 'spec_helper'
describe Ci::PipelineSchedule do
subject { build(:ci_pipeline_schedule) }
it { is_expected.to belong_to(:project) }
it { is_expected.to belong_to(:owner) }
......
......@@ -5,6 +5,8 @@ require 'spec_helper'
describe Clusters::Cluster do
it_behaves_like 'having unique enum values'
subject { build(:cluster) }
it { is_expected.to belong_to(:user) }
it { is_expected.to have_many(:cluster_projects) }
it { is_expected.to have_many(:projects) }
......
......@@ -5,8 +5,8 @@ require 'spec_helper'
describe Deployment do
subject { build(:deployment) }
it { is_expected.to belong_to(:project) }
it { is_expected.to belong_to(:environment) }
it { is_expected.to belong_to(:project).required }
it { is_expected.to belong_to(:environment).required }
it { is_expected.to belong_to(:user) }
it { is_expected.to belong_to(:deployable) }
......
......@@ -6,7 +6,7 @@ describe Environment do
let(:project) { create(:project, :stubbed_repository) }
subject(:environment) { create(:environment, project: project) }
it { is_expected.to belong_to(:project) }
it { is_expected.to belong_to(:project).required }
it { is_expected.to have_many(:deployments) }
it { is_expected.to delegate_method(:stop_action).to(:last_deployment) }
......
# monkey patch which fixes serialization matcher in Rails 5
# https://github.com/thoughtbot/shoulda-matchers/issues/913
# This can be removed when a new version of shoulda-matchers
# is released
module Shoulda
module Matchers
class RailsShim
def self.serialized_attributes_for(model)
if defined?(::ActiveRecord::Type::Serialized)
# Rails 5+
serialized_columns = model.columns.select do |column|
model.type_for_attribute(column.name).is_a?(
::ActiveRecord::Type::Serialized
)
end
serialized_columns.inject({}) do |hash, column| # rubocop:disable Style/EachWithObject
hash[column.name.to_s] = model.type_for_attribute(column.name).coder
hash
end
else
model.serialized_attributes
end
end
end
end
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