[#5421] Add Assign Deliverable to Issue permission for the new/edit issue form
This commit is contained in:
@@ -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]} ]
|
||||
|
||||
4
init.rb
4
init.rb
@@ -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)
|
||||
|
||||
|
||||
@@ -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' }
|
||||
|
||||
Reference in New Issue
Block a user