[#6441] Block assigning issues to a locked or closed Deliverable

This commit is contained in:
Eric Davis
2011-08-08 15:14:22 -07:00
parent 07c3c42ca8
commit 51f62ca5a3
4 changed files with 94 additions and 5 deletions

View File

@@ -24,10 +24,10 @@ class RedmineContracts::Hooks::ControllerIssuesEditBeforeSaveTest < ActionContro
context "for a new issue" do
setup do
visit_project(@project)
click_link "New issue"
end
should "set the issue's deliverable" do
click_link "New issue"
fill_in "Subject", :with => 'Hook test'
select @deliverable2.title, :from => "Deliverable"
click_button "Create"
@@ -38,6 +38,38 @@ class RedmineContracts::Hooks::ControllerIssuesEditBeforeSaveTest < ActionContro
end
should "not allow setting a locked Deliverable" do
assert @deliverable2.lock!
click_link "New issue"
fill_in "Subject", :with => 'Hook test'
select @deliverable2.title, :from => "Deliverable"
assert_no_difference("Issue.count") do
click_button "Create"
assert_response :success
end
assert_equal nil, Issue.last.deliverable
end
should "not allow setting a closed Deliverable" do
assert @deliverable2.close!
click_link "New issue"
fill_in "Subject", :with => 'Hook test'
select @deliverable2.title, :from => "Deliverable"
assert_no_difference("Issue.count") do
click_button "Create"
assert_response :success
end
assert_equal nil, Issue.last.deliverable
end
context "with no permission to Assign Deliverable" do
should "not allow setting the Deliverable (force HTTP request)" do
@role.permissions.delete(:assign_deliverable_to_issue)
@@ -69,6 +101,51 @@ class RedmineContracts::Hooks::ControllerIssuesEditBeforeSaveTest < ActionContro
end
should "not allow updating to a locked deliverable" do
assert @deliverable2.lock!
select @deliverable2.title, :from => "Deliverable"
click_button "Submit"
assert_response :success
@issue.reload
assert_equal nil, @issue.deliverable
end
should "not allow updating to a closed deliverable" do
assert @deliverable2.close!
select @deliverable2.title, :from => "Deliverable"
click_button "Submit"
assert_response :success
@issue.reload
assert_equal nil, @issue.deliverable
end
should "allow updating an issue, even if the deliverable is locked as long as the deliverable isn't changed" do
select @deliverable2.title, :from => "Deliverable"
click_button "Submit"
assert_response :success
@issue.reload
assert_equal @deliverable2, @issue.deliverable
# Now normal update after locking
assert @deliverable2.lock!
fill_in "Subject", :with => 'Change subject'
click_button "Submit"
assert_response :success
@issue.reload
assert_equal "Change subject", @issue.subject
assert_equal @deliverable2, @issue.deliverable
end
context "with no permission to Assign Deliverable" do
should "not allow setting the Deliverable (force HTTP request)" do
@role.permissions.delete(:assign_deliverable_to_issue)