Building specs for the controller. #1135

This commit is contained in:
Eric Davis
2008-05-20 16:39:24 -07:00
parent 15cc2c992d
commit 5919d7b177
2 changed files with 25 additions and 1 deletions

View File

@@ -4,7 +4,7 @@ class DeliverablesController < ApplicationController
before_filter :find_project, :authorize, :get_settings
def index
@deliverables = Deliverable.find(:all)
@deliverables = Deliverable.find_all_by_project_id(@project.id)
end
private

View File

@@ -8,3 +8,27 @@ describe DeliverablesController do
end
end
describe DeliverablesController,"#index when logged in" do
before(:each) do
@project = mock_model(Project)
Deliverable.stub!(:find_all_by_project_id).and_return([])
Project.should_receive(:find).with(@project.to_param).and_return(@project)
controller.stub!(:authorize).and_return(true)
end
it "should be successful" do
get :index, :id => @project.id
response.should be_success
end
it "should set @deliverables for the view" do
get :index, :id => @project.id
assigns[:deliverables].should_not be_nil
end
it "should only show the deliverables for the current project only" do
Deliverable.should_receive(:find_all_by_project_id).with(@project.id)
get :index, :id => @project.id
end
end