forked from bellmyer/seed
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Jaime Bellmyer
committed
Jan 6, 2010
1 parent
beea5bb
commit 8db751d
Showing
2 changed files
with
95 additions
and
12 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,8 +1,70 @@ | ||
require 'test_helper' | ||
|
||
def should_allow_everything_for(type, user) | ||
context "as #{type}" do | ||
setup do | ||
login_as user if user | ||
end | ||
|
||
context "getting new" do | ||
setup do | ||
get :new | ||
end | ||
|
||
should_assign_to :document, :class => Document | ||
should_respond_with :success | ||
should_render_without_layout | ||
should_not_set_the_flash | ||
end | ||
|
||
context "creating" do | ||
context "with valid data" do | ||
setup do | ||
Document.any_instance.stubs(:save).returns(true) | ||
post :create, :document => {} | ||
end | ||
|
||
should_assign_to :document, :class => Document | ||
should_respond_with :success | ||
should_render_without_layout | ||
should_not_set_the_flash | ||
end | ||
|
||
context "with invalid data" do | ||
setup do | ||
Document.any_instance.stubs(:save).returns(false) | ||
post :create, :document => {} | ||
end | ||
|
||
should_assign_to :document, :class => Document | ||
should_respond_with :success | ||
should_render_without_layout | ||
should_not_set_the_flash | ||
end | ||
end | ||
|
||
context "destroying" do | ||
setup do | ||
@document = Document.new | ||
Document.stubs(:find).returns(@document) | ||
|
||
@document.expects(:destroy).once | ||
delete :destroy, :id => 1 | ||
end | ||
|
||
should_assign_to(:document){@document} | ||
should_respond_with :success | ||
should_render_without_layout | ||
should_not_set_the_flash | ||
end | ||
end | ||
end | ||
|
||
class DocumentsControllerTest < ActionController::TestCase | ||
# Replace this with your real tests. | ||
def test_truth | ||
assert true | ||
should_allow_everything_for('admin', :admin) | ||
should_allow_everything_for('a member', :quentin) | ||
|
||
context "as a visitor" do | ||
should_require_login_for :new, :create, :destroy | ||
end | ||
end |
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