2011-05-15 22:07:53 +00:00
|
|
|
require 'test_helper'
|
|
|
|
|
|
|
|
class MainControllerTest < ActionController::TestCase
|
2011-12-25 07:23:19 +00:00
|
|
|
include Devise::TestHelpers
|
|
|
|
|
|
|
|
setup do
|
2014-04-01 08:15:29 +00:00
|
|
|
request.env['devise.mapping'] = Devise.mappings[:user]
|
2011-12-25 07:23:19 +00:00
|
|
|
@user = users(:erik)
|
|
|
|
end
|
|
|
|
|
2011-05-15 22:07:53 +00:00
|
|
|
test 'should return the home page' do
|
|
|
|
get :index
|
|
|
|
assert_response :success
|
2011-12-20 19:54:45 +00:00
|
|
|
assert_select 'title', 'Adopt-a-Hydrant'
|
2011-05-15 22:07:53 +00:00
|
|
|
assert_select 'p#tagline', 'Claim responsibility for shoveling out a fire hydrant after it snows.'
|
2011-12-25 07:23:19 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
test 'should show search form when signed in' do
|
|
|
|
sign_in @user
|
|
|
|
get :index
|
|
|
|
assert_response :success
|
2011-05-15 22:07:53 +00:00
|
|
|
assert_select 'form' do
|
2012-01-14 22:31:01 +00:00
|
|
|
assert_select '[action=?]', '/address'
|
|
|
|
assert_select '[method=?]', 'get'
|
2011-05-15 22:07:53 +00:00
|
|
|
end
|
|
|
|
assert_select 'label#city_state_label', 'City'
|
|
|
|
assert_select 'select#city_state' do
|
2012-01-02 12:36:34 +00:00
|
|
|
assert_select 'option', 'Boston, Massachusetts'
|
2011-05-15 22:07:53 +00:00
|
|
|
end
|
2011-08-09 19:40:59 +00:00
|
|
|
assert_select 'label#address_label', 'Address, Neighborhood'
|
2011-05-15 22:07:53 +00:00
|
|
|
assert_select 'input#address', true
|
|
|
|
assert_select 'input[name="commit"]' do
|
|
|
|
assert_select '[type=?]', 'submit'
|
2011-09-15 21:02:16 +00:00
|
|
|
assert_select '[value=?]', 'Find hydrants'
|
2011-05-15 22:07:53 +00:00
|
|
|
end
|
2011-12-25 07:23:19 +00:00
|
|
|
assert_select 'div#map', true
|
2011-05-15 22:07:53 +00:00
|
|
|
end
|
|
|
|
end
|