Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
68223de
commit 2f5973c
Showing
1 changed file
with
19 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |