[#6441] Don't hide or disable the issue's current deliverable
This commit is contained in:
1 parent
e019a9435e
commit
1b4191dc15
3 files changed
+66
-14
No files matched your search
@@ -25,17 +25,24 @@ module ContractsHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
def grouped_deliverable_options_for_select(project, selected_key=nil)
|
def grouped_deliverable_options_for_select(project, selected_key=nil)
|
||||||
project.contracts.with_status(["open","locked"]).inject([]) do |html, contract|
|
project.contracts.all(:include => :deliverables).inject([]) do |html, contract|
|
||||||
options = contract.deliverables.with_status(["open","locked"]).collect do |deliverable|
|
if contract.closed? && !contract.deliverable_ids.include?(selected_key.to_i)
|
||||||
option_attributes = {}
|
# skip
|
||||||
option_attributes[:value] = h(deliverable.id)
|
else
|
||||||
option_attributes[:selected] = "selected" if selected_key.to_i == deliverable.id
|
options = contract.deliverables.collect do |deliverable|
|
||||||
option_attributes[:disabled] = "disabled" if deliverable.locked? || contract.locked?
|
option_attributes = {}
|
||||||
|
option_attributes[:value] = h(deliverable.id)
|
||||||
content_tag(:option, h(deliverable.title), option_attributes)
|
option_attributes[:selected] = "selected" if selected_key.to_i == deliverable.id
|
||||||
end
|
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.join('\n')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -289,7 +289,8 @@ class Deliverable < ActiveRecord::Base
|
|||||||
|
|
||||||
if Rails.env.test?
|
if Rails.env.test?
|
||||||
generator_for :title, :method => :next_title
|
generator_for :title, :method => :next_title
|
||||||
|
generator_for :status, 'open'
|
||||||
|
|
||||||
def self.next_title
|
def self.next_title
|
||||||
@last_title ||= 'Deliverable 0000'
|
@last_title ||= 'Deliverable 0000'
|
||||||
@last_title.succ!
|
@last_title.succ!
|
||||||
|
|||||||
+47
-3
@@ -15,14 +15,15 @@ class RedmineContracts::Hooks::ViewIssuesFormDetailsBottomTest < ActionControlle
|
|||||||
@manager = User.generate!(:login => 'manager', :password => 'existing', :password_confirmation => 'existing')
|
@manager = User.generate!(:login => 'manager', :password => 'existing', :password_confirmation => 'existing')
|
||||||
@role = Role.generate!(:permissions => [:view_issues, :edit_issues])
|
@role = Role.generate!(:permissions => [:view_issues, :edit_issues])
|
||||||
User.add_to_project(@manager, @project, @role)
|
User.add_to_project(@manager, @project, @role)
|
||||||
@deliverable1 = FixedDeliverable.generate!(:contract => @contract1, :manager => @manager, :title => 'The Title')
|
@deliverable1 = FixedDeliverable.generate!(:contract => @contract1, :manager => @manager, :title => 'Deliverable1')
|
||||||
@deliverable2 = FixedDeliverable.generate!(:contract => @contract2, :manager => @manager, :title => 'The Title')
|
@deliverable2 = FixedDeliverable.generate!(:contract => @contract2, :manager => @manager, :title => 'Deliverable2')
|
||||||
@locked_deliverable = FixedDeliverable.generate!(:contract => @contract1, :manager => @manager, :title => 'Locked Deliverable', :status => 'locked')
|
@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')
|
@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')
|
@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')
|
@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')
|
@deliverable_on_closed_contract = FixedDeliverable.generate!(:contract => @closed_contract, :manager => @manager, :title => 'Deliverable on closed contract')
|
||||||
@issue.deliverable = @deliverable1
|
@issue.deliverable = @deliverable1
|
||||||
|
assert @issue.save
|
||||||
|
|
||||||
login_as('manager', 'existing')
|
login_as('manager', 'existing')
|
||||||
end
|
end
|
||||||
@@ -74,7 +75,50 @@ class RedmineContracts::Hooks::ViewIssuesFormDetailsBottomTest < ActionControlle
|
|||||||
assert_select "option", :text => /#{@deliverable_on_closed_contract.title}/, :count => 0
|
assert_select "option", :text => /#{@deliverable_on_closed_contract.title}/, :count => 0
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
||||||
context "with no permission to Assign Deliverable" do
|
context "with no permission to Assign Deliverable" do
|
||||||
|
|||||||
Reference in new issue
Block a user