diff --git a/app/views/issues/_edit_deliverable.html.erb b/app/views/issues/_edit_deliverable.html.erb index 7f519e4..47fd42b 100644 --- a/app/views/issues/_edit_deliverable.html.erb +++ b/app/views/issues/_edit_deliverable.html.erb @@ -1,4 +1,4 @@ -<% if project.module_enabled?(:contracts) %> +<% if project.module_enabled?(:contracts) && User.current.allowed_to?(:assign_deliverable_to_issue, project) %>

<% options = project.contracts.inject([]) {|data, contract| data << [contract.name, contract.deliverables.collect {|d| [d.title, d.id]} ] diff --git a/init.rb b/init.rb index fcace09..6dd2fac 100644 --- a/init.rb +++ b/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) diff --git a/test/integration/redmine_contracts/hooks/view_issues_form_details_bottom_hook_test.rb b/test/integration/redmine_contracts/hooks/view_issues_form_details_bottom_hook_test.rb index e6c9a4e..e91b926 100644 --- a/test/integration/redmine_contracts/hooks/view_issues_form_details_bottom_hook_test.rb +++ b/test/integration/redmine_contracts/hooks/view_issues_form_details_bottom_hook_test.rb @@ -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' }