]> git.openstreetmap.org Git - rails.git/blob - test/integration/user_diaries_test.rb
Merge remote-tracking branch 'upstream/pull/4717'
[rails.git] / test / integration / user_diaries_test.rb
1 require "test_helper"
2
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
7     user = create(:user)
8
9     get "/diary/new"
10     follow_redirect!
11     follow_redirect!
12     # We should now be at the login page
13     assert_response :success
14     assert_template "sessions/new"
15     # We can now login
16     post "/login", :params => { "username" => user.email, "password" => "test", :referer => "/diary/new" }
17     assert_response :redirect
18     follow_redirect!
19     assert_response :success
20     assert_template "diary_entries/new"
21
22     # We will make sure that the form exists here, full
23     # assert testing of the full form should be done in the
24     # functional tests rather than this integration test
25     # There are some things that are specific to the integratio
26     # that need to be tested, which can't be tested in the functional tests
27     assert_select "div.content-heading", :count => 1 do
28       assert_select "h1", "New Diary Entry"
29     end
30     assert_select "div#content" do
31       assert_select "form[action='/diary']" do
32         assert_select "input[id=diary_entry_title]"
33       end
34     end
35   end
36 end