Building specs for the controller. #1135
This commit is contained in:
1 parent
15cc2c992d
commit
5919d7b177
2 files changed
+25
-1
No files matched your search
@@ -4,7 +4,7 @@ class DeliverablesController < ApplicationController
|
|||||||
before_filter :find_project, :authorize, :get_settings
|
before_filter :find_project, :authorize, :get_settings
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@deliverables = Deliverable.find(:all)
|
@deliverables = Deliverable.find_all_by_project_id(@project.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -8,3 +8,27 @@ describe DeliverablesController do
|
|||||||
end
|
end
|
||||||
|
|
||||||
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
|
||||||
Reference in new issue
Block a user