Fix indentation from editorconfig

pull/8324/head
Oliver Günther 5 years ago
parent d16859ba77
commit dab04415c4
No known key found for this signature in database
GPG Key ID: A3A8BDAD7C0C552C
  1. 2
      .editorconfig
  2. 194
      spec/models/permitted_params_spec.rb
  3. 38
      spec/models/queries/work_packages/filter/assigned_to_filter_spec.rb
  4. 32
      spec_legacy/functional/users_controller_spec.rb

@ -474,7 +474,7 @@ ij_ruby_spaces_around_other_operators = true
ij_ruby_spaces_around_range_operators = false
ij_ruby_spaces_around_relational_operators = true
ij_ruby_spaces_within_array_initializer_braces = true
ij_ruby_spaces_within_braces = false
ij_ruby_spaces_within_braces = true
[{version-autocompleter.component.ts,*.ats,*.ts}]
ij_continuation_indent_size = 2

@ -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)

@ -61,7 +61,7 @@ describe Queries::WorkPackages::Filter::AssignedToFilter, type: :model do
before do
allow(User)
.to receive(:current)
.and_return(assignee)
.and_return(assignee)
end
it 'returns the work package' do
@ -84,7 +84,7 @@ describe Queries::WorkPackages::Filter::AssignedToFilter, type: :model do
before do
allow(User)
.to receive(:current)
.and_return(FactoryBot.create(:user))
.and_return(FactoryBot.create(:user))
end
it 'does not return the work package' do
@ -106,7 +106,7 @@ describe Queries::WorkPackages::Filter::AssignedToFilter, type: :model do
allow(User)
.to receive(:current)
.and_return(user)
.and_return(user)
end
it 'returns the mapped value' do
@ -191,10 +191,10 @@ describe Queries::WorkPackages::Filter::AssignedToFilter, type: :model do
loader = double('principal_loader')
allow(loader)
.to receive(:user_values)
.and_return(user_values)
.and_return(user_values)
allow(loader)
.to receive(:group_values)
.and_return(group_values)
.and_return(group_values)
loader
end
@ -218,8 +218,8 @@ describe Queries::WorkPackages::Filter::AssignedToFilter, type: :model do
before do
allow(Queries::WorkPackages::Filter::PrincipalLoader)
.to receive(:new)
.with(project)
.and_return(principal_loader)
.with(project)
.and_return(principal_loader)
end
describe '#available?' do
@ -228,7 +228,7 @@ describe Queries::WorkPackages::Filter::AssignedToFilter, type: :model do
before do
allow(User)
.to receive_message_chain(:current, :logged?)
.and_return(logged_in)
.and_return(logged_in)
end
context 'when being logged in' do
@ -239,7 +239,7 @@ describe Queries::WorkPackages::Filter::AssignedToFilter, type: :model do
it 'is true if there is another user selectable' do
allow(principal_loader)
.to receive(:user_values)
.and_return([user_1])
.and_return([user_1])
expect(instance).to be_available
end
@ -247,7 +247,7 @@ describe Queries::WorkPackages::Filter::AssignedToFilter, type: :model do
it 'is true if there is another group selectable' do
allow(principal_loader)
.to receive(:group_values)
.and_return([[group_1.name, group_1.id.to_s]])
.and_return([[group_1.name, group_1.id.to_s]])
expect(instance).to be_available
end
@ -263,7 +263,7 @@ describe Queries::WorkPackages::Filter::AssignedToFilter, type: :model do
it 'is true if there is another user selectable' do
allow(principal_loader)
.to receive(:user_values)
.and_return([[user_1.name, user_1.id.to_s]])
.and_return([[user_1.name, user_1.id.to_s]])
expect(instance).to be_available
end
@ -271,7 +271,7 @@ describe Queries::WorkPackages::Filter::AssignedToFilter, type: :model do
it 'is true if there is another group selectable' do
allow(principal_loader)
.to receive(:group_values)
.and_return([[group_1.name, group_1.id.to_s]])
.and_return([[group_1.name, group_1.id.to_s]])
expect(instance).to be_available
end
@ -279,11 +279,11 @@ describe Queries::WorkPackages::Filter::AssignedToFilter, type: :model do
it 'is false if there is another group selectable but the setting is not favourable' do
allow(Setting)
.to receive(:work_package_group_assignment?)
.and_return(false)
.and_return(false)
allow(principal_loader)
.to receive(:group_values)
.and_return([[group_1.name, group_1.id.to_s]])
.and_return([[group_1.name, group_1.id.to_s]])
expect(instance).to_not be_available
end
@ -296,15 +296,15 @@ describe Queries::WorkPackages::Filter::AssignedToFilter, type: :model do
before do
allow(User)
.to receive_message_chain(:current, :logged?)
.and_return(logged_in)
.and_return(logged_in)
allow(principal_loader)
.to receive(:user_values)
.and_return([[user_1.name, user_1.id.to_s]])
.and_return([[user_1.name, user_1.id.to_s]])
allow(principal_loader)
.to receive(:group_values)
.and_return([[group_1.name, group_1.id.to_s]])
.and_return([[group_1.name, group_1.id.to_s]])
end
context 'when being logged in' do
@ -318,7 +318,7 @@ describe Queries::WorkPackages::Filter::AssignedToFilter, type: :model do
it 'returns the me value and only the available users if no group assignmit is allowed' do
allow(Setting)
.to receive(:work_package_group_assignment?)
.and_return(false)
.and_return(false)
expect(instance.allowed_values)
.to match_array([[I18n.t(:label_me), 'me'],
@ -338,7 +338,7 @@ describe Queries::WorkPackages::Filter::AssignedToFilter, type: :model do
it 'returns the available users if no group assignmit is allowed' do
allow(Setting)
.to receive(:work_package_group_assignment?)
.and_return(false)
.and_return(false)
expect(instance.allowed_values)
.to match_array([[user_1.name, user_1.id.to_s]])

@ -55,7 +55,7 @@ describe UsersController, type: :controller do
end
it 'should index with name filter' do
get :index, params: {name: 'john'}
get :index, params: { name: 'john' }
assert_response :success
assert_template 'index'
users = assigns(:users)
@ -65,7 +65,7 @@ describe UsersController, type: :controller do
end
it 'should index with group filter' do
get :index, params: {group_id: '10'}
get :index, params: { group_id: '10' }
assert_response :success
assert_template 'index'
users = assigns(:users)
@ -80,32 +80,32 @@ describe UsersController, type: :controller do
custom_field = CustomField.create!(name: 'Testing', field_format: 'text')
user.custom_values.build(custom_field: custom_field).save!
get :show, params: {id: 2}
get :show, params: { id: 2 }
assert_response :success
end
it 'should show inactive' do
session[:user_id] = nil
get :show, params: {id: 5}
get :show, params: { id: 5 }
assert_response 404
end
it 'should show should not reveal users with no visible activity or project' do
session[:user_id] = nil
get :show, params: {id: 9}
get :show, params: { id: 9 }
assert_response 404
end
it 'should show inactive by admin' do
session[:user_id] = 1
get :show, params: {id: 5}
get :show, params: { id: 5 }
assert_response 200
refute_nil assigns(:user)
end
it 'should show displays memberships based on project visibility' do
session[:user_id] = 1
get :show, params: {id: 2}
get :show, params: { id: 2 }
assert_response :success
memberships = assigns(:memberships)
refute_nil memberships
@ -115,13 +115,13 @@ describe UsersController, type: :controller do
it 'should show current should require authentication' do
session[:user_id] = nil
get :show, params: {id: 'current'}
get :show, params: { id: 'current' }
assert_response 302
end
it 'should show current' do
session[:user_id] = 2
get :show, params: {id: 'current'}
get :show, params: { id: 'current' }
assert_response :success
assert_template 'show'
assert_equal User.find(2), assigns(:user)
@ -183,7 +183,7 @@ describe UsersController, type: :controller do
# Provide at least one user field, otherwise strong_parameters regards the user parameter
# as non-existent and raises ActionController::ParameterMissing, which in turn
# results in a 400.
post :create, params: {user: {login: 'jdoe'}}
post :create, params: { user: { login: 'jdoe' } }
end
assert_response :success
@ -191,7 +191,7 @@ describe UsersController, type: :controller do
end
it 'should edit' do
get :edit, params: {id: 2}
get :edit, params: { id: 2 }
assert_response :success
assert_template 'edit'
@ -200,7 +200,7 @@ describe UsersController, type: :controller do
it 'should update with failure' do
assert_no_difference 'User.count' do
put :update, params: {id: 2, user: {firstname: ''}}
put :update, params: { id: 2, user: { firstname: '' } }
end
assert_response :success
@ -210,10 +210,10 @@ describe UsersController, type: :controller do
it 'should update with password change should send a notification' do
Setting.bcc_recipients = '1'
put :update, params: {id: 2,
user: {password: 'newpassPASS!',
password_confirmation: 'newpassPASS!'},
send_information: '1'}
put :update, params: { id: 2,
user: { password: 'newpassPASS!',
password_confirmation: 'newpassPASS!' },
send_information: '1' }
u = User.find(2)
assert u.check_password?('newpassPASS!')

Loading…
Cancel
Save