summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Provaznik <jprovaznik@gitlab.com>2019-05-22 14:08:38 +0000
committerJan Provaznik <jprovaznik@gitlab.com>2019-05-22 14:08:38 +0000
commitbc4a18ecb9e85a5ee51541ed25b2cb9c4a2768b5 (patch)
treefdcc55def50b3436eab55a0a4c930c15c24dc795
parent744f1f2e7037f5c70c3168d9e2e89b1c327465d2 (diff)
parent37a335e60edd4f4c8b61fd2f9ffe0f1d27e3bfb8 (diff)
downloadgitlab-ce-bc4a18ecb9e85a5ee51541ed25b2cb9c4a2768b5.tar.gz
Merge branch 'sh-bump-shoulda-matcher' into 'master'
Bump shoulda-matchers to 4.0.1 See merge request gitlab-org/gitlab-ce!28443
-rw-r--r--Gemfile2
-rw-r--r--Gemfile.lock6
-rw-r--r--app/models/merge_request.rb2
-rw-r--r--spec/models/ci/pipeline_schedule_spec.rb2
-rw-r--r--spec/models/clusters/cluster_spec.rb2
-rw-r--r--spec/models/deployment_spec.rb4
-rw-r--r--spec/models/environment_spec.rb2
-rw-r--r--spec/support/shoulda/matchers/rails_shim.rb27
8 files changed, 13 insertions, 34 deletions
diff --git a/Gemfile b/Gemfile
index b6804a94971..e2842ca27db 100644
--- a/Gemfile
+++ b/Gemfile
@@ -379,7 +379,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'
diff --git a/Gemfile.lock b/Gemfile.lock
index 2dbff1674df..a63b7cc84aa 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -857,8 +857,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)
@@ -1199,7 +1199,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)
diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb
index df162e4844c..311ba1ce6bd 100644
--- a/app/models/merge_request.rb
+++ b/app/models/merge_request.rb
@@ -581,6 +581,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
diff --git a/spec/models/ci/pipeline_schedule_spec.rb b/spec/models/ci/pipeline_schedule_spec.rb
index 1bfc14d2839..42d4769a921 100644
--- a/spec/models/ci/pipeline_schedule_spec.rb
+++ b/spec/models/ci/pipeline_schedule_spec.rb
@@ -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) }
diff --git a/spec/models/clusters/cluster_spec.rb b/spec/models/clusters/cluster_spec.rb
index 60065ff22af..3ee8c340bfe 100644
--- a/spec/models/clusters/cluster_spec.rb
+++ b/spec/models/clusters/cluster_spec.rb
@@ -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) }
diff --git a/spec/models/deployment_spec.rb b/spec/models/deployment_spec.rb
index f51322e1404..1dceef3fc00 100644
--- a/spec/models/deployment_spec.rb
+++ b/spec/models/deployment_spec.rb
@@ -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) }
diff --git a/spec/models/environment_spec.rb b/spec/models/environment_spec.rb
index 17246f238e0..7233d2454c6 100644
--- a/spec/models/environment_spec.rb
+++ b/spec/models/environment_spec.rb
@@ -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) }
diff --git a/spec/support/shoulda/matchers/rails_shim.rb b/spec/support/shoulda/matchers/rails_shim.rb
deleted file mode 100644
index 8d70598beb5..00000000000
--- a/spec/support/shoulda/matchers/rails_shim.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-# 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