[#3294] Allow the query string to control if the new deliverable form is visible.

This commit is contained in:
Eric Davis
2009-11-11 13:11:21 -08:00
parent aa541f42bb
commit d552aa7f6f
3 changed files with 13 additions and 1 deletions

View File

@@ -27,6 +27,8 @@ class DeliverablesController < ApplicationController
@budget = Budget.new(@project.id)
@display_form = params[:new].present?
respond_to do |format|
format.html { render :action => 'index', :layout => !request.xhr? }
end

View File

@@ -3,7 +3,7 @@
</div>
<% if allowed_management? %>
<div id="new-deliverable" style="display:none;">
<div id="new-deliverable" style="<%= @display_form ? '' : 'display:none;' -%>">
<h2><%= l(:label_new_deliverable) %></h2>
<% remote_form_for :deliverable, @deliverable, :url => {:controller => 'deliverables', :action => 'create', :id => @project },
:method => :post, :builder => TabularFormBuilder, :lang => current_language,

View File

@@ -31,6 +31,16 @@ describe DeliverablesController,"#index when logged in" do
assigns[:deliverables].should_not be_nil
end
it "should set @display_form to false by default" do
get :index, :id => @project.id
assigns[:display_form].should eql(false)
end
it "should set @display_form to true if the 'new' parameter is used" do
get :index, :id => @project.id, :new => 'true'
assigns[:display_form].should eql(true)
end
it "should only show the deliverables for the current project only" do
# TODO: Get spec working for full finder
Deliverable.should_receive(:find)