[#4410] Replace Payment Terms with an Enumeration

Instead of using a hard coded value for Payment Terms, they will use
Redmine's Enumeration table.  This provides an admin gui to managing
the value as well as ordering them.
This commit is contained in:
Eric Davis
2010-08-12 09:26:09 -07:00
parent c17e8eaf1b
commit a2b810a4d8
18 changed files with 110 additions and 31 deletions
+1 -1
View File
@@ -5,7 +5,7 @@ class ContractsDeleteTest < ActionController::IntegrationTest
def setup
@project = Project.generate!(:identifier => 'main')
@contract = Contract.generate!(:project => @project, :name => 'A Contract', :payment_terms => 'net_15')
@contract = Contract.generate!(:project => @project, :name => 'A Contract')
end
should "allow admins to delete the contract" do
+2 -4
View File
@@ -8,7 +8,7 @@ class ContractsEditTest < ActionController::IntegrationTest
@account_executive = User.generate!
@role = Role.generate!
User.add_to_project(@account_executive, @project, @role)
@contract = Contract.generate!(:project => @project, :name => 'A Contract', :payment_terms => 'net_15', :account_executive => @account_executive)
@contract = Contract.generate!(:project => @project, :name => 'A Contract', :account_executive => @account_executive)
end
should "allow any user to edit the contract" do
@@ -23,9 +23,7 @@ class ContractsEditTest < ActionController::IntegrationTest
assert_select "h2", :text => /#{@contract.name}/
assert_select "form#edit_contract_#{@contract.id}.contract" do
assert_select "input[value=?]", /#{@contract.name}/
assert_select "select#contract_payment_terms" do
assert_select "option[selected=selected][value=net_15]"
end
assert_select "select#contract_payment_term_id"
end
fill_in "Name", :with => 'An updated name'
+3 -1
View File
@@ -5,6 +5,8 @@ class ContractsNewTest < ActionController::IntegrationTest
def setup
@project = Project.generate!(:identifier => 'main')
PaymentTerm.generate!(:type => 'PaymentTerm', :name => 'Net 15')
PaymentTerm.generate!(:type => 'PaymentTerm', :name => 'Net 30')
end
should "allow any user to open the new contracts form" do
@@ -40,7 +42,7 @@ class ContractsNewTest < ActionController::IntegrationTest
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
assert_equal 'Net 30', @contract.payment_term.name
end
end
+1 -1
View File
@@ -5,7 +5,7 @@ class DeliverablesDeleteTest < ActionController::IntegrationTest
def setup
@project = Project.generate!(:identifier => 'main')
@contract = Contract.generate!(:project => @project, :name => 'A Contract', :payment_terms => 'net_15')
@contract = Contract.generate!(:project => @project, :name => 'A Contract')
@manager = User.generate!
@deliverable = FixedDeliverable.generate!(:contract => @contract, :manager => @manager)
end
+1 -1
View File
@@ -5,7 +5,7 @@ class DeliverablesEditTest < ActionController::IntegrationTest
def setup
@project = Project.generate!(:identifier => 'main')
@contract = Contract.generate!(:project => @project, :name => 'A Contract', :payment_terms => 'net_15')
@contract = Contract.generate!(:project => @project, :name => 'A Contract')
@manager = User.generate!
@role = Role.generate!
User.add_to_project(@manager, @project, @role)
@@ -3,7 +3,7 @@ require 'test_helper'
class OverheadPluginIntegrationTest < ActionController::IntegrationTest
def setup
@project = Project.generate!(:identifier => 'main')
@contract = Contract.generate!(:project => @project, :name => 'A Contract', :payment_terms => 'net_15')
@contract = Contract.generate!(:project => @project, :name => 'A Contract')
@manager = User.generate!
@role = Role.generate!
User.add_to_project(@manager, @project, @role)
+1
View File
@@ -3,6 +3,7 @@ require File.dirname(__FILE__) + '/../test_helper'
class ContractTest < ActiveSupport::TestCase
should_belong_to :account_executive
should_belong_to :project
should_belong_to :payment_term
should_have_many :deliverables
should_validate_presence_of :name
+40
View File
@@ -0,0 +1,40 @@
require File.dirname(__FILE__) + '/../test_helper'
class PaymentTermTest < ActiveSupport::TestCase
include Redmine::I18n
should_have_many(:contracts)
should "be a subclass of Enumeration" do
assert_equal Enumeration, PaymentTerm.superclass
end
context "#option_name" do
should "be Payment Terms" do
assert_equal "Payment Terms", l(PaymentTerm.new.option_name)
end
end
context "#objects_count" do
should "count the number of contracts with this payment term" do
@payment_term = PaymentTerm.generate!(:type => 'PaymentTerm')
Contract.generate!(:payment_term => @payment_term)
Contract.generate!(:payment_term => @payment_term)
assert_equal 2, @payment_term.objects_count
end
end
context "#transfer_relations" do
should "update all contracts to use a new PaymentTerm" do
@old_payment_term = PaymentTerm.generate!(:type => 'PaymentTerm')
@new_payment_term = PaymentTerm.generate!(:type => 'PaymentTerm')
@contract1 = Contract.generate!(:payment_term => @old_payment_term)
@contract2 = Contract.generate!(:payment_term => @old_payment_term)
@old_payment_term.transfer_relations(@new_payment_term)
assert_equal @new_payment_term, @contract1.reload.payment_term
assert_equal @new_payment_term, @contract2.reload.payment_term
end
end
end