Commit 23cba922 authored by dgt's avatar dgt Committed by azul

Auto-correct params to HttpPostionalArguments

using rubocop -a --only Rails/HttpPositionalArguments
this does not cover xhr requests
parent bd88e2db
AllCops:
TargetRailsVersion: 5.1
TargetRailsVersion: 5.0
TargetRubyVersion: 2.3
Exclude:
- 'bin/*'
......
......@@ -60,7 +60,7 @@ Crabgrass::Application.configure do
## See doc/DEBUGGING for tips.
##
# Print deprecation notices to the stderr.
#config.active_support.deprecation = :stderr
config.active_support.deprecation = :stderr
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
......
......@@ -72,7 +72,7 @@ class AccountsControllerTest < ActionController::TestCase
# old_count = User::Token.count
assert_difference 'User::Token.count' do
post :reset_password, email: users(:quentin).email
post :reset_password, params: { email: users(:quentin).email }
assert_response :success
# assert_message /email has been sent.*reset.*password/i
# doesn't work becuse flash disappears with render_alert
......@@ -84,32 +84,32 @@ class AccountsControllerTest < ActionController::TestCase
assert_equal 'recovery', token.action
assert_equal users(:quentin).id, token.user_id
get :reset_password, token: token.value
get :reset_password, params: { token: token.value }
assert_response :success
assert_difference 'User::Token.count', -1 do
post :reset_password, token: token.value, new_password: 'abcdefgh', password_confirmation: 'abcdefgh'
post :reset_password, params: { token: token.value, new_password: 'abcdefgh', password_confirmation: 'abcdefgh' }
assert_response :redirect # test for success message
end
assert_equal users(:quentin), User.authenticate('quentin', 'abcdefgh')
end
def test_forgot_password_invalid_email_should_stay_put
post :reset_password, email: 'not rfc822-compliant'
post :reset_password, params: { email: 'not rfc822-compliant' }
assert_response :success
end
def test_redirect_on_old_or_invalid_token
get :reset_password, token: user_tokens(:old_token).value
get :reset_password, params: { token: user_tokens(:old_token).value }
assert_error_message(:invalid_token)
get :reset_password, token: user_tokens(:strange).value
get :reset_password, params: { token: user_tokens(:strange).value }
assert_error_message(:invalid_token)
get :reset_password, token: 'invalid'
get :reset_password, params: { token: 'invalid' }
assert_error_message(:invalid_token)
get :reset_password, token: user_tokens(:tokens_003).value
get :reset_password, params: { token: user_tokens(:tokens_003).value }
assert_response :success
end
......@@ -122,7 +122,7 @@ class AccountsControllerTest < ActionController::TestCase
protected
def post_signup_form(options = {})
post(:create, {
post(:create, params: {
user: FactoryBot.attributes_for(:user, options.delete(:user)),
usage_agreement_accepted: '1'
}.merge(options))
......
......@@ -17,35 +17,35 @@ class AssetsControllerTest < ActionController::TestCase
page = FactoryBot.create :page
asset = FactoryBot.create :image_asset, parent_page: page
assert_permission_denied do
get :show, id: asset.id, path: asset.basename
get :show, params: { id: asset.id, path: asset.basename }
end
end
def test_get_with_escaped_chars
asset = FactoryBot.create :image_asset
get :show, id: asset.id, path: asset.basename + '\xF3'
get :show, params: { id: asset.id, path: asset.basename + '\xF3' }
assert_response :redirect
get :show, id: asset.id, path: asset.basename + '\xF3'
get :show, params: { id: asset.id, path: asset.basename + '\xF3' }
assert_response :success
end
def test_not_found
assert_raises ActiveRecord::RecordNotFound do
get :show, id: :non_existant
get :show, params: { id: :non_existant }
end
end
def test_not_found_with_version
assert_raises ActiveRecord::RecordNotFound do
get :show, id: :non_existant, version: 123
get :show, params: { id: :non_existant, version: 123 }
end
end
def test_thumbnail_get
asset = FactoryBot.create :image_asset
get :show, id: asset.id, path: thumbnail(asset.basename)
get :show, params: { id: asset.id, path: thumbnail(asset.basename) }
assert_response :redirect
get :show, id: asset.id, path: thumbnail(asset.basename)
get :show, params: { id: asset.id, path: thumbnail(asset.basename) }
assert_response :success
end
......@@ -56,7 +56,7 @@ class AssetsControllerTest < ActionController::TestCase
user.updated(page)
login_as user
assert_difference 'page.assets.count', -1 do
delete :destroy, id: asset.id, page_id: page.id
delete :destroy, params: { id: asset.id, page_id: page.id }
end
end
......@@ -67,7 +67,7 @@ class AssetsControllerTest < ActionController::TestCase
user.updated(page)
login_as user
assert_permission_denied do
delete :destroy, id: asset.id, page_id: page.id
delete :destroy, params: { id: asset.id, page_id: page.id }
end
end
......
......@@ -20,28 +20,28 @@ class Group::GroupsControllerTest < ActionController::TestCase
def test_new_committee
login_as @user
get :new, type: 'committee'
get :new, params: { type: 'committee' }
assert_response :success
assert_template :_choose_parent_group
end
def test_new_council
login_as @user
get :new, type: 'council'
get :new, params: { type: 'council' }
assert_response :success
assert_template :_choose_parent_group
end
def test_new_group
login_as @user
get :new, type: 'group'
get :new, params: { type: 'group' }
assert_response :success
assert_template 'group/structures/_new_form'
end
def test_new_network
login_as @user
get :new, type: 'network'
get :new, params: { type: 'network' }
assert_response :success
assert_template 'group/structures/_new_form'
end
......@@ -49,7 +49,7 @@ class Group::GroupsControllerTest < ActionController::TestCase
def test_create_group
login_as @user
assert_difference 'Group.count' do
post :create, group: { name: 'test-create-group', full_name: 'Group for Testing Group Creation!' }
post :create, params: { group: { name: 'test-create-group', full_name: 'Group for Testing Group Creation!' } }
assert_response :redirect
group = Group.find_by_name 'test-create-group'
assert_redirected_to group_url(group)
......@@ -59,7 +59,7 @@ class Group::GroupsControllerTest < ActionController::TestCase
def test_create_no_group_without_name
login_as @user
assert_no_difference 'Group.count' do
post :create, group: { name: '' }
post :create, params: { group: { name: '' } }
assert_error_message
end
end
......@@ -68,7 +68,7 @@ class Group::GroupsControllerTest < ActionController::TestCase
FactoryBot.create(:group, name: 'flowers')
login_as @user
assert_no_difference 'Group.count' do
post :create, group: { name: 'flowers' }
post :create, params: { group: { name: 'flowers' } }
assert_error_message
end
end
......@@ -78,8 +78,7 @@ class Group::GroupsControllerTest < ActionController::TestCase
group.add_user! @user
login_as @user
assert_difference 'Group::Network.count' do
post :create, type: 'network',
group: { name: 'trees', initial_member_group: group.name }
post :create, params: { type: 'network', group: { name: 'trees', initial_member_group: group.name } }
end
network = Group::Network.last
assert !@user.direct_member_of?(network),
......@@ -93,8 +92,7 @@ class Group::GroupsControllerTest < ActionController::TestCase
network.add_user! @user
login_as @user
assert_no_difference 'Group.count' do
post :create, type: 'network',
group: { name: 'trees', initial_member_group: network.name }
post :create, params: { type: 'network', group: { name: 'trees', initial_member_group: network.name } }
assert_error_message
end
end
......@@ -105,7 +103,7 @@ class Group::GroupsControllerTest < ActionController::TestCase
group.add_user!(user)
login_as user
assert_difference 'Group.count', -1 do
delete :destroy, id: group.to_param
delete :destroy, params: { id: group.to_param }
end
end
......@@ -114,7 +112,7 @@ class Group::GroupsControllerTest < ActionController::TestCase
group = FactoryBot.create(:group)
login_as user
assert_not_found do
delete :destroy, id: group.to_param
delete :destroy, params: { id: group.to_param }
end
end
......
......@@ -11,7 +11,7 @@ class Group::HomeControllerTest < ActionController::TestCase
def test_show
login_as @user
get :show, group_id: @group.to_param
get :show, params: { group_id: @group.to_param }
assert_response :success
assert_equal @pub, assigns('public_wiki')
assert_equal @priv, assigns('private_wiki')
......@@ -20,7 +20,7 @@ class Group::HomeControllerTest < ActionController::TestCase
end
def test_show_public
get :show, group_id: 'animals'
get :show, params: { group_id: 'animals' }
assert_response :success
assert assigns('group').present?
end
......@@ -28,7 +28,7 @@ class Group::HomeControllerTest < ActionController::TestCase
def test_show_public_only
login_as FactoryBot.create(:user)
@group.grant_access! public: :view
get :show, group_id: @group.to_param
get :show, params: { group_id: @group.to_param }
assert_response :success
assert_nil assigns('private_wiki')
assert_equal @pub, assigns('public_wiki')
......@@ -38,7 +38,7 @@ class Group::HomeControllerTest < ActionController::TestCase
login_as FactoryBot.create(:user)
@group.revoke_access! public: :view
assert_not_found do
get :show, group_id: @group.to_param
get :show, params: { group_id: @group.to_param }
end
end
end
......@@ -18,7 +18,7 @@ class Group::InvitesControllerTest < ActionController::TestCase
def test_new
login_as @user
get :new, group_id: @group.to_param
get :new, params: { group_id: @group.to_param }
assert_response :success
end
......@@ -26,8 +26,7 @@ class Group::InvitesControllerTest < ActionController::TestCase
login_as @user
recipient = FactoryBot.create(:user)
assert_difference 'RequestToJoinUs.count' do
post :create, group_id: @group.to_param,
recipients: recipient.name
post :create, params: { group_id: @group.to_param, recipients: recipient.name }
end
assert_response :redirect
assert_redirected_to action: :new
......@@ -40,8 +39,7 @@ class Group::InvitesControllerTest < ActionController::TestCase
def test_invite_group_to_network
login_as @user
assert_difference 'RequestToJoinOurNetwork.count' do
post :create, group_id: @network.to_param,
recipients: @group.name
post :create, params: { group_id: @network.to_param, recipients: @group.name }
end
assert_response :redirect
assert_redirected_to action: :new
......@@ -51,8 +49,7 @@ class Group::InvitesControllerTest < ActionController::TestCase
email = 'test@mail.me'
login_as @user
assert_difference 'RequestToJoinUsViaEmail.count' do
post :create, group_id: @group.to_param,
recipients: email
post :create, params: { group_id: @group.to_param, recipients: email }
end
assert_response :redirect
assert_redirected_to action: :new
......@@ -67,7 +64,7 @@ class Group::InvitesControllerTest < ActionController::TestCase
recipient = FactoryBot.create(:user)
assert_notice_for(recipient) do
post :create, group_id: @group.to_param, recipients: recipient.name
post :create, params: { group_id: @group.to_param, recipients: recipient.name }
end
end
......@@ -77,8 +74,7 @@ class Group::InvitesControllerTest < ActionController::TestCase
# As @user already member of a group it should not be notified
assert_notice_for recipient, @user_not_in_group do
post :create, group_id: @group.to_param,
recipients: "#{recipient.name}, #{@user.name}, #{@user_not_in_group.name}"
post :create, params: { group_id: @group.to_param, recipients: "#{recipient.name}, #{@user.name}, #{@user_not_in_group.name}" }
end
end
......@@ -88,7 +84,7 @@ class Group::InvitesControllerTest < ActionController::TestCase
# @group has only two members, no council
assert_nil @group.council
assert_notice_for @user, @user_not_in_network do
post :create, group_id: @network.to_param, recipients: @group.name
post :create, params: { group_id: @network.to_param, recipients: @group.name }
end
notice = Notice::RequestNotice.last(2)
......@@ -104,7 +100,7 @@ class Group::InvitesControllerTest < ActionController::TestCase
@group.save
assert_instance_of Group::Council, @group.council
assert_notice_for @user_council do
post :create, group_id: @network.to_param, recipients: @group.name
post :create, params: { group_id: @network.to_param, recipients: @group.name }
end
end
......@@ -112,7 +108,7 @@ class Group::InvitesControllerTest < ActionController::TestCase
email = 'test@mail.me'
login_as @user
assert_no_notice do
post :create, group_id: @group.to_param, recipients: email
post :create, params: { group_id: @group.to_param, recipients: email }
end
end
......
......@@ -10,8 +10,7 @@ class Group::MembershipRequestsControllerTest < ActionController::TestCase
def test_request_to_join
@group.grant_access! public: :view
assert_difference 'RequestToJoinYou.count' do
post :create, group_id: @group.to_param,
type: :join
post :create, params: { group_id: @group.to_param, type: :join }
end
req = RequestToJoinYou.last
assert_response :redirect
......@@ -37,9 +36,7 @@ class Group::MembershipRequestsControllerTest < ActionController::TestCase
@remove_me = FactoryBot.create(:user)
@group.add_user! @remove_me
assert_difference 'RequestToRemoveUser.count' do
post :create, group_id: @group.to_param,
entity: @remove_me.login,
type: :destroy
post :create, params: { group_id: @group.to_param, entity: @remove_me.login, type: :destroy }
end
req = RequestToRemoveUser.last
assert_response :redirect
......@@ -59,20 +56,20 @@ class Group::MembershipRequestsControllerTest < ActionController::TestCase
created_by: @other
assert_difference '@group.users.count', -1 do
put :update, group_id: @group.to_param, id: @req.id, mark: :approve
put :update, params: { group_id: @group.to_param, id: @req.id, mark: :approve }
end
assert_response :success
end
def test_display_request_to_join_you
login_as users(:penguin)
get :show, id: requests(:join_animals).id, group_id: :animals
get :show, params: { id: requests(:join_animals).id, group_id: :animals }
assert_response :success
end
def test_display_request_to_join_us
login_as users(:penguin)
get :show, id: requests(:invite_from_animals).id, group_id: :animals
get :show, params: { id: requests(:invite_from_animals).id, group_id: :animals }
assert_response :success
end
end
......@@ -9,7 +9,7 @@ class Group::MembershipsControllerTest < ActionController::TestCase
def test_index
login_as @user
get :index, group_id: @group.to_param
get :index, params: { group_id: @group.to_param }
assert_response :success
end
......@@ -27,8 +27,7 @@ class Group::MembershipsControllerTest < ActionController::TestCase
def test_index_with_links_to_destroy
login_as users(:blue)
get :index, { group_id: groups(:warm) },
language_code: 'de'
get :index, params: { group_id: groups(:warm) }, session: { language_code: 'de' }
assert_response :success
end
end
......@@ -10,7 +10,7 @@ class Group::MyMembershipsControllerTest < ActionController::TestCase
@group.grant_access! public: %i[join view]
login_as @user
assert_difference '@group.users.count' do
get :create, group_id: @group.to_param
get :create, params: { group_id: @group.to_param }
end
assert_response :redirect
end
......@@ -21,7 +21,7 @@ class Group::MyMembershipsControllerTest < ActionController::TestCase
login_as @user
membership = @group.memberships.find_by_user_id(@user.id)
assert_difference '@group.users.count', -1 do
delete :destroy, group_id: @group.to_param, id: membership.id
delete :destroy, params: { group_id: @group.to_param, id: membership.id }
end
assert_response :redirect
end
......
......@@ -5,7 +5,7 @@ class Group::PagesControllerTest < ActionController::TestCase
user = users(:penguin)
group = groups(:rainbow)
login_as user
get :index, group_id: group
get :index, params: { group_id: group }
assert_response :success
assert assigns('pages').any?
assert assigns('pages').all? { |p| p.public? || user.may?(:view, p) }
......
......@@ -10,14 +10,14 @@ class Group::PermissionsControllerTest < ActionController::TestCase
def test_index
login_as @user
get :index, group_id: @group.to_param
get :index, params: { group_id: @group.to_param }
assert_response :success
end
def test_index_no_access
login_as @other_user
assert_not_found do
get :index, group_id: @group.to_param
get :index, params: { group_id: @group.to_param }
end
end
......
......@@ -9,7 +9,7 @@ class Group::ProfilesControllerTest < ActionController::TestCase
def test_edit
login_as @user
get :edit, group_id: @group.to_param
get :edit, params: { group_id: @group.to_param }
assert_response :success
end
......@@ -17,14 +17,13 @@ class Group::ProfilesControllerTest < ActionController::TestCase
stranger = FactoryBot.create(:user)
login_as stranger
assert_not_found do
get :edit, group_id: @group.to_param
get :edit, params: { group_id: @group.to_param }
end
end
def test_update
login_as @user
post :update, group_id: @group.to_param,
profile: { summary: 'test profile', entity_id: 1 }
post :update, params: { group_id: @group.to_param, profile: { summary: 'test profile', entity_id: 1 } }
assert_response :redirect
profile = @group.profiles.public.reload
assert_equal 'test profile', profile.summary
......@@ -35,8 +34,7 @@ class Group::ProfilesControllerTest < ActionController::TestCase
stranger = FactoryBot.create(:user)
login_as stranger
assert_not_found do
post :update, group_id: @group.to_param,
profile: { summary: 'test profile', entity_id: 1 }
post :update, params: { group_id: @group.to_param, profile: { summary: 'test profile', entity_id: 1 } }
end
end
......
......@@ -9,7 +9,7 @@ class Group::RequestsControllerTest < ActionController::TestCase
end
def test_index
get :index, group_id: @group.to_param
get :index, params: { group_id: @group.to_param }
assert_response :success
end
......@@ -17,13 +17,13 @@ class Group::RequestsControllerTest < ActionController::TestCase
stranger = FactoryBot.create(:user)
login_as stranger
assert_not_found do
get :index, group_id: @group.to_param
get :index, params: { group_id: @group.to_param }
end
end
def test_create
assert_difference 'RequestToDestroyOurGroup.count' do
get :create, group_id: @group.to_param, type: 'destroy_group'
get :create, params: { group_id: @group.to_param, type: 'destroy_group' }
end
assert_response :redirect
end
......@@ -32,7 +32,7 @@ class Group::RequestsControllerTest < ActionController::TestCase
stranger = FactoryBot.create(:user)
login_as stranger
assert_not_found do
get :create, group_id: @group.to_param, type: 'destroy_group'
get :create, params: { group_id: @group.to_param, type: 'destroy_group' }
end
end
......@@ -43,7 +43,7 @@ class Group::RequestsControllerTest < ActionController::TestCase
group.memberships.find_by_user_id(user.id).update(created_at: Time.now - 1.month)
login_as user
assert_difference 'RequestToCreateCouncil.count' do
get :create, group_id: group.to_param, type: 'create_council'
get :create, params: { group_id: group.to_param, type: 'create_council' }
end
end
......@@ -51,7 +51,7 @@ class Group::RequestsControllerTest < ActionController::TestCase
group = groups(:animals)
assert_no_difference 'RequestToCreateCouncil.count' do
assert_permission_denied do
get :create, group_id: group.to_param, type: 'create_council'
get :create, params: { group_id: group.to_param, type: 'create_council' }
end
end
end
......@@ -64,7 +64,7 @@ class Group::RequestsControllerTest < ActionController::TestCase
created_by: @other
assert_difference 'Group::Council.count' do
post :update, group_id: @group.to_param, id: @req.id, mark: :approve
post :update, params: { group_id: @group.to_param, id: @req.id, mark: :approve }
end
assert_response :success
end
......
......@@ -10,14 +10,14 @@ class Group::SettingsControllerTest < ActionController::TestCase
def test_logged_in
login_as @user
get :show, group_id: @group.to_param
get :show, params: { group_id: @group.to_param }
assert_response :success
assert_select '.inline_message_list', 0
end
def test_not_logged_in
assert_login_required do
get :show, group_id: @group.to_param
get :show, params: { group_id: @group.to_param }
end
end
......@@ -25,21 +25,21 @@ class Group::SettingsControllerTest < ActionController::TestCase
stranger = FactoryBot.create(:user)
login_as stranger
assert_permission_denied do
get :show, group_id: @group.to_param
get :show, params: { group_id: @group.to_param }
end
end
def test_member_can_see_private
login_as @user
@group.revoke_access! public: :all
get :show, group_id: @group.to_param
get :show, params: { group_id: @group.to_param }
assert_response :success
assert_select '.inline_message_list', 0
end
def test_update
login_as @user
post :update, group: { full_name: 'full name' }, group_id: @group.to_param
post :update, params: { group: { full_name: 'full name' }, group_id: @group.to_param }
assert_response 302
assert_equal 'full name', assigns('group').full_name
end
......@@ -48,7 +48,7 @@ class Group::SettingsControllerTest < ActionController::TestCase
stranger = FactoryBot.create(:user)
login_as stranger
assert_permission_denied do
post :update, group: { full_name: 'full name' }, group_id: @group.to_param
post :update, params: { group: { full_name: 'full name' }, group_id: @group.to_param }
end
end
......
......@@ -9,19 +9,14 @@ class Group::StructuresControllerTest < ActionController::TestCase
def test_new_committee
login_as @user
get :new,
group_id: @group.to_param,
type: 'committee'
get :new, params: { group_id: @group.to_param, type: 'committee' }
assert_response :success
end
def test_create_committee
login_as @user
assert_difference '@group.committees.count' do
get :create,
group_id: @group.to_param,
type: 'committee',
group: committee_attributes
get :create, params: { group_id: @group.to_param, type: 'committee', group: committee_attributes }
end
assert_response :redirect
end
......@@ -30,20 +25,14 @@ class Group::StructuresControllerTest < ActionController::TestCase
stranger = FactoryBot.create(:user)
login_as stranger
assert_not_found do
get :create,
group_id: @group.to_param,
type: 'committee',
group: committee_attributes
get :create, params: { group_id: @group.to_param, type: 'committee', group: committee_attributes }
end
end
def test_create_committee_namespace
login_as @user
assert_difference '@group.committees.count' do
get :create,
group_id: @group.to_param,
type: 'committee',
group: committee_attributes(name: 'the-warm-colors')
get :create, params: { group_id: @group.to_param, type: 'committee', group: committee_attributes(name: 'the-warm-colors') }
end
assert_response :redirect
end
......@@ -51,28 +40,20 @@ class Group::StructuresControllerTest < ActionController::TestCase
def test_create_no_duplicates
login_as users(:blue)
assert_no_difference 'Group::Committee.count' do
get :create,
group_id: groups(:rainbow),
type: 'committee',
group: committee_attributes(name: 'the-warm-colors')
get :create, params: { group_id: groups(:rainbow), type: 'committee', group: committee_attributes(name: 'the-warm-colors') }
end
end
def test_new_council
login_as @user
get :new,
group_id: @group.to_param,
type: 'council'
get :new, params: { group_id: @group.to_param, type: 'council' }
assert_response :success
end
def test_create_council
login_as @user
assert_difference '@group.committees.count' do
get :create,
group_id: @group.to_param,
type: 'council',
group: committee_attributes
get :create, params: { group_id: @group.to_param, type: 'council', group: committee_attributes }
end
assert_response :redirect
end
......@@ -81,10 +62,7 @@ class Group::StructuresControllerTest < ActionController::TestCase
stranger = FactoryBot.create(:user)
login_as stranger
assert_not_found do
get :create,
group_id: @group.to_param,
type: 'council',
group: committee_attributes
get :create, params: { group_id: @group.to_param, type: 'council', group: committee_attributes }
end
end
......
......@@ -31,6 +31,6 @@ class Me::AvatarsControllerTest < ActionController::TestCase
file_path = File.join('files', 'photo.jpg')
file = fixture_file_upload(file_path, 'image/jpeg')