-
Notifications
You must be signed in to change notification settings - Fork 0
Controller tests #4
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
Conversation
In partocular we use turbo_frame_tag.
There was a problem hiding this 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.
| 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 |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
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.
| 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 |
No description provided.