[#5421] Add Assign Deliverable to Issue permission for the new/edit issue form

This commit is contained in:
Eric Davis
2011-02-08 09:25:37 -08:00
parent 75680e5a49
commit 40fc6e9751
3 changed files with 33 additions and 13 deletions

View File

@@ -1,4 +1,4 @@
<% if project.module_enabled?(:contracts) %>
<% if project.module_enabled?(:contracts) && User.current.allowed_to?(:assign_deliverable_to_issue, project) %>
<p>
<% options = project.contracts.inject([]) {|data, contract|
data << [contract.name, contract.deliverables.collect {|d| [d.title, d.id]} ]

View File

@@ -21,6 +21,10 @@ Redmine::Plugin.register :redmine_contracts do
})
end
project_module :issue_tracking do
permission(:assign_deliverable_to_issue, {})
end
contract_list_submenu_items = Proc.new {|project|
if project && project.module_enabled?(:contracts)

View File

@@ -21,23 +21,39 @@ class RedmineContracts::Hooks::ViewIssuesFormDetailsBottomTest < ActionControlle
end
context "with Contracts Enabled" do
setup do
visit_issue_page(@issue)
end
should "render the a select field for the deliverables with all of the deliverables grouped by contract" do
assert_select "select#issue_deliverable_id" do
assert_select "optgroup[label=?]", @contract1.name do
assert_select "option", :text => /#{@deliverable1.title}/
end
context "with permission to Assign Deliverable" do
setup do
@role.permissions << :assign_deliverable_to_issue
@role.save!
visit_issue_page(@issue)
end
assert_select "optgroup[label=?]", @contract2.name do
assert_select "option", :text => /#{@deliverable2.title}/
should "render the a select field for the deliverables with all of the deliverables grouped by contract" do
assert_select "select#issue_deliverable_id" do
assert_select "optgroup[label=?]", @contract1.name do
assert_select "option", :text => /#{@deliverable1.title}/
end
assert_select "optgroup[label=?]", @contract2.name do
assert_select "option", :text => /#{@deliverable2.title}/
end
end
end
end
end
context "with no permission to Assign Deliverable" do
setup do
@role.permissions.delete(:assign_deliverable_to_issue)
@role.save!
visit_issue_page(@issue)
end
should "not render the deliverable select field" do
assert_select 'select#issue_deliverable_id', :count => 0
end
end
end
context "with Contracts Disabled" do
setup do
@project.enabled_modules.collect {|m| m.destroy if m.name == 'contracts' }