Skip to content

Conversation

@koppen
Copy link
Member

@koppen koppen commented Oct 4, 2025

No description provided.

Copilot AI review requested due to automatic review settings October 4, 2025 09:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds controller tests for the Uchi gem by creating comprehensive test coverage for the AuthorsController. The changes introduce necessary testing infrastructure and ensure proper HTTP status codes are returned for validation failures.

  • Added comprehensive controller tests covering all CRUD operations for AuthorsController
  • Added proper HTTP status codes (422) for validation failures in create and update actions
  • Added testing dependencies and turbo-rails support

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
uchi.gemspec Added turbo-rails dependency
test/dummy/app/models/author.rb Added name presence validation for testing
test/dummy/app/controllers/uchi/authors_controller.rb Created AuthorsController for testing
test/controllers/uchi/authors_controller_test.rb Added comprehensive controller tests
lib/uchi.rb Added turbo-rails require statements
app/controllers/uchi/repository_controller.rb Fixed status codes for validation failures
Gemfile Added rails-controller-testing gem

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +71 to +77
post uchi_authors_url, params: {author: {name: "New Author"}}
assert_redirected_to uchi_author_url(id: Author.last.id)
end

test "POST create creates a new author" do
post uchi_authors_url, params: {author: {name: "New Author"}}
assert_equal "New Author", Author.last.name
Copy link

Copilot AI Oct 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test relies on Author.last which could be flaky if other tests create authors. Consider using assert_difference 'Author.count', 1 and finding the created author more reliably.

Suggested change
post uchi_authors_url, params: {author: {name: "New Author"}}
assert_redirected_to uchi_author_url(id: Author.last.id)
end
test "POST create creates a new author" do
post uchi_authors_url, params: {author: {name: "New Author"}}
assert_equal "New Author", Author.last.name
assert_difference 'Author.count', 1 do
post uchi_authors_url, params: {author: {name: "New Author"}}
end
created_author = Author.find_by(name: "New Author")
assert_redirected_to uchi_author_url(id: created_author.id)
end
test "POST create creates a new author" do
assert_difference 'Author.count', 1 do
post uchi_authors_url, params: {author: {name: "New Author"}}
end
created_author = Author.find_by(name: "New Author")
assert_not_nil created_author
assert_equal "New Author", created_author.name

Copilot uses AI. Check for mistakes.
@koppen koppen merged commit eb7aebc into main Oct 4, 2025
3 checks passed
@koppen koppen deleted the controller_tests branch October 4, 2025 09:48
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.

1 participant