Merge pull request #65 from finnlabs/feature/bugfix-contextmenu
Feature/bugfix contextmenupull/6827/head
commit
e7f3949d87
@ -1,24 +1,27 @@ |
||||
<% if @project && @project.module_enabled?(:costs_module) %> |
||||
<% |
||||
cost_objects_any = false |
||||
possible_cost_objects = issues.inject(issues.first.project.cost_objects) do |intersect, work_package| |
||||
cost_objects_any = false |
||||
possible_cost_objects = issues.inject(issues.first.project.cost_objects) do |intersect, work_package| |
||||
cost_objects_any |= work_package.project.cost_objects.any? |
||||
work_package.project.cost_objects & intersect |
||||
end |
||||
%> |
||||
<li class="folder"> |
||||
<a href="#" class="submenu"><%= l(:label_cost_object) %></a> |
||||
<ul> |
||||
|
||||
<% unless possible_cost_objects.empty? -%> |
||||
<% possible_cost_objects.each do |co| -%> |
||||
<li> |
||||
<%= context_menu_link co.subject, {:controller => '/issues', :action => 'bulk_edit', :ids => issues.collect(&:id), 'cost_object_id' => co, :back_url => back}, :method => :post, |
||||
:selected => (issue && co == issue.cost_object), :disabled => !can[:edit] %> |
||||
</li> |
||||
<% end -%> |
||||
<%= context_menu_entry title: l(:label_cost_object), |
||||
back_url: back, |
||||
updated_object_ids: issues.collect(&:id), |
||||
collection: possible_cost_objects, |
||||
attribute: 'cost_object', |
||||
selected: lambda { |cost_object| @work_package && cost_object == @work_package.cost_object }, |
||||
disabled: lambda { |cost_object| !can[:edit] } %> |
||||
|
||||
<% else -%> |
||||
<li><%= l(cost_objects_any ? :notice_cost_object_conflict : :notice_no_cost_objects_available)%></li> |
||||
<li class="folder"> |
||||
<a href="#" class="submenu"><%= l(:label_cost_object) %></a> |
||||
<ul> |
||||
<li><%= l(cost_objects_any ? :notice_cost_object_conflict : :notice_no_cost_objects_available)%></li> |
||||
</ul> |
||||
</li> |
||||
<% end -%> |
||||
</ul> |
||||
</li> |
||||
<% end %> |
||||
|
@ -0,0 +1,24 @@ |
||||
require 'spec_helper' |
||||
|
||||
describe WorkPackages::BulkController do |
||||
let(:project) { FactoryGirl.create(:project_with_types) } |
||||
let(:controller_role) { FactoryGirl.build(:role, :permissions => [:view_work_packages, :edit_work_packages]) } |
||||
let(:user) { FactoryGirl.create :user, member_in_project: project, member_through_role: controller_role } |
||||
let(:cost_object) { FactoryGirl.create :cost_object, project: project } |
||||
let(:work_package) { FactoryGirl.create(:work_package, project: project) } |
||||
|
||||
before do |
||||
User.stub(:current).and_return user |
||||
end |
||||
|
||||
describe :update do |
||||
context 'when a cost report is assigned' do |
||||
before { put :update, ids: [work_package.id], work_package: {cost_object_id: cost_object.id} } |
||||
|
||||
subject { work_package.reload.cost_object.try :id } |
||||
|
||||
it { should == cost_object.id } |
||||
end |
||||
end |
||||
|
||||
end |
Loading…
Reference in new issue