Created
June 23, 2010 15:55
-
-
Save mallain/450116 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
require 'test_helper' | |
class Hr::AlertCollaboratorsControllerTest < ActionController::TestCase | |
context "logged in" do | |
setup do | |
UserSession.create(Factory(:user)) | |
Factory(:agency) | |
Factory(:feedback) | |
@alert_collaborator = Factory.stub(:alert_collaborator) | |
@alert_collaborator.id = 1001 | |
AlertCollaborator.stubs(:find).returns(@alert_collaborator) | |
AlertCollaborator.stubs(:find).with(:all, anything).returns([@alert_collaborator]) | |
end | |
context "on GET to :index" do | |
setup do | |
get :index | |
end | |
should_render_with_layout | |
should_render_template :index | |
should_not_set_the_flash | |
should_respond_with :success | |
end | |
context "on GET to :new" do | |
setup do | |
get :new | |
end | |
should_respond_with :success | |
should_render_with_layout | |
should_render_template :new | |
should_not_set_the_flash | |
end | |
context "on POST to :create (valid data)" do | |
setup do | |
AlertCollaborator.any_instance.expects(:save).returns(true).once | |
AlertCollaborator.any_instance.stubs(:id).returns(1001) | |
post :create, :alert_collaborator => {} | |
end | |
should_assign_to :alert_collaborator, :class => AlertCollaborator | |
should_respond_with :redirect | |
should_redirect_to("alert_collaborator index page"){hr_alert_collaborators_path} | |
end | |
context "on POST to :create (invalid data)" do | |
setup do | |
AlertCollaborator.any_instance.expects(:save).returns(false).once | |
post :create, :alert_collaborator => {} | |
end | |
should_assign_to :alert_collaborator, :class => AlertCollaborator | |
should_respond_with :success | |
should_render_with_layout | |
should_render_template :new | |
should_not_set_the_flash | |
end | |
context "on GET to :show" do | |
setup do | |
get :show, {:id => @alert_collaborator.id} | |
end | |
should_respond_with :success | |
should_render_with_layout | |
should_render_template :show | |
end | |
context "on GET to :edit" do | |
setup do | |
get :edit, :id => @alert_collaborator.id | |
end | |
should_respond_with :success | |
should_render_with_layout | |
should_render_template :edit | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment