|
|
|
@ -35,17 +35,19 @@ describe PermittedParams, type: :model do |
|
|
|
|
shared_context 'prepare params comparison' do |
|
|
|
|
let(:params_key) { defined?(hash_key) ? hash_key : attribute } |
|
|
|
|
let(:params) do |
|
|
|
|
nested_params = if defined?(nested_key) |
|
|
|
|
{nested_key => hash} |
|
|
|
|
else |
|
|
|
|
hash |
|
|
|
|
end |
|
|
|
|
nested_params = |
|
|
|
|
if defined?(nested_key) |
|
|
|
|
{ nested_key => hash } |
|
|
|
|
else |
|
|
|
|
hash |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
ac_params = if defined?(flat) && flat |
|
|
|
|
nested_params |
|
|
|
|
else |
|
|
|
|
{params_key => nested_params} |
|
|
|
|
end |
|
|
|
|
ac_params = |
|
|
|
|
if defined?(flat) && flat |
|
|
|
|
nested_params |
|
|
|
|
else |
|
|
|
|
{ params_key => nested_params } |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
ActionController::Parameters.new(ac_params) |
|
|
|
|
end |
|
|
|
@ -81,7 +83,7 @@ describe PermittedParams, type: :model do |
|
|
|
|
# taking the originally whitelisted params to be restored later |
|
|
|
|
original_whitelisted = PermittedParams.instance_variable_get(:@whitelisted_params) |
|
|
|
|
|
|
|
|
|
params = ActionController::Parameters.new(project_type: {'blubs1' => 'blubs'}) |
|
|
|
|
params = ActionController::Parameters.new(project_type: { 'blubs1' => 'blubs' }) |
|
|
|
|
|
|
|
|
|
PermittedParams.instance_variable_set(:@whitelisted_params, original_whitelisted) |
|
|
|
|
end |
|
|
|
@ -114,7 +116,7 @@ describe PermittedParams, type: :model do |
|
|
|
|
|
|
|
|
|
acceptable_params_with_data = HashWithIndifferentAccess[acceptable_params.map { |x| [x, 'value'] }] |
|
|
|
|
|
|
|
|
|
acceptable_params_with_data['custom_field_values'] = {'1' => 'foo', '2' => 'bar', '3' => 'baz'} |
|
|
|
|
acceptable_params_with_data['custom_field_values'] = { '1' => 'foo', '2' => 'bar', '3' => 'baz' } |
|
|
|
|
|
|
|
|
|
acceptable_params_with_data |
|
|
|
|
end |
|
|
|
@ -177,7 +179,7 @@ describe PermittedParams, type: :model do |
|
|
|
|
describe '#membership' do |
|
|
|
|
let(:attribute) { :membership } |
|
|
|
|
let(:hash) do |
|
|
|
|
{'project_id' => '1', 'role_ids' => ['1', '2', '4']} |
|
|
|
|
{ 'project_id' => '1', 'role_ids' => ['1', '2', '4'] } |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
@ -211,7 +213,7 @@ describe PermittedParams, type: :model do |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'custom field values' do |
|
|
|
|
let(:hash) { {'custom_field_values' => {'1' => '5'}} } |
|
|
|
|
let(:hash) { { 'custom_field_values' => { '1' => '5' } } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
@ -242,11 +244,11 @@ describe PermittedParams, type: :model do |
|
|
|
|
let(:instance) { double('message', project: double('project')) } |
|
|
|
|
let(:project) { double('project') } |
|
|
|
|
let(:allowed_params) do |
|
|
|
|
{'subject' => 'value', |
|
|
|
|
'content' => 'value', |
|
|
|
|
'forum_id' => 'value', |
|
|
|
|
'sticky' => 'true', |
|
|
|
|
'locked' => 'true'} |
|
|
|
|
{ 'subject' => 'value', |
|
|
|
|
'content' => 'value', |
|
|
|
|
'forum_id' => 'value', |
|
|
|
|
'sticky' => 'true', |
|
|
|
|
'locked' => 'true' } |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
let(:hash) do |
|
|
|
@ -269,8 +271,8 @@ describe PermittedParams, type: :model do |
|
|
|
|
let(:attribute) { :attachments } |
|
|
|
|
|
|
|
|
|
let(:hash) do |
|
|
|
|
{'file' => 'myfile', |
|
|
|
|
'description' => 'mydescription'} |
|
|
|
|
{ 'file' => 'myfile', |
|
|
|
|
'description' => 'mydescription' } |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
@ -281,7 +283,7 @@ describe PermittedParams, type: :model do |
|
|
|
|
let(:hash_key) { 'project' } |
|
|
|
|
|
|
|
|
|
let(:hash) do |
|
|
|
|
{'type_ids' => ['1', '', '2']} |
|
|
|
|
{ 'type_ids' => ['1', '', '2'] } |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
let(:allowed_params) do |
|
|
|
@ -301,8 +303,8 @@ describe PermittedParams, type: :model do |
|
|
|
|
let(:attribute) { :color } |
|
|
|
|
|
|
|
|
|
let(:hash) do |
|
|
|
|
{'name' => 'blubs', |
|
|
|
|
'hexcode' => '#fff'} |
|
|
|
|
{ 'name' => 'blubs', |
|
|
|
|
'hexcode' => '#fff' } |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
@ -313,7 +315,7 @@ describe PermittedParams, type: :model do |
|
|
|
|
let(:hash_key) { 'color' } |
|
|
|
|
|
|
|
|
|
let(:hash) do |
|
|
|
|
{'move_to' => '1'} |
|
|
|
|
{ 'move_to' => '1' } |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
@ -323,7 +325,7 @@ describe PermittedParams, type: :model do |
|
|
|
|
let(:attribute) { :custom_field } |
|
|
|
|
|
|
|
|
|
let(:hash) do |
|
|
|
|
{'editable' => '0', 'visible' => '0'} |
|
|
|
|
{ 'editable' => '0', 'visible' => '0' } |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
@ -335,8 +337,8 @@ describe PermittedParams, type: :model do |
|
|
|
|
{ |
|
|
|
|
'name' => 'blubs', |
|
|
|
|
'description' => 'blubs blubs', |
|
|
|
|
'actions' => {'assigned_to' => '1'}, |
|
|
|
|
'conditions' => {'status' => '42'}, |
|
|
|
|
'actions' => { 'assigned_to' => '1' }, |
|
|
|
|
'conditions' => { 'status' => '42' }, |
|
|
|
|
'move_to' => 'lower' |
|
|
|
|
} |
|
|
|
|
end |
|
|
|
@ -349,116 +351,116 @@ describe PermittedParams, type: :model do |
|
|
|
|
let(:hash_key) { 'work_package' } |
|
|
|
|
|
|
|
|
|
context 'subject' do |
|
|
|
|
let(:hash) { {'subject' => 'blubs'} } |
|
|
|
|
let(:hash) { { 'subject' => 'blubs' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'description' do |
|
|
|
|
let(:hash) { {'description' => 'blubs'} } |
|
|
|
|
let(:hash) { { 'description' => 'blubs' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'start_date' do |
|
|
|
|
let(:hash) { {'start_date' => '2013-07-08'} } |
|
|
|
|
let(:hash) { { 'start_date' => '2013-07-08' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'due_date' do |
|
|
|
|
let(:hash) { {'due_date' => '2013-07-08'} } |
|
|
|
|
let(:hash) { { 'due_date' => '2013-07-08' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'assigned_to_id' do |
|
|
|
|
let(:hash) { {'assigned_to_id' => '1'} } |
|
|
|
|
let(:hash) { { 'assigned_to_id' => '1' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'responsible_id' do |
|
|
|
|
let(:hash) { {'responsible_id' => '1'} } |
|
|
|
|
let(:hash) { { 'responsible_id' => '1' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'type_id' do |
|
|
|
|
let(:hash) { {'type_id' => '1'} } |
|
|
|
|
let(:hash) { { 'type_id' => '1' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'priority_id' do |
|
|
|
|
let(:hash) { {'priority_id' => '1'} } |
|
|
|
|
let(:hash) { { 'priority_id' => '1' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'parent_id' do |
|
|
|
|
let(:hash) { {'parent_id' => '1'} } |
|
|
|
|
let(:hash) { { 'parent_id' => '1' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'parent_id' do |
|
|
|
|
let(:hash) { {'parent_id' => '1'} } |
|
|
|
|
let(:hash) { { 'parent_id' => '1' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'version_id' do |
|
|
|
|
let(:hash) { {'version_id' => '1'} } |
|
|
|
|
let(:hash) { { 'version_id' => '1' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'estimated_hours' do |
|
|
|
|
let(:hash) { {'estimated_hours' => '1'} } |
|
|
|
|
let(:hash) { { 'estimated_hours' => '1' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'done_ratio' do |
|
|
|
|
let(:hash) { {'done_ratio' => '1'} } |
|
|
|
|
let(:hash) { { 'done_ratio' => '1' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'lock_version' do |
|
|
|
|
let(:hash) { {'lock_version' => '1'} } |
|
|
|
|
let(:hash) { { 'lock_version' => '1' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'status_id' do |
|
|
|
|
let(:hash) { {'status_id' => '1'} } |
|
|
|
|
let(:hash) { { 'status_id' => '1' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'category_id' do |
|
|
|
|
let(:hash) { {'category_id' => '1'} } |
|
|
|
|
let(:hash) { { 'category_id' => '1' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'notes' do |
|
|
|
|
let(:hash) { {'journal_notes' => 'blubs'} } |
|
|
|
|
let(:hash) { { 'journal_notes' => 'blubs' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'attachments' do |
|
|
|
|
let(:hash) { {'attachments' => [{'file' => 'djskfj', 'description' => 'desc'}]} } |
|
|
|
|
let(:hash) { { 'attachments' => [{ 'file' => 'djskfj', 'description' => 'desc' }] } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'watcher_user_ids' do |
|
|
|
|
include_context 'prepare params comparison' |
|
|
|
|
let(:hash) { {'watcher_user_ids' => ['1', '2']} } |
|
|
|
|
let(:hash) { { 'watcher_user_ids' => ['1', '2'] } } |
|
|
|
|
let(:project) { double('project') } |
|
|
|
|
|
|
|
|
|
before do |
|
|
|
@ -487,7 +489,7 @@ describe PermittedParams, type: :model do |
|
|
|
|
context 'time_entry' do |
|
|
|
|
include_context 'prepare params comparison' |
|
|
|
|
|
|
|
|
|
let(:hash) { {'time_entry' => {'hours' => '5', 'activity_id' => '1', 'comments' => 'lorem'}} } |
|
|
|
|
let(:hash) { { 'time_entry' => { 'hours' => '5', 'activity_id' => '1', 'comments' => 'lorem' } } } |
|
|
|
|
let(:project) { double('project') } |
|
|
|
|
|
|
|
|
|
before do |
|
|
|
@ -514,13 +516,13 @@ describe PermittedParams, type: :model do |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'custom field values' do |
|
|
|
|
let(:hash) { {'custom_field_values' => {'1' => '5'}} } |
|
|
|
|
let(:hash) { { 'custom_field_values' => { '1' => '5' } } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "removes custom field values that do not follow the schema 'id as string' => 'value as string'" do |
|
|
|
|
let(:hash) { {'custom_field_values' => {'blubs' => '5', '5' => {'1' => '2'}}} } |
|
|
|
|
let(:hash) { { 'custom_field_values' => { 'blubs' => '5', '5' => { '1' => '2' } } } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'forbids params' |
|
|
|
|
end |
|
|
|
@ -530,12 +532,12 @@ describe PermittedParams, type: :model do |
|
|
|
|
let(:attribute) { :time_entry_activities_project } |
|
|
|
|
let(:hash) do |
|
|
|
|
[ |
|
|
|
|
{"activity_id" => "5", "active" => "0"}, |
|
|
|
|
{"activity_id" => "6", "active" => "1"} |
|
|
|
|
{ "activity_id" => "5", "active" => "0" }, |
|
|
|
|
{ "activity_id" => "6", "active" => "1" } |
|
|
|
|
] |
|
|
|
|
end |
|
|
|
|
let(:allowed_params) do |
|
|
|
|
[{"activity_id" => "5", "active" => "0"}, {"activity_id" => "6", "active" => "1"}] |
|
|
|
|
[{ "activity_id" => "5", "active" => "0" }, { "activity_id" => "6", "active" => "1" }] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' do |
|
|
|
@ -579,7 +581,7 @@ describe PermittedParams, type: :model do |
|
|
|
|
|
|
|
|
|
admin_permissions.each do |field| |
|
|
|
|
context field do |
|
|
|
|
let(:hash) { {field => 'test'} } |
|
|
|
|
let(:hash) { { field => 'test' } } |
|
|
|
|
|
|
|
|
|
it "permits #{field}" do |
|
|
|
|
expect(subject).to eq(field => 'test') |
|
|
|
@ -588,7 +590,7 @@ describe PermittedParams, type: :model do |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'with no password change allowed' do |
|
|
|
|
let(:hash) { {'force_password_change' => 'true'} } |
|
|
|
|
let(:hash) { { 'force_password_change' => 'true' } } |
|
|
|
|
let(:change_password_allowed) { false } |
|
|
|
|
|
|
|
|
|
it 'does not permit force_password_change' do |
|
|
|
@ -597,7 +599,7 @@ describe PermittedParams, type: :model do |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'with external authentication' do |
|
|
|
|
let(:hash) { {'auth_source_id' => 'true'} } |
|
|
|
|
let(:hash) { { 'auth_source_id' => 'true' } } |
|
|
|
|
let(:external_authentication) { true } |
|
|
|
|
|
|
|
|
|
it 'does not permit auth_source_id' do |
|
|
|
@ -606,7 +608,7 @@ describe PermittedParams, type: :model do |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'custom field values' do |
|
|
|
|
let(:hash) { {'custom_field_values' => {'1' => '5'}} } |
|
|
|
|
let(:hash) { { 'custom_field_values' => { '1' => '5' } } } |
|
|
|
|
|
|
|
|
|
it 'permits custom_field_values' do |
|
|
|
|
expect(subject).to eq(hash) |
|
|
|
@ -614,7 +616,7 @@ describe PermittedParams, type: :model do |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "custom field values that do not follow the schema 'id as string' => 'value as string'" do |
|
|
|
|
let(:hash) { {'custom_field_values' => {'blubs' => '5', '5' => {'1' => '2'}}} } |
|
|
|
|
let(:hash) { { 'custom_field_values' => { 'blubs' => '5', '5' => { '1' => '2' } } } } |
|
|
|
|
|
|
|
|
|
it 'are removed' do |
|
|
|
|
expect(subject).to eq({}) |
|
|
|
@ -638,7 +640,7 @@ describe PermittedParams, type: :model do |
|
|
|
|
|
|
|
|
|
user_permissions.each do |field| |
|
|
|
|
context field do |
|
|
|
|
let(:hash) { {field => 'test'} } |
|
|
|
|
let(:hash) { { field => 'test' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
@ -646,26 +648,26 @@ describe PermittedParams, type: :model do |
|
|
|
|
|
|
|
|
|
(admin_permissions - user_permissions).each do |field| |
|
|
|
|
context "#{field} (admin-only)" do |
|
|
|
|
let(:hash) { {field => 'test'} } |
|
|
|
|
let(:hash) { { field => 'test' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'forbids params' |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'custom field values' do |
|
|
|
|
let(:hash) { {'custom_field_values' => {'1' => '5'}} } |
|
|
|
|
let(:hash) { { 'custom_field_values' => { '1' => '5' } } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context "custom field values that do not follow the schema 'id as string' => 'value as string'" do |
|
|
|
|
let(:hash) { {'custom_field_values' => {'blubs' => '5', '5' => {'1' => '2'}}} } |
|
|
|
|
let(:hash) { { 'custom_field_values' => { 'blubs' => '5', '5' => { '1' => '2' } } } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'forbids params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'identity_url' do |
|
|
|
|
let(:hash) { {'identity_url' => 'test_identity_url'} } |
|
|
|
|
let(:hash) { { 'identity_url' => 'test_identity_url' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'forbids params' |
|
|
|
|
end |
|
|
|
@ -679,39 +681,39 @@ describe PermittedParams, type: :model do |
|
|
|
|
user_permissions = %w(login firstname lastname mail language) |
|
|
|
|
|
|
|
|
|
user_permissions.each do |field| |
|
|
|
|
let(:hash) { {field => 'test'} } |
|
|
|
|
let(:hash) { { field => 'test' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'identity_url' do |
|
|
|
|
let(:hash) { {'identity_url' => 'test_identity_url'} } |
|
|
|
|
let(:hash) { { 'identity_url' => 'test_identity_url' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'forbids params' |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
shared_examples_for 'allows enumeration move params' do |
|
|
|
|
let(:hash) { {'2' => {'move_to' => 'lower'}} } |
|
|
|
|
let(:hash) { { '2' => { 'move_to' => 'lower' } } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
shared_examples_for 'allows move params' do |
|
|
|
|
let(:hash) { {'move_to' => 'lower'} } |
|
|
|
|
let(:hash) { { 'move_to' => 'lower' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
shared_examples_for 'allows custom fields' do |
|
|
|
|
describe 'valid custom fields' do |
|
|
|
|
let(:hash) { {'1' => {'custom_field_values' => {'1' => '5'}}} } |
|
|
|
|
let(:hash) { { '1' => { 'custom_field_values' => { '1' => '5' } } } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe 'invalid custom fields' do |
|
|
|
|
let(:hash) { {'custom_field_values' => {'blubs' => '5', '5' => {'1' => '2'}}} } |
|
|
|
|
let(:hash) { { 'custom_field_values' => { 'blubs' => '5', '5' => { '1' => '2' } } } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'forbids params' |
|
|
|
|
end |
|
|
|
@ -721,25 +723,25 @@ describe PermittedParams, type: :model do |
|
|
|
|
let (:attribute) { :status } |
|
|
|
|
|
|
|
|
|
describe 'name' do |
|
|
|
|
let(:hash) { {'name' => 'blubs'} } |
|
|
|
|
let(:hash) { { 'name' => 'blubs' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe 'default_done_ratio' do |
|
|
|
|
let(:hash) { {'default_done_ratio' => '10'} } |
|
|
|
|
let(:hash) { { 'default_done_ratio' => '10' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe 'is_closed' do |
|
|
|
|
let(:hash) { {'is_closed' => 'true'} } |
|
|
|
|
let(:hash) { { 'is_closed' => 'true' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe 'is_default' do |
|
|
|
|
let(:hash) { {'is_default' => 'true'} } |
|
|
|
|
let(:hash) { { 'is_default' => 'true' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
@ -765,7 +767,7 @@ describe PermittedParams, type: :model do |
|
|
|
|
'brute_force_block_after_failed_logins' => 'value', |
|
|
|
|
'password_active_rules' => ['value'], |
|
|
|
|
'default_projects_modules' => ['value', 'value'], |
|
|
|
|
'emails_footer' => {'en' => 'value'} |
|
|
|
|
'emails_footer' => { 'en' => 'value' } |
|
|
|
|
} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
@ -787,7 +789,7 @@ describe PermittedParams, type: :model do |
|
|
|
|
'brute_force_block_after_failed_logins' => 'value', |
|
|
|
|
'password_active_rules' => ['value'], |
|
|
|
|
'default_projects_modules' => ['value', 'value'], |
|
|
|
|
'emails_footer' => {'en' => 'value'} |
|
|
|
|
'emails_footer' => { 'en' => 'value' } |
|
|
|
|
} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
@ -796,7 +798,7 @@ describe PermittedParams, type: :model do |
|
|
|
|
'sendmail_arguments' => 'value', |
|
|
|
|
'brute_force_block_after_failed_logins' => 'value', |
|
|
|
|
'default_projects_modules' => ['value', 'value'], |
|
|
|
|
'emails_footer' => {'en' => 'value'} |
|
|
|
|
'emails_footer' => { 'en' => 'value' } |
|
|
|
|
} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
@ -850,25 +852,25 @@ describe PermittedParams, type: :model do |
|
|
|
|
let (:attribute) { :enumerations } |
|
|
|
|
|
|
|
|
|
describe 'name' do |
|
|
|
|
let(:hash) { {'1' => {'name' => 'blubs'}} } |
|
|
|
|
let(:hash) { { '1' => { 'name' => 'blubs' } } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe 'active' do |
|
|
|
|
let(:hash) { {'1' => {'active' => 'true'}} } |
|
|
|
|
let(:hash) { { '1' => { 'active' => 'true' } } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe 'is_default' do |
|
|
|
|
let(:hash) { {'1' => {'is_default' => 'true'}} } |
|
|
|
|
let(:hash) { { '1' => { 'is_default' => 'true' } } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe 'reassign_to_id' do |
|
|
|
|
let(:hash) { {'1' => {'reassign_to_id' => '1'}} } |
|
|
|
|
let(:hash) { { '1' => { 'reassign_to_id' => '1' } } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
@ -887,13 +889,13 @@ describe PermittedParams, type: :model do |
|
|
|
|
let (:attribute) { :wiki_page_rename } |
|
|
|
|
|
|
|
|
|
describe 'title' do |
|
|
|
|
let(:hash) { {'title' => 'blubs'} } |
|
|
|
|
let(:hash) { { 'title' => 'blubs' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe 'redirect_existing_links' do |
|
|
|
|
let(:hash) { {'redirect_existing_links' => '1'} } |
|
|
|
|
let(:hash) { { 'redirect_existing_links' => '1' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
@ -905,19 +907,19 @@ describe PermittedParams, type: :model do |
|
|
|
|
let (:attribute) { :wiki_page } |
|
|
|
|
|
|
|
|
|
describe 'title' do |
|
|
|
|
let(:hash) { {'title' => 'blubs'} } |
|
|
|
|
let(:hash) { { 'title' => 'blubs' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows nested params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe 'parent_id' do |
|
|
|
|
let(:hash) { {'parent_id' => '1'} } |
|
|
|
|
let(:hash) { { 'parent_id' => '1' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows nested params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe 'redirect_existing_links' do |
|
|
|
|
let(:hash) { {'redirect_existing_links' => '1'} } |
|
|
|
|
let(:hash) { { 'redirect_existing_links' => '1' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows nested params' |
|
|
|
|
end |
|
|
|
@ -928,19 +930,19 @@ describe PermittedParams, type: :model do |
|
|
|
|
let (:attribute) { :wiki_content } |
|
|
|
|
|
|
|
|
|
describe 'title' do |
|
|
|
|
let(:hash) { {'comments' => 'blubs'} } |
|
|
|
|
let(:hash) { { 'comments' => 'blubs' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe 'text' do |
|
|
|
|
let(:hash) { {'text' => 'blubs'} } |
|
|
|
|
let(:hash) { { 'text' => 'blubs' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe 'lock_version' do |
|
|
|
|
let(:hash) { {'lock_version' => '1'} } |
|
|
|
|
let(:hash) { { 'lock_version' => '1' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
@ -950,31 +952,31 @@ describe PermittedParams, type: :model do |
|
|
|
|
let (:attribute) { :member } |
|
|
|
|
|
|
|
|
|
describe 'role_ids' do |
|
|
|
|
let(:hash) { {'role_ids' => []} } |
|
|
|
|
let(:hash) { { 'role_ids' => [] } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe 'user_id' do |
|
|
|
|
let(:hash) { {'user_id' => 'blubs'} } |
|
|
|
|
let(:hash) { { 'user_id' => 'blubs' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'forbids params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe 'project_id' do |
|
|
|
|
let(:hash) { {'user_id' => 'blubs'} } |
|
|
|
|
let(:hash) { { 'user_id' => 'blubs' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'forbids params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe 'created_on' do |
|
|
|
|
let(:hash) { {'created_on' => 'blubs'} } |
|
|
|
|
let(:hash) { { 'created_on' => 'blubs' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'forbids params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
describe 'mail_notification' do |
|
|
|
|
let(:hash) { {'mail_notification' => 'blubs'} } |
|
|
|
|
let(:hash) { { 'mail_notification' => 'blubs' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'forbids params' |
|
|
|
|
end |
|
|
|
@ -1002,13 +1004,13 @@ describe PermittedParams, type: :model do |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'with an allowed parameter' do |
|
|
|
|
let(:hash) { {'a_test_field' => 'a test value'} } |
|
|
|
|
let(:hash) { { 'a_test_field' => 'a test value' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'allows params' |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
context 'with a disallowed parameter' do |
|
|
|
|
let(:hash) { {'a_not_allowed_field' => 'a test value'} } |
|
|
|
|
let(:hash) { { 'a_not_allowed_field' => 'a test value' } } |
|
|
|
|
|
|
|
|
|
it_behaves_like 'forbids params' |
|
|
|
|
end |
|
|
|
@ -1016,7 +1018,7 @@ describe PermittedParams, type: :model do |
|
|
|
|
|
|
|
|
|
describe 'with an unknown key' do |
|
|
|
|
let(:attribute) { :unknown_key } |
|
|
|
|
let(:hash) { {'a_test_field' => 'a test value'} } |
|
|
|
|
let(:hash) { { 'a_test_field' => 'a test value' } } |
|
|
|
|
|
|
|
|
|
before do |
|
|
|
|
expect(Rails.logger).not_to receive(:warn) |
|
|
|
|