diff --git a/app/controllers/query_menu_items_controller.rb b/app/controllers/query_menu_items_controller.rb deleted file mode 100644 index 8810ad5860..0000000000 --- a/app/controllers/query_menu_items_controller.rb +++ /dev/null @@ -1,102 +0,0 @@ -#-- encoding: UTF-8 -#-- copyright -# OpenProject is a project management system. -# Copyright (C) 2012-2014 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. -#++ - -class QueryMenuItemsController < ApplicationController - before_filter :load_project_and_query - before_filter :authorize - - def create - @query_menu_item = MenuItems::QueryMenuItem.find_or_initialize_by_name_and_navigatable_id @query.normalized_name, @query.id, title: @query.name - if @query_menu_item.save - flash[:notice] = l(:notice_successful_create) - else - flash[:error] = l(:error_menu_item_not_created) - end - - redirect_to query_path - end - - def update - @query_menu_item = MenuItems::QueryMenuItem.find params[:id] - - if @query_menu_item.update_attributes query_menu_item_params - flash[:notice] = l(:notice_successful_update) - else - flash[:error] = l(:error_menu_item_not_saved) - end - - redirect_to query_path - end - - def destroy - @query_menu_item = MenuItems::QueryMenuItem.find params[:id] - - @query_menu_item.destroy - flash[:notice] = l(:notice_successful_delete) - - redirect_to query_path - end - - def edit - @query_menu_item = MenuItems::QueryMenuItem.find params[:id] - end - - private - - def load_project_and_query - @project = Project.find params[:project_id] - @query = Query.find params[:query_id] - end - - def query_path - project_work_packages_path(@project, :query_id => @query.id) - end - - def normalized_query_name - @query.name.parameterize.underscore - end - - # inherit permissions from queries where create and update are performed bei new and edit actions - def authorize(ctrl = 'queries', action = params[:action], global = false) - action = case action - when 'create' - 'new' - when 'update' - 'edit' - else - action - end - - super - end - - def query_menu_item_params - params.require(:menu_items_query_menu_item).permit(:name, :title, :navigatable_id, :parent_id) - end -end diff --git a/app/views/query_menu_items/edit.html.erb b/app/views/query_menu_items/edit.html.erb deleted file mode 100644 index c6d0b2e52e..0000000000 --- a/app/views/query_menu_items/edit.html.erb +++ /dev/null @@ -1,47 +0,0 @@ -<%#-- copyright -OpenProject is a project management system. -Copyright (C) 2012-2014 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. - -++#%> - -<%= error_messages_for "query_menu_item", object: @query_menu_item %> - -
- <%= form.label :name, l(:label_menu_item_name), {id: 'name_of_item'} %> - <%= form.text_field :title, size: 20 %> -
- - - - -- <%= submit_tag l(:button_save), method: :post %> - <%= link_to l(:button_cancel), project_work_packages_path(@project) %> -
-<% end %> diff --git a/spec/controllers/query_menu_items_controller_spec.rb b/spec/controllers/query_menu_items_controller_spec.rb deleted file mode 100644 index f9086a95ff..0000000000 --- a/spec/controllers/query_menu_items_controller_spec.rb +++ /dev/null @@ -1,65 +0,0 @@ -#-- copyright -# OpenProject is a project management system. -# Copyright (C) 2012-2014 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 QueryMenuItemsController, :type => :controller do - let(:current_user) { FactoryGirl.create(:admin) } - - let(:project) { FactoryGirl.create :project } - let(:public_query) { FactoryGirl.create :public_query } - - before do - # log in user - allow(User).to receive(:current).and_return current_user - end - - describe '#create' do - before :each do - post :create, project_id: project, query_id: public_query - @query_menu_item = public_query.reload.query_menu_item - end - - it 'creates a query menu item' do - expect(@query_menu_item).to be_present - end - - it 'redirects to the query on work_packages#index' do - expect(response).to redirect_to project_work_packages_path(project, query_id: public_query.id) - end - end - - describe '#destroy' do - let(:query_menu_item) { public_query.create_query_menu_item name: public_query.name, title: public_query.name } - - it 'destroys the query_menu_item' do - delete :destroy, id: query_menu_item, project_id: project, query_id: public_query - expect(MenuItems::QueryMenuItem.exists?(query_menu_item.id)).to be_falsey - end - end -end