Skip to content

Add submission list and detail API tests#104

Draft
Copilot wants to merge 4 commits intov4-devfrom
copilot/add-submission-api-tests
Draft

Add submission list and detail API tests#104
Copilot wants to merge 4 commits intov4-devfrom
copilot/add-submission-api-tests

Conversation

Copy link

Copilot AI commented Feb 21, 2026

Integration tests for submissions index (/contests/{slug}/submissions), all (/contests/{slug}/submissions/all), and show (/contests/{slug}/submissions/{id}) endpoints covering auth, permissions, and visibility rules.

Tests (29 total)

  • index (8): unauthorized access, own-submissions-only filtering, pagination, not-found, response shape
  • all (9): ended vs running contest visibility, forbidden for anonymous/regular users on running contests, admin/writer access during running contests
  • show (12): owner/anonymous/admin/writer access to public/private submissions, contest-slug mismatch, running-contest restrictions, response detail fields

Test infrastructure

  • Fixtures for users (admin/writer/member roles), contests (ended/running), problems, submissions (public/private), testcases, registrations
  • GCS client stubbed via define_singleton_method in setup/teardown
  • Session middleware added to test env for DeviseTokenAuth bypass_sign_in compatibility

Pre-existing fixes required to unblock test execution

  • enum syntax updated in Contest and TestcaseSet models (Rails 8 removed the hash-style enum field: {} API)
  • GCS client initialization guarded with unless Rails.env.test? to prevent eager-load failures without credentials
# Rails 8 enum syntax fix
-  enum standings_mode: { atcoder: 1, icpc: 2 }
+  enum :standings_mode, { atcoder: 1, icpc: 2 }
Original prompt

This section details on the original issue you should resolve

<issue_title>[Phase 1] 提出一覧および詳細 API のテスト作成</issue_title>
<issue_description>- 提出一覧 (/contests/{slug}/submissions) にテストを作成する

  • 提出詳細 (/contests/{slug}/submissions/{id})

  • 正常系・異常系とも作成

  • 権限については慎重に
    -</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits February 21, 2026 06:55
Co-authored-by: kichi2004 <25224540+kichi2004@users.noreply.github.com>
…nfrastructure

- Create submissions_controller_test.rb with 29 tests covering:
  - index: auth, own submissions, pagination, not found, response fields
  - all: visibility rules, permissions (admin, writer, regular user)
  - show: owner access, public/private, admin/writer access, running contest
- Add users.yml fixture with admin, writer, member, other_user
- Update contest, problem, submission, testcase fixtures with proper associations
- Add registrations, contest_admins, tester_relations, testcase_results fixtures
- Fix Contest and TestcaseSet enum syntax for Rails 8 compatibility
- Guard GCS client initialization in test environment
- Add session middleware for DeviseTokenAuth compatibility in tests

Co-authored-by: kichi2004 <25224540+kichi2004@users.noreply.github.com>
Co-authored-by: kichi2004 <25224540+kichi2004@users.noreply.github.com>
Copilot AI changed the title [WIP] Add tests for submission list and detail API Add submission list and detail API tests Feb 21, 2026
Copilot AI requested a review from kichi2004 February 21, 2026 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants