[#6441] Don't hide or disable the issue's current deliverable
This commit is contained in:
@@ -25,17 +25,24 @@ module ContractsHelper
|
||||
end
|
||||
|
||||
def grouped_deliverable_options_for_select(project, selected_key=nil)
|
||||
project.contracts.with_status(["open","locked"]).inject([]) do |html, contract|
|
||||
options = contract.deliverables.with_status(["open","locked"]).collect do |deliverable|
|
||||
option_attributes = {}
|
||||
option_attributes[:value] = h(deliverable.id)
|
||||
option_attributes[:selected] = "selected" if selected_key.to_i == deliverable.id
|
||||
option_attributes[:disabled] = "disabled" if deliverable.locked? || contract.locked?
|
||||
|
||||
content_tag(:option, h(deliverable.title), option_attributes)
|
||||
end
|
||||
project.contracts.all(:include => :deliverables).inject([]) do |html, contract|
|
||||
if contract.closed? && !contract.deliverable_ids.include?(selected_key.to_i)
|
||||
# skip
|
||||
else
|
||||
options = contract.deliverables.collect do |deliverable|
|
||||
option_attributes = {}
|
||||
option_attributes[:value] = h(deliverable.id)
|
||||
option_attributes[:selected] = "selected" if selected_key.to_i == deliverable.id
|
||||
option_attributes[:disabled] = "disabled" if (deliverable.locked? || contract.locked?) && selected_key.to_i != deliverable.id
|
||||
|
||||
html << content_tag(:optgroup, options.join("\n"), :label => h(contract.name))
|
||||
next if deliverable.closed? && option_attributes[:selected].blank? # Skip unselected, closed
|
||||
|
||||
content_tag(:option, h(deliverable.title), option_attributes)
|
||||
end
|
||||
|
||||
html << content_tag(:optgroup, options.join("\n"), :label => h(contract.name))
|
||||
end
|
||||
html
|
||||
end.join('\n')
|
||||
end
|
||||
|
||||
|
||||
@@ -289,7 +289,8 @@ class Deliverable < ActiveRecord::Base
|
||||
|
||||
if Rails.env.test?
|
||||
generator_for :title, :method => :next_title
|
||||
|
||||
generator_for :status, 'open'
|
||||
|
||||
def self.next_title
|
||||
@last_title ||= 'Deliverable 0000'
|
||||
@last_title.succ!
|
||||
|
||||
+47
-3
@@ -15,14 +15,15 @@ class RedmineContracts::Hooks::ViewIssuesFormDetailsBottomTest < ActionControlle
|
||||
@manager = User.generate!(:login => 'manager', :password => 'existing', :password_confirmation => 'existing')
|
||||
@role = Role.generate!(:permissions => [:view_issues, :edit_issues])
|
||||
User.add_to_project(@manager, @project, @role)
|
||||
@deliverable1 = FixedDeliverable.generate!(:contract => @contract1, :manager => @manager, :title => 'The Title')
|
||||
@deliverable2 = FixedDeliverable.generate!(:contract => @contract2, :manager => @manager, :title => 'The Title')
|
||||
@deliverable1 = FixedDeliverable.generate!(:contract => @contract1, :manager => @manager, :title => 'Deliverable1')
|
||||
@deliverable2 = FixedDeliverable.generate!(:contract => @contract2, :manager => @manager, :title => 'Deliverable2')
|
||||
@locked_deliverable = FixedDeliverable.generate!(:contract => @contract1, :manager => @manager, :title => 'Locked Deliverable', :status => 'locked')
|
||||
@closed_deliverable = FixedDeliverable.generate!(:contract => @contract1, :manager => @manager, :title => 'Closed Deliverable', :status => 'closed')
|
||||
@deliverable1_on_locked_contract = FixedDeliverable.generate!(:contract => @locked_contract, :manager => @manager, :title => 'Deliverable 1 on locked contract')
|
||||
@deliverable2_on_locked_contract = FixedDeliverable.generate!(:contract => @locked_contract, :manager => @manager, :title => 'Deliverable 2 on locked contract')
|
||||
@deliverable_on_closed_contract = FixedDeliverable.generate!(:contract => @closed_contract, :manager => @manager, :title => 'Deliverable on closed contract')
|
||||
@issue.deliverable = @deliverable1
|
||||
assert @issue.save
|
||||
|
||||
login_as('manager', 'existing')
|
||||
end
|
||||
@@ -74,7 +75,50 @@ class RedmineContracts::Hooks::ViewIssuesFormDetailsBottomTest < ActionControlle
|
||||
assert_select "option", :text => /#{@deliverable_on_closed_contract.title}/, :count => 0
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
should "show the assigned deliverable as an option, even if it's locked" do
|
||||
@deliverable1.lock!
|
||||
visit_issue_page(@issue)
|
||||
|
||||
assert_select "select#issue_deliverable_id" do
|
||||
assert_select "option[disabled=disabled]", :text => /#{@deliverable1.title}/, :count => 0 # Not disabled
|
||||
assert_select "option", :text => /#{@deliverable1.title}/, :count => 1 # Present
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
should "show the assigned deliverable as an option, even if it's closed" do
|
||||
@deliverable1.close!
|
||||
visit_issue_page(@issue)
|
||||
|
||||
assert_select "select#issue_deliverable_id" do
|
||||
assert_select "option[disabled=disabled]", :text => /#{@deliverable1.title}/, :count => 0 # Not disabled
|
||||
assert_select "option", :text => /#{@deliverable1.title}/, :count => 1 # Present
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
should "show the assigned deliverable as an option, even if it's contract is locked" do
|
||||
@contract1.lock!
|
||||
visit_issue_page(@issue)
|
||||
|
||||
assert_select "select#issue_deliverable_id" do
|
||||
assert_select "option[disabled=disabled]", :text => /#{@deliverable1.title}/, :count => 0 # Not disabled
|
||||
assert_select "option", :text => /#{@deliverable1.title}/, :count => 1 # Present
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
should "show the assigned deliverable as an option, even if it's contract is closed" do
|
||||
@contract1.close!
|
||||
visit_issue_page(@issue)
|
||||
|
||||
assert_select "select#issue_deliverable_id" do
|
||||
assert_select "option[disabled=disabled]", :text => /#{@deliverable1.title}/, :count => 0 # Not disabled
|
||||
assert_select "option", :text => /#{@deliverable1.title}/, :count => 1 # Present
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
context "with no permission to Assign Deliverable" do
|
||||
|
||||
Reference in New Issue
Block a user