rename project attributes

pull/7722/head
ulferts 5 years ago
parent 00bd5ec0ab
commit 4e5b9afef5
No known key found for this signature in database
GPG Key ID: A205708DE1284017
  1. 29
      app/contracts/projects/base_contract.rb
  2. 2
      app/controllers/application_controller.rb
  3. 2
      app/controllers/projects_controller.rb
  4. 2
      app/models/permitted_params.rb
  5. 2
      app/models/principal.rb
  6. 27
      app/models/project.rb
  7. 2
      app/models/project/copy.rb
  8. 24
      app/models/queries/filters/shared/boolean_filter.rb
  9. 2
      app/models/queries/projects.rb
  10. 37
      app/models/queries/projects/filters/active_filter.rb
  11. 2
      app/models/queries/projects/orders/default_order.rb
  12. 17
      app/models/queries/queries/filters/hidden_filter.rb
  13. 4
      app/models/work_package.rb
  14. 4
      app/services/authorization/project_query.rb
  15. 2
      app/services/authorization/user_allowed_query.rb
  16. 1
      app/services/authorization/user_allowed_service.rb
  17. 3
      app/services/authorization/user_project_roles_query.rb
  18. 2
      app/services/projects/archive_service.rb
  19. 6
      app/services/projects/set_attributes_service.rb
  20. 2
      app/services/projects/unarchive_service.rb
  21. 2
      app/views/projects/form/_project_attributes.html.erb
  22. 2
      app/views/projects/form/attributes/_public.html.erb
  23. 4
      app/views/projects/index.html.erb
  24. 2
      config/locales/en.seeders.standard.yml.example
  25. 1
      config/locales/en.yml
  26. 20
      db/migrate/20190923111902_add_project_status_reporting.rb
  27. 48
      db/migrate/20190923123858_simplify_project_active_and_timestamp.rb
  28. 84
      docs/api/apiv3/endpoints/projects.apib
  29. 11
      lib/api/v3/projects/project_representer.rb
  30. 2
      lib/api/v3/projects/schemas/project_schema_representer.rb
  31. 2
      lib/open_project/reminders/due_issues_reminder.rb
  32. 4
      lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb
  33. 2
      lib/plugins/acts_as_watchable/lib/acts_as_watchable.rb
  34. 2
      modules/backlogs/app/models/sprint.rb
  35. 2
      modules/backlogs/spec/api/work_packages/form_resource_spec.rb
  36. 4
      modules/backlogs/spec/features/onboarding/backlogs_onboarding_tour_spec.rb
  37. 4
      modules/boards/spec/features/onboarding/boards_onboarding_tour_spec.rb
  38. 4
      modules/costs/spec/models/time_entry_spec.rb
  39. 2
      modules/costs/spec/requests/api/budgets/budget_resource_spec.rb
  40. 2
      modules/costs/spec/requests/api/work_packages/work_package_form_resource_spec.rb
  41. 2
      modules/costs/spec/requests/api/work_packages/work_package_resource_spec.rb
  42. 4
      modules/global_roles/spec/models/users/allowed_to_spec.rb
  43. 4
      spec/contracts/projects/create_contract_spec.rb
  44. 13
      spec/contracts/projects/shared_contract_examples.rb
  45. 4
      spec/contracts/projects/update_contract_spec.rb
  46. 2
      spec/contracts/work_packages/update_contract_spec.rb
  47. 14
      spec/controllers/copy_projects_controller_spec.rb
  48. 8
      spec/controllers/projects_controller_spec.rb
  49. 10
      spec/controllers/sys_controller_spec.rb
  50. 4
      spec/controllers/work_packages/moves_controller_spec.rb
  51. 4
      spec/controllers/work_packages_controller_spec.rb
  52. 8
      spec/factories/project_factory.rb
  53. 35
      spec/factories/project_status.rb
  54. 4
      spec/features/onboarding/onboarding_tour_spec.rb
  55. 4
      spec/features/projects/projects_index_spec.rb
  56. 2
      spec/features/work_packages/details/date_editor_spec.rb
  57. 2
      spec/features/work_packages/details/details_toolbar_spec.rb
  58. 2
      spec/features/work_packages/details/inplace_editor/subject_editor_spec.rb
  59. 2
      spec/features/work_packages/details/inplace_editor/version_editor_spec.rb
  60. 2
      spec/features/work_packages/details/markdown/activity_comments_spec.rb
  61. 2
      spec/features/work_packages/details/markdown/description_editor_spec.rb
  62. 6
      spec/features/work_packages/select/select_query_spec.rb
  63. 2
      spec/features/work_packages/table/inline_create/create_work_packages_spec.rb
  64. 4
      spec/features/work_packages/table/inline_create/parallel_creation_spec.rb
  65. 2
      spec/features/work_packages/table/queries/me_filter_spec.rb
  66. 2
      spec/features/work_packages/table/queries/subject_filter_spec.rb
  67. 2
      spec/features/work_packages/table/queries/summary_spec.rb
  68. 2
      spec/features/work_packages/tabs/activity_revisions_spec.rb
  69. 2
      spec/features/work_packages/tabs/activity_tab_spec.rb
  70. 2
      spec/lib/api/v3/categories/category_representer_spec.rb
  71. 21
      spec/lib/api/v3/projects/project_representer_spec.rb
  72. 4
      spec/lib/api/v3/projects/schemas/project_schema_representer_spec.rb
  73. 2
      spec/lib/api/v3/versions/version_representer_rendering_spec.rb
  74. 2
      spec/lib/api/v3/work_packages/schema/work_package_schema_representer_spec.rb
  75. 4
      spec/lib/api/v3/work_packages/work_package_representer_spec.rb
  76. 2
      spec/lib/open_project/text_formatting/markdown/markdown_spec.rb
  77. 2
      spec/models/copy_project_job_spec.rb
  78. 8
      spec/models/mail_handler_spec.rb
  79. 2
      spec/models/news_spec.rb
  80. 34
      spec/models/project/allowed_to_scope_spec.rb
  81. 14
      spec/models/project/copy_spec.rb
  82. 14
      spec/models/project/status_spec.rb
  83. 75
      spec/models/project_spec.rb
  84. 16
      spec/models/queries/projects/filters/active_filter_spec.rb
  85. 2
      spec/models/system_user_spec.rb
  86. 23
      spec/models/users/allowed_scope_spec.rb
  87. 38
      spec/models/users/allowed_to_spec.rb
  88. 2
      spec/models/work_package/work_package_acts_as_searchable_spec.rb
  89. 6
      spec/models/work_package/work_package_visibility_spec.rb
  90. 4
      spec/models/work_package_spec.rb
  91. 6
      spec/requests/api/v3/activity_resource_spec.rb
  92. 2
      spec/requests/api/v3/attachments/attachment_resource_shared_examples.rb
  93. 4
      spec/requests/api/v3/category_resource_spec.rb
  94. 2
      spec/requests/api/v3/priority_resource_spec.rb
  95. 8
      spec/requests/api/v3/project_resource_spec.rb
  96. 2
      spec/requests/api/v3/projects/available_parents_resource_spec.rb
  97. 4
      spec/requests/api/v3/projects/version_resource_spec.rb
  98. 2
      spec/requests/api/v3/queries/queries_by_project_resource_spec.rb
  99. 2
      spec/requests/api/v3/queries/query_resource_spec.rb
  100. 2
      spec/requests/api/v3/render_resource_spec.rb
  101. Some files were not shown because too many files have changed in this diff Show More

@ -36,17 +36,14 @@ module Projects
attribute :name
attribute :identifier
attribute :description
attribute :is_public
attribute :status do
validate_status_not_nil
validate_status_included
attribute :public
attribute :active do
validate_active_present
end
attribute :parent do
validate_parent_assignable
end
attribute_alias :is_public, :public
def validate
validate_user_allowed_to_manage
@ -59,10 +56,6 @@ module Projects
.where.not(id: model.self_and_descendants)
end
def assignable_statuses
Project.statuses.keys
end
def available_custom_fields
if user.admin?
model.available_custom_fields
@ -77,16 +70,6 @@ module Projects
private
def validate_status_not_nil
errors.add(:status, :blank) if model.status.nil?
end
def validate_status_included
if model.status.present? && !assignable_statuses.include?(model.status)
errors.add(:status, :inclusion)
end
end
def validate_parent_assignable
if model.parent &&
model.parent_id_changed? &&
@ -95,6 +78,12 @@ module Projects
end
end
def validate_active_present
if model.active.nil?
errors.add(:active, :blank)
end
end
def validate_user_allowed_to_manage
errors.add :base, :error_unauthorized unless user.allowed_to?(manage_permission, model)
end

@ -447,7 +447,7 @@ class ApplicationController < ActionController::Base
# on the project.
def check_project_privacy
if @project && @project.active?
if @project.is_public? || User.current.member_of?(@project) || User.current.admin?
if @project.public? || User.current.member_of?(@project) || User.current.admin?
true
else
User.current.logged? ? render_403 : require_login

@ -246,7 +246,7 @@ class ProjectsController < ApplicationController
@query = ParamsToQueryService.new(Project, current_user).call(params)
# Set default filter on status no filter is provided.
@query.where('status', '=', Project::STATUS_ACTIVE.to_s) unless params[:filters]
@query.where('active', '=', OpenProject::Database::DB_VALUE_TRUE) unless params[:filters]
# Order lft if no order is provided.
@query.order(lft: :asc) unless params[:sortBy]

@ -294,7 +294,7 @@ class PermittedParams
def project
whitelist = params.require(:project).permit(:name,
:description,
:is_public,
:public,
:responsible_id,
:identifier,
:project_type_id,

@ -48,7 +48,7 @@ class Principal < ActiveRecord::Base
has_many :members, foreign_key: 'user_id', dependent: :destroy
has_many :memberships, -> {
includes(:project, :roles)
.where(projects: { status: Project::STATUS_ACTIVE })
.where(projects: { active: true })
.order(Arel.sql('projects.name ASC'))
# haven't been able to produce the order using hashes
},

@ -36,12 +36,6 @@ class Project < ActiveRecord::Base
include Project::Storage
include Project::Activity
# Project statuses
STATUS_ACTIVE = 1
STATUS_ARCHIVED = 9
enum status: { active: STATUS_ACTIVE, archived: STATUS_ARCHIVED }
# Maximum length for project identifiers
IDENTIFIER_MAX_LENGTH = 100
@ -144,15 +138,19 @@ class Project < ActiveRecord::Base
}, class_name: 'WorkPackageCustomField',
join_table: "#{table_name_prefix}custom_fields_projects#{table_name_suffix}",
association_foreign_key: 'custom_field_id'
has_one :status, class_name: 'Project::Status', dependent: :destroy
acts_as_nested_set order_column: :name, dependent: :destroy
acts_as_customizable
acts_as_searchable columns: ["#{table_name}.name", "#{table_name}.identifier", "#{table_name}.description"], project_key: 'id', permission: nil
acts_as_searchable columns: %W(#{table_name}.name #{table_name}.identifier #{table_name}.description),
date_column: "#{table_name}.created_at",
project_key: 'id',
permission: nil
acts_as_event title: Proc.new { |o| "#{Project.model_name.human}: #{o.name}" },
url: Proc.new { |o| { controller: '/projects', action: 'show', id: o } },
author: nil,
datetime: :created_on
datetime: :created_at
validates :name,
presence: true,
@ -179,12 +177,17 @@ class Project < ActiveRecord::Base
scope :has_module, ->(mod) {
where(["#{Project.table_name}.id IN (SELECT em.project_id FROM #{EnabledModule.table_name} em WHERE em.name=?)", mod.to_s])
}
scope :public_projects, -> { where(is_public: true) }
scope :public_projects, -> { where(public: true) }
scope :visible, ->(user = User.current) { merge(Project.visible_by(user)) }
scope :newest, -> { order(created_on: :desc) }
scope :newest, -> { order(created_at: :desc) }
scope :active, -> { where(active: true) }
def visible?(user = User.current)
active? and (is_public? or user.admin? or user.member_of?(self))
active? and (public? or user.admin? or user.member_of?(self))
end
def archived?
!active?
end
def copy_allowed?
@ -453,7 +456,7 @@ class Project < ActiveRecord::Base
# Returns an auto-generated project identifier based on the last identifier used
def self.next_identifier
p = Project.order(Arel.sql('created_on DESC')).first
p = Project.newest.first
p.nil? ? nil : p.identifier.to_s.succ
end

@ -33,7 +33,7 @@ module Project::Copy
base.send :include, self::CopyMethods
# things that are explicitly excluded when copying a project
base.not_to_copy ['id', 'created_on', 'updated_on', 'name', 'identifier', 'status', 'lft', 'rgt']
base.not_to_copy ['id', 'created_at', 'updated_at', 'name', 'identifier', 'active', 'lft', 'rgt']
# specify the order of associations to copy
base.copy_precedence ['members', 'versions', 'categories', 'work_packages', 'wiki', 'custom_values', 'queries']

@ -28,23 +28,19 @@
# See docs/COPYRIGHT.rdoc for more details.
#++
class Queries::Projects::Filters::ActiveOrArchivedFilter < Queries::Projects::Filters::ProjectFilter
def type
:list_all
end
def self.key
:status
module Queries::Filters::Shared::BooleanFilter
def allowed_values
[
[I18n.t(:general_text_yes), OpenProject::Database::DB_VALUE_TRUE],
[I18n.t(:general_text_no), OpenProject::Database::DB_VALUE_FALSE]
]
end
def human_name
I18n.t('query_fields.active_or_archived')
def type
:list
end
def allowed_values
[
[I18n.t(:status_active), Project::STATUS_ACTIVE.to_s],
[I18n.t(:status_archived), Project::STATUS_ARCHIVED.to_s]
]
def type_strategy
@type_strategy ||= ::Queries::Filters::Strategies::BooleanList.new self
end
end

@ -36,7 +36,7 @@ module Queries::Projects
register.filter query, filters::AncestorFilter
register.filter query, filters::TypeFilter
register.filter query, filters::ActiveOrArchivedFilter
register.filter query, filters::ActiveFilter
register.filter query, filters::NameAndIdentifierFilter
register.filter query, filters::CustomFieldFilter
register.filter query, filters::CreatedOnFilter

@ -0,0 +1,37 @@
#-- 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.
#++
class Queries::Projects::Filters::ActiveFilter < Queries::Projects::Filters::ProjectFilter
include Queries::Filters::Shared::BooleanFilter
def self.key
:active
end
end

@ -32,6 +32,6 @@ class Queries::Projects::Orders::DefaultOrder < Queries::BaseOrder
self.model = Project
def self.key
/id|name|created_on|is_public|lft/
/id|name|created_on|public|lft/
end
end

@ -28,22 +28,9 @@
#++
class Queries::Queries::Filters::HiddenFilter < Queries::Queries::Filters::QueryFilter
include Queries::Filters::Shared::BooleanFilter
def self.key
:hidden
end
def allowed_values
[
[I18n.t(:general_text_yes), OpenProject::Database::DB_VALUE_TRUE],
[I18n.t(:general_text_no), OpenProject::Database::DB_VALUE_FALSE]
]
end
def type
:list
end
def type_strategy
@type_strategy ||= ::Queries::Filters::Strategies::BooleanList.new self
end
end

@ -89,7 +89,7 @@ class WorkPackage < ActiveRecord::Base
.where(statuses: { is_closed: false })
}
scope :with_status_closed, ->() {
scope :with_status_closed, -> {
includes(:status)
.where(statuses: { is_closed: true })
}
@ -100,7 +100,7 @@ class WorkPackage < ActiveRecord::Base
scope :on_active_project, -> {
includes(:status, :project, :type)
.where(projects: { status: Project::STATUS_ACTIVE })
.where(projects: { active: true })
}
scope :without_version, -> {

@ -60,7 +60,7 @@ class Authorization::ProjectQuery < Authorization::AbstractQuery
end
def self.project_active_condition
projects_table[:status].eq(Project::STATUS_ACTIVE)
projects_table[:active].eq(true)
end
def self.members_member_roles_join
@ -124,7 +124,7 @@ class Authorization::ProjectQuery < Authorization::AbstractQuery
Role::BUILTIN_ANONYMOUS
end
projects_table[:is_public]
projects_table[:public]
.eq(true)
.and(assigned_roles_table[:builtin].eq(builtin_role))
.and(member_roles_table[:id].eq(nil))

@ -88,7 +88,7 @@ class Authorization::UserAllowedQuery < Authorization::AbstractUserQuery
def self.roles_member_roles_join(project)
id_equal = roles_table[:id].eq(member_roles_table[:role_id])
if project.is_public?
if project.public?
member_or_public_project_condition(id_equal)
else
id_equal

@ -1,4 +1,5 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2018 the OpenProject Foundation (OPF)

@ -1,4 +1,5 @@
#-- encoding: UTF-8
#-- copyright
# OpenProject is a project management system.
# Copyright (C) 2012-2018 the OpenProject Foundation (OPF)
@ -37,7 +38,7 @@ class Authorization::UserProjectRolesQuery < Authorization::UserRolesQuery
end
transformations.register roles_member_roles_join, :builtin_role do |statement, user, project|
if project.is_public?
if project.public?
builtin_role = if user.logged?
Role::BUILTIN_NON_MEMBER
else

@ -51,7 +51,7 @@ module Projects
def archive_project(project)
# we do not care for validations
project.update_column(:status, Project::STATUS_ARCHIVED)
project.update_column(:active, true)
end
end
end

@ -36,7 +36,7 @@ module Projects
attribute_keys = attributes.keys.map(&:to_s)
set_default_identifier(attribute_keys.include?('identifier'))
set_default_is_public(attribute_keys.include?('is_public'))
set_default_public(attribute_keys.include?('public'))
set_default_module_names(attribute_keys.include?('enabled_module_names'))
set_default_types(attribute_keys.include?('types') || attribute_keys.include?('type_ids'))
end
@ -47,8 +47,8 @@ module Projects
end
end
def set_default_is_public(provided)
model.is_public = Setting.default_projects_public? unless provided
def set_default_public(provided)
model.public = Setting.default_projects_public? unless provided
end
def set_default_module_names(provided)

@ -49,7 +49,7 @@ module Projects
def activate_project(project)
# we do not care for validations
project.update_column(:status, Project::STATUS_ACTIVE)
project.update_column(:active, true)
end
end
end

@ -46,7 +46,7 @@ See docs/COPYRIGHT.rdoc for more details.
locals: { form: form } %>
<%= render partial: "projects/form/attributes/identifier",
locals: { form: form } %>
<%= render partial: "projects/form/attributes/is_public",
<%= render partial: "projects/form/attributes/public",
locals: { form: form } %>
<% unless all_fields %>
<%= render partial: "customizable/form",

@ -28,5 +28,5 @@ See docs/COPYRIGHT.rdoc for more details.
++#%>
<div class="form--field">
<%= form.check_box :is_public %>
<%= form.check_box :public %>
</div>

@ -65,7 +65,7 @@ See docs/COPYRIGHT.rdoc for more details.
<tr>
<%= render partial: 'hierarchy_header' %>
<%= projects_sort_header_tag('name', caption: Project.human_attribute_name(:name), param: :json) %>
<%= projects_sort_header_tag('is_public', caption: Project.human_attribute_name(:is_public), param: :json) %>
<%= projects_sort_header_tag('public', caption: Project.human_attribute_name(:public), param: :json) %>
<% if EnterpriseToken.allows_to?(:custom_fields_in_projects_list) %>
<% @custom_fields.each do |custom_field| %>
<%= sort_header_tag("cf_#{custom_field.id}", caption: custom_field.name, param: :json) %>
@ -100,7 +100,7 @@ See docs/COPYRIGHT.rdoc for more details.
<% end %>
<%= link_to_project(project, {}, {}, false) %>
</td>
<td><%= checked_image project.is_public? %></td>
<td><%= checked_image project.public? %></td>
<% if EnterpriseToken.allows_to?(:custom_fields_in_projects_list) %>
<% @custom_fields.each do |custom_field| %>
<td class="format-<%= custom_field.field_format %>">

@ -47,7 +47,7 @@ en:
timeline: false
sort_by: id
hidden: true
is_public: false
public: false
type_configuration:
- type: :default_type_bug
description: |

@ -729,6 +729,7 @@ en:
password: "Password"
priority: "Priority"
project: "Project"
public: "Public"
responsible: "Accountable"
role: "Role"
roles: "Roles"

@ -1,9 +1,25 @@
class AddProjectStatusReporting < ActiveRecord::Migration[6.0]
def change
create_table :project_statuses do |table|
table.references :project, foreign_key: true, index: { unique: true }
table.text :description
table.references :project, null: false, foreign_key: true, index: { unique: true }
table.text :explanation
table.integer :code
table.timestamps
end
reversible do |change|
change.up do
project_status_for_existing_projects
end
end
end
def project_status_for_existing_projects
insert_sql = <<-SQL
INSERT into project_statuses
SELECT id AS project_id, #{Project::Status.codes['on_track']} as code FROM projects
SQL
insert Arel.sql(insert_sql)
end
end

@ -0,0 +1,48 @@
class SimplifyProjectActiveAndTimestamp < ActiveRecord::Migration[6.0]
STATUS_ACTIVE = 1
STATUS_ARCHIVED = 9
class Project < ActiveRecord::Base; end
def change
change_project_columns
reversible do |change|
change.up do
fill_active_column
end
change.down do
recreate_status_column_and_information
end
end
end
private
def change_project_columns
change_table :projects do |table|
table.rename :created_on, :created_at
table.rename :updated_on, :updated_at
table.rename :is_public, :public
end
end
def fill_active_column
add_column :projects, :active, :boolean, default: true, index: true, null: false
Project.reset_column_information
Project.where(status: STATUS_ARCHIVED).update_all(active: false)
remove_column :projects, :status
end
def recreate_status_column_and_information
add_column :projects, :status, :integer, default: STATUS_ACTIVE, null: false
Project.reset_column_information
Project.where(active: true).update_all(status: STATUS_ACTIVE)
Project.where(active: false).update_all(status: STATUS_ARCHIVED)
remove_column :projects, :active
end
end

@ -26,16 +26,16 @@ Depending on custom fields defined for projects, additional links might exist.
## Local Properties
| Property | Description | Type | Constraints | Supported operations |
| :---------: | ------------- | ---- | ----------- | -------------------- |
| id | Projects's id | Integer | x > 0 | READ/WRITE |
| identifier | | String | | READ/WRITE |
| name | | String | | READ/WRITE |
| status | The project's status | String | 'active' or 'archived' | READ/WRITE |
| public | Indicates whether the project is accessible for everybody | Boolean | | READ/WRITE |
| description | | Formattable | | READ/WRITE |
| createdAt | Time of creation | DateTime | | READ |
| updatedAt | Time of the most recent change to the project | DateTime | | READ |
| Property | Description | Type | Constraints | Supported operations |
| :---------: | ------------- | ---- | ----------- | -------------------- |
| id | Projects's id | Integer | x > 0 | READ/WRITE |
| identifier | | String | | READ/WRITE |
| name | | String | | READ/WRITE |
| active | Indicates whether the project is currently active or already archived | Boolean | | READ/WRITE |
| public | Indicates whether the project is accessible for everybody | Boolean | | READ/WRITE |
| description | | Formattable | | READ/WRITE |
| createdAt | Time of creation | DateTime | | READ |
| updatedAt | Time of the most recent change to the project | DateTime | | READ |
Depending on custom fields defined for projects, additional properties might exist.
@ -85,7 +85,7 @@ Depending on custom fields defined for projects, additional properties might exi
"id": 1,
"identifier": "project_identifier",
"name": "Project example",
"status": active,
"active": true,
"public": false,
"description": {
"format": "markdown",
@ -317,7 +317,7 @@ the project scheduled for deletion, it is archived at once.
"id": 6,
"identifier": "a_project",
"name": "A project",
"status": "active",
"active": true,
"public": false,
"description": {
"format": "markdown",
@ -356,7 +356,7 @@ the project scheduled for deletion, it is archived at once.
"id": 14,
"identifier": "another_project",
"name": "Another project",
"status": "archived",
"active": false,
"public": true,
"description": {
"format": "markdown",
@ -379,7 +379,7 @@ Returns a collection of projects. The collection can be filtered via query param
+ filters (optional, string, `[{ "ancestor": { "operator": "=", "values": ['1'] }" }]`) ... JSON specifying filter conditions.
Accepts the same format as returned by the [queries](#queries) endpoint.
Currently supported filters are:
+ status: based on the status of the project
+ active: based on the active property of the project
+ ancestor: filters projects by their ancestor. A project is not considered to be it's own ancestor.
+ created_on: based on the time the project was created
+ latest_activity_at: based on the time the last activity was registered on a project.
@ -394,7 +394,7 @@ Returns a collection of projects. The collection can be filtered via query param
+ id
+ name
+ created_on
+ is_public
+ public
+ latest_activity_at
+ required_disk_space
There might also be additional orders based on the custom fields that have been configured.
@ -524,14 +524,12 @@ You can use the form and schema to be retrieve the valid attribute values and by
"hasDefault": false,
"writable": true
},
"status": {
"type": "String",
"name": "Status",
"active": {
"type": "Boolean",
"name": "Active",
"required": true,
"hasDefault": false,
"writable": true,
"visibility": "default",
"_links": {}
"hasDefault": true,
"writable": true
},
"parent": {
"type": "Project",
@ -639,7 +637,7 @@ For more details and all possible responses see the general specification of [Fo
"payload": {
"identifier": "new_project_identifier",
"name": "New project name",
"status": "active",
"active": true,
"public": false,
"description": {
"format": "markdown",
@ -711,20 +709,12 @@ For more details and all possible responses see the general specification of [Fo
"hasDefault": false,
"writable": true
},
"status": {
"type": "String",
"name": "Status",
"active": {
"type": "Boolean",
"name": "Active",
"required": true,
"hasDefault": false,
"writable": true,
"visibility": "default",
"_embedded": {
"allowedValues": [
"active",
"archived"
]
},
"_links": {}
"hasDefault": true,
"writable": true
},
"parent": {
"type": "Project",
@ -949,7 +939,7 @@ For more details and all possible responses see the general specification of [Fo
"payload": {
"identifier": "new_project_identifier",
"name": "New project name",
"status": "active",
"active": true,
"public": false,
"description": {
"format": "markdown",
@ -1021,20 +1011,12 @@ For more details and all possible responses see the general specification of [Fo
"hasDefault": false,
"writable": true
},
"status": {
"type": "String",
"name": "Status",
"active": {
"type": "Boolean",
"name": "Active",
"required": true,
"hasDefault": false,
"hasDefault": true,
"writable": true,
"visibility": "default",
"_embedded": {
"allowedValues": [
"active",
"archived"
]
},
"_links": {}
},
"parent": {
"type": "Project",
@ -1271,7 +1253,7 @@ For more details and all possible responses see the general specification of [Fo
"id": 6,
"identifier": "a_project",
"name": "A project",
"status": "active",
"active": true,
"public": false,
"description": {
"format": "markdown",
@ -1307,7 +1289,7 @@ For more details and all possible responses see the general specification of [Fo
"id": 14,
"identifier": "another_project",
"name": "Another project",
"status": "archived",
"active": false,
"public": true,
"description": {
"format": "markdown",

@ -143,17 +143,14 @@ module API
property :id
property :identifier
property :name
property :status
property :is_public,
as: :public
property :active
property :public
formattable_property :description
date_time_property :created_on,
as: 'createdAt'
date_time_property :created_at
date_time_property :updated_on,
as: 'updatedAt'
date_time_property :updated_at
def _type
'Project'

@ -57,7 +57,7 @@ module API
visibility: false,
required: false
schema :is_public,
schema :public,
as: :public,
type: 'Boolean',
visibility: false

@ -44,7 +44,7 @@ module OpenProject
.includes(:status, :assigned_to, :project, :type)
.where("#{Status.table_name}.is_closed = false AND #{WorkPackage.table_name}.due_date <= ?", due_date)
.where("#{WorkPackage.table_name}.assigned_to_id IS NOT NULL")
.where("#{Project.table_name}.status = #{Project::STATUS_ACTIVE}")
.where("#{Project.table_name}.active = #{true}")
if user_ids.any?
scope = scope.where("#{WorkPackage.table_name}.assigned_to_id IN (?)", user_ids)

@ -156,7 +156,7 @@ module Redmine
def restrict_projects_by_permission(permission, query)
perm = OpenProject::AccessControl.permission(permission)
query = query.where(projects_table[:status].eq(Project::STATUS_ACTIVE))
query = query.where(projects_table[:active].eq(true))
if perm && perm.project_module
m = EnabledModule.arel_table
@ -187,7 +187,7 @@ module Redmine
end
if perm && (Role.anonymous.allowed_to?(perm.name) || Role.non_member.allowed_to?(perm.name)) && !is_member
public_project = projects_table[:is_public].eq(true)
public_project = projects_table[:public].eq(true)
stmt = stmt ? stmt.or(public_project) : public_project
end

@ -114,7 +114,7 @@ module Redmine
# User.active_or_registered.allowed_members(self.class.acts_as_watchable_permission, project)
# compared to
# User.allowed_members(self.class.acts_as_watchable_permission, project).active_or_registered
scope = if project.is_public?
scope = if project.public?
User.allowed(self.class.acts_as_watchable_permission, project)
else
User.allowed_members(self.class.acts_as_watchable_permission, project)

@ -51,7 +51,7 @@ class Sprint < Version
scope :apply_to, lambda { |project|
where("#{Version.table_name}.project_id = #{project.id}" +
" OR (#{Project.table_name}.status = #{Project::STATUS_ACTIVE} AND (" +
" OR (#{Project.table_name}.active = #{true} AND (" +
" #{Version.table_name}.sharing = 'system'" +
" OR (#{Project.table_name}.lft >= #{project.root.lft} AND #{Project.table_name}.rgt <= #{project.root.rgt} AND #{Version.table_name}.sharing = 'tree')" +
" OR (#{Project.table_name}.lft < #{project.lft} AND #{Project.table_name}.rgt > #{project.rgt} AND #{Version.table_name}.sharing IN ('hierarchy', 'descendants'))" +

@ -33,7 +33,7 @@ describe 'API v3 Work package form resource', type: :request do
include Rack::Test::Methods
include Capybara::RSpecMatchers
let(:project) { FactoryBot.create(:project, is_public: false) }
let(:project) { FactoryBot.create(:project, public: false) }
let(:work_package) { FactoryBot.create(:work_package, project: project) }
let(:authorized_user) { FactoryBot.create(:user, member_in_project: project) }
let(:unauthorized_user) { FactoryBot.create(:user) }

@ -35,14 +35,14 @@ describe 'backlogs onboarding tour', js: true do
FactoryBot.create :project,
name: 'Demo project',
identifier: 'demo-project',
is_public: true,
public: true,
enabled_module_names: %w[work_package_tracking wiki]
end
let(:project) do
FactoryBot.create :project,
name: 'Scrum project',
identifier: 'your-scrum-project',
is_public: true,
public: true,
enabled_module_names: %w[work_package_tracking wiki backlogs]
end
let(:sprint) { FactoryBot.create(:version, project: project, name: 'Sprint 1') }

@ -50,14 +50,14 @@ describe 'boards onboarding tour', js: true do
FactoryBot.create :project,
name: 'Demo project',
identifier: 'demo-project',
is_public: true,
public: true,
enabled_module_names: %w[work_package_tracking wiki board_view]
end
let(:scrum_project) do
FactoryBot.create :project,
name: 'Scrum project',
identifier: 'your-scrum-project',
is_public: true,
public: true,
enabled_module_names: %w[work_package_tracking wiki board_view]
end
let!(:wp_1) { FactoryBot.create(:work_package, project: demo_project) }

@ -21,8 +21,8 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
describe TimeEntry, type: :model do
include Cost::PluginSpecHelper
let(:project) { FactoryBot.create(:project_with_types, is_public: false) }
let(:project2) { FactoryBot.create(:project_with_types, is_public: false) }
let(:project) { FactoryBot.create(:project_with_types, public: false) }
let(:project2) { FactoryBot.create(:project_with_types, public: false) }
let(:work_package) {
FactoryBot.create(:work_package, project: project,
type: project.types.first,

@ -34,7 +34,7 @@ describe 'API v3 Budget resource' do
include API::V3::Utilities::PathHelper
let(:role) { FactoryBot.create(:role, permissions: [:view_work_packages]) }
let(:project) { FactoryBot.create(:project, is_public: false) }
let(:project) { FactoryBot.create(:project, public: false) }
let(:current_user) do
FactoryBot.create(:user,
member_in_project: project,

@ -34,7 +34,7 @@ describe 'API v3 Work package form resource', type: :request do
include Capybara::RSpecMatchers
include API::V3::Utilities::PathHelper
let(:project) { FactoryBot.create(:project, is_public: false) }
let(:project) { FactoryBot.create(:project, public: false) }
let(:work_package) { FactoryBot.create(:work_package, project: project) }
let(:role) { FactoryBot.create(:role, permissions: permissions) }
let(:authorized_user) do

@ -39,7 +39,7 @@ describe 'API v3 Work package resource', type: :request do
}
let(:project) do
FactoryBot.create(:project, identifier: 'test_project', is_public: false)
FactoryBot.create(:project, identifier: 'test_project', public: false)
end
let(:role) do
FactoryBot.create(:role, permissions: [:view_work_packages, :edit_work_packages, :view_cost_objects])

@ -14,8 +14,8 @@ require 'spec_helper'
describe User, 'allowed to' do
let(:user) { member.principal }
let(:anonymous) { FactoryBot.build(:anonymous) }
let(:project) { FactoryBot.build(:project, is_public: false) }
let(:project2) { FactoryBot.build(:project, is_public: false) }
let(:project) { FactoryBot.build(:project, public: false) }
let(:project2) { FactoryBot.build(:project, public: false) }
let(:role) { FactoryBot.build(:role) }
let(:role2) { FactoryBot.build(:role) }
let(:anonymous_role) { FactoryBot.build(:anonymous_role) }

@ -35,8 +35,8 @@ describe Projects::CreateContract do
Project.new(name: project_name,
identifier: project_identifier,
description: project_description,
status: project_status,
is_public: project_public,
active: project_active,
public: project_public,
parent: project_parent)
end
let(:permissions) { [:add_project] }

@ -41,7 +41,7 @@ shared_examples_for 'project contract' do
let(:project_name) { 'Project name' }
let(:project_identifier) { 'project_identifier' }
let(:project_description) { 'Project description' }
let(:project_status) { Project::STATUS_ACTIVE }
let(:project_active) { true }
let(:project_public) { true }
let(:project_parent) do
FactoryBot.build_stubbed(:project)
@ -132,10 +132,10 @@ shared_examples_for 'project contract' do
end
context 'if the status is nil' do
let(:project_status) { nil }
let(:project_active) { nil }
it 'is invalid' do
expect_valid(false, status: %i(blank))
expect_valid(false, active: %i(blank))
end
end
@ -159,13 +159,6 @@ shared_examples_for 'project contract' do
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 list custom field' do
let(:custom_field) { FactoryBot.build_stubbed(:list_project_custom_field) }

@ -34,8 +34,8 @@ describe Projects::UpdateContract do
let(:project) do
FactoryBot.build_stubbed(:project,
identifier: project_identifier,
status: project_status,
is_public: project_public).tap do |p|
active: project_active,
public: project_public).tap do |p|
# in order to actually have something changed
p.name = project_name
p.parent = project_parent

@ -31,7 +31,7 @@ require 'contracts/work_packages/shared_base_contract'
describe WorkPackages::UpdateContract do
let(:project) do
FactoryBot.build_stubbed(:project, is_public: false).tap do |p|
FactoryBot.build_stubbed(:project, public: false).tap do |p|
allow(Project)
.to receive(:find)
.with(p.id)

@ -32,15 +32,15 @@ describe CopyProjectsController, type: :controller do
let(:current_user) { FactoryBot.create(:admin) }
let(:redirect_path) { "/projects/#{project.id}/settings" }
let(:permission) { :copy_projects }
let(:project) { FactoryBot.create(:project_with_types, is_public: false) }
let(:copy_project_params) {
let(:project) { FactoryBot.create(:project_with_types, public: false) }
let(:copy_project_params) do
{
'description' => 'Some pretty description',
'enabled_module_names' => ['work_package_tracking', 'boards', ''],
'is_public' => project.is_public,
'public' => project.public,
'type_ids' => project.types.map(&:id)
}
}
end
before do
allow(User).to receive(:current).and_return current_user
@ -70,10 +70,10 @@ describe CopyProjectsController, type: :controller do
end
describe 'copy_from_settings without name and identifier' do
before {
before do
post 'copy',
params: { id: project.id, project: copy_project_params }
}
end
it { expect(response).to render_template('copy_from_settings') }
it 'should display error validation messages' do
@ -137,7 +137,7 @@ describe CopyProjectsController, type: :controller do
end
let(:permission) { [:copy_projects, :add_project] }
let(:project) { FactoryBot.create(:project, is_public: false) }
let(:project) { FactoryBot.create(:project, public: false) }
it_should_behave_like 'a controller action which needs project permissions'
end

@ -52,10 +52,10 @@ describe ProjectsController, type: :controller do
end
describe 'index.html' do
let(:project_a) { FactoryBot.create(:project, name: 'Project A', is_public: false, status: :active) }
let(:project_b) { FactoryBot.create(:project, name: 'Project B', is_public: false, status: :active) }
let(:project_c) { FactoryBot.create(:project, name: 'Project C', is_public: true, status: :active) }
let(:project_d) { FactoryBot.create(:project, name: 'Project D', is_public: true, status: :archived) }
let(:project_a) { FactoryBot.create(:project, name: 'Project A', public: false, active: true) }
let(:project_b) { FactoryBot.create(:project, name: 'Project B', public: false, active: true) }
let(:project_c) { FactoryBot.create(:project, name: 'Project C', public: true, active: true) }
let(:project_d) { FactoryBot.create(:project, name: 'Project D', public: true, active: false) }
let(:projects) { [project_a, project_b, project_c, project_d] }

@ -45,13 +45,13 @@ describe SysController, type: :controller do
let(:api_key) { '12345678' }
let(:public) { false }
let(:project) { FactoryBot.create(:project, is_public: public) }
let(:project) { FactoryBot.create(:project, public: public) }
before(:each) do
FactoryBot.create(:non_member, permissions: [:browse_repository])
DeletedUser.first # creating it first in order to avoid problems with should_receive
random_project = FactoryBot.create(:project, is_public: false)
random_project = FactoryBot.create(:project, public: false)
FactoryBot.create(:member,
user: valid_user,
roles: [browse_role],
@ -193,7 +193,7 @@ describe SysController, type: :controller do
let(:public) { true }
before(:each) do
random_project = FactoryBot.create(:project, is_public: false)
random_project = FactoryBot.create(:project, public: false)
FactoryBot.create(:member,
user: valid_user,
roles: [browse_role],
@ -391,7 +391,7 @@ describe SysController, type: :controller do
context 'for valid login and user is not member for project' do
before(:each) do
project = FactoryBot.create(:project, is_public: false)
project = FactoryBot.create(:project, public: false)
request.env['HTTP_AUTHORIZATION'] =
ActionController::HttpAuthentication::Basic.encode_credentials(
valid_user.login,
@ -414,7 +414,7 @@ describe SysController, type: :controller do
context 'for valid login and project is public' do
let(:public) { true }
before(:each) do
random_project = FactoryBot.create(:project, is_public: false)
random_project = FactoryBot.create(:project, public: false)
FactoryBot.create(:member,
user: valid_user,
roles: [browse_role],

@ -46,7 +46,7 @@ describe WorkPackages::MovesController, type: :controller do
let(:target_priority) { FactoryBot.create :priority }
let(:project) do
FactoryBot.create(:project,
is_public: false,
public: false,
types: [type, type_2])
end
let(:work_package) do
@ -118,7 +118,7 @@ describe WorkPackages::MovesController, type: :controller do
describe '#create' do
let!(:source_member) { FactoryBot.create(:member, user: current_user, project: project, roles: [role]) }
let!(:target_member) { FactoryBot.create(:member, user: current_user, project: target_project, roles: [role]) }
let(:target_project) { FactoryBot.create(:project, is_public: false) }
let(:target_project) { FactoryBot.create(:project, public: false) }
let(:work_package_2) {
FactoryBot.create(:work_package,
project_id: project.id,

@ -37,8 +37,8 @@ describe WorkPackagesController, type: :controller do
allow(UserMailer).to receive(:new).and_return(double('mailer').as_null_object)
end
let(:project) { FactoryBot.create(:project, identifier: 'test_project', is_public: false) }
let(:stub_project) { FactoryBot.build_stubbed(:project, identifier: 'test_project', is_public: false) }
let(:project) { FactoryBot.create(:project, identifier: 'test_project', public: false) }
let(:stub_project) { FactoryBot.build_stubbed(:project, identifier: 'test_project', public: false) }
let(:stub_work_package) { double('work_package', id: 1337, project: stub_project).as_null_object }
let(:current_user) { FactoryBot.create(:user) }

@ -36,10 +36,10 @@ FactoryBot.define do
sequence(:name) { |n| "My Project No. #{n}" }
sequence(:identifier) { |n| "myproject_no_#{n}" }
created_on { Time.now }
updated_on { Time.now }
created_at { Time.now }
updated_at { Time.now }
enabled_module_names { OpenProject::AccessControl.available_project_modules }
is_public { false }
public { false }
callback(:after_build) do |project, evaluator|
disabled_modules = Array(evaluator.disable_modules)
@ -51,7 +51,7 @@ FactoryBot.define do
end
factory :public_project do
is_public { true } # Remark: is_public defaults to true
public { true } # Remark: public defaults to true
end
factory :project_with_types do

@ -0,0 +1,35 @@
# 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.
#++
FactoryBot.define do
factory :project_status, class: Project::Status do
project
sequence(:explanation) { |n| "Status explanation #{n}" }
end
end

@ -30,8 +30,8 @@ require 'spec_helper'
describe 'onboarding tour for new users', js: true do
let(:user) { FactoryBot.create :admin }
let(:project) { FactoryBot.create :project, name: 'Demo project', identifier: 'demo-project', is_public: true, enabled_module_names: %w[work_package_tracking wiki] }
let(:scrum_project) {FactoryBot.create :project, name: 'Scrum project', identifier: 'your-scrum-project', is_public: true, enabled_module_names: %w[work_package_tracking] }
let(:project) { FactoryBot.create :project, name: 'Demo project', identifier: 'demo-project', public: true, enabled_module_names: %w[work_package_tracking wiki] }
let(:scrum_project) {FactoryBot.create :project, name: 'Scrum project', identifier: 'your-scrum-project', public: true, enabled_module_names: %w[work_package_tracking] }
let!(:wp_1) { FactoryBot.create(:work_package, project: project) }
let(:next_button) { find('.enjoyhint_next_btn') }

@ -49,7 +49,7 @@ describe 'Projects index page',
project = FactoryBot.create(:project,
name: 'Public project',
identifier: 'public-project',
is_public: true)
public: true)
project.custom_field_values = { invisible_custom_field.id => 'Secret CF' }
project.save
project
@ -629,7 +629,7 @@ describe 'Projects index page',
Role.non_member
# Remove public projects from the default list for these scenarios.
public_project.update_attribute :status, Project::STATUS_ARCHIVED
public_project.update(active: false)
project.update(created_on: 7.days.ago)

@ -36,7 +36,7 @@ require 'features/work_packages/work_packages_page'
describe 'date inplace editor',
with_settings: { date_format: '%Y-%m-%d' },
js: true, selenium: true do
let(:project) { FactoryBot.create :project_with_types, is_public: true }
let(:project) { FactoryBot.create :project_with_types, public: true }
let(:work_package) { FactoryBot.create :work_package, project: project, start_date: '2016-01-01' }
let(:user) { FactoryBot.create :admin }
let(:work_packages_page) { Pages::FullWorkPackage.new(work_package,project) }

@ -30,7 +30,7 @@ require 'spec_helper'
require 'features/work_packages/work_packages_page'
describe 'Work package details toolbar', js: true, selenium: true do
let(:project) { FactoryBot.create :project_with_types, is_public: true }
let(:project) { FactoryBot.create :project_with_types, public: true }
let!(:work_package) { FactoryBot.create :work_package, project: project }
let(:work_packages_page) { WorkPackagesPage.new(project) }

@ -6,7 +6,7 @@ require 'support/work_packages/work_package_field'
require 'features/work_packages/work_packages_page'
describe 'subject inplace editor', js: true, selenium: true do
let(:project) { FactoryBot.create :project_with_types, is_public: true }
let(:project) { FactoryBot.create :project_with_types, public: true }
let(:property_name) { :subject }
let(:property_title) { 'Subject' }
let(:work_package) { FactoryBot.create :work_package, project: project }

@ -5,7 +5,7 @@ require 'support/work_packages/work_package_field'
require 'features/work_packages/work_packages_page'
describe 'subject inplace editor', js: true, selenium: true do
let(:project) { FactoryBot.create :project_with_types, name: 'Root', is_public: true }
let(:project) { FactoryBot.create :project_with_types, name: 'Root', public: true }
let(:subproject1) { FactoryBot.create :project_with_types, name: 'Child', parent: project }
let(:subproject2) { FactoryBot.create :project_with_types, name: 'Aunt', parent: project }

@ -4,7 +4,7 @@ require 'features/work_packages/shared_contexts'
require 'features/work_packages/details/inplace_editor/shared_examples'
describe 'activity comments', js: true, with_mail: false do
let(:project) { FactoryBot.create :project, is_public: true }
let(:project) { FactoryBot.create :project, public: true }
let!(:work_package) do
FactoryBot.create(:work_package,
project: project,

@ -33,7 +33,7 @@ require 'support/work_packages/work_package_field'
require 'features/work_packages/work_packages_page'
describe 'description inplace editor', js: true, selenium: true do
let(:project) { FactoryBot.create :project_with_types, is_public: true }
let(:project) { FactoryBot.create :project_with_types, public: true }
let(:property_name) { :description }
let(:property_title) { 'Description' }
let(:description_text) { 'Ima description' }

@ -30,7 +30,7 @@ require 'spec_helper'
require 'features/work_packages/work_packages_page'
describe 'Query selection', type: :feature do
let(:project) { FactoryBot.create :project, identifier: 'test_project', is_public: false }
let(:project) { FactoryBot.create :project, identifier: 'test_project', public: false }
let(:role) { FactoryBot.create :role, permissions: [:view_work_packages] }
let(:current_user) do
FactoryBot.create :user, member_in_project: project,
@ -43,7 +43,7 @@ describe 'Query selection', type: :feature do
let(:query) do
FactoryBot.build(:query, project: project, is_public: true).tap do |query|
FactoryBot.build(:query, project: project, public: true).tap do |query|
query.filters.clear
query.add_filter('assigned_to_id', '=', ['me'])
query.add_filter('done_ratio', '>=', [10])
@ -91,7 +91,7 @@ describe 'Query selection', type: :feature do
context 'when the selected query is changed' do
let(:query2) do
FactoryBot.create(:query, project: project, is_public: true)
FactoryBot.create(:query, project: project, public: true)
end
before do

@ -20,7 +20,7 @@ describe 'inline create work package', js: true do
role: role
end
let!(:project) { FactoryBot.create(:project, is_public: true, types: types) }
let!(:project) { FactoryBot.create(:project, public: true, types: types) }
let!(:existing_wp) { FactoryBot.create(:work_package, project: project) }
let!(:priority) { FactoryBot.create :priority, is_default: true }
let(:filters) { ::Components::WorkPackages::Filters.new }

@ -19,8 +19,8 @@ describe 'Parallel work package creation spec', js: true do
role: role
end
let!(:project) { FactoryBot.create(:project, is_public: true) }
let!(:priority) { FactoryBot.create :priority, is_default: true }
let!(:project) { FactoryBot.create(:project, public: true) }
let!(:priority) { FactoryBot.create :priority, default: true }
let(:wp_table) { ::Pages::WorkPackagesTable.new(project) }
before do

@ -31,7 +31,7 @@ require 'spec_helper'
describe 'filter me value', js: true do
let(:status) { FactoryBot.create :default_status}
let!(:priority) { FactoryBot.create :default_priority }
let(:project) { FactoryBot.create :project, is_public: true }
let(:project) { FactoryBot.create :project, public: true }
let(:role) { FactoryBot.create :existing_role, permissions: [:view_work_packages] }
let(:admin) { FactoryBot.create :admin }
let(:user) { FactoryBot.create :user }

@ -29,7 +29,7 @@
require 'spec_helper'
describe 'Work package filtering by subject', js: true do
let(:project) { FactoryBot.create :project, is_public: true }
let(:project) { FactoryBot.create :project, public: true }
let(:role) { FactoryBot.create :existing_role, permissions: [:view_work_packages] }
let(:admin) { FactoryBot.create :admin }
let(:wp_table) { ::Pages::WorkPackagesTable.new(project) }

@ -30,7 +30,7 @@ require 'spec_helper'
require 'features/work_packages/work_packages_page'
describe 'Work package query summary item', type: :feature, js: true do
let(:project) { FactoryBot.create :project, identifier: 'test_project', is_public: false }
let(:project) { FactoryBot.create :project, identifier: 'test_project', public: false }
let(:role) { FactoryBot.create :role, permissions: [:view_work_packages] }
let(:work_package) { FactoryBot.create :work_package, project: project }
let(:wp_page) { ::Pages::WorkPackagesTable.new project }

@ -11,7 +11,7 @@ describe 'Activity tab', js: true, selenium: true do
note_journal.update(created_at: at, user: attributes[:user])
end
let(:project) { FactoryBot.create :project_with_types, is_public: true }
let(:project) { FactoryBot.create :project_with_types, public: true }
let!(:work_package) do
work_package = FactoryBot.create(:work_package,
project: project,

@ -11,7 +11,7 @@ describe 'Activity tab', js: true, selenium: true do
note_journal.update(created_at: at, user: attributes[:user])
end
let(:project) { FactoryBot.create :project_with_types, is_public: true }
let(:project) { FactoryBot.create :project_with_types, public: true }
let!(:work_package) do
work_package = FactoryBot.create(:work_package,
project: project,

@ -117,7 +117,7 @@ describe ::API::V3::Categories::CategoryRepresenter do
end
it 'changes when the category\'s project is updated' do
category.project.updated_on = Time.now + 20.seconds
category.project.updated_at = Time.now + 20.seconds
expect(representer.json_cache_key)
.not_to eql former_cache_key

@ -34,7 +34,8 @@ describe ::API::V3::Projects::ProjectRepresenter do
let(:project) do
FactoryBot.build_stubbed(:project,
parent: parent_project,
description: 'some description').tap do |p|
description: 'some description',
status: status).tap do |p|
allow(p)
.to receive(:available_custom_fields)
.and_return([int_custom_field, version_custom_field])
@ -49,6 +50,9 @@ describe ::API::V3::Projects::ProjectRepresenter do
.and_return(version_custom_value)
end
end
let(:status) do
FactoryBot.build_stubbed(:project_status)
end
let(:parent_project) { FactoryBot.build_stubbed(:project) }
let(:representer) { described_class.create(project, current_user: user) }
@ -103,25 +107,28 @@ describe ::API::V3::Projects::ProjectRepresenter do
let(:value) { project.name }
end
it_behaves_like 'property', :status do
let(:value) { project.status }
it_behaves_like 'property', :active do
let(:value) { project.active }
end
it_behaves_like 'property', :public do
let(:value) { project.is_public }
let(:value) { project.public }
end
it_behaves_like 'formattable property', :description do
let(:value) { project.description }
end
context 'status' do
end
it_behaves_like 'has UTC ISO 8601 date and time' do
let(:date) { project.created_on }
let(:date) { project.created_at }
let(:json_path) { 'createdAt' }
end
it_behaves_like 'has UTC ISO 8601 date and time' do
let(:date) { project.updated_on }
let(:date) { project.updated_at }
let(:json_path) { 'updatedAt' }
end
@ -423,7 +430,7 @@ describe ::API::V3::Projects::ProjectRepresenter do
end
it 'changes when the project is updated' do
project.updated_on = Time.now + 20.seconds
project.updated_at = Time.now + 20.seconds
expect(representer.json_cache_key)
.not_to eql former_cache_key

@ -47,7 +47,7 @@ describe ::API::V3::Projects::Schemas::ProjectSchemaRepresenter do
allow(contract)
.to receive(:writable?) do |attribute|
writable = %w(name identifier description is_public status parent)
writable = %w(name identifier description public status parent)
writable.include?(attribute.to_s)
end
@ -158,7 +158,7 @@ describe ::API::V3::Projects::Schemas::ProjectSchemaRepresenter do
it_behaves_like 'has basic schema properties' do
let(:type) { 'Boolean' }
let(:name) { I18n.t('attributes.is_public') }
let(:name) { I18n.t('attributes.public') }
let(:required) { true }
let(:writable) { true }
end

@ -262,7 +262,7 @@ describe ::API::V3::Versions::VersionRepresenter, 'rendering' do
end
it 'changes when the version\'s project is updated' do
version.project.updated_on = Time.now + 20.seconds
version.project.updated_at = Time.now + 20.seconds
expect(representer.json_cache_key)
.not_to eql former_cache_key

@ -934,7 +934,7 @@ describe ::API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter do
context 'if the project is updated' do
it_behaves_like 'changes' do
let(:change) { work_package.project.updated_on += 1.hour }
let(:change) { work_package.project.updated_at += 1.hour }
end
end

@ -752,8 +752,8 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do
end
describe 'linked relations' do
let(:project) { FactoryBot.create(:project, is_public: false) }
let(:forbidden_project) { FactoryBot.create(:project, is_public: false) }
let(:project) { FactoryBot.create(:project, public: false) }
let(:forbidden_project) { FactoryBot.create(:project, public: false) }
let(:user) { FactoryBot.create(:user, member_in_project: project) }
before do

@ -274,7 +274,7 @@ describe OpenProject::TextFormatting,
end
context 'Project links' do
let(:subproject) { FactoryBot.create :valid_project, parent: project, is_public: true }
let(:subproject) { FactoryBot.create :valid_project, parent: project, public: true }
let(:project_url) { project_overview_path(subproject) }
context 'Plain project link' do

@ -29,7 +29,7 @@
require 'spec_helper'
describe CopyProjectJob, type: :model do
let(:project) { FactoryBot.create(:project, is_public: false) }
let(:project) { FactoryBot.create(:project, public: false) }
let(:user) { FactoryBot.create(:user) }
let(:role) { FactoryBot.create(:role, permissions: [:copy_projects]) }
let(:params) { { name: 'Copy', identifier: 'copy' } }

@ -32,8 +32,8 @@ DEVELOPER_PERMISSIONS = [:view_messages, :delete_own_messages, :edit_own_message
describe MailHandler, type: :model do
let(:anno_user) { User.anonymous }
let(:project) { FactoryBot.create(:valid_project, identifier: 'onlinestore', name: 'OnlineStore', is_public: false) }
let(:public_project) { FactoryBot.create(:valid_project, identifier: 'onlinestore', name: 'OnlineStore', is_public: true) }
let(:project) { FactoryBot.create(:valid_project, identifier: 'onlinestore', name: 'OnlineStore', public: false) }
let(:public_project) { FactoryBot.create(:valid_project, identifier: 'onlinestore', name: 'OnlineStore', public: true) }
let(:priority_low) { FactoryBot.create(:priority_low, is_default: true) }
before do
@ -52,7 +52,7 @@ describe MailHandler, type: :model do
describe '#receive' do
it 'should add a work_package by create user on public project' do
Role.non_member.update_attribute :permissions, [:add_work_packages]
project.update_attribute :is_public, true
project.update_attribute :public, true
expect do
work_package = submit_email('ticket_by_unknown_user.eml', issue: { project: 'onlinestore' }, unknown_user: 'create')
work_package_created(work_package)
@ -196,7 +196,7 @@ describe MailHandler, type: :model do
it 'should add a work_package with category' do
allow(Setting).to receive(:default_language).and_return('en')
Role.non_member.update_attribute :permissions, [:add_work_packages]
project.update_attribute :is_public, true
project.update_attribute :public, true
work_package = submit_email 'ticket_with_category.eml',
issue: { project: 'onlinestore' },

@ -66,7 +66,7 @@ describe News, type: :model do
end
it 'only includes news elements from projects that are visible to the user' do
private_project = FactoryBot.create(:project, is_public: false)
private_project = FactoryBot.create(:project, public: false)
FactoryBot.create(:news, project: private_project)
latest_news = News.latest(user: User.anonymous)

@ -36,27 +36,27 @@ describe Project, 'allowed to', type: :model do
let(:private_project) do
FactoryBot.build(:project,
is_public: false,
status: project_status)
public: false,
active: project_status)
end
let(:public_project) do
FactoryBot.build(:project,
is_public: true,
status: project_status)
public: true,
active: project_status)
end
let(:project_status) { Project::STATUS_ACTIVE }
let(:project_status) { true }
let(:role) do
FactoryBot.build(:role,
permissions: permissions)
permissions: permissions)
end
let(:anonymous_role) do
FactoryBot.build(:anonymous_role,
permissions: anonymous_permissions)
permissions: anonymous_permissions)
end
let(:non_member_role) do
FactoryBot.build(:non_member,
permissions: non_member_permissions)
permissions: non_member_permissions)
end
let(:permissions) { [action] }
let(:anonymous_permissions) { [action] }
@ -66,9 +66,9 @@ describe Project, 'allowed to', type: :model do
let(:public_non_module_action) { :view_project }
let(:member) do
FactoryBot.build(:member,
user: user,
roles: [role],
project: project)
user: user,
roles: [role],
project: project)
end
shared_examples_for 'includes the project' do
@ -102,7 +102,7 @@ describe Project, 'allowed to', type: :model do
context 'w/ the user being member
w/ the role having the permission
w/o the project being active' do
let(:project_status) { Project::STATUS_ARCHIVED }
let(:project_status) { false }
before do
member.save!
@ -189,14 +189,14 @@ describe Project, 'allowed to', type: :model do
end
context 'w/o the project being active' do
let(:project_status) { Project::STATUS_ARCHIVED }
let(:project_status) { false }
it_behaves_like 'is empty'
end
context 'w/o the project being active
w/ the permission being public' do
let(:project_status) { Project::STATUS_ARCHIVED }
let(:project_status) { false }
it 'is empty' do
expect(Project.allowed_to(user, public_action)).to be_empty
@ -260,7 +260,7 @@ describe Project, 'allowed to', type: :model do
context 'w/ the anonymous role having the permission
w/o the project being active' do
let(:project_status) { Project::STATUS_ARCHIVED }
let(:project_status) { false }
it 'is empty' do
expect(Project.allowed_to(anonymous, action)).to be_empty
@ -334,14 +334,14 @@ describe Project, 'allowed to', type: :model do
context 'w/ the non member role having the permission
w/o the project being active' do
let(:project_status) { Project::STATUS_ARCHIVED }
let(:project_status) { false}
it_behaves_like 'is empty'
end
context 'w/ the permission being public and not module bound
w/o the project being active' do
let(:project_status) { Project::STATUS_ARCHIVED }
let(:project_status) { false}
it 'is empty' do
expect(Project.allowed_to(user, public_non_module_action)).to be_empty

@ -82,31 +82,31 @@ describe Project::Copy, type: :model, with_mail: false do
it { is_expected.to eq(project.work_package_custom_fields) }
end
describe '#is_public' do
describe '#public' do
describe '#non_public' do
let(:project) do
project = FactoryBot.create(:project_with_types)
project.is_public = false
project.public = false
project.save
project
end
subject { copy.is_public }
subject { copy.public }
it { expect(copy.is_public?).to eq(project.is_public?) }
it { expect(copy.public?).to eq(project.public?) }
end
describe '#public' do
let(:project) do
project = FactoryBot.create(:project_with_types)
project.is_public = true
project.public = true
project.save
project
end
subject { copy.is_public }
subject { copy.public }
it { expect(copy.is_public?).to eq(project.is_public?) }
it { expect(copy.public?).to eq(project.public?) }
end
end
end

@ -31,18 +31,18 @@ require 'spec_helper'
describe Project::Status, type: :model do
let(:project) { FactoryBot.create(:project) }
let(:description) { 'some description' }
let(:explanation) { 'some explanation' }
let(:code) { :on_track }
let(:instance) { described_class.new description: description, code: code, project: project }
let(:instance) { described_class.new explanation: explanation, code: code, project: project }
describe 'description' do
it 'stores a description' do
describe 'explanation' do
it 'stores an explanation' do
instance.save
instance.reload
expect(instance.description)
.to eql description
expect(instance.explanation)
.to eql explanation
end
end
@ -78,7 +78,7 @@ describe Project::Status, type: :model do
end
it 'cannot be one already having a status' do
described_class.create! description: 'some other description', code: :off_track, project: project
described_class.create! explanation: 'some other explanation', code: :off_track, project: project
expect(instance)
.to be_invalid

@ -32,26 +32,41 @@ require File.expand_path('../../support/shared/become_member', __FILE__)
describe Project, type: :model do
include BecomeMember
let(:project) { FactoryBot.create(:project, is_public: false) }
let(:active) { true }
let(:project) { FactoryBot.create(:project, active: active) }
let(:build_project) { FactoryBot.build_stubbed(:project, active: active) }
let(:admin) { FactoryBot.create(:admin) }
let(:user) { FactoryBot.create(:user) }
describe Project::STATUS_ACTIVE do
it 'equals 1' do
# spec that STATUS_ACTIVE has the correct value
expect(Project::STATUS_ACTIVE).to eq(1)
describe '#active?' do
context 'if active' do
it 'is true' do
expect(project).to be_active
end
end
context 'if not active' do
let(:active) { false }
it 'is false' do
expect(project).not_to be_active
end
end
end
describe '#active?' do
it 'is active when :status equals STATUS_ACTIVE' do
project = FactoryBot.build :project, status: :active
expect(project).to be_active
describe '#archived?' do
context 'if active' do
it 'is true' do
expect(project).not_to be_archived
end
end
it "is not active when :status doesn't equal STATUS_ACTIVE" do
project = FactoryBot.build :project, status: :archived
expect(project).not_to be_active
context 'if not active' do
let(:active) { false }
it 'is false' do
expect(project).to be_archived
end
end
end
@ -82,9 +97,9 @@ describe Project, type: :model do
let(:project) { FactoryBot.create(:project, parent: parent_project) }
let!(:subproject_member) do
FactoryBot.create(:member,
user: user,
project: project,
roles: [role_copy_projects])
user: user,
project: project,
roles: [role_copy_projects])
end
before do
login_as(user)
@ -93,9 +108,9 @@ describe Project, type: :model do
context 'with permission to add subprojects' do
let!(:member_add_subproject) do
FactoryBot.create(:member,
user: user,
project: parent_project,
roles: [role_add_subproject])
user: user,
project: parent_project,
roles: [role_add_subproject])
end
it 'should allow copy' do
@ -154,6 +169,28 @@ describe Project, type: :model do
end
end
describe 'status' do
let(:status) { FactoryBot.build_stubbed(:project_status) }
let(:stubbed_project) do
FactoryBot.build_stubbed(:project,
status: status)
end
it 'has a status' do
expect(stubbed_project.status)
.to eql status
end
it 'is destroyed along with the project' do
status = project.create_status description: 'some description'
project.destroy!
expect(Project::Status.where(id: status.id))
.not_to exist
end
end
describe '#types_used_by_work_packages' do
let(:project) { FactoryBot.create(:project_with_types) }
let(:type) { project.types.first }
@ -204,7 +241,7 @@ describe Project, type: :model do
it 'should only check active projects' do
subproject = FactoryBot.create(:project, parent: project)
FactoryBot.create(:version, project: subproject)
subproject.archived!
subproject.update(active: false)
project.reload

@ -30,19 +30,9 @@
require 'spec_helper'
describe Queries::Projects::Filters::ActiveOrArchivedFilter, type: :model do
it_behaves_like 'list_all query filter' do
let(:values) { ['A name'] }
describe Queries::Projects::Filters::ActiveFilter, type: :model do
it_behaves_like 'boolean query filter' do
let(:model) { Project }
let(:class_key) { :status }
let(:type) { :list_all }
let(:attribute) { :status }
let(:valid_values) { [Project::STATUS_ACTIVE.to_s, Project::STATUS_ARCHIVED.to_s] }
describe '#allowed_values' do
it 'to be either active or archived' do
expect(instance.allowed_values.map(&:second)).to eq valid_values
end
end
let(:attribute) { :active }
end
end

@ -65,7 +65,7 @@ describe SystemUser, type: :model do
end
describe '#run_given' do
let(:project) { FactoryBot.create(:project_with_types, is_public: false) }
let(:project) { FactoryBot.create(:project_with_types, public: false) }
let(:user) { FactoryBot.build(:user) }
let(:role) { FactoryBot.create(:role, permissions: [:view_work_packages]) }
let(:member) {

@ -31,8 +31,8 @@ require 'spec_helper'
describe User, 'allowed scope' do
let(:user) { member.principal }
let(:anonymous) { FactoryBot.build(:anonymous) }
let(:project) { FactoryBot.build(:project, is_public: false) }
let(:project2) { FactoryBot.build(:project, is_public: false) }
let(:project) { FactoryBot.build(:project, public: false) }
let(:project2) { FactoryBot.build(:project, public: false) }
let(:role) { FactoryBot.build(:role) }
let(:role2) { FactoryBot.build(:role) }
let(:anonymous_role) { FactoryBot.build(:anonymous_role) }
@ -132,8 +132,7 @@ describe User, 'allowed scope' do
before do
role.add_permission! action
project.is_public = true
project.save!
project.update(public: true)
member.project = project2
member.save!
@ -149,7 +148,7 @@ describe User, 'allowed scope' do
w/o the user being member in the project
w/ the non member role having the necessary permission' do
before do
project.is_public = true
project.public = true
non_member = Role.non_member
non_member.add_permission! action
@ -167,7 +166,7 @@ describe User, 'allowed scope' do
w/o the user being member in the project
w/ the anonymous role having the necessary permission' do
before do
project.is_public = true
project.public = true
anonymous_role = Role.anonymous
anonymous_role.add_permission! action
@ -185,7 +184,7 @@ describe User, 'allowed scope' do
w/o the user being member in the project
w/ the non member role having another permission' do
before do
project.is_public = true
project.public = true
non_member = Role.non_member
non_member.add_permission! other_action
@ -220,7 +219,7 @@ describe User, 'allowed scope' do
w/o the role having the necessary permission
w/ the non member role having the permission' do
before do
project.is_public = true
project.public = true
project.save
role.add_permission! other_action
@ -255,7 +254,7 @@ describe User, 'allowed scope' do
w/o the role having the permission
w/ the permission being public' do
before do
project.is_public = true
project.public = true
project.save
end
@ -315,7 +314,7 @@ describe User, 'allowed scope' do
role.add_permission! action
member.save!
project.update_attribute(:status, Project::STATUS_ARCHIVED)
project.update(active: false)
end
it 'should be empty' do
@ -369,7 +368,7 @@ describe User, 'allowed scope' do
w/ the user being member in the project
w/ the role having the necessary permission' do
before do
project.update_attribute(:is_public, true)
project.update_attribute(:public, true)
role.add_permission! action
@ -386,7 +385,7 @@ describe User, 'allowed scope' do
w/o the user being member in the project
w/ the role having the necessary permission' do
before do
project.update_attribute(:is_public, true)
project.update_attribute(:public, true)
role.add_permission! action
end

@ -31,8 +31,8 @@ require 'spec_helper'
describe User, 'allowed_to?' do
let(:user) { FactoryBot.build(:user) }
let(:anonymous) { FactoryBot.build(:anonymous) }
let(:project) { FactoryBot.build(:project, is_public: false) }
let(:project2) { FactoryBot.build(:project, is_public: false) }
let(:project) { FactoryBot.build(:project, public: false) }
let(:project2) { FactoryBot.build(:project, public: false) }
let(:role) { FactoryBot.build(:role) }
let(:role2) { FactoryBot.build(:role) }
let(:anonymous_role) { FactoryBot.build(:anonymous_role) }
@ -59,7 +59,7 @@ describe User, 'allowed_to?' do
context 'w/ the user being admin' do
before do
user.update_attribute(:admin, true)
user.update(admin: true)
project.save
@ -74,8 +74,8 @@ describe User, 'allowed_to?' do
context 'w/ the user being admin
w/ the project being archived' do
before do
user.update_attribute(:admin, true)
project.update_attribute(:status, Project::STATUS_ARCHIVED)
user.update(admin: true)
project.update(active: false)
final_setup_step
end
@ -88,7 +88,7 @@ describe User, 'allowed_to?' do
context 'w/ the user being admin
w/ the project module the permission belongs to being inactive' do
before do
user.update_attribute(:admin, true)
user.update(admin: true)
project.enabled_module_names = []
final_setup_step
@ -170,7 +170,7 @@ describe User, 'allowed_to?' do
w/o the role having the necessary permission
w/ non members having the necessary permission' do
before do
project.is_public = false
project.public = false
non_member = Role.non_member
non_member.add_permission! permission
@ -191,7 +191,7 @@ describe User, 'allowed_to?' do
let(:permission) { :view_project }
before do
project.is_public = false
project.public = false
member.save!
@ -207,7 +207,7 @@ describe User, 'allowed_to?' do
w/ non member being allowed the action
w/ the project being private' do
before do
project.is_public = false
project.public = false
project.save!
non_member = Role.non_member
@ -226,7 +226,7 @@ describe User, 'allowed_to?' do
w/ the project being public
w/ non members being allowed the action' do
before do
project.is_public = true
project.public = true
project.save!
non_member = Role.non_member
@ -246,7 +246,7 @@ describe User, 'allowed_to?' do
w/ non members being allowed the action
w/o the role being allowed the action' do
before do
project.is_public = true
project.public = true
project.save!
non_member = Role.non_member
@ -266,7 +266,7 @@ describe User, 'allowed_to?' do
w/ the project being public
w/ anonymous being allowed the action' do
before do
project.is_public = true
project.public = true
project.save!
anonymous_role.add_permission! permission
@ -285,7 +285,7 @@ describe User, 'allowed_to?' do
let(:permission) { :view_project }
before do
project.is_public = true
project.public = true
project.save!
anonymous_role.save!
@ -305,7 +305,7 @@ describe User, 'allowed_to?' do
let(:permission) { { controller: '/project_settings', action: 'show' } }
before do
project.is_public = true
project.public = true
project.save!
anonymous_role.add_permission! :manage_categories
@ -323,7 +323,7 @@ describe User, 'allowed_to?' do
w/ the project being public
w/ anonymous being not allowed the action' do
before do
project.is_public = true
project.public = true
project.save!
final_setup_step
@ -374,8 +374,8 @@ describe User, 'allowed_to?' do
non_member = Role.non_member
non_member.add_permission! permission
project.update_attribute(:is_public, true)
project2.update_attribute(:is_public, true)
project.update(public: true)
project2.update(public: true)
final_setup_step
end
@ -392,8 +392,8 @@ describe User, 'allowed_to?' do
non_member = Role.non_member
non_member.add_permission! permission
project.update_attribute(:is_public, true)
project2.update_attribute(:is_public, false)
project.update(public: true)
project2.update(public: false)
final_setup_step
end

@ -34,7 +34,7 @@ describe WorkPackage, 'acts_as_searchable', type: :model do
let(:wp_subject) { 'the quick brown fox jumps over the lazy dog' }
let(:project) {
FactoryBot.create(:project,
is_public: false)
public: false)
}
let(:work_package) {
FactoryBot.create(:work_package,

@ -32,9 +32,9 @@ describe 'WorkPackage-Visibility', type: :model do
let(:admin) { FactoryBot.create(:admin) }
let(:anonymous) { FactoryBot.create(:anonymous) }
let(:user) { FactoryBot.create(:user) }
let(:public_project) { FactoryBot.create(:project, is_public: true) }
let(:private_project) { FactoryBot.create(:project, is_public: false) }
let(:other_project) { FactoryBot.create(:project, is_public: true) }
let(:public_project) { FactoryBot.create(:project, public: true) }
let(:private_project) { FactoryBot.create(:project, public: false) }
let(:other_project) { FactoryBot.create(:project, public: true) }
let(:view_work_packages) { FactoryBot.create(:role, permissions: [:view_work_packages]) }
let(:view_work_packages_role2) { FactoryBot.create(:role, permissions: [:view_work_packages]) }

@ -562,7 +562,7 @@ describe WorkPackage, type: :model do
describe '#on_active_project' do
let(:project_archived) {
FactoryBot.create(:project,
status: Project::STATUS_ARCHIVED)
active: false)
}
let!(:work_package) { FactoryBot.create(:work_package) }
let(:work_package_in_archived_project) {
@ -587,7 +587,7 @@ describe WorkPackage, type: :model do
let(:user) { FactoryBot.create(:user) }
let(:project_archived) {
FactoryBot.create(:project,
status: Project::STATUS_ARCHIVED)
active: false)
}
let!(:work_package) { FactoryBot.create(:work_package, author: user) }
let(:work_package_in_archived_project) {

@ -36,7 +36,7 @@ describe 'API v3 Activity resource', type: :request do
let(:current_user) {
FactoryBot.create(:user, member_in_project: project, member_through_role: role)
}
let(:project) { FactoryBot.create(:project, is_public: false) }
let(:project) { FactoryBot.create(:project, public: false) }
let(:work_package) { FactoryBot.create(:work_package, author: current_user, project: project) }
let(:role) { FactoryBot.create(:role, permissions: permissions) }
let(:permissions) { [:view_work_packages, :edit_work_package_notes] }
@ -75,7 +75,7 @@ describe 'API v3 Activity resource', type: :request do
end
context 'requesting activity without sufficient permissions' do
let(:another_project) { FactoryBot.create(:project, is_public: false) }
let(:another_project) { FactoryBot.create(:project, public: false) }
let(:another_work_package) { FactoryBot.create(:work_package, project: another_project) }
let(:another_activity) { FactoryBot.create(:work_package_journal, journable: another_work_package) }
let(:get_path) { api_v3_paths.activity another_activity.id }
@ -85,7 +85,7 @@ describe 'API v3 Activity resource', type: :request do
end
it_behaves_like 'handling anonymous user' do
let(:project) { FactoryBot.create(:project, is_public: true) }
let(:project) { FactoryBot.create(:project, public: true) }
let(:path) { api_v3_paths.activity activity.id }
end
end

@ -44,7 +44,7 @@ shared_examples 'an APIv3 attachment resource', type: :request, content_type: :j
current_user
end
let(:project) { FactoryBot.create(:project, is_public: false) }
let(:project) { FactoryBot.create(:project, public: false) }
let(:role) { FactoryBot.create(:role, permissions: permissions) }
let(:attachment) { FactoryBot.create(:attachment, container: container, author: author) }

@ -34,8 +34,8 @@ describe 'API v3 Category resource' do
include API::V3::Utilities::PathHelper
let(:role) { FactoryBot.create(:role, permissions: []) }
let(:private_project) { FactoryBot.create(:project, is_public: false) }
let(:public_project) { FactoryBot.create(:project, is_public: true) }
let(:private_project) { FactoryBot.create(:project, public: false) }
let(:public_project) { FactoryBot.create(:project, public: true) }
let(:anonymous_user) { FactoryBot.create(:user) }
let(:privileged_user) do
FactoryBot.create(:user,

@ -34,7 +34,7 @@ describe 'API v3 Priority resource' do
include API::V3::Utilities::PathHelper
let(:role) { FactoryBot.create(:role, permissions: [:view_work_packages]) }
let(:project) { FactoryBot.create(:project, is_public: false) }
let(:project) { FactoryBot.create(:project, public: false) }
let(:current_user) do
FactoryBot.create(:user,
member_in_project: project,

@ -37,10 +37,10 @@ describe 'API v3 Project resource', type: :request, content_type: :json do
FactoryBot.create(:user, member_in_project: project, member_through_role: role)
end
let(:project) do
FactoryBot.create(:project, is_public: false)
FactoryBot.create(:project, public: false)
end
let(:other_project) do
FactoryBot.create(:project, is_public: false)
FactoryBot.create(:project, public: false)
end
let(:role) { FactoryBot.create(:role) }
let(:custom_field) do
@ -59,7 +59,7 @@ describe 'API v3 Project resource', type: :request, content_type: :json do
describe '#get /projects/:id' do
let(:get_path) { api_v3_paths.project project.id }
let!(:parent_project) do
FactoryBot.create(:project, is_public: false).tap do |p|
FactoryBot.create(:project, public: false).tap do |p|
project.parent = p
project.save!
end
@ -172,7 +172,7 @@ describe 'API v3 Project resource', type: :request, content_type: :json do
let(:projects) { [project, other_project, parent_project] }
let(:parent_project) do
parent_project = FactoryBot.create(:project, is_public: false)
parent_project = FactoryBot.create(:project, public: false)
project.update_attribute(:parent_id, parent_project.id)

@ -63,7 +63,7 @@ describe 'API v3 Project available parents resource', type: :request, content_ty
end
end
let!(:project) do
FactoryBot.create(:project, is_public: false)
FactoryBot.create(:project, public: false)
end
let(:permissions) { %i[edit_project add_subprojects] }
let(:global_permissions) { %i[add_project] }

@ -43,8 +43,8 @@ describe "API v3 project's versions resource" do
user
end
let(:role) { FactoryBot.create(:role, permissions: [:view_work_packages]) }
let(:project) { FactoryBot.create(:project, is_public: false) }
let(:other_project) { FactoryBot.create(:project, is_public: false) }
let(:project) { FactoryBot.create(:project, public: false) }
let(:other_project) { FactoryBot.create(:project, public: false) }
let(:versions) { FactoryBot.create_list(:version, 4, project: project) }
let(:other_versions) { FactoryBot.create_list(:version, 2) }

@ -33,7 +33,7 @@ describe 'API v3 Query resource', type: :request do
include Rack::Test::Methods
include API::V3::Utilities::PathHelper
let(:project) { FactoryBot.create(:project, identifier: 'test_project', is_public: false) }
let(:project) { FactoryBot.create(:project, identifier: 'test_project', public: false) }
let(:current_user) do
FactoryBot.create(:user, member_in_project: project, member_through_role: role)
end

@ -33,7 +33,7 @@ describe 'API v3 Query resource', type: :request, content_type: :json do
include Rack::Test::Methods
include API::V3::Utilities::PathHelper
let(:project) { FactoryBot.create(:project, identifier: 'test_project', is_public: false) }
let(:project) { FactoryBot.create(:project, identifier: 'test_project', public: false) }
let(:other_project) { FactoryBot.create(:project) }
let(:current_user) do
FactoryBot.create(:user, member_in_project: project, member_through_role: role)

@ -33,7 +33,7 @@ describe 'API v3 Render resource', type: :request do
include Rack::Test::Methods
include API::V3::Utilities::PathHelper
let(:project) { FactoryBot.create(:project, is_public: false) }
let(:project) { FactoryBot.create(:project, public: false) }
let(:work_package) { FactoryBot.create(:work_package, project: project) }
let(:user) { FactoryBot.create(:user, member_in_project: project) }
let(:content_type) { 'text/plain, charset=UTF-8' }

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save