3 class UserDiariesTest < ActionDispatch::IntegrationTest
4 # Test the creation of a diary entry, making sure that you are redirected to
5 # login page when not logged in
6 def test_showing_create_diary_entry
12 # We should now be at the login page
13 assert_response :success
14 assert_template "sessions/new"
16 post "/login", :params => { "username" => user.email, "password" => "test", :referer => "/diary/new" }
17 assert_response :redirect
19 # Check that there is some payload alerting the user to the redirect
20 # and allowing them to get to the page they are being directed to
21 assert_select "html:root" do
22 assert_select "body" do
23 assert_select "a[href='http://www.example.com/diary/new']"
26 # Required due to a bug in the rails testing framework
27 # http://markmail.org/message/wnslvi5xv5moqg7g
31 assert_response :success
32 assert_template "diary_entries/new"
34 # We will make sure that the form exists here, full
35 # assert testing of the full form should be done in the
36 # functional tests rather than this integration test
37 # There are some things that are specific to the integratio
38 # that need to be tested, which can't be tested in the functional tests
39 assert_select "div.content-heading", :count => 1 do
40 assert_select "h1", "New Diary Entry"
42 assert_select "div#content" do
43 assert_select "form[action='/diary']" do
44 assert_select "input[id=diary_entry_title]"