Signed-off-by: Alex Coles <alex@alexbcoles.com> Conflicts: app/assets/stylesheets/content/_work_packages.sasspull/2612/head
commit
7ebd7368ed
@ -0,0 +1,12 @@ |
|||||||
|
if OpenProject::Configuration.blacklisted_routes.any? |
||||||
|
# Block logins from a bad user agent |
||||||
|
Rack::Attack.blacklist('block forbidden routes') do |req| |
||||||
|
regex = OpenProject::Configuration.blacklisted_routes.map! { |str| Regexp.new(str) } |
||||||
|
regex.any? { |i| i =~ req.path } |
||||||
|
end |
||||||
|
|
||||||
|
Rack::Attack.blacklisted_response = lambda do |_env| |
||||||
|
# All blacklisted routes would return a 404. |
||||||
|
[404, {}, ['Not found']] |
||||||
|
end |
||||||
|
end |
@ -1,8 +1,8 @@ |
|||||||
<span ng-if="entity.links.version"> |
<span ng-if="entity.links.version.href"> |
||||||
<a href="{{pathHelper.versionPath(entity.embedded.version.props.id)}}"> |
<a href="{{pathHelper.versionPath(entity.embedded.version.props.id)}}"> |
||||||
{{entity.links.version.props.title}} |
{{entity.links.version.props.title}} |
||||||
</a> |
</a> |
||||||
</span> |
</span> |
||||||
<span ng-if="!entity.links.version"> |
<span ng-if="!entity.links.version.href"> |
||||||
{{readValue}} |
{{readValue}} |
||||||
</span> |
</span> |
||||||
|
@ -0,0 +1,53 @@ |
|||||||
|
#-- encoding: UTF-8 |
||||||
|
#-- copyright |
||||||
|
# OpenProject is a project management system. |
||||||
|
# Copyright (C) 2012-2015 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 'roar/decorator' |
||||||
|
require 'roar/json/hal' |
||||||
|
|
||||||
|
module API |
||||||
|
module V3 |
||||||
|
module StringObjects |
||||||
|
class StringObjectRepresenter < ::API::Decorators::Single |
||||||
|
link :self do |
||||||
|
{ |
||||||
|
href: api_v3_paths.string_object(represented) |
||||||
|
} |
||||||
|
end |
||||||
|
|
||||||
|
property :value, |
||||||
|
exec_context: :decorator, |
||||||
|
getter: -> (*) { represented } |
||||||
|
|
||||||
|
def _type |
||||||
|
'StringObject' |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,45 @@ |
|||||||
|
#-- encoding: UTF-8 |
||||||
|
#-- copyright |
||||||
|
# OpenProject is a project management system. |
||||||
|
# Copyright (C) 2012-2015 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. |
||||||
|
#++ |
||||||
|
|
||||||
|
module API |
||||||
|
module V3 |
||||||
|
module StringObjects |
||||||
|
class StringObjectsAPI < Grape::API |
||||||
|
resources :string_objects do |
||||||
|
|
||||||
|
namespace ':value' do |
||||||
|
get do |
||||||
|
StringObjectRepresenter.new(params[:value]) |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,58 @@ |
|||||||
|
#-- copyright |
||||||
|
# OpenProject is a project management system. |
||||||
|
# Copyright (C) 2012-2015 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 ::API::V3::StringObjects::StringObjectRepresenter do |
||||||
|
let(:value) { 'foo bar' } |
||||||
|
let(:representer) { described_class.new(value) } |
||||||
|
|
||||||
|
include API::V3::Utilities::PathHelper |
||||||
|
|
||||||
|
context 'generation' do |
||||||
|
subject { representer.to_json } |
||||||
|
|
||||||
|
it 'should indicate its type' do |
||||||
|
is_expected.to be_json_eql('StringObject'.to_json).at_path('_type') |
||||||
|
end |
||||||
|
|
||||||
|
describe 'links' do |
||||||
|
it 'should link to self' do |
||||||
|
path = api_v3_paths.string_object(value) |
||||||
|
|
||||||
|
is_expected.to be_json_eql(path.to_json).at_path('_links/self/href') |
||||||
|
end |
||||||
|
end |
||||||
|
|
||||||
|
describe 'value' do |
||||||
|
it 'should have a value' do |
||||||
|
is_expected.to be_json_eql(value.to_json).at_path('value') |
||||||
|
end |
||||||
|
end |
||||||
|
end |
||||||
|
end |
@ -0,0 +1,52 @@ |
|||||||
|
#-- copyright |
||||||
|
# OpenProject is a project management system. |
||||||
|
# Copyright (C) 2012-2015 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 'rack/test' |
||||||
|
|
||||||
|
describe 'API v3 String Objects resource' do |
||||||
|
include Rack::Test::Methods |
||||||
|
|
||||||
|
describe 'string_objects' do |
||||||
|
subject(:response) { last_response } |
||||||
|
|
||||||
|
let(:path) { '/api/v3/string_objects/foo%20bar' } |
||||||
|
|
||||||
|
before do |
||||||
|
get path |
||||||
|
end |
||||||
|
|
||||||
|
it 'is successful' do |
||||||
|
expect(subject.status).to eql(200) |
||||||
|
end |
||||||
|
|
||||||
|
it 'returns the value' do |
||||||
|
expect(subject.body).to be_json_eql('foo bar'.to_json).at_path('value') |
||||||
|
end |
||||||
|
end |
||||||
|
end |
Loading…
Reference in new issue