Skip to content

Commit

Permalink
branches controller test
Browse files Browse the repository at this point in the history
  • Loading branch information
mcfiredrill committed Nov 17, 2011
1 parent 68223de commit 2f5973c
Showing 1 changed file with 19 additions and 37 deletions.
56 changes: 19 additions & 37 deletions test/functional/branches_controller_test.rb
@@ -1,49 +1,31 @@
require 'test_helper'

class BranchesControllerTest < ActionController::TestCase
setup do
@branch = branches(:one)
end

test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:branches)
end

test "should get new" do
get :new
assert_response :success
end

test "should create branch" do
assert_difference('Branch.count') do
post :create, :branch => @branch.attributes
context "a branches controller" do
setup do
@branch = Factory.create :branch
end

assert_redirected_to branch_path(assigns(:branch))
end
should "get new" do
get :new
assert_response :success
end

test "should show branch" do
get :show, :id => @branch.to_param
assert_response :success
end
should "create branch" do
assert_difference('Branch.count', 1) do
post :create, :leaf => {:content => @branch.leafs.first.content}
end

test "should get edit" do
get :edit, :id => @branch.to_param
assert_response :success
end
assert_redirected_to new_branch_path
end

test "should update branch" do
put :update, :id => @branch.to_param, :branch => @branch.attributes
assert_redirected_to branch_path(assigns(:branch))
end
should "destroy branch" do
@admin = Factory.create :admin
assert_difference('Branch.count', -1) do
delete :destroy, :delete => [@branch.leafs.first.id], :password => @admin.password, :id => "new"
end

test "should destroy branch" do
assert_difference('Branch.count', -1) do
delete :destroy, :id => @branch.to_param
assert_redirected_to new_branch_path
end

assert_redirected_to branches_path
end
end

0 comments on commit 2f5973c

Please sign in to comment.