collab/test/functional/projects_controller_test.rb

53 lines
1.2 KiB
Ruby
Raw Normal View History

2010-03-04 06:22:45 +00:00
require 'test_helper'
class ProjectsControllerTest < ActionController::TestCase
2010-03-15 15:47:32 +00:00
def setup
@user = Factory(:user)
sign_in_as(@user)
end
2010-03-04 06:22:45 +00:00
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:projects)
end
test "should get new" do
get :new
assert_response :success
end
test "should create project" do
2010-03-15 15:47:32 +00:00
2010-03-04 06:22:45 +00:00
assert_difference('Project.count') do
2010-03-15 15:47:32 +00:00
post :create, :project => Factory.attributes_for(:project)
2010-03-04 06:22:45 +00:00
end
assert_redirected_to project_path(assigns(:project))
end
test "should show project" do
2010-03-15 15:47:32 +00:00
get :show, :id => Factory(:project).id
2010-03-04 06:22:45 +00:00
assert_response :success
end
test "should get edit" do
2010-03-15 15:47:32 +00:00
get :edit, :id => Factory(:project).id
2010-03-04 06:22:45 +00:00
assert_response :success
end
test "should update project" do
2010-03-15 15:47:32 +00:00
put :update, :id => Factory(:project).id, :project => Factory.attributes_for(:project)
2010-03-04 06:22:45 +00:00
assert_redirected_to project_path(assigns(:project))
end
test "should destroy project" do
2010-03-15 15:47:32 +00:00
project = Factory(:project)
2010-03-04 06:22:45 +00:00
assert_difference('Project.count', -1) do
2010-03-15 15:47:32 +00:00
delete :destroy, :id => project.id
2010-03-04 06:22:45 +00:00
end
assert_redirected_to projects_path
end
end