parent
0540001031
commit
cc41884048
@ -0,0 +1,32 @@ |
||||
#-- 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. |
||||
#++ |
||||
|
||||
module Projects |
||||
class CreateContract < BaseContract |
||||
end |
||||
end |
@ -0,0 +1,32 @@ |
||||
#-- 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. |
||||
#++ |
||||
|
||||
module Projects |
||||
class UpdateContract < BaseContract |
||||
end |
||||
end |
@ -0,0 +1,41 @@ |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2018 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 docs/COPYRIGHT.rdoc for more details. |
||||
#++ |
||||
|
||||
module API |
||||
module V3 |
||||
module Projects |
||||
module Schemas |
||||
class ProjectSchemaAPI < ::API::OpenProjectAPI |
||||
resources :schema do |
||||
get &::API::V3::Utilities::Endpoints::Schema.new(model: Project).mount |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,83 @@ |
||||
#-- encoding: UTF-8 |
||||
|
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2018 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 docs/COPYRIGHT.rdoc for more details. |
||||
#++ |
||||
|
||||
module API |
||||
module V3 |
||||
module Projects |
||||
module Schemas |
||||
class ProjectSchemaRepresenter < ::API::Decorators::SchemaRepresenter |
||||
extend ::API::V3::Utilities::CustomFieldInjector::RepresenterClass |
||||
custom_field_injector type: :schema_representer |
||||
|
||||
schema :id, |
||||
type: 'Integer', |
||||
visibility: false |
||||
|
||||
schema :name, |
||||
type: 'String', |
||||
visibility: false, |
||||
min_length: 1, |
||||
max_length: 255 |
||||
|
||||
schema :identifier, |
||||
type: 'String', |
||||
visibility: false, |
||||
min_length: 1, |
||||
max_length: 100 |
||||
|
||||
schema :description, |
||||
type: 'Formattable', |
||||
visibility: false, |
||||
required: false |
||||
|
||||
schema :is_public, |
||||
as: :public, |
||||
type: 'Boolean', |
||||
visibility: false |
||||
|
||||
schema_with_allowed_string_collection :status, |
||||
type: 'String' |
||||
|
||||
schema :created_at, |
||||
type: 'DateTime', |
||||
visibility: false |
||||
|
||||
schema :updated_at, |
||||
type: 'DateTime', |
||||
visibility: false |
||||
|
||||
def self.represented_class |
||||
::Project |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,45 @@ |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2018 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 docs/COPYRIGHT.rdoc for more details. |
||||
#++ |
||||
|
||||
require 'spec_helper' |
||||
require_relative './shared_contract_examples' |
||||
|
||||
describe Projects::CreateContract do |
||||
it_behaves_like 'project contract' do |
||||
let(:project) do |
||||
Project.new(name: project_name, |
||||
identifier: project_identifier, |
||||
description: project_description, |
||||
status: project_status, |
||||
is_public: project_public, |
||||
parent: project_parent) |
||||
end |
||||
|
||||
subject(:contract) { described_class.new(project, current_user) } |
||||
end |
||||
end |
@ -0,0 +1,171 @@ |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2018 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 docs/COPYRIGHT.rdoc for more details. |
||||
#++ |
||||
|
||||
require 'spec_helper' |
||||
|
||||
shared_examples_for 'project contract' do |
||||
let(:current_user) do |
||||
FactoryBot.build_stubbed(:user) |
||||
end |
||||
let(:project_name) { 'Project name' } |
||||
let(:project_identifier) { 'project_identifier' } |
||||
let(:project_description) { 'Project description' } |
||||
let(:project_status) { Project::STATUS_ACTIVE } |
||||
let(:project_public) { true } |
||||
let(:project_parent) do |
||||
FactoryBot.build_stubbed(:project).tap do |p| |
||||
allow(p) |
||||
.to receive(:visible?) |
||||
.and_return(parent_visible) |
||||
end |
||||
end |
||||
let(:parent_visible) { true } |
||||
|
||||
def expect_valid(valid, symbols = {}) |
||||
expect(contract.validate).to eq(valid) |
||||
|
||||
symbols.each do |key, arr| |
||||
expect(contract.errors.symbols_for(key)).to match_array arr |
||||
end |
||||
end |
||||
|
||||
shared_examples 'is valid' do |
||||
it 'is valid' do |
||||
expect_valid(true) |
||||
end |
||||
end |
||||
|
||||
it_behaves_like 'is valid' |
||||
|
||||
context 'if the name is nil' do |
||||
let(:project_name) { nil } |
||||
|
||||
it 'is invalid' do |
||||
expect_valid(false, name: %i(blank)) |
||||
end |
||||
end |
||||
|
||||
context 'if the identifier is nil' do |
||||
let(:project_identifier) { nil } |
||||
|
||||
it 'is invalid' do |
||||
expect_valid(false, identifier: %i(blank too_short)) |
||||
end |
||||
end |
||||
|
||||
context 'if the description is nil' do |
||||
let(:project_description) { nil } |
||||
|
||||
it_behaves_like 'is valid' |
||||
end |
||||
|
||||
context 'if the parent is nil' do |
||||
let(:project_parent) { nil } |
||||
|
||||
it_behaves_like 'is valid' |
||||
end |
||||
|
||||
context 'if the parent is invisible to the user' do |
||||
let(:parent_visible) { false } |
||||
|
||||
it 'is invalid' do |
||||
expect_valid(false, parent: %i(does_not_exist)) |
||||
end |
||||
end |
||||
|
||||
context 'if the status is nil' do |
||||
let(:project_status) { nil } |
||||
|
||||
it 'is invalid' do |
||||
expect_valid(false, status: %i(blank)) |
||||
end |
||||
end |
||||
|
||||
describe 'assignable_values' do |
||||
context 'for project' do |
||||
let(:visible_projects) { double('visible projects') } |
||||
before do |
||||
allow(Project) |
||||
.to receive(:visible) |
||||
.and_return(visible_projects) |
||||
end |
||||
|
||||
it 'is the list of visible projects' do |
||||
expect(subject.assignable_values(:parent, current_user)) |
||||
.to eql visible_projects |
||||
end |
||||
end |
||||
|
||||
context 'for status' do |
||||
it 'is a list of all available status' do |
||||
expect(subject.assignable_values(:status, current_user)) |
||||
.to eql Project.statuses.keys |
||||
end |
||||
end |
||||
|
||||
context 'for a custom field' do |
||||
let(:custom_field) { FactoryBot.build_stubbed(:list_project_custom_field) } |
||||
|
||||
it 'is the list of custom field values' do |
||||
expect(subject.assignable_custom_field_values(custom_field)) |
||||
.to eql custom_field.possible_values |
||||
end |
||||
end |
||||
end |
||||
|
||||
describe 'available_custom_fields' do |
||||
let(:visible_custom_field) { FactoryBot.build_stubbed(:int_project_custom_field, visible: true) } |
||||
let(:invisible_custom_field) { FactoryBot.build_stubbed(:int_project_custom_field, visible: false) } |
||||
|
||||
before do |
||||
allow(project) |
||||
.to receive(:available_custom_fields) |
||||
.and_return([visible_custom_field, invisible_custom_field]) |
||||
end |
||||
|
||||
context 'if the user is admin' do |
||||
before do |
||||
allow(current_user) |
||||
.to receive(:admin?) |
||||
.and_return(true) |
||||
end |
||||
|
||||
it 'returns all available_custom_fields of the project' do |
||||
expect(subject.available_custom_fields) |
||||
.to match_array([visible_custom_field, invisible_custom_field]) |
||||
end |
||||
end |
||||
|
||||
context 'if the user is no admin' do |
||||
it 'returns all visible and available_custom_fields of the project' do |
||||
expect(subject.available_custom_fields) |
||||
.to match_array([visible_custom_field]) |
||||
end |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,47 @@ |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2018 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 docs/COPYRIGHT.rdoc for more details. |
||||
#++ |
||||
|
||||
require 'spec_helper' |
||||
require_relative './shared_contract_examples' |
||||
|
||||
describe Projects::UpdateContract do |
||||
it_behaves_like 'project contract' do |
||||
let(:project) do |
||||
FactoryBot.build_stubbed(:project, |
||||
identifier: project_identifier, |
||||
status: project_status, |
||||
is_public: project_public).tap do |p| |
||||
# in order to actually have something changed |
||||
p.name = project_name |
||||
p.parent = project_parent |
||||
end |
||||
end |
||||
|
||||
subject(:contract) { described_class.new(project, current_user) } |
||||
end |
||||
end |
@ -0,0 +1,233 @@ |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2018 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 docs/COPYRIGHT.rdoc for more details. |
||||
#++ |
||||
|
||||
require 'spec_helper' |
||||
|
||||
describe ::API::V3::Projects::Schemas::ProjectSchemaRepresenter do |
||||
include API::V3::Utilities::PathHelper |
||||
|
||||
let(:current_user) { FactoryBot.build_stubbed(:user) } |
||||
|
||||
let(:self_link) { '/a/self/link' } |
||||
let(:embedded) { true } |
||||
let(:new_record) { true } |
||||
let(:custom_field) do |
||||
FactoryBot.build_stubbed(:int_project_custom_field) |
||||
end |
||||
let(:allowed_status) { ['some status'] } |
||||
let(:contract) do |
||||
contract = double('contract') |
||||
|
||||
allow(contract) |
||||
.to receive(:writable?) do |attribute| |
||||
writable = %w(name identifier description is_public status) |
||||
|
||||
writable.include?(attribute.to_s) |
||||
end |
||||
|
||||
allow(contract) |
||||
.to receive(:available_custom_fields) |
||||
.and_return([custom_field]) |
||||
|
||||
allow(contract) |
||||
.to receive(:assignable_values) |
||||
.with(:status, current_user) |
||||
.and_return(allowed_status) |
||||
|
||||
contract |
||||
end |
||||
let(:representer) do |
||||
described_class.create(contract, |
||||
self_link, |
||||
form_embedded: embedded, |
||||
current_user: current_user) |
||||
end |
||||
|
||||
context 'generation' do |
||||
subject(:generated) { representer.to_json } |
||||
|
||||
describe '_type' do |
||||
it 'is indicated as Schema' do |
||||
is_expected.to be_json_eql('Schema'.to_json).at_path('_type') |
||||
end |
||||
end |
||||
|
||||
describe 'id' do |
||||
let(:path) { 'id' } |
||||
|
||||
it_behaves_like 'has basic schema properties' do |
||||
let(:type) { 'Integer' } |
||||
let(:name) { I18n.t('attributes.id') } |
||||
let(:required) { true } |
||||
let(:writable) { false } |
||||
end |
||||
|
||||
it_behaves_like 'has no visibility property' |
||||
end |
||||
|
||||
describe 'name' do |
||||
let(:path) { 'name' } |
||||
|
||||
it_behaves_like 'has basic schema properties' do |
||||
let(:type) { 'String' } |
||||
let(:name) { I18n.t('attributes.name') } |
||||
let(:required) { true } |
||||
let(:writable) { true } |
||||
end |
||||
|
||||
it_behaves_like 'indicates length requirements' do |
||||
let(:min_length) { 1 } |
||||
let(:max_length) { 255 } |
||||
end |
||||
|
||||
it_behaves_like 'has no visibility property' |
||||
end |
||||
|
||||
describe 'identifier' do |
||||
let(:path) { 'identifier' } |
||||
|
||||
it_behaves_like 'has basic schema properties' do |
||||
let(:type) { 'String' } |
||||
let(:name) { I18n.t('activerecord.attributes.project.identifier') } |
||||
let(:required) { true } |
||||
let(:writable) { true } |
||||
end |
||||
|
||||
it_behaves_like 'indicates length requirements' do |
||||
let(:min_length) { 1 } |
||||
let(:max_length) { 100 } |
||||
end |
||||
|
||||
it_behaves_like 'has no visibility property' |
||||
end |
||||
|
||||
describe 'description' do |
||||
let(:path) { 'description' } |
||||
|
||||
it_behaves_like 'has basic schema properties' do |
||||
let(:type) { 'Formattable' } |
||||
let(:name) { I18n.t('attributes.description') } |
||||
let(:required) { false } |
||||
let(:writable) { true } |
||||
end |
||||
|
||||
it_behaves_like 'has no visibility property' |
||||
end |
||||
|
||||
describe 'public' do |
||||
let(:path) { 'public' } |
||||
|
||||
it_behaves_like 'has basic schema properties' do |
||||
let(:type) { 'Boolean' } |
||||
let(:name) { I18n.t('attributes.is_public') } |
||||
let(:required) { true } |
||||
let(:writable) { true } |
||||
end |
||||
|
||||
it_behaves_like 'has no visibility property' |
||||
end |
||||
|
||||
describe 'status' do |
||||
let(:path) { 'status' } |
||||
|
||||
it_behaves_like 'has basic schema properties' do |
||||
let(:type) { 'String' } |
||||
let(:name) { I18n.t('attributes.status') } |
||||
let(:required) { true } |
||||
let(:writable) { true } |
||||
end |
||||
|
||||
it 'contains no link to the allowed values' do |
||||
is_expected |
||||
.not_to have_json_path("#{path}/_links/allowedValues") |
||||
end |
||||
|
||||
it 'embeds the allowed values' do |
||||
allowed_path = "#{path}/_embedded/allowedValues" |
||||
|
||||
is_expected |
||||
.to be_json_eql(allowed_status.to_json) |
||||
.at_path(allowed_path) |
||||
end |
||||
end |
||||
|
||||
describe 'createdAt' do |
||||
let(:path) { 'createdAt' } |
||||
|
||||
it_behaves_like 'has basic schema properties' do |
||||
let(:type) { 'DateTime' } |
||||
let(:name) { I18n.t('attributes.created_at') } |
||||
let(:required) { true } |
||||
let(:writable) { false } |
||||
end |
||||
|
||||
it_behaves_like 'has no visibility property' |
||||
end |
||||
|
||||
describe 'updatedAt' do |
||||
let(:path) { 'updatedAt' } |
||||
|
||||
it_behaves_like 'has basic schema properties' do |
||||
let(:type) { 'DateTime' } |
||||
let(:name) { I18n.t('attributes.updated_at') } |
||||
let(:required) { true } |
||||
let(:writable) { false } |
||||
end |
||||
|
||||
it_behaves_like 'has no visibility property' |
||||
end |
||||
|
||||
describe 'int custom field' do |
||||
let(:path) { "customField#{custom_field.id}" } |
||||
|
||||
it_behaves_like 'has basic schema properties' do |
||||
let(:type) { 'Integer' } |
||||
let(:name) { custom_field.name } |
||||
let(:required) { false } |
||||
let(:writable) { true } |
||||
end |
||||
end |
||||
|
||||
context '_links' do |
||||
describe 'self link' do |
||||
it_behaves_like 'has an untitled link' do |
||||
let(:link) { 'self' } |
||||
let(:href) { self_link } |
||||
end |
||||
|
||||
context 'embedded in a form' do |
||||
let(:self_link) { nil } |
||||
|
||||
it_behaves_like 'has no link' do |
||||
let(:link) { 'self' } |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,68 @@ |
||||
#-- copyright |
||||
# OpenProject is a project management system. |
||||
# Copyright (C) 2012-2018 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 docs/COPYRIGHT.rdoc for more details. |
||||
#++ |
||||
|
||||
require 'spec_helper' |
||||
require 'rack/test' |
||||
|
||||
describe 'API v3 Projects schema resource', type: :request, content_type: :json do |
||||
include Rack::Test::Methods |
||||
include API::V3::Utilities::PathHelper |
||||
|
||||
shared_let(:current_user) do |
||||
FactoryBot.create(:user) |
||||
end |
||||
|
||||
let(:path) { api_v3_paths.project_schema } |
||||
|
||||
before do |
||||
login_as(current_user) |
||||
end |
||||
|
||||
subject(:response) { last_response } |
||||
|
||||
describe '#GET /projects/schema' do |
||||
before do |
||||
get path |
||||
end |
||||
|
||||
it 'responds with 200 OK' do |
||||
expect(subject.status).to eq(200) |
||||
end |
||||
|
||||
it 'returns a schema' do |
||||
expect(subject.body) |
||||
.to be_json_eql('Schema'.to_json) |
||||
.at_path '_type' |
||||
end |
||||
|
||||
#it 'does not embed' do |
||||
# expect(subject.body) |
||||
# .not_to have_json_path('page/_links/allowedValues') |
||||
#end |
||||
end |
||||
end |
Loading…
Reference in new issue