From b7c02b163cf0408436c1dc800fbdf4d9460c42d8 Mon Sep 17 00:00:00 2001 From: Hagen Schink Date: Wed, 2 Oct 2013 11:45:03 +0200 Subject: [PATCH 01/17] Moves bulk edit tests to specs --- spec/controllers/issues_controller_spec.rb | 142 +++++++++++++++++++++ test/functional/issues_controller_test.rb | 35 ----- 2 files changed, 142 insertions(+), 35 deletions(-) create mode 100644 spec/controllers/issues_controller_spec.rb diff --git a/spec/controllers/issues_controller_spec.rb b/spec/controllers/issues_controller_spec.rb new file mode 100644 index 0000000000..00f6c558e8 --- /dev/null +++ b/spec/controllers/issues_controller_spec.rb @@ -0,0 +1,142 @@ +#-- copyright +# OpenProject is a project management system. +# Copyright (C) 2012-2013 the OpenProject Foundation (OPF) +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2013 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See doc/COPYRIGHT.rdoc for more details. +#++ + +require 'spec_helper' + +describe IssuesController do + let(:user) { FactoryGirl.create(:user) } + let(:custom_field_1) { FactoryGirl.create(:work_package_custom_field, + field_format: 'date', + is_for_all: true) } + let(:custom_field_2) { FactoryGirl.create(:work_package_custom_field) } + let(:type) { FactoryGirl.create(:type_standard) } + let(:project_1) { FactoryGirl.create(:project, + types: [type], + work_package_custom_fields: [custom_field_2]) } + let(:project_2) { FactoryGirl.create(:project, + types: [type]) } + let(:role) { FactoryGirl.create(:role, + permissions: [:edit_work_packages, + :manage_subtasks]) } + let(:member_1) { FactoryGirl.create(:member, + project: project_1, + principal: user, + roles: [role]) } + let(:member_2) { FactoryGirl.create(:member, + project: project_2, + principal: user, + roles: [role]) } + let(:work_package_1) { FactoryGirl.create(:work_package, + author: user, + type: type, + project: project_1) } + let(:work_package_2) { FactoryGirl.create(:work_package, + author: user, + type: type, + project: project_1) } + let(:work_package_3) { FactoryGirl.create(:work_package, + author: user, + type: type, + project: project_2) } + + before do + custom_field_1 + member_1 + + User.stub(:current).and_return user + end + + describe :bulk_edit do + shared_examples_for :response do + subject { response } + + it { should be_success } + + it { should render_template('bulk_edit') } + end + + context "same project" do + before { get :bulk_edit, ids: [work_package_1.id, work_package_2.id] } + + it_behaves_like :response + + describe :view do + render_views + + subject { response } + + describe :parent do + it { assert_tag :input, attributes: { name: 'issue[parent_id]' } } + end + + context :custom_field do + describe :type do + it { assert_tag :input, attributes: { name: "issue[custom_field_values][#{custom_field_1.id}]" } } + end + + describe :project do + it { assert_tag :select, attributes: { name: "issue[custom_field_values][#{custom_field_2.id}]" } } + end + end + end + end + + context "different projects" do + before do + member_2 + + get :bulk_edit, ids: [work_package_1.id, work_package_2.id, work_package_3.id] + end + + it_behaves_like :response + + describe :view do + render_views + + subject { response } + + describe :parent do + it { assert_no_tag :input, attributes: { name: 'issue[parent_id]' } } + end + + context :custom_field do + describe :type do + it { assert_tag :input, attributes: { name: "issue[custom_field_values][#{custom_field_1.id}]" } } + end + + describe :project do + it { assert_no_tag :select, attributes: { name: "issue[custom_field_values][#{custom_field_2.id}]" } } + end + end + end + end + end + + describe :bulk_edit do + end +end diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb index bc7233e497..37a01462b8 100644 --- a/test/functional/issues_controller_test.rb +++ b/test/functional/issues_controller_test.rb @@ -43,41 +43,6 @@ class IssuesControllerTest < ActionController::TestCase User.current = nil end - def test_get_bulk_edit - @request.session[:user_id] = 2 - get :bulk_edit, :ids => [1, 2] - assert_response :success - assert_template 'bulk_edit' - - assert_tag :input, :attributes => {:name => 'issue[parent_id]'} - - # Project specific custom field, date type - field = CustomField.find(9) - assert !field.is_for_all? - assert_equal 'date', field.field_format - assert_tag :input, :attributes => {:name => 'issue[custom_field_values][9]'} - - # System wide custom field - assert CustomField.find(1).is_for_all? - assert_tag :select, :attributes => {:name => 'issue[custom_field_values][1]'} - end - - def test_get_bulk_edit_on_different_projects - @request.session[:user_id] = 2 - get :bulk_edit, :ids => [1, 2, 6] - assert_response :success - assert_template 'bulk_edit' - - # Can not set issues from different projects as children of an issue - assert_no_tag :input, :attributes => {:name => 'issue[parent_id]'} - - # Project specific custom field, date type - field = CustomField.find(9) - assert !field.is_for_all? - assert !field.project_ids.include?(WorkPackage.find(6).project_id) - assert_no_tag :input, :attributes => {:name => 'issue[custom_field_values][9]'} - end - def test_bulk_update issue = WorkPackage.find(1) issue.recreate_initial_journal! From 27328eb70e57f7fa3f5f597dee717caf29bb05b8 Mon Sep 17 00:00:00 2001 From: Hagen Schink Date: Tue, 8 Oct 2013 12:26:11 +0200 Subject: [PATCH 02/17] Moves bulk update tests to specs --- spec/controllers/issues_controller_spec.rb | 276 ++++++++++++++++++++- test/functional/issues_controller_test.rb | 247 ------------------ 2 files changed, 273 insertions(+), 250 deletions(-) delete mode 100644 test/functional/issues_controller_test.rb diff --git a/spec/controllers/issues_controller_spec.rb b/spec/controllers/issues_controller_spec.rb index 00f6c558e8..57a3814fdb 100644 --- a/spec/controllers/issues_controller_spec.rb +++ b/spec/controllers/issues_controller_spec.rb @@ -30,11 +30,14 @@ require 'spec_helper' describe IssuesController do let(:user) { FactoryGirl.create(:user) } + let(:custom_field_value) { '125' } let(:custom_field_1) { FactoryGirl.create(:work_package_custom_field, - field_format: 'date', + field_format: 'string', is_for_all: true) } let(:custom_field_2) { FactoryGirl.create(:work_package_custom_field) } - let(:type) { FactoryGirl.create(:type_standard) } + let(:status) { FactoryGirl.create(:status) } + let(:type) { FactoryGirl.create(:type_standard, + custom_fields: [custom_field_1, custom_field_2]) } let(:project_1) { FactoryGirl.create(:project, types: [type], work_package_custom_fields: [custom_field_2]) } @@ -42,6 +45,7 @@ describe IssuesController do types: [type]) } let(:role) { FactoryGirl.create(:role, permissions: [:edit_work_packages, + :view_work_packages, :manage_subtasks]) } let(:member_1) { FactoryGirl.create(:member, project: project_1, @@ -53,15 +57,23 @@ describe IssuesController do roles: [role]) } let(:work_package_1) { FactoryGirl.create(:work_package, author: user, + assigned_to: user, type: type, + status: status, + custom_field_values: { custom_field_1.id => custom_field_value }, project: project_1) } let(:work_package_2) { FactoryGirl.create(:work_package, author: user, + assigned_to: user, type: type, + status: status, + custom_field_values: { custom_field_1.id => custom_field_value }, project: project_1) } let(:work_package_3) { FactoryGirl.create(:work_package, author: user, type: type, + status: status, + custom_field_values: { custom_field_1.id => custom_field_value }, project: project_2) } before do @@ -137,6 +149,264 @@ describe IssuesController do end end - describe :bulk_edit do + describe :bulk_update do + let(:work_package_ids) { [work_package_1.id, work_package_2.id] } + let(:work_packages) { WorkPackage.find_all_by_id(work_package_ids) } + let(:priority) { FactoryGirl.create(:priority_immediate) } + let(:group_id) { '' } + + describe :redirect do + context "in host" do + let(:url) { '/work_packages' } + + before { put :bulk_update, ids: work_package_ids, back_url: url } + + subject { response } + + it { should be_redirect } + + it { should redirect_to(url) } + end + + context "of host" do + let(:url) { 'http://google.com' } + + before { put :bulk_update, ids: work_package_ids, back_url: url } + + subject { response } + + it { should be_redirect } + + it { should redirect_to(controller: 'work_packages', + action: :index, + project_id: project_1.identifier) } + end + end + + shared_context :bulk_update_request do + before do + put :bulk_update, + ids: work_package_ids, + notes: 'Bulk editing', + issue: { priority_id: priority.id, + assigned_to_id: group_id, + custom_field_values: { custom_field_1.id.to_s => '' }, + send_notification: send_notification } + end + end + + shared_examples_for :delivered do + subject { ActionMailer::Base.deliveries.size } + + it { delivery_size } + end + + context "with notification" do + let(:send_notification) { '1' } + let(:delivery_size) { 2 } + + shared_examples_for "updated work package" do + describe :priority do + subject { WorkPackage.find_all_by_priority_id(priority.id).collect(&:id) } + + it { should =~ work_package_ids } + end + + describe :custom_fields do + let(:result) { [custom_field_value] } + + subject { WorkPackage.find_all_by_id(work_package_ids) + .collect {|w| w.custom_value_for(custom_field_1.id).value } + .uniq } + + it { should =~ result } + end + + describe :journal do + describe :notes do + let(:result) { ['Bulk editing'] } + + subject { WorkPackage.find_all_by_id(work_package_ids) + .collect {|w| w.last_journal.notes } + .uniq } + + it { should =~ result } + end + + describe :details do + let(:result) { [1] } + + subject { WorkPackage.find_all_by_id(work_package_ids) + .collect {|w| w.last_journal.details.size } + .uniq } + + it { should =~ result } + end + end + end + + context "single project" do + include_context :bulk_update_request + + it { response.response_code.should == 302 } + + it_behaves_like :delivered + + it_behaves_like "updated work package" + end + + context "different projects" do + let(:work_package_ids) { [work_package_1.id, work_package_2.id, work_package_3.id] } + + context "with permission" do + before { member_2 } + + include_context :bulk_update_request + + it { response.response_code.should == 302 } + + it_behaves_like :delivered + + it_behaves_like "updated work package" + end + + context "w/o permission" do + include_context :bulk_update_request + + it { response.response_code.should == 403 } + + describe :journal do + subject { Journal.count } + + it { should eq(work_package_ids.count) } + end + end + end + + describe :properties do + describe :groups do + let(:group) { FactoryGirl.create(:group) } + let(:group_id) { group.id } + + include_context :bulk_update_request + + subject { work_packages.collect {|w| w.assigned_to_id }.uniq } + + it { should =~ [group_id] } + end + + describe :status do + let(:closed_status) { FactoryGirl.create(:closed_status) } + let(:workflow) { FactoryGirl.create(:workflow, + role: role, + type_id: type.id, + old_status: status, + new_status: closed_status) } + + before do + workflow + + put :bulk_update, + ids: work_package_ids, + issue: { status_id: closed_status.id } + end + + subject { work_packages.collect(&:status_id).uniq } + + it { should =~ [closed_status.id] } + end + + describe :parent do + let(:parent) { FactoryGirl.create(:work_package, + author: user, + project: project_1) } + + before do + put :bulk_update, + ids: work_package_ids, + issue: { parent_id: parent.id } + end + + subject { work_packages.collect(&:parent_id).uniq } + + it { should =~ [parent.id] } + end + + describe :custom_fields do + let(:result) { '777' } + + before do + put :bulk_update, + ids: work_package_ids, + issue: { custom_field_values: { custom_field_1.id.to_s => result } } + end + + subject { work_packages.collect {|w| w.custom_value_for(custom_field_1.id).value } + .uniq } + + it { should =~ [result] } + end + + describe :unassign do + before do + put :bulk_update, + ids: work_package_ids, + issue: { assigned_to_id: 'none' } + end + + subject { work_packages.collect(&:assigned_to_id).uniq } + + it { should =~ [nil] } + end + + describe :version do + let(:version) { FactoryGirl.create(:version, + status: 'open', + sharing: 'tree', + project: subproject) } + let(:subproject) { FactoryGirl.create(:project, + parent: project_1, + types: [type]) } + + before do + put :bulk_update, + ids: work_package_ids, + issue: { fixed_version_id: version.id.to_s } + end + + subject { response } + + it { should be_redirect } + + describe :work_package do + describe :fixed_version do + subject { work_packages.collect(&:fixed_version_id).uniq } + + it { should =~ [version.id] } + end + + describe :project do + subject { work_packages.collect(&:project_id).uniq } + + it { should_not =~ [subproject.id] } + end + end + end + end + end + + context "w/o notification" do + let(:send_notification) { '0' } + + describe :delivery do + include_context :bulk_update_request + + it { response.response_code.should == 302 } + + let(:delivery_size) { 0 } + + it_behaves_like :delivered + end + end end end diff --git a/test/functional/issues_controller_test.rb b/test/functional/issues_controller_test.rb deleted file mode 100644 index 37a01462b8..0000000000 --- a/test/functional/issues_controller_test.rb +++ /dev/null @@ -1,247 +0,0 @@ -#-- encoding: UTF-8 -#-- copyright -# OpenProject is a project management system. -# Copyright (C) 2012-2013 the OpenProject Foundation (OPF) -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License version 3. -# -# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: -# Copyright (C) 2006-2013 Jean-Philippe Lang -# Copyright (C) 2010-2013 the ChiliProject Team -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# See doc/COPYRIGHT.rdoc for more details. -#++ -require File.expand_path('../../test_helper', __FILE__) -require 'issues_controller' - -# Re-raise errors caught by the controller. -class IssuesController; def rescue_action(e) raise e end; end - -class IssuesControllerTest < ActionController::TestCase - fixtures :all - - def setup - super - @controller = IssuesController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - User.current = nil - end - - def test_bulk_update - issue = WorkPackage.find(1) - issue.recreate_initial_journal! - - @request.session[:user_id] = 2 - # update issues priority - put :bulk_update, :ids => [1, 2], :notes => 'Bulk editing', - :issue => { :priority_id => 7, - :assigned_to_id => '', - :custom_field_values => {'2' => ''} } - - assert_response 302 - # check that the issues were updated - assert_equal [7, 7], WorkPackage.find_all_by_id([1, 2]).collect {|i| i.priority.id} - - issue.reload - journal = issue.journals.reorder('created_at DESC').first - assert_equal '125', issue.custom_value_for(2).value - assert_equal 'Bulk editing', journal.notes - assert_equal 1, journal.details.size - end - - def test_bullk_update_should_not_send_a_notification_if_send_notification_is_off - @request.session[:user_id] = 2 - ActionMailer::Base.deliveries.clear - put(:bulk_update, - { - :ids => [1, 2], - :issue => { - :priority_id => 7, - :assigned_to_id => '', - :custom_field_values => {'2' => ''} - }, - :notes => 'Bulk editing', - :send_notification => '0' - }) - - assert_response 302 - assert_equal 0, ActionMailer::Base.deliveries.size - end - - def test_bulk_update_with_group_assignee - group = Group.find(11) - project = Project.find(1) - project.members << Member.new(:principal => group, :roles => [Role.first]) - - @request.session[:user_id] = 2 - # update issues assignee - post :bulk_update, :ids => [1, 2], :notes => 'Bulk editing', - :issue => {:priority_id => '', - :assigned_to_id => group.id, - :custom_field_values => {'2' => ''}} - - assert_response 302 - assert_equal [group, group], WorkPackage.find_all_by_id([1, 2]).collect {|i| i.assigned_to} - end - - def test_bulk_update_on_different_projects - issue = WorkPackage.find(1) - issue.recreate_initial_journal! - - @request.session[:user_id] = 2 - # update issues priority - put :bulk_update, :ids => [1, 2, 6], :notes => 'Bulk editing', - :issue => {:priority_id => 7, - :assigned_to_id => '', - :custom_field_values => {'2' => ''}} - - assert_response 302 - # check that the issues were updated - assert_equal [7, 7, 7], WorkPackage.find([1,2,6]).map(&:priority_id) - - issue.reload - journal = issue.journals.reorder('created_at DESC').first - assert_equal '125', issue.custom_value_for(2).value - assert_equal 'Bulk editing', journal.notes - assert_equal 1, journal.details.size - end - - def test_bulk_update_on_different_projects_without_rights - Journal.delete_all - - @request.session[:user_id] = 3 - user = User.find(3) - action = { :controller => "issues", :action => "bulk_update" } - assert user.allowed_to?(action, WorkPackage.find(1).project) - assert ! user.allowed_to?(action, WorkPackage.find(6).project) - put :bulk_update, :ids => [1, 6], :notes => 'Bulk should fail', - :issue => {:priority_id => 7, - :assigned_to_id => '', - :custom_field_values => {'2' => ''}} - assert_response 403 - assert Journal.all.empty? - end - - def test_bulk_update_should_send_a_notification - WorkPackage.find(1).recreate_initial_journal! - WorkPackage.find(2).recreate_initial_journal! - - @request.session[:user_id] = 2 - ActionMailer::Base.deliveries.clear - put(:bulk_update, - { - :ids => [1, 2], - :notes => 'Bulk editing', - :issue => { - :priority_id => 7, - :assigned_to_id => '', - :custom_field_values => {'2' => ''} - } - }) - - assert_response 302 - assert_equal 5, ActionMailer::Base.deliveries.size - end - - def test_bulk_update_status - @request.session[:user_id] = 2 - # update issues priority - put :bulk_update, :ids => [1, 2], :notes => 'Bulk editing status', - :issue => {:priority_id => '', - :assigned_to_id => '', - :status_id => '5'} - - assert_response 302 - issue = WorkPackage.find(1) - assert issue.closed? - end - - def test_bulk_update_parent_id - @request.session[:user_id] = 2 - put :bulk_update, :ids => [1, 3], - :notes => 'Bulk editing parent', - :issue => {:priority_id => '', :assigned_to_id => '', :status_id => '', :parent_id => '2'} - - assert_response 302 - parent = WorkPackage.find(2) - assert_equal parent.id, WorkPackage.find(1).parent_id - assert_equal parent.id, WorkPackage.find(3).parent_id - assert_equal [1, 3], parent.children.collect(&:id).sort - end - - def test_bulk_update_custom_field - issue = WorkPackage.find(1) - issue.recreate_initial_journal! - - @request.session[:user_id] = 2 - # update issues priority - put :bulk_update, :ids => [1, 2], :notes => 'Bulk editing custom field', - :issue => {:priority_id => '', - :assigned_to_id => '', - :custom_field_values => {'2' => '777'}} - - assert_response 302 - - issue.reload - journal = issue.journals.last - assert_equal '777', issue.custom_value_for(2).value - assert_equal 1, journal.details.size - assert_equal '125', journal.old_value_for(:custom_fields_2) - assert_equal '777', journal.new_value_for(:custom_fields_2) - end - - def test_bulk_update_unassign - assert_not_nil WorkPackage.find(2).assigned_to - @request.session[:user_id] = 2 - # unassign issues - put :bulk_update, :ids => [1, 2], :notes => 'Bulk unassigning', :issue => {:assigned_to_id => 'none'} - assert_response 302 - # check that the issues were updated - assert_nil WorkPackage.find(2).assigned_to - end - - def test_post_bulk_update_should_allow_fixed_version_to_be_set_to_a_subproject - @request.session[:user_id] = 2 - - put :bulk_update, :ids => [1,2], :issue => {:fixed_version_id => 4} - - assert_response :redirect - issues = WorkPackage.find([1,2]) - issues.each do |issue| - assert_equal 4, issue.fixed_version_id - assert_not_equal issue.project_id, issue.fixed_version.project_id - end - end - - def test_post_bulk_update_should_redirect_back_using_the_back_url_parameter - @request.session[:user_id] = 2 - put :bulk_update, :ids => [1,2], :back_url => '/issues' - - assert_response :redirect - assert_redirected_to '/issues' - end - - def test_post_bulk_update_should_not_redirect_back_using_the_back_url_parameter_off_the_host - @request.session[:user_id] = 2 - put :bulk_update, :ids => [1,2], :back_url => 'http://google.com' - - assert_response :redirect - assert_redirected_to :controller => 'work_packages', :action => 'index', :project_id => Project.find(1).identifier - end -end From 22c3e4e2df251c987b10369816cb520bd7afaea1 Mon Sep 17 00:00:00 2001 From: Hagen Schink Date: Tue, 8 Oct 2013 15:49:20 +0200 Subject: [PATCH 03/17] Moved routing tests to specs --- spec/routing/issues_spec.rb | 42 ++++++++++++++++++++++++++++++++ test/integration/routing_test.rb | 5 ---- 2 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 spec/routing/issues_spec.rb diff --git a/spec/routing/issues_spec.rb b/spec/routing/issues_spec.rb new file mode 100644 index 0000000000..1fbb2c24b2 --- /dev/null +++ b/spec/routing/issues_spec.rb @@ -0,0 +1,42 @@ +#-- copyright +# OpenProject is a project management system. +# Copyright (C) 2012-2013 the OpenProject Foundation (OPF) +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2013 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See doc/COPYRIGHT.rdoc for more details. +#++ + +require 'spec_helper' + +describe IssuesController do + + it "should connect GET /issues/bulk_edit to issues/bulk_edit" do + get("/issues/bulk_edit").should route_to(controller: 'issues', + action: 'bulk_edit' ) + end + + it "should connect PUT /issues/bulk_update to issues#bulk_update" do + put("/issues/bulk_update").should route_to(controller: 'issues', + action: 'bulk_update') + end +end diff --git a/test/integration/routing_test.rb b/test/integration/routing_test.rb index d0855b4e06..f07bae96d4 100644 --- a/test/integration/routing_test.rb +++ b/test/integration/routing_test.rb @@ -149,11 +149,6 @@ class RoutingTest < ActionDispatch::IntegrationTest # Extra actions should route(:get, "/issues/changes").to( :controller => 'journals', :action => 'index') - - should route(:get, "/issues/bulk_edit").to( :controller => 'issues', - :action => 'bulk_edit') - should route(:put, "/issues/bulk_update").to( :controller => 'issues', - :action => 'bulk_update') end From 8d51b2433f51e404ebc55798b574fbdbcee7e50d Mon Sep 17 00:00:00 2001 From: Hagen Schink Date: Tue, 8 Oct 2013 15:50:16 +0200 Subject: [PATCH 04/17] Uses work package custom field factory --- spec/factories/custom_value_factory.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/factories/custom_value_factory.rb b/spec/factories/custom_value_factory.rb index 854f573a68..b470ceb7f6 100644 --- a/spec/factories/custom_value_factory.rb +++ b/spec/factories/custom_value_factory.rb @@ -42,7 +42,8 @@ FactoryGirl.define do end factory :work_package_custom_value do - custom_field :factory => :issue_custom_field + custom_field :factory => :work_package_custom_field + customized_type "WorkPackageCustomField" customized :factory => :work_package end end From 95d54b4d22a77aac9f952cf6b8a7cda046c9661d Mon Sep 17 00:00:00 2001 From: Hagen Schink Date: Tue, 8 Oct 2013 15:50:39 +0200 Subject: [PATCH 05/17] Improves code layout --- spec/models/work_package/work_package_copy_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/models/work_package/work_package_copy_spec.rb b/spec/models/work_package/work_package_copy_spec.rb index 74318481a4..f07250ecf4 100644 --- a/spec/models/work_package/work_package_copy_spec.rb +++ b/spec/models/work_package/work_package_copy_spec.rb @@ -31,7 +31,7 @@ require 'spec_helper' describe WorkPackage do describe :copy do let(:user) { FactoryGirl.create(:user) } - let (:custom_field) { FactoryGirl.create(:work_package_custom_field) } + let(:custom_field) { FactoryGirl.create(:work_package_custom_field) } let(:source_type) { FactoryGirl.create(:type, custom_fields: [custom_field]) } let(:source_project) { FactoryGirl.create(:project, @@ -199,7 +199,7 @@ describe WorkPackage do let(:type) { FactoryGirl.create(:type_standard) } let(:project) { FactoryGirl.create(:project, types: [type]) } - let (:custom_field) { FactoryGirl.create(:work_package_custom_field, + let(:custom_field) { FactoryGirl.create(:work_package_custom_field, name: 'Database', field_format: 'list', possible_values: ['MySQL', 'PostgreSQL', 'Oracle'], From 646fce25192332845e14f7c9f153b6d2df155f1f Mon Sep 17 00:00:00 2001 From: Hagen Schink Date: Wed, 9 Oct 2013 09:00:56 +0200 Subject: [PATCH 06/17] Adds permission spec --- .../bulk_edit_update_work_packages_spec.rb | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 spec/permissions/bulk_edit_update_work_packages_spec.rb diff --git a/spec/permissions/bulk_edit_update_work_packages_spec.rb b/spec/permissions/bulk_edit_update_work_packages_spec.rb new file mode 100644 index 0000000000..fb999ed54c --- /dev/null +++ b/spec/permissions/bulk_edit_update_work_packages_spec.rb @@ -0,0 +1,37 @@ +#-- copyright +# OpenProject is a project management system. +# Copyright (C) 2012-2013 the OpenProject Foundation (OPF) +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License version 3. +# +# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: +# Copyright (C) 2006-2013 Jean-Philippe Lang +# Copyright (C) 2010-2013 the ChiliProject Team +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# See doc/COPYRIGHT.rdoc for more details. +#++ + +require 'spec_helper' +require_relative '../support/permission_specs' + +describe IssuesController, "edit_work_packages permission", type: :controller do + include PermissionSpecs + + check_permission_required_for('issues#bulk_edit', :edit_work_packages) + check_permission_required_for('issues#bulk_update', :edit_work_packages) +end From 104d6f7da40dae526706711975e750d15ca0d5d9 Mon Sep 17 00:00:00 2001 From: Hagen Schink Date: Wed, 9 Oct 2013 11:34:17 +0200 Subject: [PATCH 07/17] Rename issues controller --- ...ntroller.rb => work_package_bulk_controller.rb} | 2 +- .../bulk_edit.html.erb | 0 config/routes.rb | 10 +++++----- lib/redmine.rb | 3 ++- ...pec.rb => work_package_bulk_controller_spec.rb} | 2 +- ...packages_spec.rb => work_packages_bulk_spec.rb} | 6 +++--- .../{issues_spec.rb => work_package_bulk_spec.rb} | 14 +++++++------- 7 files changed, 19 insertions(+), 18 deletions(-) rename app/controllers/{issues_controller.rb => work_package_bulk_controller.rb} (98%) rename app/views/{issues => work_package_bulk}/bulk_edit.html.erb (100%) rename spec/controllers/{issues_controller_spec.rb => work_package_bulk_controller_spec.rb} (99%) rename spec/permissions/{bulk_edit_update_work_packages_spec.rb => work_packages_bulk_spec.rb} (83%) rename spec/routing/{issues_spec.rb => work_package_bulk_spec.rb} (68%) diff --git a/app/controllers/issues_controller.rb b/app/controllers/work_package_bulk_controller.rb similarity index 98% rename from app/controllers/issues_controller.rb rename to app/controllers/work_package_bulk_controller.rb index 2cc18ef779..6fbcb774a9 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/work_package_bulk_controller.rb @@ -27,7 +27,7 @@ # See doc/COPYRIGHT.rdoc for more details. #++ -class IssuesController < ApplicationController +class WorkPackageBulkController < ApplicationController before_filter :disable_api before_filter :find_issues, :only => [:bulk_edit, :bulk_update] before_filter :authorize diff --git a/app/views/issues/bulk_edit.html.erb b/app/views/work_package_bulk/bulk_edit.html.erb similarity index 100% rename from app/views/issues/bulk_edit.html.erb rename to app/views/work_package_bulk/bulk_edit.html.erb diff --git a/config/routes.rb b/config/routes.rb index b7bd87d717..86a29d4477 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -290,11 +290,6 @@ OpenProject::Application.routes.draw do resources :time_entries, :controller => 'timelog' resources :relations, :controller => 'relations', :only => [:create, :destroy] - - collection do - get :bulk_edit, :format => false - put :bulk_update, :format => false - end end namespace :work_packages do @@ -303,6 +298,11 @@ OpenProject::Application.routes.draw do resources :calendar, :controller => 'calendars', :only => [:index] end + namespace :work_package_bulk do + get :bulk_edit, :format => false + put :bulk_update, :format => false + end + resources :work_packages, :only => [:show, :edit, :update, :index] do get :new_type, :on => :member put :preview, :on => :member diff --git a/lib/redmine.rb b/lib/redmine.rb index 2811a3e09a..22fccff6af 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -108,7 +108,8 @@ Redmine::AccessControl.map do |map| :'issues/previews' => :create, :work_packages => [:new, :new_type, :preview, :create] } map.permission :move_work_packages, {:'work_packages/moves' => [:new, :create]}, :require => :loggedin - map.permission :edit_work_packages, { :issues => [:edit, :update, :bulk_edit, :bulk_update, :update_form], + map.permission :edit_work_packages, { :issues => [:edit, :update, :update_form], + :work_package_bulk => [:bulk_edit, :bulk_update], :work_packages => [:edit, :update, :new_type, :preview, :quoted], :journals => :preview, :planning_elements => [:new, :create, :edit, :update], diff --git a/spec/controllers/issues_controller_spec.rb b/spec/controllers/work_package_bulk_controller_spec.rb similarity index 99% rename from spec/controllers/issues_controller_spec.rb rename to spec/controllers/work_package_bulk_controller_spec.rb index 57a3814fdb..4a404830d9 100644 --- a/spec/controllers/issues_controller_spec.rb +++ b/spec/controllers/work_package_bulk_controller_spec.rb @@ -28,7 +28,7 @@ require 'spec_helper' -describe IssuesController do +describe WorkPackageBulkController do let(:user) { FactoryGirl.create(:user) } let(:custom_field_value) { '125' } let(:custom_field_1) { FactoryGirl.create(:work_package_custom_field, diff --git a/spec/permissions/bulk_edit_update_work_packages_spec.rb b/spec/permissions/work_packages_bulk_spec.rb similarity index 83% rename from spec/permissions/bulk_edit_update_work_packages_spec.rb rename to spec/permissions/work_packages_bulk_spec.rb index fb999ed54c..f42fd5bacc 100644 --- a/spec/permissions/bulk_edit_update_work_packages_spec.rb +++ b/spec/permissions/work_packages_bulk_spec.rb @@ -29,9 +29,9 @@ require 'spec_helper' require_relative '../support/permission_specs' -describe IssuesController, "edit_work_packages permission", type: :controller do +describe WorkPackageBulkController, "edit_work_packages permission", type: :controller do include PermissionSpecs - check_permission_required_for('issues#bulk_edit', :edit_work_packages) - check_permission_required_for('issues#bulk_update', :edit_work_packages) + check_permission_required_for('work_package_bulk#bulk_edit', :edit_work_packages) + check_permission_required_for('work_package_bulk#bulk_update', :edit_work_packages) end diff --git a/spec/routing/issues_spec.rb b/spec/routing/work_package_bulk_spec.rb similarity index 68% rename from spec/routing/issues_spec.rb rename to spec/routing/work_package_bulk_spec.rb index 1fbb2c24b2..9b01c279aa 100644 --- a/spec/routing/issues_spec.rb +++ b/spec/routing/work_package_bulk_spec.rb @@ -28,15 +28,15 @@ require 'spec_helper' -describe IssuesController do +describe WorkPackageBulkController do - it "should connect GET /issues/bulk_edit to issues/bulk_edit" do - get("/issues/bulk_edit").should route_to(controller: 'issues', - action: 'bulk_edit' ) + it "should connect GET /work_package_bulk/bulk_edit to work_package_bulk/bulk_edit" do + get("/work_package_bulk/bulk_edit").should route_to(controller: 'work_package_bulk', + action: 'bulk_edit' ) end - it "should connect PUT /issues/bulk_update to issues#bulk_update" do - put("/issues/bulk_update").should route_to(controller: 'issues', - action: 'bulk_update') + it "should connect PUT /work_package_bulk/bulk_update to work_package_bulk#bulk_update" do + put("/work_package_bulk/bulk_update").should route_to(controller: 'work_package_bulk', + action: 'bulk_update') end end From 18b1d8808627d6f3429682588e61a07388e23c5a Mon Sep 17 00:00:00 2001 From: Hagen Schink Date: Wed, 9 Oct 2013 12:04:07 +0200 Subject: [PATCH 08/17] Fixes specs --- app/helpers/application_helper.rb | 2 +- app/views/work_packages/context_menus/index.html.erb | 2 +- .../work_packages/context_menus_controller_spec.rb | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 5efa367363..929044477c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -955,7 +955,7 @@ module ApplicationHelper ret += content_tag :ul do args[:collection].collect do |(s, name)| content_tag :li do - context_menu_link (name || s), bulk_update_issues_path(:ids => args[:updated_object_ids], + context_menu_link (name || s), work_package_bulk_bulk_update_path(:ids => args[:updated_object_ids], :issue => { db_attribute => s }, :back_url => args[:back_url]), :method => :put, diff --git a/app/views/work_packages/context_menus/index.html.erb b/app/views/work_packages/context_menus/index.html.erb index fd9b666896..46c2a9c956 100644 --- a/app/views/work_packages/context_menus/index.html.erb +++ b/app/views/work_packages/context_menus/index.html.erb @@ -38,7 +38,7 @@ See doc/COPYRIGHT.rdoc for more details. <% else %>
  • - <%= context_menu_link l(:button_edit), bulk_edit_issues_path(:ids => @work_packages.collect(&:id)), + <%= context_menu_link l(:button_edit), work_package_bulk_bulk_edit_path(:ids => @work_packages.collect(&:id)), :class => 'icon-edit', :disabled => !@can[:edit] %>
  • diff --git a/spec/controllers/work_packages/context_menus_controller_spec.rb b/spec/controllers/work_packages/context_menus_controller_spec.rb index 3a15f9b39f..65b82e9734 100644 --- a/spec/controllers/work_packages/context_menus_controller_spec.rb +++ b/spec/controllers/work_packages/context_menus_controller_spec.rb @@ -89,7 +89,7 @@ describe WorkPackages::ContextMenusController do end shared_examples_for :bulk_edit do - let(:edit_link) { "/issues/bulk_edit?#{ids_link}" } + let(:edit_link) { "/work_package_bulk/bulk_edit?#{ids_link}" } it_behaves_like :edit_impl end @@ -126,7 +126,7 @@ describe WorkPackages::ContextMenusController do get :index, ids: ids end - let(:status_link) { "/issues/bulk_update?#{ids_link}"\ + let(:status_link) { "/work_package_bulk/bulk_update?#{ids_link}"\ "&issue%5Bstatus_id%5D=#{status_2.id}" } it do @@ -139,7 +139,7 @@ describe WorkPackages::ContextMenusController do shared_examples_for :priority do let(:priority_immediate) { FactoryGirl.create(:priority_immediate) } - let(:priority_link) { "/issues/bulk_update?#{ids_link}"\ + let(:priority_link) { "/work_package_bulk/bulk_update?#{ids_link}"\ "&issue%5Bpriority_id%5D=#{priority_immediate.id}" } before do @@ -161,9 +161,9 @@ describe WorkPackages::ContextMenusController do project: project_1) } let(:version_2) { FactoryGirl.create(:version, project: project_1) } - let(:version_link_1) { "/issues/bulk_update?#{ids_link}"\ + let(:version_link_1) { "/work_package_bulk/bulk_update?#{ids_link}"\ "&issue%5Bfixed_version_id%5D=#{version_1.id}" } - let(:version_link_2) { "/issues/bulk_update?#{ids_link}"\ + let(:version_link_2) { "/work_package_bulk/bulk_update?#{ids_link}"\ "&issue%5Bfixed_version_id%5D=#{version_2.id}" } before do @@ -182,7 +182,7 @@ describe WorkPackages::ContextMenusController do end shared_examples_for :assigned_to do - let(:assigned_to_link) { "/issues/bulk_update?#{ids_link}"\ + let(:assigned_to_link) { "/work_package_bulk/bulk_update?#{ids_link}"\ "&issue%5Bassigned_to_id%5D=#{user.id}" } before { get :index, ids: ids } From 8b2d7a13ef539c7a78e4bff22de6de71e624d2cd Mon Sep 17 00:00:00 2001 From: Hagen Schink Date: Wed, 9 Oct 2013 13:08:06 +0200 Subject: [PATCH 09/17] Rename bulk edit/update actions --- .../work_package_bulk_controller.rb | 11 +++--- app/helpers/application_helper.rb | 12 +++--- .../{bulk_edit.html.erb => edit.html.erb} | 4 +- .../context_menus/index.html.erb | 2 +- config/locales/de.yml | 2 +- config/locales/en.yml | 2 +- config/routes.rb | 4 +- lib/redmine.rb | 2 +- .../work_package_bulk_controller_spec.rb | 38 +++++++++---------- .../context_menus_controller_spec.rb | 12 +++--- spec/permissions/work_packages_bulk_spec.rb | 4 +- spec/routing/work_package_bulk_spec.rb | 12 +++--- 12 files changed, 52 insertions(+), 53 deletions(-) rename app/views/work_package_bulk/{bulk_edit.html.erb => edit.html.erb} (98%) diff --git a/app/controllers/work_package_bulk_controller.rb b/app/controllers/work_package_bulk_controller.rb index 6fbcb774a9..2c9fdec96b 100644 --- a/app/controllers/work_package_bulk_controller.rb +++ b/app/controllers/work_package_bulk_controller.rb @@ -29,7 +29,7 @@ class WorkPackageBulkController < ApplicationController before_filter :disable_api - before_filter :find_issues, :only => [:bulk_edit, :bulk_update] + before_filter :find_issues, only: [:edit, :update] before_filter :authorize include JournalsHelper @@ -39,8 +39,7 @@ class WorkPackageBulkController < ApplicationController include QueriesHelper include IssuesHelper - # Bulk edit a set of issues - def bulk_edit + def edit @issues.sort! @available_statuses = @projects.map{|p|Workflow.available_statuses(p)}.inject{|memo,w|memo & w} @custom_fields = @projects.map{|p|p.all_work_package_custom_fields}.inject{|memo,c|memo & c} @@ -48,9 +47,9 @@ class WorkPackageBulkController < ApplicationController @types = @projects.map(&:types).inject{|memo,t| memo & t} end - def bulk_update + def update @issues.sort! - attributes = parse_params_for_bulk_issue_attributes(params) + attributes = parse_params_for_bulk_work_package_attributes(params) unsaved_issue_ids = [] @issues.each do |issue| @@ -70,7 +69,7 @@ class WorkPackageBulkController < ApplicationController private - def parse_params_for_bulk_issue_attributes(params) + def parse_params_for_bulk_work_package_attributes(params) attributes = (params[:issue] || {}).reject {|k,v| v.blank?} attributes.keys.each {|k| attributes[k] = '' if attributes[k] == 'none'} attributes[:custom_field_values].reject! {|k,v| v.blank?} if attributes[:custom_field_values] diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 929044477c..ec8ac34ec0 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -955,12 +955,12 @@ module ApplicationHelper ret += content_tag :ul do args[:collection].collect do |(s, name)| content_tag :li do - context_menu_link (name || s), work_package_bulk_bulk_update_path(:ids => args[:updated_object_ids], - :issue => { db_attribute => s }, - :back_url => args[:back_url]), - :method => :put, - :selected => args[:selected].call(s), - :disabled => args[:disabled].call(s) + context_menu_link (name || s), work_package_bulk_update_path(:ids => args[:updated_object_ids], + :issue => { db_attribute => s }, + :back_url => args[:back_url]), + :method => :put, + :selected => args[:selected].call(s), + :disabled => args[:disabled].call(s) end end.join.html_safe end diff --git a/app/views/work_package_bulk/bulk_edit.html.erb b/app/views/work_package_bulk/edit.html.erb similarity index 98% rename from app/views/work_package_bulk/bulk_edit.html.erb rename to app/views/work_package_bulk/edit.html.erb index a4f618d9f9..7afda02e4d 100644 --- a/app/views/work_package_bulk/bulk_edit.html.erb +++ b/app/views/work_package_bulk/edit.html.erb @@ -27,11 +27,11 @@ See doc/COPYRIGHT.rdoc for more details. ++#%> -

    <%= l(:label_bulk_edit_selected_issues) %>

    +

    <%= l(:label_bulk_edit_selected_work_packages) %>

      <%= @issues.collect {|i| content_tag('li', link_to(h("#{i.type} ##{i.id}"), { :action => 'show', :id => i }) + h(": #{i.subject}")) }.join("\n").html_safe %>
    -<%= form_tag(:action => 'bulk_update') do %> +<%= form_tag(:action => 'update') do %> <%= @issues.collect {|i| hidden_field_tag('ids[]', i.id)}.join.html_safe %>
    diff --git a/app/views/work_packages/context_menus/index.html.erb b/app/views/work_packages/context_menus/index.html.erb index 46c2a9c956..bed61f1938 100644 --- a/app/views/work_packages/context_menus/index.html.erb +++ b/app/views/work_packages/context_menus/index.html.erb @@ -38,7 +38,7 @@ See doc/COPYRIGHT.rdoc for more details. <% else %>
  • - <%= context_menu_link l(:button_edit), work_package_bulk_bulk_edit_path(:ids => @work_packages.collect(&:id)), + <%= context_menu_link l(:button_edit), work_package_bulk_edit_path(:ids => @work_packages.collect(&:id)), :class => 'icon-edit', :disabled => !@can[:edit] %>
  • diff --git a/config/locales/de.yml b/config/locales/de.yml index dedcfda719..1c5237f800 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -611,7 +611,7 @@ de: label_boolean: "Boolean" label_branch: "Zweig" label_browse: "Codebrowser" - label_bulk_edit_selected_issues: "Alle ausgewählten Tickets bearbeiten" + label_bulk_edit_selected_work_packages: "Alle ausgewählten Arbeitspakete bearbeiten" label_calendar: "Kalender" label_calendar_show: "Kalender anzeigen" label_category: "Kategorie" diff --git a/config/locales/en.yml b/config/locales/en.yml index 34ff1d90d7..06fcc2b539 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -593,7 +593,7 @@ en: label_boolean: "Boolean" label_branch: "Branch" label_browse: "Browse" - label_bulk_edit_selected_issues: "Bulk edit selected issues" + label_bulk_edit_selected_work_packages: "Bulk edit selected work packages" label_calendar: "Calendar" label_calendar_show: "Show Calendar" label_category: "Category" diff --git a/config/routes.rb b/config/routes.rb index 86a29d4477..4e8c8f93d6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -299,8 +299,8 @@ OpenProject::Application.routes.draw do end namespace :work_package_bulk do - get :bulk_edit, :format => false - put :bulk_update, :format => false + get :edit, :format => false + put :update, :format => false end resources :work_packages, :only => [:show, :edit, :update, :index] do diff --git a/lib/redmine.rb b/lib/redmine.rb index 22fccff6af..f7cb1c3e1f 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -109,7 +109,7 @@ Redmine::AccessControl.map do |map| :work_packages => [:new, :new_type, :preview, :create] } map.permission :move_work_packages, {:'work_packages/moves' => [:new, :create]}, :require => :loggedin map.permission :edit_work_packages, { :issues => [:edit, :update, :update_form], - :work_package_bulk => [:bulk_edit, :bulk_update], + :work_package_bulk => [:edit, :update], :work_packages => [:edit, :update, :new_type, :preview, :quoted], :journals => :preview, :planning_elements => [:new, :create, :edit, :update], diff --git a/spec/controllers/work_package_bulk_controller_spec.rb b/spec/controllers/work_package_bulk_controller_spec.rb index 4a404830d9..cd7eced32a 100644 --- a/spec/controllers/work_package_bulk_controller_spec.rb +++ b/spec/controllers/work_package_bulk_controller_spec.rb @@ -83,17 +83,17 @@ describe WorkPackageBulkController do User.stub(:current).and_return user end - describe :bulk_edit do + describe :edit do shared_examples_for :response do subject { response } it { should be_success } - it { should render_template('bulk_edit') } + it { should render_template('edit') } end context "same project" do - before { get :bulk_edit, ids: [work_package_1.id, work_package_2.id] } + before { get :edit, ids: [work_package_1.id, work_package_2.id] } it_behaves_like :response @@ -122,7 +122,7 @@ describe WorkPackageBulkController do before do member_2 - get :bulk_edit, ids: [work_package_1.id, work_package_2.id, work_package_3.id] + get :edit, ids: [work_package_1.id, work_package_2.id, work_package_3.id] end it_behaves_like :response @@ -149,7 +149,7 @@ describe WorkPackageBulkController do end end - describe :bulk_update do + describe :update do let(:work_package_ids) { [work_package_1.id, work_package_2.id] } let(:work_packages) { WorkPackage.find_all_by_id(work_package_ids) } let(:priority) { FactoryGirl.create(:priority_immediate) } @@ -159,7 +159,7 @@ describe WorkPackageBulkController do context "in host" do let(:url) { '/work_packages' } - before { put :bulk_update, ids: work_package_ids, back_url: url } + before { put :update, ids: work_package_ids, back_url: url } subject { response } @@ -171,7 +171,7 @@ describe WorkPackageBulkController do context "of host" do let(:url) { 'http://google.com' } - before { put :bulk_update, ids: work_package_ids, back_url: url } + before { put :update, ids: work_package_ids, back_url: url } subject { response } @@ -183,9 +183,9 @@ describe WorkPackageBulkController do end end - shared_context :bulk_update_request do + shared_context :update_request do before do - put :bulk_update, + put :update, ids: work_package_ids, notes: 'Bulk editing', issue: { priority_id: priority.id, @@ -246,7 +246,7 @@ describe WorkPackageBulkController do end context "single project" do - include_context :bulk_update_request + include_context :update_request it { response.response_code.should == 302 } @@ -261,7 +261,7 @@ describe WorkPackageBulkController do context "with permission" do before { member_2 } - include_context :bulk_update_request + include_context :update_request it { response.response_code.should == 302 } @@ -271,7 +271,7 @@ describe WorkPackageBulkController do end context "w/o permission" do - include_context :bulk_update_request + include_context :update_request it { response.response_code.should == 403 } @@ -288,7 +288,7 @@ describe WorkPackageBulkController do let(:group) { FactoryGirl.create(:group) } let(:group_id) { group.id } - include_context :bulk_update_request + include_context :update_request subject { work_packages.collect {|w| w.assigned_to_id }.uniq } @@ -306,7 +306,7 @@ describe WorkPackageBulkController do before do workflow - put :bulk_update, + put :update, ids: work_package_ids, issue: { status_id: closed_status.id } end @@ -322,7 +322,7 @@ describe WorkPackageBulkController do project: project_1) } before do - put :bulk_update, + put :update, ids: work_package_ids, issue: { parent_id: parent.id } end @@ -336,7 +336,7 @@ describe WorkPackageBulkController do let(:result) { '777' } before do - put :bulk_update, + put :update, ids: work_package_ids, issue: { custom_field_values: { custom_field_1.id.to_s => result } } end @@ -349,7 +349,7 @@ describe WorkPackageBulkController do describe :unassign do before do - put :bulk_update, + put :update, ids: work_package_ids, issue: { assigned_to_id: 'none' } end @@ -369,7 +369,7 @@ describe WorkPackageBulkController do types: [type]) } before do - put :bulk_update, + put :update, ids: work_package_ids, issue: { fixed_version_id: version.id.to_s } end @@ -399,7 +399,7 @@ describe WorkPackageBulkController do let(:send_notification) { '0' } describe :delivery do - include_context :bulk_update_request + include_context :update_request it { response.response_code.should == 302 } diff --git a/spec/controllers/work_packages/context_menus_controller_spec.rb b/spec/controllers/work_packages/context_menus_controller_spec.rb index 65b82e9734..b9f82ef20d 100644 --- a/spec/controllers/work_packages/context_menus_controller_spec.rb +++ b/spec/controllers/work_packages/context_menus_controller_spec.rb @@ -89,7 +89,7 @@ describe WorkPackages::ContextMenusController do end shared_examples_for :bulk_edit do - let(:edit_link) { "/work_package_bulk/bulk_edit?#{ids_link}" } + let(:edit_link) { "/work_package_bulk/edit?#{ids_link}" } it_behaves_like :edit_impl end @@ -126,7 +126,7 @@ describe WorkPackages::ContextMenusController do get :index, ids: ids end - let(:status_link) { "/work_package_bulk/bulk_update?#{ids_link}"\ + let(:status_link) { "/work_package_bulk/update?#{ids_link}"\ "&issue%5Bstatus_id%5D=#{status_2.id}" } it do @@ -139,7 +139,7 @@ describe WorkPackages::ContextMenusController do shared_examples_for :priority do let(:priority_immediate) { FactoryGirl.create(:priority_immediate) } - let(:priority_link) { "/work_package_bulk/bulk_update?#{ids_link}"\ + let(:priority_link) { "/work_package_bulk/update?#{ids_link}"\ "&issue%5Bpriority_id%5D=#{priority_immediate.id}" } before do @@ -161,9 +161,9 @@ describe WorkPackages::ContextMenusController do project: project_1) } let(:version_2) { FactoryGirl.create(:version, project: project_1) } - let(:version_link_1) { "/work_package_bulk/bulk_update?#{ids_link}"\ + let(:version_link_1) { "/work_package_bulk/update?#{ids_link}"\ "&issue%5Bfixed_version_id%5D=#{version_1.id}" } - let(:version_link_2) { "/work_package_bulk/bulk_update?#{ids_link}"\ + let(:version_link_2) { "/work_package_bulk/update?#{ids_link}"\ "&issue%5Bfixed_version_id%5D=#{version_2.id}" } before do @@ -182,7 +182,7 @@ describe WorkPackages::ContextMenusController do end shared_examples_for :assigned_to do - let(:assigned_to_link) { "/work_package_bulk/bulk_update?#{ids_link}"\ + let(:assigned_to_link) { "/work_package_bulk/update?#{ids_link}"\ "&issue%5Bassigned_to_id%5D=#{user.id}" } before { get :index, ids: ids } diff --git a/spec/permissions/work_packages_bulk_spec.rb b/spec/permissions/work_packages_bulk_spec.rb index f42fd5bacc..2200934311 100644 --- a/spec/permissions/work_packages_bulk_spec.rb +++ b/spec/permissions/work_packages_bulk_spec.rb @@ -32,6 +32,6 @@ require_relative '../support/permission_specs' describe WorkPackageBulkController, "edit_work_packages permission", type: :controller do include PermissionSpecs - check_permission_required_for('work_package_bulk#bulk_edit', :edit_work_packages) - check_permission_required_for('work_package_bulk#bulk_update', :edit_work_packages) + check_permission_required_for('work_package_bulk#edit', :edit_work_packages) + check_permission_required_for('work_package_bulk#update', :edit_work_packages) end diff --git a/spec/routing/work_package_bulk_spec.rb b/spec/routing/work_package_bulk_spec.rb index 9b01c279aa..993494e6c2 100644 --- a/spec/routing/work_package_bulk_spec.rb +++ b/spec/routing/work_package_bulk_spec.rb @@ -30,13 +30,13 @@ require 'spec_helper' describe WorkPackageBulkController do - it "should connect GET /work_package_bulk/bulk_edit to work_package_bulk/bulk_edit" do - get("/work_package_bulk/bulk_edit").should route_to(controller: 'work_package_bulk', - action: 'bulk_edit' ) + it "should connect GET /work_package_bulk/edit to work_package_bulk/edit" do + get("/work_package_bulk/edit").should route_to(controller: 'work_package_bulk', + action: 'edit') end - it "should connect PUT /work_package_bulk/bulk_update to work_package_bulk#bulk_update" do - put("/work_package_bulk/bulk_update").should route_to(controller: 'work_package_bulk', - action: 'bulk_update') + it "should connect PUT /work_package_bulk/update to work_package_bulk#update" do + put("/work_package_bulk/update").should route_to(controller: 'work_package_bulk', + action: 'update') end end From e164c4345ed3bee8c08a42d8f105a056fa692f35 Mon Sep 17 00:00:00 2001 From: Hagen Schink Date: Wed, 9 Oct 2013 13:26:47 +0200 Subject: [PATCH 10/17] Renames variables --- app/controllers/application_controller.rb | 15 ------- .../work_package_bulk_controller.rb | 43 +++++++++++++------ app/helpers/application_helper.rb | 2 +- app/views/work_package_bulk/edit.html.erb | 6 +-- .../work_package_bulk_controller_spec.rb | 18 ++++---- .../context_menus_controller_spec.rb | 10 ++--- 6 files changed, 47 insertions(+), 47 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 4b69b963b2..f4d0011240 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -571,21 +571,6 @@ class ApplicationController < ActionController::Base flash[:warning] = l(:warning_attachments_not_saved, obj.unsaved_attachments.size) if obj.unsaved_attachments.present? end - # Sets the `flash` notice or error based the number of issues that did not save - # - # @param [Array, Issue] issues all of the saved and unsaved Issues - # @param [Array, Integer] unsaved_issue_ids the issue ids that were not saved - def set_flash_from_bulk_issue_save(issues, unsaved_issue_ids) - if unsaved_issue_ids.empty? - flash[:notice] = l(:notice_successful_update) unless issues.empty? - else - flash[:error] = l(:notice_failed_to_save_work_packages, - :count => unsaved_issue_ids.size, - :total => issues.size, - :ids => '#' + unsaved_issue_ids.join(', #')) - end - end - # Rescues an invalid query statement. Just in case... def query_statement_invalid(exception) logger.error "Query::StatementInvalid: #{exception.message}" if logger diff --git a/app/controllers/work_package_bulk_controller.rb b/app/controllers/work_package_bulk_controller.rb index 2c9fdec96b..e40f059d72 100644 --- a/app/controllers/work_package_bulk_controller.rb +++ b/app/controllers/work_package_bulk_controller.rb @@ -29,7 +29,7 @@ class WorkPackageBulkController < ApplicationController before_filter :disable_api - before_filter :find_issues, only: [:edit, :update] + before_filter :find_work_packages, only: [:edit, :update] before_filter :authorize include JournalsHelper @@ -40,7 +40,7 @@ class WorkPackageBulkController < ApplicationController include IssuesHelper def edit - @issues.sort! + @work_packages.sort! @available_statuses = @projects.map{|p|Workflow.available_statuses(p)}.inject{|memo,w|memo & w} @custom_fields = @projects.map{|p|p.all_work_package_custom_fields}.inject{|memo,c|memo & c} @assignables = @projects.map(&:assignable_users).inject{|memo,a| memo & a} @@ -48,32 +48,47 @@ class WorkPackageBulkController < ApplicationController end def update - @issues.sort! + @work_packages.sort! attributes = parse_params_for_bulk_work_package_attributes(params) - unsaved_issue_ids = [] - @issues.each do |issue| - issue.reload - issue.add_journal(User.current, params[:notes]) - issue.safe_attributes = attributes - call_hook(:controller_issues_bulk_edit_before_save, { :params => params, :issue => issue }) + unsaved_work_package_ids = [] + @work_packages.each do |work_package| + work_package.reload + work_package.add_journal(User.current, params[:notes]) + work_package.safe_attributes = attributes + call_hook(:controller_work_package_bulk_before_save, { params: params, work_package: work_package }) JournalObserver.instance.send_notification = params[:send_notification] == '0' ? false : true - unless issue.save + unless work_package.save # Keep unsaved issue ids to display them in flash error - unsaved_issue_ids << issue.id + unsaved_work_package_ids << work_package.id end end - set_flash_from_bulk_issue_save(@issues, unsaved_issue_ids) - redirect_back_or_default({:controller => '/work_packages', :action => 'index', :project_id => @project}) + set_flash_from_bulk_save(@work_packages, unsaved_work_package_ids) + redirect_back_or_default({controller: '/work_packages', action: :index, project_id: @project}) end private def parse_params_for_bulk_work_package_attributes(params) - attributes = (params[:issue] || {}).reject {|k,v| v.blank?} + attributes = (params[:work_package] || {}).reject {|k,v| v.blank?} attributes.keys.each {|k| attributes[k] = '' if attributes[k] == 'none'} attributes[:custom_field_values].reject! {|k,v| v.blank?} if attributes[:custom_field_values] attributes.delete :custom_field_values if not attributes.has_key?(:custom_field_values) or attributes[:custom_field_values].empty? attributes end + + # Sets the `flash` notice or error based the number of work packages that did not save + # + # @param [Array, WorkPackage] work_packages all of the saved and unsaved WorkPackages + # @param [Array, Integer] unsaved_work_package_ids the WorkPackage ids that were not saved + def set_flash_from_bulk_save(work_packages, unsaved_work_package_ids) + if unsaved_work_package_ids.empty? + flash[:notice] = l(:notice_successful_update) unless work_packages.empty? + else + flash[:error] = l(:notice_failed_to_save_work_packages, + :count => unsaved_work_package_ids.size, + :total => work_packages.size, + :ids => '#' + unsaved_work_package_ids.join(', #')) + end + end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ec8ac34ec0..c752f006b9 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -956,7 +956,7 @@ module ApplicationHelper args[:collection].collect do |(s, name)| content_tag :li do context_menu_link (name || s), work_package_bulk_update_path(:ids => args[:updated_object_ids], - :issue => { db_attribute => s }, + :work_package => { db_attribute => s }, :back_url => args[:back_url]), :method => :put, :selected => args[:selected].call(s), diff --git a/app/views/work_package_bulk/edit.html.erb b/app/views/work_package_bulk/edit.html.erb index 7afda02e4d..3032c3d7b9 100644 --- a/app/views/work_package_bulk/edit.html.erb +++ b/app/views/work_package_bulk/edit.html.erb @@ -29,10 +29,10 @@ See doc/COPYRIGHT.rdoc for more details.

    <%= l(:label_bulk_edit_selected_work_packages) %>

    -
      <%= @issues.collect {|i| content_tag('li', link_to(h("#{i.type} ##{i.id}"), { :action => 'show', :id => i }) + h(": #{i.subject}")) }.join("\n").html_safe %>
    +
      <%= @work_packages.collect {|i| content_tag('li', link_to(h("#{i.type} ##{i.id}"), { :action => 'show', :id => i }) + h(": #{i.subject}")) }.join("\n").html_safe %>
    <%= form_tag(:action => 'update') do %> -<%= @issues.collect {|i| hidden_field_tag('ids[]', i.id)}.join.html_safe %> +<%= @work_packages.collect {|i| hidden_field_tag('ids[]', i.id)}.join.html_safe %>
    <%= l(:label_change_properties) %> @@ -83,7 +83,7 @@ See doc/COPYRIGHT.rdoc for more details.

    <% end %> -<%= call_hook(:view_work_packages_bulk_edit_details_bottom, { :issues => @issues }) %> +<%= call_hook(:view_work_packages_bulk_edit_details_bottom, { work_packages: @work_packages }) %>
    diff --git a/spec/controllers/work_package_bulk_controller_spec.rb b/spec/controllers/work_package_bulk_controller_spec.rb index cd7eced32a..877c206beb 100644 --- a/spec/controllers/work_package_bulk_controller_spec.rb +++ b/spec/controllers/work_package_bulk_controller_spec.rb @@ -188,10 +188,10 @@ describe WorkPackageBulkController do put :update, ids: work_package_ids, notes: 'Bulk editing', - issue: { priority_id: priority.id, - assigned_to_id: group_id, - custom_field_values: { custom_field_1.id.to_s => '' }, - send_notification: send_notification } + work_package: { priority_id: priority.id, + assigned_to_id: group_id, + custom_field_values: { custom_field_1.id.to_s => '' }, + send_notification: send_notification } end end @@ -308,7 +308,7 @@ describe WorkPackageBulkController do put :update, ids: work_package_ids, - issue: { status_id: closed_status.id } + work_package: { status_id: closed_status.id } end subject { work_packages.collect(&:status_id).uniq } @@ -324,7 +324,7 @@ describe WorkPackageBulkController do before do put :update, ids: work_package_ids, - issue: { parent_id: parent.id } + work_package: { parent_id: parent.id } end subject { work_packages.collect(&:parent_id).uniq } @@ -338,7 +338,7 @@ describe WorkPackageBulkController do before do put :update, ids: work_package_ids, - issue: { custom_field_values: { custom_field_1.id.to_s => result } } + work_package: { custom_field_values: { custom_field_1.id.to_s => result } } end subject { work_packages.collect {|w| w.custom_value_for(custom_field_1.id).value } @@ -351,7 +351,7 @@ describe WorkPackageBulkController do before do put :update, ids: work_package_ids, - issue: { assigned_to_id: 'none' } + work_package: { assigned_to_id: 'none' } end subject { work_packages.collect(&:assigned_to_id).uniq } @@ -371,7 +371,7 @@ describe WorkPackageBulkController do before do put :update, ids: work_package_ids, - issue: { fixed_version_id: version.id.to_s } + work_package: { fixed_version_id: version.id.to_s } end subject { response } diff --git a/spec/controllers/work_packages/context_menus_controller_spec.rb b/spec/controllers/work_packages/context_menus_controller_spec.rb index b9f82ef20d..438d470b3c 100644 --- a/spec/controllers/work_packages/context_menus_controller_spec.rb +++ b/spec/controllers/work_packages/context_menus_controller_spec.rb @@ -127,7 +127,7 @@ describe WorkPackages::ContextMenusController do end let(:status_link) { "/work_package_bulk/update?#{ids_link}"\ - "&issue%5Bstatus_id%5D=#{status_2.id}" } + "&work_package%5Bstatus_id%5D=#{status_2.id}" } it do assert_tag tag: 'a', @@ -140,7 +140,7 @@ describe WorkPackages::ContextMenusController do shared_examples_for :priority do let(:priority_immediate) { FactoryGirl.create(:priority_immediate) } let(:priority_link) { "/work_package_bulk/update?#{ids_link}"\ - "&issue%5Bpriority_id%5D=#{priority_immediate.id}" } + "&work_package%5Bpriority_id%5D=#{priority_immediate.id}" } before do priority_immediate @@ -162,9 +162,9 @@ describe WorkPackages::ContextMenusController do let(:version_2) { FactoryGirl.create(:version, project: project_1) } let(:version_link_1) { "/work_package_bulk/update?#{ids_link}"\ - "&issue%5Bfixed_version_id%5D=#{version_1.id}" } + "&work_package%5Bfixed_version_id%5D=#{version_1.id}" } let(:version_link_2) { "/work_package_bulk/update?#{ids_link}"\ - "&issue%5Bfixed_version_id%5D=#{version_2.id}" } + "&work_package%5Bfixed_version_id%5D=#{version_2.id}" } before do version_1 @@ -183,7 +183,7 @@ describe WorkPackages::ContextMenusController do shared_examples_for :assigned_to do let(:assigned_to_link) { "/work_package_bulk/update?#{ids_link}"\ - "&issue%5Bassigned_to_id%5D=#{user.id}" } + "&work_package%5Bassigned_to_id%5D=#{user.id}" } before { get :index, ids: ids } From 7f7c0d281670ef1f60c6b93faac22d47ecaa4a87 Mon Sep 17 00:00:00 2001 From: Hagen Schink Date: Wed, 9 Oct 2013 13:32:45 +0200 Subject: [PATCH 11/17] Removes superfluous comment --- app/controllers/work_package_bulk_controller.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/controllers/work_package_bulk_controller.rb b/app/controllers/work_package_bulk_controller.rb index e40f059d72..9f3fd6e0e8 100644 --- a/app/controllers/work_package_bulk_controller.rb +++ b/app/controllers/work_package_bulk_controller.rb @@ -59,7 +59,6 @@ class WorkPackageBulkController < ApplicationController call_hook(:controller_work_package_bulk_before_save, { params: params, work_package: work_package }) JournalObserver.instance.send_notification = params[:send_notification] == '0' ? false : true unless work_package.save - # Keep unsaved issue ids to display them in flash error unsaved_work_package_ids << work_package.id end end From 25c691c56b5c3c5f193df59cea16548b75b22eee Mon Sep 17 00:00:00 2001 From: Hagen Schink Date: Wed, 9 Oct 2013 13:35:25 +0200 Subject: [PATCH 12/17] Adds changelog entry --- doc/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index b657430b84..131dc8413e 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -31,6 +31,7 @@ See doc/COPYRIGHT.rdoc for more details. * `#1281` I18n.js Not working correctly. Always returns English Translations * `#1771` Fixed bug: Refactor Types Project Settings into new Tab +* `#2306` Migrate issues controller tests * `#2307` Change icon of home button in header from OpenProjct icon to house icon * `#2319` Add a request-store to avoid redundant calls From 42f7e9c4f62f2cf7d3c50e1556999f7d46a55d7f Mon Sep 17 00:00:00 2001 From: Stefan Frank Date: Thu, 10 Oct 2013 15:30:01 +0200 Subject: [PATCH 13/17] event.srcElement is not filled in firefox, replaced with event.target --- app/assets/javascripts/context_menu.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/context_menu.js b/app/assets/javascripts/context_menu.js index fc790ce985..a6e7520d9c 100644 --- a/app/assets/javascripts/context_menu.js +++ b/app/assets/javascripts/context_menu.js @@ -140,11 +140,11 @@ ContextMenu.prototype = { $('context-menu').style['top'] = (render_y + 'px'); Element.update('context-menu', ''); - new Ajax.Updater({success:'context-menu'}, this.url, + new Ajax.Updater({success:'context-menu'}, this.url, {asynchronous:true, method: 'get', evalScripts:true, - parameters:jQuery(e.srcElement).closest("form").serialize(), + parameters: jQuery(e.target).closest("form").serialize(), onComplete:function(request){ dims = $('context-menu').getDimensions(); menu_width = dims.width; From e2aab7c10b0b64a040e984fd8ce1deb87f135262 Mon Sep 17 00:00:00 2001 From: Hagen Schink Date: Thu, 10 Oct 2013 15:30:44 +0200 Subject: [PATCH 14/17] Renames attributes --- .../work_packages/context_menus_controller.rb | 1 + app/views/work_package_bulk/edit.html.erb | 42 +++++++++---------- .../work_package_bulk_controller_spec.rb | 12 +++--- 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/app/controllers/work_packages/context_menus_controller.rb b/app/controllers/work_packages/context_menus_controller.rb index 5668e598e8..a5f35a96ce 100644 --- a/app/controllers/work_packages/context_menus_controller.rb +++ b/app/controllers/work_packages/context_menus_controller.rb @@ -44,6 +44,7 @@ class WorkPackages::ContextMenusController < ApplicationController memo & s end end + @projects = @work_packages.collect(&:project).compact.uniq @project = @projects.first if @projects.size == 1 diff --git a/app/views/work_package_bulk/edit.html.erb b/app/views/work_package_bulk/edit.html.erb index 3032c3d7b9..ac8fe758ea 100644 --- a/app/views/work_package_bulk/edit.html.erb +++ b/app/views/work_package_bulk/edit.html.erb @@ -39,29 +39,29 @@ See doc/COPYRIGHT.rdoc for more details.

    - - <%= select_tag('issue[type_id]', "" + options_from_collection_for_select(@types, :id, :name)) %> + + <%= select_tag('work_package[type_id]', "" + options_from_collection_for_select(@types, :id, :name)) %>

    <% if @available_statuses.any? %>

    - <%= select_tag('issue[status_id]', "" + options_from_collection_for_select(@available_statuses, :id, :name)) %> + <%= select_tag('work_package[status_id]', "" + options_from_collection_for_select(@available_statuses, :id, :name)) %>

    <% end %>

    - - <%= select_tag('issue[priority_id]', "" + options_from_collection_for_select(IssuePriority.all, :id, :name)) %> + + <%= select_tag('work_package[priority_id]', "" + options_from_collection_for_select(IssuePriority.all, :id, :name)) %>

    - - <%= select_tag('issue[assigned_to_id]', content_tag('option', l(:label_no_change_option), :value => '') + + + <%= select_tag('work_package[assigned_to_id]', content_tag('option', l(:label_no_change_option), :value => '') + content_tag('option', l(:label_nobody), :value => 'none') + options_from_collection_for_select(@assignables, :id, :name)) %>

    <% if @project %>

    - <%= select_tag('issue[category_id]', content_tag('option', l(:label_no_change_option), :value => '') + + <%= select_tag('work_package[category_id]', content_tag('option', l(:label_no_change_option), :value => '') + content_tag('option', l(:label_none), :value => 'none') + options_from_collection_for_select(@project.categories, :id, :name)) %>

    @@ -69,8 +69,8 @@ See doc/COPYRIGHT.rdoc for more details. <% #TODO: allow editing versions when multiple projects %> <% if @project %>

    - - <%= select_tag('issue[fixed_version_id]', content_tag('option', l(:label_no_change_option), :value => '') + + + <%= select_tag('work_package[fixed_version_id]', content_tag('option', l(:label_no_change_option), :value => '') + content_tag('option', l(:label_none), :value => 'none') + version_options_for_select(@project.shared_versions.open.sort)) %>

    @@ -78,8 +78,8 @@ See doc/COPYRIGHT.rdoc for more details. <% @custom_fields.each do |custom_field| %>

    - <%= blank_custom_field_label_tag('issue', custom_field) %> - <%= custom_field_tag_for_bulk_edit('issue', custom_field) %> + <%= blank_custom_field_label_tag('work_package', custom_field) %> + <%= custom_field_tag_for_bulk_edit('work_package', custom_field) %>

    <% end %> @@ -89,24 +89,24 @@ See doc/COPYRIGHT.rdoc for more details.
    <% if @project && User.current.allowed_to?(:manage_subtasks, @project) %>

    - - <%= text_field_tag 'issue[parent_id]', '', :size => 10 %> + + <%= text_field_tag 'work_package[parent_id]', '', :size => 10 %>

    -
    +
    <%= javascript_tag "observeParentIssueField('#{work_packages_auto_complete_path(project_id: @project.id)}')" %> <% end %>

    - - <%= text_field_tag 'issue[start_date]', '', :size => 10 %><%= calendar_for('issue_start_date') %> + + <%= text_field_tag 'work_package[start_date]', '', :size => 10 %><%= calendar_for('work_package_start_date') %>

    - - <%= text_field_tag 'issue[due_date]', '', :size => 10 %><%= calendar_for('issue_due_date') %> + + <%= text_field_tag 'work_package[due_date]', '', :size => 10 %><%= calendar_for('work_package_due_date') %>

    <% if WorkPackage.use_field_for_done_ratio? %>

    - - <%= select_tag 'issue[done_ratio]', options_for_select([[l(:label_no_change_option), '']] + (0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) %> + + <%= select_tag 'work_package[done_ratio]', options_for_select([[l(:label_no_change_option), '']] + (0..10).to_a.collect {|r| ["#{r*10} %", r*10] }) %>

    <% end %>
    diff --git a/spec/controllers/work_package_bulk_controller_spec.rb b/spec/controllers/work_package_bulk_controller_spec.rb index 877c206beb..bd947c88bf 100644 --- a/spec/controllers/work_package_bulk_controller_spec.rb +++ b/spec/controllers/work_package_bulk_controller_spec.rb @@ -103,16 +103,16 @@ describe WorkPackageBulkController do subject { response } describe :parent do - it { assert_tag :input, attributes: { name: 'issue[parent_id]' } } + it { assert_tag :input, attributes: { name: 'work_package[parent_id]' } } end context :custom_field do describe :type do - it { assert_tag :input, attributes: { name: "issue[custom_field_values][#{custom_field_1.id}]" } } + it { assert_tag :input, attributes: { name: "work_package[custom_field_values][#{custom_field_1.id}]" } } end describe :project do - it { assert_tag :select, attributes: { name: "issue[custom_field_values][#{custom_field_2.id}]" } } + it { assert_tag :select, attributes: { name: "work_package[custom_field_values][#{custom_field_2.id}]" } } end end end @@ -133,16 +133,16 @@ describe WorkPackageBulkController do subject { response } describe :parent do - it { assert_no_tag :input, attributes: { name: 'issue[parent_id]' } } + it { assert_no_tag :input, attributes: { name: 'work_package[parent_id]' } } end context :custom_field do describe :type do - it { assert_tag :input, attributes: { name: "issue[custom_field_values][#{custom_field_1.id}]" } } + it { assert_tag :input, attributes: { name: "work_package[custom_field_values][#{custom_field_1.id}]" } } end describe :project do - it { assert_no_tag :select, attributes: { name: "issue[custom_field_values][#{custom_field_2.id}]" } } + it { assert_no_tag :select, attributes: { name: "work_package[custom_field_values][#{custom_field_2.id}]" } } end end end From 64ac1ec040f848b233f2f9a678d3a38e3309684d Mon Sep 17 00:00:00 2001 From: Hagen Schink Date: Thu, 10 Oct 2013 15:31:46 +0200 Subject: [PATCH 15/17] Adds mandatory html safe calls --- app/views/work_package_bulk/edit.html.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/work_package_bulk/edit.html.erb b/app/views/work_package_bulk/edit.html.erb index ac8fe758ea..02316e24fb 100644 --- a/app/views/work_package_bulk/edit.html.erb +++ b/app/views/work_package_bulk/edit.html.erb @@ -40,17 +40,17 @@ See doc/COPYRIGHT.rdoc for more details.

    - <%= select_tag('work_package[type_id]', "" + options_from_collection_for_select(@types, :id, :name)) %> + <%= select_tag('work_package[type_id]', "".html_safe + options_from_collection_for_select(@types, :id, :name)) %>

    <% if @available_statuses.any? %>

    - <%= select_tag('work_package[status_id]', "" + options_from_collection_for_select(@available_statuses, :id, :name)) %> + <%= select_tag('work_package[status_id]', "".html_safe + options_from_collection_for_select(@available_statuses, :id, :name)) %>

    <% end %>

    - <%= select_tag('work_package[priority_id]', "" + options_from_collection_for_select(IssuePriority.all, :id, :name)) %> + <%= select_tag('work_package[priority_id]', "".html_safe + options_from_collection_for_select(IssuePriority.all, :id, :name)) %>

    From bbeb0e24afab3dd57061ed5d6d60ba53220926bb Mon Sep 17 00:00:00 2001 From: Stefan Frank Date: Thu, 10 Oct 2013 15:51:25 +0200 Subject: [PATCH 16/17] Use either e.target or e.srcElement, whatever is available. --- app/assets/javascripts/context_menu.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/context_menu.js b/app/assets/javascripts/context_menu.js index a6e7520d9c..f60aa1181a 100644 --- a/app/assets/javascripts/context_menu.js +++ b/app/assets/javascripts/context_menu.js @@ -140,11 +140,14 @@ ContextMenu.prototype = { $('context-menu').style['top'] = (render_y + 'px'); Element.update('context-menu', ''); + // some IE-versions only know the srcElement + var target = e.target ? e.target : e.srcElement; + new Ajax.Updater({success:'context-menu'}, this.url, {asynchronous:true, method: 'get', evalScripts:true, - parameters: jQuery(e.target).closest("form").serialize(), + parameters: jQuery(target).closest("form").serialize(), onComplete:function(request){ dims = $('context-menu').getDimensions(); menu_width = dims.width; From b8bed4e307b0690098a280efcb1fff30a6f1cbb4 Mon Sep 17 00:00:00 2001 From: Martin Czuchra Date: Thu, 10 Oct 2013 16:28:34 +0200 Subject: [PATCH 17/17] Changelog. --- doc/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index 131dc8413e..6749eb3b1f 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -30,6 +30,7 @@ See doc/COPYRIGHT.rdoc for more details. # Changelog * `#1281` I18n.js Not working correctly. Always returns English Translations +* `#1758` Migrate functional-tests for issues into specs for work package * `#1771` Fixed bug: Refactor Types Project Settings into new Tab * `#2306` Migrate issues controller tests * `#2307` Change icon of home button in header from OpenProjct icon to house icon