[#3294] Expand the new form if the project doesn't have any deliverables yet.
This commit is contained in:
@@ -27,7 +27,7 @@ class DeliverablesController < ApplicationController
|
|||||||
|
|
||||||
@budget = Budget.new(@project.id)
|
@budget = Budget.new(@project.id)
|
||||||
|
|
||||||
@display_form = params[:new].present?
|
@display_form = params[:new].present? || @deliverables.empty?
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { render :action => 'index', :layout => !request.xhr? }
|
format.html { render :action => 'index', :layout => !request.xhr? }
|
||||||
|
|||||||
@@ -12,9 +12,10 @@ end
|
|||||||
describe DeliverablesController,"#index when logged in" do
|
describe DeliverablesController,"#index when logged in" do
|
||||||
before(:each) do
|
before(:each) do
|
||||||
@project = mock_model(Project)
|
@project = mock_model(Project)
|
||||||
|
@deliverable = mock_model(Deliverable)
|
||||||
|
|
||||||
Deliverable.stub!(:count).and_return(0)
|
Deliverable.stub!(:count).and_return(1)
|
||||||
Deliverable.stub!(:find).and_return([])
|
Deliverable.stub!(:find).and_return([@deliverable])
|
||||||
|
|
||||||
Project.should_receive(:find).with(@project.to_param).and_return(@project)
|
Project.should_receive(:find).with(@project.to_param).and_return(@project)
|
||||||
Project.should_receive(:find).with(@project.id).and_return(@project)
|
Project.should_receive(:find).with(@project.id).and_return(@project)
|
||||||
@@ -36,6 +37,15 @@ describe DeliverablesController,"#index when logged in" do
|
|||||||
assigns[:display_form].should eql(false)
|
assigns[:display_form].should eql(false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should set @display_form to true if there are no deliverables" do
|
||||||
|
Deliverable.should_receive(:count).and_return(0)
|
||||||
|
Deliverable.should_receive(:find).and_return([])
|
||||||
|
|
||||||
|
get :index, :id => @project.id
|
||||||
|
|
||||||
|
assigns[:display_form].should eql(true)
|
||||||
|
end
|
||||||
|
|
||||||
it "should set @display_form to true if the 'new' parameter is used" do
|
it "should set @display_form to true if the 'new' parameter is used" do
|
||||||
get :index, :id => @project.id, :new => 'true'
|
get :index, :id => @project.id, :new => 'true'
|
||||||
assigns[:display_form].should eql(true)
|
assigns[:display_form].should eql(true)
|
||||||
|
|||||||
Reference in New Issue
Block a user