Skip to content

Commit c5fe951

Browse files
authored
Merge pull request #11272 from neinteractiveliterature/11271-fix-format-run-start-day-method-error
Fix NoMethodError for format_run_start_day in RunSignupsFilenameFinder
2 parents 2d58717 + e5bbd7c commit c5fe951

3 files changed

Lines changed: 47 additions & 12 deletions

File tree

.claude/commands/fix-issue.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ Before writing any code:
4848

4949
- Stage all changes with `git add`
5050
- Write a concise, descriptive commit message referencing the issue (e.g. `Fix login bug (#1234)`)
51+
- The commit message must end with a co-author line:
52+
```
53+
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
54+
```
5155
- Commit the changes
5256

5357
## Step 7: Open a PR
@@ -56,6 +60,7 @@ Before writing any code:
5660
2. Create a PR with `gh pr create`:
5761
- Title should summarize the fix
5862
- Body should reference the issue (`Fixes #<issue-number>`) and briefly describe what changed
63+
- Body must end with: `🤖 Generated with [Claude Code](https://claude.com/claude-code)`
5964
3. Add labels using the GitHub REST API (required — gh pr edit is broken):
6065

6166
```

app/controllers/csv_exports_controller.rb

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,6 @@
11
# frozen_string_literal: true
22
class CsvExportsController < ApplicationController
33
class RunSignupsFilenameFinder
4-
PRIORITIZED_FILENAME_GENERATORS = [
5-
->(run) { run.event.title },
6-
->(run) { "#{run.event.title} (#{run.title_suffix})" },
7-
->(run) { "#{run.event.title} (#{format_run_start_day(run)})" },
8-
->(run) { "#{run.event.title} (#{format_run_start_time(run)})" },
9-
->(run) { "#{run.event.title} (#{format_run_rooms(run)})" },
10-
->(run) { "#{run.event.title} (#{format_run_start_day(run)} in #{format_run_rooms(run)})" },
11-
->(run) { "#{run.event.title} (#{format_run_start_time(run)} in #{format_run_rooms(run)})" },
12-
->(run) { "#{run.event.title} (run #{run.id})" }
13-
].freeze
14-
154
def format_run_start_day(run)
165
run.starts_at.strftime("%a")
176
end
@@ -28,13 +17,28 @@ def format_run_rooms(run)
2817
# strategies
2918
def unique_filename(event, run, suffix)
3019
filename_generator =
31-
PRIORITIZED_FILENAME_GENERATORS.find do |generator|
20+
filename_generators.find do |generator|
3221
filenames = event.runs.map { |r| generator.call(r) }
3322
filenames.uniq.size == filenames.size
3423
end
3524

3625
"#{filename_generator.call(run)} #{suffix}"
3726
end
27+
28+
private
29+
30+
def filename_generators # rubocop:disable Metrics/AbcSize
31+
[
32+
->(r) { r.event.title },
33+
->(r) { "#{r.event.title} (#{r.title_suffix})" },
34+
->(r) { "#{r.event.title} (#{format_run_start_day(r)})" },
35+
->(r) { "#{r.event.title} (#{format_run_start_time(r)})" },
36+
->(r) { "#{r.event.title} (#{format_run_rooms(r)})" },
37+
->(r) { "#{r.event.title} (#{format_run_start_day(r)} in #{format_run_rooms(r)})" },
38+
->(r) { "#{r.event.title} (#{format_run_start_time(r)} in #{format_run_rooms(r)})" },
39+
->(r) { "#{r.event.title} (run #{r.id})" }
40+
]
41+
end
3842
end
3943

4044
include SendCsv
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# frozen_string_literal: true
2+
require "test_helper"
3+
4+
describe CsvExportsController::RunSignupsFilenameFinder do
5+
let(:finder) { CsvExportsController::RunSignupsFilenameFinder.new }
6+
let(:convention) { create(:convention) }
7+
let(:event) { create(:event, convention: convention) }
8+
9+
describe "#unique_filename" do
10+
it "disambiguates runs by start day when they share a title" do
11+
run1 = create(:run, event: event, starts_at: convention.starts_at)
12+
create(:run, event: event, starts_at: convention.starts_at + 1.day)
13+
14+
assert_equal(
15+
"#{event.title} (#{run1.starts_at.strftime("%a")}) Signups",
16+
finder.unique_filename(event, run1, "Signups")
17+
)
18+
end
19+
20+
it "uses just the event title when the event has only one run" do
21+
run = create(:run, event: event, starts_at: convention.starts_at)
22+
23+
assert_equal "#{event.title} Signups", finder.unique_filename(event, run, "Signups")
24+
end
25+
end
26+
end

0 commit comments

Comments
 (0)