{"id":19339384,"url":"https://github.com/appfolio/rails5_xhr_update","last_synced_at":"2025-04-23T02:30:44.222Z","repository":{"id":32468527,"uuid":"134771085","full_name":"appfolio/rails5_xhr_update","owner":"appfolio","description":"Program to help update Rails 4 xhr test method calls to rails 5 syntax.","archived":false,"fork":false,"pushed_at":"2022-02-04T23:43:13.000Z","size":47,"stargazers_count":4,"open_issues_count":1,"forks_count":4,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-13T13:17:16.407Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/appfolio.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-24T21:33:53.000Z","updated_at":"2022-09-27T16:17:43.000Z","dependencies_parsed_at":"2022-08-07T17:31:19.666Z","dependency_job_id":null,"html_url":"https://github.com/appfolio/rails5_xhr_update","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appfolio%2Frails5_xhr_update","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appfolio%2Frails5_xhr_update/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appfolio%2Frails5_xhr_update/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/appfolio%2Frails5_xhr_update/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/appfolio","download_url":"https://codeload.github.com/appfolio/rails5_xhr_update/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250357546,"owners_count":21417303,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T03:21:51.772Z","updated_at":"2025-04-23T02:30:43.938Z","avatar_url":"https://github.com/appfolio.png","language":"Ruby","funding_links":[],"categories":["Converters"],"sub_categories":[],"readme":"[![Gem](https://img.shields.io/gem/v/rails5_xhr_update.svg)](https://rubygems.org/gems/rails5_xhr_update)\n[![Build Status](https://travis-ci.org/appfolio/rails5_xhr_update.svg?branch=master)](https://travis-ci.org/appfolio/rails5_xhr_update)\n\n# rails5_xhr_update\n\nrails5_xhr_update is a program that can be used to help convert from the Rails\n4 xhr test syntax, like the following:\n\n```ruby\nxhr :get, images_path, limit: 10, sort: 'new'\n```\n\nto the equivalent Rails 5 syntax:\n\n```ruby\nget images_path, params: { limit: 10, sort: 'new' }, xhr: true\n```\n\nFurthermore, `xhr` calls using `session`, or `flash` parameters are also\nsupported. The following call:\n\n```ruby\nxhr :get, images_path, { id: 1 }, { user_ud: 2 }, success: 'logged in'\n```\n\nis translated into:\n\n```ruby\nget images_path, flash: { success: \"logged in\" }, params: { id: 1 }, session: { user_ud: 2 }, xhr: true\n```\n\n## Installation\n\nTo install rails5_xhr_update run:\n\n    gem install rails5_xhr_update\n\n\n## Running\n\nExecute this program via:\n\n```sh\nrails5_xhr_update --write FILE...\n```\n\nOmit ``--write`` if you don't want to write back to the files, and instead\noutput to STDOUT.\n\nConsider running the following to locate and run against files with potential\nissues:\n\n```sh\ngit grep -l \"xhr :\" | rails5_xhr_update --write\n```\n\n\n## See Also\n\n### Handling non-XHR cases\n\nAs part of the upgrade to Rails 5 one also needs to use keyword arguments for\n`params` and `headers` when calling these *request* test methods. Fortunately,\n[rubocop](https://github.com/bbatsov/rubocop) can help handle that conversion:\n\n\n```sh\nrubocop -a --only Rails/HttpPositionalArguments PATH\n```\n\n### Supporting Rails 5 syntax in Rails 4\n\nFinally, with your project, it might be difficult to do all this conversion\nwork at once. You might instead, prefer to remain on Rails 4, but be forward\ncompatible with Rails 5. And you might want to output a `DeprecationWarning`,\nor even raise an exception when attempting to use the older syntax. To help\nwith that please see our\n[rails-forward_compatible_controller_tests](https://github.com/appfolio/rails-forward_compatible_controller_tests)\ngem.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappfolio%2Frails5_xhr_update","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fappfolio%2Frails5_xhr_update","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fappfolio%2Frails5_xhr_update/lists"}