source: subversion/sites/rails_port/test/integration/user_diaries_test.rb @ 16387

Last change on this file since 16387 was 15418, checked in by Shaun McDonald, 10 years ago

Fix the integration test

File size: 1.9 KB
Line 
1require File.dirname(__FILE__) + '/../test_helper'
2
3class UserDiariesTest < ActionController::IntegrationTest
4  fixtures :users, :diary_entries
5
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    get_via_redirect '/user/test/diary/new'
10    # We should now be at the login page
11    assert_response :success
12    assert_template 'user/login'
13    # We can now login
14    post  '/login', {'user[email]' => "test@openstreetmap.org", 'user[password]' => "test", :referer => '/user/test/diary/new'}
15    assert_response :redirect
16    #print @response.body
17    # Check that there is some payload alerting the user to the redirect
18    # and allowing them to get to the page they are being directed to
19    assert_select "html:root" do
20      assert_select "body" do
21        assert_select "a[href='http://www.example.com/user/test/diary/new']"
22      end
23    end
24    # Required due to a bug in the rails testing framework
25    # http://markmail.org/message/wnslvi5xv5moqg7g
26    @html_document = nil
27    follow_redirect!
28   
29    assert_response :success
30    assert_template 'diary_entry/edit'
31    #print @response.body
32    #print @html_document.to_yaml
33
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 "html:root" do
40      assert_select "body" do
41        assert_select "div#content" do
42          assert_select "h1", "New Diary Entry" 
43          assert_select "form[action='/user/#{users(:normal_user).display_name}/diary/new']" do
44            assert_select "input[id=diary_entry_title]"
45          end
46        end
47      end
48    end
49   
50   
51  end
52end
Note: See TracBrowser for help on using the repository browser.