parent
a0b822d50b
commit
126d2baf00
@ -0,0 +1,42 @@ |
||||
#-- encoding: UTF-8 |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2017 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-2017 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 CustomActionsController < ApplicationController |
||||
before_action :require_admin |
||||
|
||||
def index; end |
||||
|
||||
def new |
||||
@custom_action = OpenStruct.new name: '' |
||||
end |
||||
|
||||
def create |
||||
redirect_to custom_actions_path |
||||
end |
||||
end |
@ -0,0 +1,3 @@ |
||||
<div class="form--field"> |
||||
<%= f.text_field :name, required: true, container_class: '-middle', label: 'Name' %> |
||||
</div> |
@ -0,0 +1,12 @@ |
||||
<% html_title l(:label_administration), 'Custom actions (placeholder)' -%> |
||||
<%= toolbar title: 'Custom actions (placeholder)' do %> |
||||
<li class="toolbar-item"> |
||||
<%= link_to new_custom_action_path, |
||||
{ class: 'button -alt-highlight', |
||||
aria: { label: 'Custom action (placeholder)' }, |
||||
title: 'Custom action (placeholder)' } do %> |
||||
<%= op_icon('button--icon icon-add') %> |
||||
<span class="button--text"><%= t('Custom action (placeholer)') %></span> |
||||
<% end %> |
||||
</li> |
||||
<% end %> |
@ -0,0 +1,38 @@ |
||||
<%#-- copyright |
||||
OpenProject is a project management system. |
||||
Copyright (C) 2012-2017 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-2017 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. |
||||
|
||||
++#%> |
||||
|
||||
<% html_title l(:label_administration), t('custom_actions.new') %> |
||||
|
||||
<% local_assigns[:additional_breadcrumb] = t('custom_actions.new') %> |
||||
<%= breadcrumb_toolbar t('custom_actions.new') %> |
||||
|
||||
<%= labelled_tabular_form_for @custom_action, as: :custom_action, url: custom_actions_path do |f| %> |
||||
<%= render partial: 'form', locals: { f: f } %> |
||||
<%= styled_button_tag l(:button_create), class: '-highlight -with-icon icon-checkmark' %> |
||||
<% end %> |
@ -0,0 +1,130 @@ |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2017 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-2017 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 CustomActionsController, type: :controller do |
||||
let(:admin) { FactoryGirl.build(:admin) } |
||||
let(:non_admin) { FactoryGirl.build(:user) } |
||||
|
||||
describe '#index' do |
||||
context 'for admins' do |
||||
before do |
||||
login_as(admin) |
||||
|
||||
get :index |
||||
end |
||||
|
||||
it 'returns 200' do |
||||
expect(response.response_code) |
||||
.to eql 200 |
||||
end |
||||
|
||||
it 'renders index template' do |
||||
expect(response) |
||||
.to render_template('index') |
||||
end |
||||
end |
||||
|
||||
context 'for non admins' do |
||||
before do |
||||
login_as(non_admin) |
||||
get :index |
||||
end |
||||
|
||||
it 'returns 403' do |
||||
expect(response.response_code) |
||||
.to eql 403 |
||||
end |
||||
end |
||||
end |
||||
|
||||
describe '#new' do |
||||
context 'for admins' do |
||||
before do |
||||
login_as(admin) |
||||
|
||||
get :new |
||||
end |
||||
|
||||
it 'returns 200' do |
||||
expect(response.response_code) |
||||
.to eql 200 |
||||
end |
||||
|
||||
it 'renders new template' do |
||||
expect(response) |
||||
.to render_template('new') |
||||
end |
||||
|
||||
it 'assigns custom_action' do |
||||
expect(assigns(:custom_action)) |
||||
.not_to be_nil |
||||
end |
||||
end |
||||
|
||||
context 'for non admins' do |
||||
before do |
||||
login_as(non_admin) |
||||
get :new |
||||
end |
||||
|
||||
it 'returns 403' do |
||||
expect(response.response_code) |
||||
.to eql 403 |
||||
end |
||||
end |
||||
end |
||||
|
||||
describe '#create' do |
||||
context 'for admins' do |
||||
before do |
||||
login_as(admin) |
||||
|
||||
post :create |
||||
end |
||||
|
||||
it 'redirects to index' do |
||||
expect(response) |
||||
.to redirect_to(custom_actions_path) |
||||
end |
||||
end |
||||
|
||||
context 'for non admins' do |
||||
before do |
||||
login_as(non_admin) |
||||
get :new |
||||
end |
||||
|
||||
it 'returns 403' do |
||||
expect(response.response_code) |
||||
.to eql 403 |
||||
end |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,52 @@ |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2017 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-2017 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 'custom_actions routes', type: :routing do |
||||
describe 'index' do |
||||
it 'links GET /admin/custom_actions' do |
||||
expect(get('/admin/custom_actions')) |
||||
.to route_to('custom_actions#index') |
||||
end |
||||
end |
||||
|
||||
describe 'new' do |
||||
it 'links GET /admin/custom_actions/new' do |
||||
expect(get('/admin/custom_actions/new')) |
||||
.to route_to('custom_actions#new') |
||||
end |
||||
end |
||||
|
||||
describe 'create' do |
||||
it 'links POST /admin/custom_actions' do |
||||
expect(post('/admin/custom_actions')) |
||||
.to route_to('custom_actions#create') |
||||
end |
||||
end |
||||
end |
Loading…
Reference in new issue