[#6441] Block editing Locked or Closed Deliverables.

This commit is contained in:
Eric Davis
2011-08-08 15:52:13 -07:00
parent 51f62ca5a3
commit ac24ae08e6
4 changed files with 202 additions and 2 deletions

View File

@@ -9,7 +9,7 @@ class DeliverablesEditTest < ActionController::IntegrationTest
@manager = User.generate!
@role = Role.generate!
User.add_to_project(@manager, @project, @role)
@fixed_deliverable = FixedDeliverable.generate!(:contract => @contract, :manager => @manager, :title => 'The Title')
@fixed_deliverable = FixedDeliverable.generate!(:contract => @contract, :manager => @manager, :title => 'The Title', :notes => "", :feature_sign_off => false, :warranty_sign_off => false)
@hourly_deliverable = HourlyDeliverable.generate!(:contract => @contract, :manager => @manager, :title => 'An Hourly')
@user = User.generate_user_with_permission_to_manage_budget(:project => @project)
@@ -475,4 +475,168 @@ class DeliverablesEditTest < ActionController::IntegrationTest
assert_equal 3, @retainer_deliverable.fixed_budgets.count
assert_equal [600, nil, nil], @retainer_deliverable.fixed_budgets.collect(&:budget)
end
context "locked deliverable" do
setup do
assert @fixed_deliverable.lock!
end
should "block edits to locked deliverables" do
visit_contract_page(@contract)
click_link_within "#deliverable_details_#{@fixed_deliverable.id}", 'Edit'
assert_response :success
within("#deliverable-details") do
fill_in "Title", :with => 'An updated title'
end
click_button "Save"
assert_response :success
assert_template 'deliverables/edit'
assert_not_equal "An updated title", @fixed_deliverable.reload.title
end
should "block edits to locked deliverables even when status changes to closed" do
visit_contract_page(@contract)
click_link_within "#deliverable_details_#{@fixed_deliverable.id}", 'Edit'
assert_response :success
within("#deliverable-details") do
fill_in "Title", :with => 'An updated title'
select "Closed", :from => "Status"
end
click_button "Save"
assert_response :success
assert_template 'deliverables/edit'
assert_not_equal "An updated title", @fixed_deliverable.reload.title
assert @fixed_deliverable.reload.locked?
end
should "be allowed to change the status on a locked deliverables to open" do
assert @fixed_deliverable.lock!
visit_contract_page(@contract)
click_link_within "#deliverable_details_#{@fixed_deliverable.id}", 'Edit'
assert_response :success
within("#deliverable-details") do
select "Open", :from => "Status"
end
click_button "Save"
assert_response :success
assert_template 'contracts/show'
assert @fixed_deliverable.reload.open?
end
should "be allowed to change the status on a locked deliverables to closed" do
assert @fixed_deliverable.lock!
visit_contract_page(@contract)
click_link_within "#deliverable_details_#{@fixed_deliverable.id}", 'Edit'
assert_response :success
within("#deliverable-details") do
select "Closed", :from => "Status"
end
click_button "Save"
assert_response :success
assert_template 'contracts/show'
assert @fixed_deliverable.reload.closed?
end
end
context "closed deliverable" do
setup do
assert @fixed_deliverable.close!
end
should "block edits to closed deliverables" do
visit_contract_page(@contract)
click_link_within "#deliverable_details_#{@fixed_deliverable.id}", 'Edit'
assert_response :success
within("#deliverable-details") do
fill_in "Title", :with => 'An updated title'
end
click_button "Save"
assert_response :success
assert_template 'deliverables/edit'
assert_not_equal "An updated title", @fixed_deliverable.reload.title
end
should "block edits to closed deliverables even when the status is changed to locked" do
visit_contract_page(@contract)
click_link_within "#deliverable_details_#{@fixed_deliverable.id}", 'Edit'
assert_response :success
within("#deliverable-details") do
fill_in "Title", :with => 'An updated title'
select "Locked", :from => "Status"
end
click_button "Save"
assert_response :success
assert_template 'deliverables/edit'
assert_not_equal "An updated title", @fixed_deliverable.reload.title
assert @fixed_deliverable.reload.closed?
end
should "be allowed to change the status on a closed deliverables to open" do
assert @fixed_deliverable.close!
visit_contract_page(@contract)
click_link_within "#deliverable_details_#{@fixed_deliverable.id}", 'Edit'
assert_response :success
within("#deliverable-details") do
select "Open", :from => "Status"
end
click_button "Save"
assert_response :success
assert_template 'contracts/show'
assert @fixed_deliverable.reload.open?
end
should "be allowed to change the status on a closed deliverables to Locked" do
assert @fixed_deliverable.lock!
visit_contract_page(@contract)
click_link_within "#deliverable_details_#{@fixed_deliverable.id}", 'Edit'
assert_response :success
within("#deliverable-details") do
select "Locked", :from => "Status"
end
click_button "Save"
assert_response :success
assert_template 'contracts/show'
assert @fixed_deliverable.reload.locked?
end
end
end