1 # frozen_string_literal: true
 
   5 class UserDiariesTest < ActionDispatch::IntegrationTest
 
   6   # Test the creation of a diary entry, making sure that you are redirected to
 
   7   # login page when not logged in
 
   8   def test_showing_create_diary_entry
 
  14     # We should now be at the login page
 
  15     assert_response :success
 
  16     assert_template "sessions/new"
 
  18     post "/login", :params => { "username" => user.email, "password" => "s3cr3t", :referer => "/diary/new" }
 
  19     assert_response :redirect
 
  21     assert_response :success
 
  22     assert_template "diary_entries/new"
 
  24     # We will make sure that the form exists here, full
 
  25     # assert testing of the full form should be done in the
 
  26     # functional tests rather than this integration test
 
  27     # There are some things that are specific to the integratio
 
  28     # that need to be tested, which can't be tested in the functional tests
 
  29     assert_select "div.content-heading", :count => 1 do
 
  30       assert_select "h1", "New Diary Entry"
 
  32     assert_select "div#content" do
 
  33       assert_select "form[action='/diary']" do
 
  34         assert_select "input[id=diary_entry_title]"