[#6441] Add a manual Contract#status
This commit is contained in:
@@ -48,12 +48,13 @@ class ContractsEditTest < ActionController::IntegrationTest
|
||||
end
|
||||
|
||||
fill_in "Name", :with => 'An updated name'
|
||||
select "Locked", :from => "Status"
|
||||
click_button "Save Contract"
|
||||
|
||||
assert_response :success
|
||||
assert_template 'contracts/show'
|
||||
|
||||
assert_equal "An updated name", @contract.reload.name
|
||||
|
||||
assert_equal "locked", @contract.reload.status
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,8 +5,10 @@ class ContractsListTest < ActionController::IntegrationTest
|
||||
|
||||
def setup
|
||||
@project = Project.generate!(:identifier => 'main')
|
||||
@contract = Contract.generate!(:project => @project)
|
||||
@contract2 = Contract.generate!(:project => @project)
|
||||
@contract = Contract.generate!(:project => @project, :name => 'Contract1').reload
|
||||
@contract2 = Contract.generate!(:project => @project, :name => 'Contract2').reload
|
||||
@contract_locked = Contract.generate!(:project => @project, :status => 'locked', :name => 'LockedContract').reload
|
||||
@contract_closed = Contract.generate!(:project => @project, :status => 'closed', :name => 'ClosedContract').reload
|
||||
|
||||
@other_project = Project.generate!(:identifier => 'other')
|
||||
@other_contract = Contract.generate!(:project => @other_project)
|
||||
@@ -44,10 +46,10 @@ class ContractsListTest < ActionController::IntegrationTest
|
||||
visit_contracts_for_project(@project)
|
||||
end
|
||||
|
||||
should "list all contracts for the project" do
|
||||
should "list all contracts for the project grouped by status" do
|
||||
visit_contracts_for_project(@project)
|
||||
|
||||
assert_select "table#contracts" do
|
||||
assert_select "table#contracts.open" do
|
||||
[@contract, @contract2].each do |contract|
|
||||
assert_select "td.id", :text => /#{contract.id}/
|
||||
assert_select "td.name", :text => /#{contract.name}/
|
||||
@@ -56,7 +58,23 @@ class ContractsListTest < ActionController::IntegrationTest
|
||||
assert_select "td.total-budget"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
assert_select "table#contracts.locked" do
|
||||
assert_select "td.id", :text => /#{@contract_locked.id}/
|
||||
assert_select "td.name", :text => /#{@contract_locked.name}/
|
||||
assert_select "td.account-executive", :text => /#{@contract_locked.account_executive.name}/
|
||||
assert_select "td.end-date", :text => /#{format_date(@contract_locked.end_date)}/
|
||||
assert_select "td.total-budget"
|
||||
end
|
||||
|
||||
assert_select "table#contracts.closed" do
|
||||
assert_select "td.id", :text => /#{@contract_closed.id}/
|
||||
assert_select "td.name", :text => /#{@contract_closed.name}/
|
||||
assert_select "td.account-executive", :text => /#{@contract_closed.account_executive.name}/
|
||||
assert_select "td.end-date", :text => /#{format_date(@contract_closed.end_date)}/
|
||||
assert_select "td.total-budget"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
should "not list contracts from other projects" do
|
||||
|
||||
@@ -52,6 +52,7 @@ class ContractsNewTest < ActionController::IntegrationTest
|
||||
fill_in "Start", :with => '2010-01-01'
|
||||
fill_in "End Date", :with => '2010-12-31'
|
||||
select "Net 30", :from => "Payment Terms"
|
||||
select "Locked", :from => "Status"
|
||||
|
||||
click_button "Save Contract"
|
||||
|
||||
@@ -64,6 +65,7 @@ class ContractsNewTest < ActionController::IntegrationTest
|
||||
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_term.name
|
||||
assert_equal "locked", @contract.status
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -17,6 +17,9 @@ class ContractTest < ActiveSupport::TestCase
|
||||
should_allow_values_for :discount_type, "$", "%", nil, ''
|
||||
should_not_allow_values_for :discount_type, ["amount", "percent", "bar"]
|
||||
|
||||
should_allow_values_for :status, "", nil, 'open', 'locked', 'closed'
|
||||
should_not_allow_values_for :status, "other", "things", "1"
|
||||
|
||||
context "end_date" do
|
||||
should "be after start_date" do
|
||||
@contract = Contract.new(:start_date => Date.today, :end_date => Date.yesterday)
|
||||
@@ -32,6 +35,12 @@ class ContractTest < ActiveSupport::TestCase
|
||||
assert_equal false, @contract.executed
|
||||
end
|
||||
|
||||
should "default status to open" do
|
||||
@contract = Contract.new
|
||||
|
||||
assert_equal "open", @contract.status
|
||||
end
|
||||
|
||||
context "#labor_budget" do
|
||||
should "sum all of the labor budgets of the Deliverables" do
|
||||
contract = Contract.generate!
|
||||
|
||||
Reference in New Issue
Block a user