[#6441] Block logging time on locked contracts and deliverables
This commit is contained in:
@@ -4,6 +4,8 @@ en:
|
||||
messages:
|
||||
cant_create_time_on_closed_deliverable: "Can't create a time entry on a closed deliverable"
|
||||
cant_create_time_on_closed_contract: "Can't create a time entry on a closed contract"
|
||||
cant_create_time_on_locked_deliverable: "Can't create a time entry on a locked deliverable"
|
||||
cant_create_time_on_locked_contract: "Can't create a time entry on a locked contract"
|
||||
cant_assign_to_closed_deliverable: "Can't assign issue to a closed deliverable"
|
||||
cant_assign_to_locked_deliverable: "Can't assign issue to a locked deliverable"
|
||||
cant_update_locked_deliverable: "Can't update a locked deliverable"
|
||||
|
||||
@@ -13,12 +13,14 @@ module RedmineContracts
|
||||
|
||||
def validate_deliverable_status
|
||||
if issue.present? && issue.deliverable.present?
|
||||
errors.add_to_base(:cant_create_time_on_locked_deliverable) if issue.deliverable.locked?
|
||||
errors.add_to_base(:cant_create_time_on_closed_deliverable) if issue.deliverable.closed?
|
||||
end
|
||||
end
|
||||
|
||||
def validate_contract_status
|
||||
if issue.present? && issue.deliverable.present? && issue.deliverable.contract.present?
|
||||
errors.add_to_base(:cant_create_time_on_locked_contract) if issue.deliverable.contract.locked?
|
||||
errors.add_to_base(:cant_create_time_on_closed_contract) if issue.deliverable.contract.closed?
|
||||
end
|
||||
end
|
||||
|
||||
@@ -24,6 +24,14 @@ class RedmineContracts::Patches::TimeEntryTest < ActionController::TestCase
|
||||
:user => @user)
|
||||
end
|
||||
|
||||
def assert_error_about_locked_deliverable(time_entry)
|
||||
assert_equal "Can't create a time entry on a locked deliverable", time_entry.errors.on_base
|
||||
end
|
||||
|
||||
def assert_error_about_locked_contract(time_entry)
|
||||
assert_equal "Can't create a time entry on a locked contract", time_entry.errors.on_base
|
||||
end
|
||||
|
||||
def assert_error_about_closed_deliverable(time_entry)
|
||||
assert_equal "Can't create a time entry on a closed deliverable", time_entry.errors.on_base
|
||||
end
|
||||
@@ -36,27 +44,31 @@ class RedmineContracts::Patches::TimeEntryTest < ActionController::TestCase
|
||||
assert_difference("TimeEntry.count") { create_time_entry }
|
||||
end
|
||||
|
||||
should "allow logging time to an issue on a locked deliverable, open contract" do
|
||||
should "block logging time to an issue on a locked deliverable, open contract" do
|
||||
assert @deliverable.lock!
|
||||
assert @deliverable.locked?
|
||||
|
||||
assert_difference("TimeEntry.count") { create_time_entry }
|
||||
assert_no_difference("TimeEntry.count") { create_time_entry }
|
||||
assert_error_about_locked_deliverable(@time_entry)
|
||||
end
|
||||
|
||||
should "allow logging time to an issue on an open deliverable, locked contract" do
|
||||
should "block logging time to an issue on an open deliverable, locked contract" do
|
||||
assert @contract.lock!
|
||||
assert @contract.locked?
|
||||
|
||||
assert_difference("TimeEntry.count") { create_time_entry }
|
||||
assert_no_difference("TimeEntry.count") { create_time_entry }
|
||||
assert_error_about_locked_contract(@time_entry)
|
||||
end
|
||||
|
||||
should "allow logging time to an issue on a locked deliverable, locked contract" do
|
||||
should "block logging time to an issue on a locked deliverable, locked contract" do
|
||||
assert @deliverable.lock!
|
||||
assert @deliverable.locked?
|
||||
assert @contract.lock!
|
||||
assert @contract.locked?
|
||||
|
||||
assert_difference("TimeEntry.count") { create_time_entry }
|
||||
assert_no_difference("TimeEntry.count") { create_time_entry }
|
||||
assert @time_entry.errors.on_base.include?("Can't create a time entry on a locked deliverable")
|
||||
assert @time_entry.errors.on_base.include?("Can't create a time entry on a locked contract")
|
||||
end
|
||||
|
||||
should "block logging time to an issue on a closed deliverable, open contract" do
|
||||
@@ -74,7 +86,8 @@ class RedmineContracts::Patches::TimeEntryTest < ActionController::TestCase
|
||||
assert @contract.locked?
|
||||
|
||||
assert_no_difference("TimeEntry.count") { create_time_entry }
|
||||
assert_error_about_closed_deliverable(@time_entry)
|
||||
assert @time_entry.errors.on_base.include?("Can't create a time entry on a closed deliverable")
|
||||
assert @time_entry.errors.on_base.include?("Can't create a time entry on a locked contract")
|
||||
end
|
||||
|
||||
should "block logging time to an issue on an open deliverable, closed contract" do
|
||||
@@ -92,7 +105,8 @@ class RedmineContracts::Patches::TimeEntryTest < ActionController::TestCase
|
||||
assert @contract.closed?
|
||||
|
||||
assert_no_difference("TimeEntry.count") { create_time_entry }
|
||||
assert_error_about_closed_contract(@time_entry)
|
||||
assert @time_entry.errors.on_base.include?("Can't create a time entry on a locked deliverable")
|
||||
assert @time_entry.errors.on_base.include?("Can't create a time entry on a closed contract")
|
||||
end
|
||||
|
||||
should "block logging time to an issue on a closed deliverable, closed contract" do
|
||||
|
||||
Reference in New Issue
Block a user