Commit 47dd7d0b authored by Rémy Coutable's avatar Rémy Coutable

Use gitlab-default_value_with Rails 5

This forks live at https://github.com/gitlabhq/default_value_for/tree/69-fix-action_controller-parameters-handling
and fixes an issue where default_value_for wouldn't handle
`ActionController::Parameters` correctly with Rails 5.

This fixes https://gitlab.com/gitlab-org/gitlab-ce/issues/54093.
Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 84db49ea
...@@ -4,10 +4,9 @@ def rails5? ...@@ -4,10 +4,9 @@ def rails5?
end end
gem_versions = {} gem_versions = {}
gem_versions['activerecord_sane_schema_dumper'] = rails5? ? '1.0' : '0.2' gem_versions['activerecord_sane_schema_dumper'] = rails5? ? '1.0' : '0.2'
gem_versions['default_value_for'] = rails5? ? '~> 3.0.5' : '~> 3.0.0' gem_versions['rails'] = rails5? ? '5.0.7' : '4.2.10'
gem_versions['rails'] = rails5? ? '5.0.7' : '4.2.10' gem_versions['rails-i18n'] = rails5? ? '~> 5.1' : '~> 4.0.9'
gem_versions['rails-i18n'] = rails5? ? '~> 5.1' : '~> 4.0.9'
# --- The end of special code for migrating to Rails 5.0 --- # --- The end of special code for migrating to Rails 5.0 ---
source 'https://rubygems.org' source 'https://rubygems.org'
...@@ -21,7 +20,11 @@ gem 'responders', '~> 2.0' ...@@ -21,7 +20,11 @@ gem 'responders', '~> 2.0'
gem 'sprockets', '~> 3.7.0' gem 'sprockets', '~> 3.7.0'
# Default values for AR models # Default values for AR models
gem 'default_value_for', gem_versions['default_value_for'] if rails5?
gem 'gitlab-default_value_for', '~> 3.1.1', require: 'default_value_for'
else
gem 'default_value_for', '~> 3.0.0'
end
# Supported DBs # Supported DBs
gem 'mysql2', '~> 0.4.10', group: :mysql gem 'mysql2', '~> 0.4.10', group: :mysql
......
...@@ -146,8 +146,6 @@ GEM ...@@ -146,8 +146,6 @@ GEM
html-pipeline html-pipeline
declarative (0.0.10) declarative (0.0.10)
declarative-option (0.1.0) declarative-option (0.1.0)
default_value_for (3.0.5)
activerecord (>= 3.2.0, < 5.2)
descendants_tracker (0.0.4) descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1) thread_safe (~> 0.3, >= 0.3.1)
device_detector (1.0.0) device_detector (1.0.0)
...@@ -277,6 +275,8 @@ GEM ...@@ -277,6 +275,8 @@ GEM
gitaly-proto (0.123.0) gitaly-proto (0.123.0)
grpc (~> 1.0) grpc (~> 1.0)
github-markup (1.7.0) github-markup (1.7.0)
gitlab-default_value_for (3.1.1)
activerecord (>= 3.2.0, < 6.0)
gitlab-markup (1.6.5) gitlab-markup (1.6.5)
gitlab-sidekiq-fetcher (0.3.0) gitlab-sidekiq-fetcher (0.3.0)
sidekiq (~> 5) sidekiq (~> 5)
...@@ -971,7 +971,6 @@ DEPENDENCIES ...@@ -971,7 +971,6 @@ DEPENDENCIES
creole (~> 0.5.0) creole (~> 0.5.0)
database_cleaner (~> 1.5.0) database_cleaner (~> 1.5.0)
deckar01-task_list (= 2.0.0) deckar01-task_list (= 2.0.0)
default_value_for (~> 3.0.5)
device_detector device_detector
devise (~> 4.4) devise (~> 4.4)
devise-two-factor (~> 3.0.0) devise-two-factor (~> 3.0.0)
...@@ -1007,6 +1006,7 @@ DEPENDENCIES ...@@ -1007,6 +1006,7 @@ DEPENDENCIES
gettext_i18n_rails_js (~> 1.3) gettext_i18n_rails_js (~> 1.3)
gitaly-proto (~> 0.123.0) gitaly-proto (~> 0.123.0)
github-markup (~> 1.7.0) github-markup (~> 1.7.0)
gitlab-default_value_for (~> 3.1.1)
gitlab-markup (~> 1.6.5) gitlab-markup (~> 1.6.5)
gitlab-sidekiq-fetcher gitlab-sidekiq-fetcher
gitlab-styles (~> 2.4) gitlab-styles (~> 2.4)
......
...@@ -28,7 +28,7 @@ module Users ...@@ -28,7 +28,7 @@ module Users
identity_attrs = params.slice(:extern_uid, :provider) identity_attrs = params.slice(:extern_uid, :provider)
if identity_attrs.any? unless identity_attrs.empty?
user.identities.build(identity_attrs) user.identities.build(identity_attrs)
end end
......
---
title: Fixes an issue where default values from models would override values set in
the interface (e.g. users would be set to external even though their emails matches
the internal email address pattern)
merge_request: 23114
author:
type: fixed
...@@ -8,7 +8,7 @@ describe Users::BuildService do ...@@ -8,7 +8,7 @@ describe Users::BuildService do
context 'with an admin user' do context 'with an admin user' do
let(:admin_user) { create(:admin) } let(:admin_user) { create(:admin) }
let(:service) { described_class.new(admin_user, params) } let(:service) { described_class.new(admin_user, ActionController::Parameters.new(params).permit!) }
it 'returns a valid user' do it 'returns a valid user' do
expect(service.execute).to be_valid expect(service.execute).to be_valid
......
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