]> git.openstreetmap.org Git - rails.git/blob - test/integration/user_diaries_test.rb
Merge pull request #6394 from openstreetmap/dependabot/github_actions/ruby/setup...
[rails.git] / test / integration / user_diaries_test.rb
1 # frozen_string_literal: true
2
3 require "test_helper"
4
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
9     user = create(:user)
10
11     get "/diary/new"
12     follow_redirect!
13     follow_redirect!
14     # We should now be at the login page
15     assert_response :success
16     assert_template "sessions/new"
17     # We can now login
18     post "/login", :params => { "username" => user.email, "password" => "test", :referer => "/diary/new" }
19     assert_response :redirect
20     follow_redirect!
21     assert_response :success
22     assert_template "diary_entries/new"
23
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"
31     end
32     assert_select "div#content" do
33       assert_select "form[action='/diary']" do
34         assert_select "input[id=diary_entry_title]"
35       end
36     end
37   end
38 end