Repository: rails/rails
File: railties/test/generators/app_generator_test.rb (Ruby)

Code before:

  def test_inclusion_of_kamal_storage_volume_if_only_skip_active_storage_is_given
    generator [destination_root], ["--skip-active-storage"]
    run_generator_instance

    assert_equal 1, @bundle_commands.count("binstubs kamal")
    assert_equal 1, @bundle_commands.count("exec kamal init")

    assert_file "config/deploy.yml" do |content|
      assert_match(%r{storage:/rails/storage}, content)
    end
  end

  def test_kamal_storage_volume_is_skipped_if_required
    generator [destination_root], ["--skip-active-storage", "--database=postgresql"]
    run_generator_instance

    assert_equal 1, @bundle_commands.count("binstubs kamal")
    assert_equal 1, @bundle_commands.count("exec kamal init")

    assert_file "config/deploy.yml" do |content|
      assert_no_match(%r{storage:/rails/storage}, content)
    end
  end

  def test_gitignore_appends__storage_entries_when_active_storage_is_skippped_but_database_is_sqlite
    generator [destination_root], ["--skip-active-storage"]
    run_generator_instance

    assert_file ".gitignore" do |content|
      assert_match(%r{storage/}, content)
    end
  end

  def test_gitignore_does_not_append_storage_entries_when_active_storage_is_skipped_and_database_is_not_sqlite
    generator [destination_root], ["--skip-active-storage", "--database=postgresql"]
    run_generator_instance

    assert_file ".gitignore" do |content|
      assert_no_match(%r{storage/}, content)
    end
  end

  def test_usage_read_from_file
    assert_called(File, :read, returns: "USAGE FROM FILE") do
      assert_equal "USAGE FROM FILE", Rails::Generators::AppGenerator.desc
    end
  end

  def test_default_usage
    assert_called(Rails::Generators::AppGenerator, :usage_path, returns: nil) do

Review comment (suggestion):
```suggestion
  def test_gitignore_appends_storage_entries_when_active_storage_is_skippped
```
We don't need to describe "but_database_is_sqlite" because that is the default, and we can assume it.

Thanks!


Code after:
    run_generator [destination_root, "--skip-bundler-audit"]

    assert_no_gem "bundler-audit"
    assert_no_file "bin/bundler-audit"
  end

  def test_inclusion_of_ci_files
    run_generator
    assert_file ".github/workflows/ci.yml" do |yaml|
      assert_nothing_raised do
        YAML.load(yaml)
      end
    end
    assert_file ".github/dependabot.yml" do |yaml|
      assert_nothing_raised do
        YAML.load(yaml)
      end
    end
  end

  def test_config_ci_includes_seed_step_by_default
    run_generator [destination_root]

    assert_file "config/ci.rb" do |content|
      assert_match(/step "Tests: Seeds", "env RAILS_ENV=test bin\/rails db:seed:replant"/, content)
    end
  end

  def test_config_ci_does_not_include_test_steps_when_skip_test_is_given
    run_generator [destination_root, "--skip-test"]

    assert_file "config/ci.rb" do |content|
      assert_no_match(/step "Tests: Rails"/, content)
      assert_no_match(/step "Tests: System"/, content)
      assert_no_match(/step "Tests: Seeds"/, content)
      assert_no_match(/bin\/rails db:seed:replant/, content)
    end
  end

  def test_config_ci_does_not_include_seed_step_when_skip_active_record_is_given
    run_generator [destination_root, "--skip-active-record"]

    assert_file "config/ci.rb" do |content|
      assert_no_match(/step "Tests: Seeds"/, content)
      assert_no_match(/bin\/rails db:seed:replant/, content)
    end
  end

  def test_ci_workflow_includes_db_test_prepare_by_default
    run_generator
    assert_file ".github/workflows/ci.yml" do |content|