swt2-intro-exercise / rails-exercise-20-sirkrypt0

rails-exercise-20-sirkrypt0 created by GitHub Classroom
MIT License
0 stars 0 forks source link

New author page should save the author #4

Closed swt2public closed 4 years ago

swt2public commented 4 years ago

Scenario

When a user visits the new author page And fills in 'Alan', 'Turing', and 'http://wikipedia.org/Alan_Turing', respectively And submits the form Then Alan Turing should be found in the database

Hints

Write a test that visits the new-author page, fills in the 'new author' form and submits it. Use fill_in to enter data into input fields. Submit the form using the find and click methods. Try a new it block in new_author_spec.rb.

visit new_author_path
page.fill_in 'author[last_name]', with: 'Dijkstra'
# ...
find('input[type="submit"]').click

Here is the relevant section in the guide.

Make the failing test pass by saving the POSTed form data in a new Author database object. This is the task of a create action in authors_controller.rb. Make sure to set the :url option of the form_with, to control where the data will be POSTed to. Read up on "strong parameters" and whitelisting of required parameters.

Do not issue a redirect_to @author, as this will error (there is no code for showing authors yet). Instead you can redirect_to root_path, notice: 'Success!'.

Tips:

Error

Got ActiveRecord::RecordNotFound: Couldn't find Author

6/44 exercise tests have passed