Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scaffold generator for system tests indefinite article agreement error if model name begins with a vowel sound #40744

Closed
msducheminjr opened this issue Dec 3, 2020 · 4 comments · Fixed by #40745

Comments

@msducheminjr
Copy link
Contributor

Steps to reproduce

In a new or existing rails app, invoke the scaffold generator with a model name that starts with a vowel sound

~$ rails generate scaffold Author

Expected behavior

Rails will handle the vast majority of linguistic inflections out of the box. When you run

~$ rails generate scaffold Author

The expected resulting file for a model that begins with a vowel sound is:

  # test/system/authors_test.rb
  # rest of test class 
  test "creating an Author" do
    # body omitted
  end

  test "updating an Author" do
    # body omitted
  end

  test "destroying an Author" do
    # body omitted
  end

Or some sort of name that doesn't have indefinite article agreement issues:

  # test/system/authors_test.rb
  # rest of test class
  test "creating my Author" do # won't be dependent on beginning vowel sound
    # body omitted
  end

  test "updating my Author" do
    # body omitted
  end

  test "destroying my Author" do
    # body omitted
  end

Actual behavior

  # test/system/authors_test.rb
  # rest of test class 
  test "creating a Author" do
    # body omitted
  end

  test "updating a Author" do
    # body omitted
  end

  test "destroying a Author" do
    # body omitted
  end

Fix

The quick solution

Change the generator template to reword the generated test so that it doesn't use the indefinite article. I am attaching a PR that changes "a" to "my" in the template generator.

The comprehensive solution

Add inflection of the indefinite article into ActiveSupport. I'm creating a feature proposal to do that on the Rails mailing list here

System configuration

Rails version: Master, but present in 6.0.x and in every release that incorporates commit d502cd1

Ruby version: 2.7.1

@rails-bot
Copy link

rails-bot bot commented Mar 3, 2021

This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails team are limited, and so we are asking for your help.
If you can still reproduce this error on the 6-1-stable branch or on main, please reply with all of the information you have about it in order to keep the issue open.
Thank you for all your contributions.

@rails-bot rails-bot bot added the stale label Mar 3, 2021
@msducheminjr
Copy link
Contributor Author

Still an issue on 6-1-stable and main, and still fixable by #40745.

@rails-bot rails-bot bot removed the stale label Mar 10, 2021
@rails-bot
Copy link

rails-bot bot commented Jun 8, 2021

This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails team are limited, and so we are asking for your help.
If you can still reproduce this error on the 6-1-stable branch or on main, please reply with all of the information you have about it in order to keep the issue open.
Thank you for all your contributions.

@rails-bot rails-bot bot added the stale label Jun 8, 2021
@rails-bot rails-bot bot removed the stale label Jun 8, 2021
@ghiculescu
Copy link
Member

@msducheminjr could you please fix the merge conflict on #40745

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants