agenda-libre-ruby/test/controllers/cities_controller_test.rb

50 lines
1.3 KiB
Ruby

require 'test_helper'
class CitiesControllerTest < ActionController::TestCase
setup do
@city = cities(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:cities)
end
test "should get new" do
get :new
assert_response :success
end
test "should create city" do
assert_difference('City.count') do
post :create, city: { inseecode: @city.inseecode, latitude: @city.latitude, longitude: @city.longitude, majname: @city.majname, name: @city.name, postalcode: @city.postalcode, regioncode: @city.regioncode }
end
assert_redirected_to city_path(assigns(:city))
end
test "should show city" do
get :show, id: @city
assert_response :success
end
test "should get edit" do
get :edit, id: @city
assert_response :success
end
test "should update city" do
patch :update, id: @city, city: { inseecode: @city.inseecode, latitude: @city.latitude, longitude: @city.longitude, majname: @city.majname, name: @city.name, postalcode: @city.postalcode, regioncode: @city.regioncode }
assert_redirected_to city_path(assigns(:city))
end
test "should destroy city" do
assert_difference('City.count', -1) do
delete :destroy, id: @city
end
assert_redirected_to cities_path
end
end