remove planning_element from permitted_params

pull/6141/head
Jens Ulferts 7 years ago committed by Oliver Günther
parent 5370e146df
commit dd80b0d670
  1. 70
      app/models/permitted_params.rb
  2. 45
      spec/models/permitted_params_spec.rb

@ -120,26 +120,6 @@ class PermittedParams
params.require(:member).permit(*self.class.permitted_attributes[:member])
end
def planning_element_type
params.require(:planning_element_type)
.permit(*self.class.permitted_attributes[:planning_element_type])
end
def planning_element_type_move
params.require(:planning_element_type)
.permit(*self.class.permitted_attributes[:move_to])
end
def planning_element(args = {})
permitted = permitted_attributes(:planning_element, args)
permitted_params = params.require(:planning_element).permit(*permitted)
permitted_params = permitted_params.merge(custom_field_values(:planning_element))
permitted_params
end
def project_type
params.require(:project_type).permit(*self.class.permitted_attributes[:project_type])
end
@ -522,7 +502,6 @@ class PermittedParams
member: [
role_ids: []],
new_work_package: [
# attributes common with :planning_element below
:assigned_to_id,
{ attachments: [:file, :description] },
:category_id,
@ -559,55 +538,6 @@ class PermittedParams
# attributes unique to :new_work_package
:journal_notes,
:lock_version],
planning_element: [
# attributes common with :new_work_package above
:assigned_to_id,
{ attachments: [:file, :description] },
:category_id,
:description,
:done_ratio,
:due_date,
:estimated_hours,
:fixed_version_id,
:parent_id,
:priority_id,
:responsible_id,
:start_date,
:status_id,
:type_id,
:subject,
Proc.new do |args|
# avoid costly allowed_to? if the param is not there at all
if args[:params]['planning_element'] &&
args[:params]['planning_element'].has_key?('watcher_user_ids') &&
args[:current_user].allowed_to?(:add_work_package_watchers, args[:project])
{ watcher_user_ids: [] }
end
end,
Proc.new do |args|
# avoid costly allowed_to? if the param is not there at all
if args[:params]['planning_element'] &&
args[:params]['planning_element'].has_key?('time_entry') &&
args[:current_user].allowed_to?(:log_time, args[:project])
{ time_entry: [:hours, :activity_id, :comments] }
end
end,
# attributes unique to planning_element
:note,
custom_fields: [ # json
:id,
:value,
custom_field: [ # xml
:id,
:value]]],
planning_element_type: [
:name,
:in_aggregation,
:is_milestone,
:is_default,
:color_id],
project_type: [
:name,
:allows_association,

@ -387,51 +387,6 @@ describe PermittedParams, type: :model do
it_behaves_like 'allows params'
end
describe '#planning_element_type' do
let(:attribute) { :planning_element_type }
context 'name' do
let(:hash) { { 'name' => 'blubs' } }
it_behaves_like 'allows params'
end
context 'in_aggregation' do
let(:hash) { { 'in_aggregation' => '1' } }
it_behaves_like 'allows params'
end
context 'is_milestone' do
let(:hash) { { 'is_milestone' => '1' } }
it_behaves_like 'allows params'
end
context 'is_default' do
let(:hash) { { 'is_default' => '1' } }
it_behaves_like 'allows params'
end
context 'color_id' do
let(:hash) { { 'color_id' => '1' } }
it_behaves_like 'allows params'
end
end
describe '#planning_element_type_move' do
let(:attribute) { :planning_element_type_move }
let(:hash_key) { 'planning_element_type' }
context 'move_to' do
let(:hash) { { 'move_to' => '1' } }
it_behaves_like 'allows params'
end
end
describe "#update_work_package" do
let(:attribute) { :update_work_package }
let(:hash_key) { 'work_package' }

Loading…
Cancel
Save