[#4177] Hooked up the create action for contracts.
This commit is contained in:
@@ -6,6 +6,10 @@ class ContractsController < InheritedResources::Base
|
|||||||
before_filter :find_project
|
before_filter :find_project
|
||||||
before_filter :authorize
|
before_filter :authorize
|
||||||
|
|
||||||
|
def create
|
||||||
|
create! { contract_url(@project, resource) }
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def begin_of_association_chain
|
def begin_of_association_chain
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<% collection.each do |contract| %>
|
<% collection.each do |contract| %>
|
||||||
<% content_tag_for(:tr, contract) do %>
|
<% content_tag_for(:tr, contract) do %>
|
||||||
<td class="id"><%= h contract.id %></td>
|
<td class="id"><%= link_to(h(contract.id), contract_path(@project, contract)) %></td>
|
||||||
<td class="name"><%= h contract.name %></td>
|
<td class="name"><%= h contract.name %></td>
|
||||||
<td class="account-executive"><%= h contract.account_executive.name %></td>
|
<td class="account-executive"><%= h contract.account_executive.name %></td>
|
||||||
<td class="end-date"><%= h format_date(contract.end_date) %></td>
|
<td class="end-date"><%= h format_date(contract.end_date) %></td>
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
@@ -14,7 +14,7 @@ Redmine::Plugin.register :redmine_contracts do
|
|||||||
requires_redmine_plugin :redmine_rate, :version_or_higher => '0.1.0'
|
requires_redmine_plugin :redmine_rate, :version_or_higher => '0.1.0'
|
||||||
|
|
||||||
project_module :contracts do
|
project_module :contracts do
|
||||||
permission :manage_budget, {:contracts => [:index, :new] }, :public => true
|
permission :manage_budget, {:contracts => [:index, :new, :create, :show] }, :public => true
|
||||||
end
|
end
|
||||||
|
|
||||||
menu(:project_menu,
|
menu(:project_menu,
|
||||||
|
|||||||
@@ -15,4 +15,30 @@ class ContractsNewTest < ActionController::IntegrationTest
|
|||||||
assert_select "form#new_contract"
|
assert_select "form#new_contract"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "create a new contract" do
|
||||||
|
@account_executive = User.generate!
|
||||||
|
|
||||||
|
visit_contracts_for_project(@project)
|
||||||
|
click_link 'New Contract'
|
||||||
|
assert_response :success
|
||||||
|
|
||||||
|
fill_in "Name", :with => 'A New Contract'
|
||||||
|
select @account_executive.name, :from => "Account Executive"
|
||||||
|
fill_in "Start", :with => '2010-01-01'
|
||||||
|
fill_in "End Date", :with => '2010-12-31'
|
||||||
|
select "Net 30", :from => "Payment Terms"
|
||||||
|
|
||||||
|
click_button "Create Contract"
|
||||||
|
|
||||||
|
assert_response :success
|
||||||
|
assert_template 'contracts/show'
|
||||||
|
|
||||||
|
@contract = Contract.last
|
||||||
|
assert_equal "A New Contract", @contract.name
|
||||||
|
assert_equal @account_executive, @contract.account_executive
|
||||||
|
assert_equal '2010-01-01', @contract.start_date.to_s
|
||||||
|
assert_equal '2010-12-31', @contract.end_date.to_s
|
||||||
|
assert_equal 'net_30', @contract.payment_terms
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user