Commit bc4a18ec authored by Jan Provaznik's avatar Jan Provaznik

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

Bump shoulda-matchers to 4.0.1

See merge request gitlab-org/gitlab-ce!28443
parents 744f1f2e 37a335e6
...@@ -379,7 +379,7 @@ group :development, :test do ...@@ -379,7 +379,7 @@ group :development, :test do
end end
group :test do 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 'email_spec', '~> 2.2.0'
gem 'json-schema', '~> 2.8.0' gem 'json-schema', '~> 2.8.0'
gem 'webmock', '~> 3.5.1' gem 'webmock', '~> 3.5.1'
......
...@@ -857,8 +857,8 @@ GEM ...@@ -857,8 +857,8 @@ GEM
sexp_processor (4.12.0) sexp_processor (4.12.0)
sham_rack (1.3.6) sham_rack (1.3.6)
rack rack
shoulda-matchers (3.1.2) shoulda-matchers (4.0.1)
activesupport (>= 4.0.0) activesupport (>= 4.2.0)
sidekiq (5.2.7) sidekiq (5.2.7)
connection_pool (~> 2.2, >= 2.2.2) connection_pool (~> 2.2, >= 2.2.2)
rack (>= 1.5.0) rack (>= 1.5.0)
...@@ -1199,7 +1199,7 @@ DEPENDENCIES ...@@ -1199,7 +1199,7 @@ DEPENDENCIES
sentry-raven (~> 2.7) sentry-raven (~> 2.7)
settingslogic (~> 2.0.9) settingslogic (~> 2.0.9)
sham_rack (~> 1.3.6) sham_rack (~> 1.3.6)
shoulda-matchers (~> 3.1.2) shoulda-matchers (~> 4.0.1)
sidekiq (~> 5.2.7) sidekiq (~> 5.2.7)
sidekiq-cron (~> 1.0) sidekiq-cron (~> 1.0)
simple_po_parser (~> 1.1.2) simple_po_parser (~> 1.1.2)
......
...@@ -581,6 +581,8 @@ class MergeRequest < ApplicationRecord ...@@ -581,6 +581,8 @@ class MergeRequest < ApplicationRecord
end end
def validate_branches def validate_branches
return unless target_project && source_project
if target_project == source_project && target_branch == source_branch if target_project == source_project && target_branch == source_branch
errors.add :branch_conflict, "You can't use same project/branch for source and target" errors.add :branch_conflict, "You can't use same project/branch for source and target"
return return
......
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
require 'spec_helper' require 'spec_helper'
describe Ci::PipelineSchedule do describe Ci::PipelineSchedule do
subject { build(:ci_pipeline_schedule) }
it { is_expected.to belong_to(:project) } it { is_expected.to belong_to(:project) }
it { is_expected.to belong_to(:owner) } it { is_expected.to belong_to(:owner) }
......
...@@ -5,6 +5,8 @@ require 'spec_helper' ...@@ -5,6 +5,8 @@ require 'spec_helper'
describe Clusters::Cluster do describe Clusters::Cluster do
it_behaves_like 'having unique enum values' it_behaves_like 'having unique enum values'
subject { build(:cluster) }
it { is_expected.to belong_to(:user) } it { is_expected.to belong_to(:user) }
it { is_expected.to have_many(:cluster_projects) } it { is_expected.to have_many(:cluster_projects) }
it { is_expected.to have_many(:projects) } it { is_expected.to have_many(:projects) }
......
...@@ -5,8 +5,8 @@ require 'spec_helper' ...@@ -5,8 +5,8 @@ require 'spec_helper'
describe Deployment do describe Deployment do
subject { build(:deployment) } subject { build(:deployment) }
it { is_expected.to belong_to(:project) } it { is_expected.to belong_to(:project).required }
it { is_expected.to belong_to(:environment) } it { is_expected.to belong_to(:environment).required }
it { is_expected.to belong_to(:user) } it { is_expected.to belong_to(:user) }
it { is_expected.to belong_to(:deployable) } it { is_expected.to belong_to(:deployable) }
......
...@@ -6,7 +6,7 @@ describe Environment do ...@@ -6,7 +6,7 @@ describe Environment do
let(:project) { create(:project, :stubbed_repository) } let(:project) { create(:project, :stubbed_repository) }
subject(:environment) { create(:environment, project: project) } 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 have_many(:deployments) }
it { is_expected.to delegate_method(:stop_action).to(:last_deployment) } 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