Created
June 24, 2010 08:43
-
-
Save mallain/451179 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 | |
should_get_action :index | |
should_get_action :new | |
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 | |
should_not_set_the_flash | |
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 | |
should_not_set_the_flash | |
end | |
context "on PUT to :update (valid data)" do | |
setup do | |
@alert_collaborator.expects(:update_attributes).returns(true).once | |
put :update, :id => @alert_collaborator.id, :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 PUT to :update (invalid data)" do | |
setup do | |
@alert_collaborator.expects(:update_attributes).returns(false).once | |
put :update, :id => @alert_collaborator.id, :alert_collaborator => {} | |
end | |
should_assign_to :alert_collaborator, :class => AlertCollaborator | |
should_respond_with :success | |
should_render_template :edit | |
end | |
context "on DELETE to :destroy" do | |
setup do | |
@alert_collaborator.expects(:destroy).returns(true).once | |
delete :destroy, :id => @alert_collaborator.id | |
end | |
should_assign_to(:alert_collaborator){@alert_collaborator} | |
should_respond_with :redirect | |
should_redirect_to("alert_collaborator index page"){hr_alert_collaborators_path} | |
end | |
end | |
end |
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
class Hr::ArrivalCollaboratorsController < ApplicationController | |
resource_controller | |
before_filter :require_user | |
before_filter :load_data | |
create.wants.html { redirect_to hr_arrival_collaborators_path } | |
update.wants.html { redirect_to hr_arrival_collaborators_path } | |
create.before { | |
@arrival_collaborator.agency = current_agency | |
@arrival_collaborator.feedback = current_time | |
} | |
def load_data | |
@arrival_collaborators_agency = ArrivalCollaborator.find(:all, :conditions => {:agency_id => current_agency.id, :feedback_id => current_time.id}) | |
end | |
end |
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
mickael@mickael-laptop:~/projects/pabd/test$ ruby functional/hr/alert_collaborators_controller_test.rb | |
Loaded suite functional/hr/alert_collaborators_controller_test | |
Started | |
................................. | |
Finished in 5.545446 seconds. | |
33 tests, 50 assertions, 0 failures, 0 errors |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Voilà, je viens de trouver le pourquoi du comment, il "suffisait" de transformer :
(Ligne 90) @alert_collaborator.expects(:destroy).once
en
(Ligne 90) @alert_collaborator.expects(:destroy).returns(true).once
Dans le fichier "alert_collaborators_controller_test.rb"
Une bonne chose de faite.