Ensure versions params play well with plugins

pull/3625/head
Mohamed Wael Khobalatte 9 years ago
parent a1bf92212d
commit 602dd749e3
  1. 1
      Gemfile.lock
  2. 12
      app/controllers/copy_projects_controller.rb
  3. 2
      app/controllers/versions_controller.rb
  4. 20
      app/models/permitted_params.rb

@ -584,7 +584,6 @@ DEPENDENCIES
parallel_tests parallel_tests
pg (~> 0.18.3) pg (~> 0.18.3)
poltergeist poltergeist
protected_attributes
prototype-rails! prototype-rails!
prototype_legacy_helper (= 0.0.0)! prototype_legacy_helper (= 0.0.0)!
pry-byebug pry-byebug

@ -41,12 +41,12 @@ class CopyProjectsController < ApplicationController
@copy_project.attributes = permitted_params.project @copy_project.attributes = permitted_params.project
if @copy_project.valid? if @copy_project.valid?
modules = permitted_params.project[:enabled_module_names] || params[:enabled_modules] modules = permitted_params.project[:enabled_module_names] || params[:enabled_modules]
copy_project_job = CopyProjectJob.new(User.current.id, copy_project_job = CopyProjectJob.new(user_id: User.current.id,
@project.id, source_project_id: @project.id,
permitted_params.project, target_project_params: permitted_params.project,
modules, enabled_modules: modules,
params[:only], associations_to_copy: params[:only],
params[:notifications] == '1') send_mails: params[:notifications] == '1')
Delayed::Job.enqueue copy_project_job Delayed::Job.enqueue copy_project_job
flash[:notice] = I18n.t('copy_project.started', flash[:notice] = I18n.t('copy_project.started',

@ -109,7 +109,7 @@ class VersionsController < ApplicationController
end end
def update def update
if request.patch? && permitted_params.version.present? if request.patch? && permitted_params.version
attributes = permitted_params.version.dup attributes = permitted_params.version.dup
attributes.delete('sharing') unless @version.allowed_sharings.include?(attributes['sharing']) attributes.delete('sharing') unless @version.allowed_sharings.include?(attributes['sharing'])
@version.attributes = attributes @version.attributes = attributes

@ -272,10 +272,6 @@ class PermittedParams
:theme) :theme)
end end
def membership
params.require(:membership).permit(:project_id, role_ids: [])
end
def project(instance = nil) def project(instance = nil)
whitelist = params.require(:project).permit(:name, whitelist = params.require(:project).permit(:name,
:description, :description,
@ -292,8 +288,7 @@ class PermittedParams
whitelist.permit(enabled_module_names: []) whitelist.permit(enabled_module_names: [])
end end
whitelist.tap do unless params[:project][:custom_field_values].nil?
break if params[:project][:custom_field_values].nil?
whitelist[:custom_field_values] = params[:project][:custom_field_values] whitelist[:custom_field_values] = params[:project][:custom_field_values]
end end
@ -314,6 +309,9 @@ class PermittedParams
end end
def version def version
# `version_settings_attributes` is from a plugin. Unfortunately as it stands
# now it is less work to do it this way than have the plugin override this
# method. We hopefully will change this in the future.
params.require(:version).permit(:name, params.require(:version).permit(:name,
:description, :description,
:effective_date, :effective_date,
@ -322,7 +320,8 @@ class PermittedParams
:wiki_page_title, :wiki_page_title,
:status, :status,
:sharing, :sharing,
:custom_field_value) :custom_field_value,
version_settings_attributes: [:id, :display, :project])
end end
def comment def comment
@ -389,6 +388,10 @@ class PermittedParams
params.fetch(:reporting, {}).permit(:reporting_to_project_id, :reported_project_status_id, :reported_project_status_comment) params.fetch(:reporting, {}).permit(:reporting_to_project_id, :reported_project_status_id, :reported_project_status_comment)
end end
def membership
params.require(:membership).permit(*self.class.permitted_attributes[:membership])
end
protected protected
def custom_field_values(key) def custom_field_values(key)
@ -469,6 +472,9 @@ class PermittedParams
:reassign_to_id], :reassign_to_id],
group: [ group: [
:lastname], :lastname],
membership: [
:project_id,
role_ids: []],
group_membership: [ group_membership: [
:membership_id, :membership_id,
membership: [ membership: [

Loading…
Cancel
Save