Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Add Team Planner Global Create Form

Aaron Contrerase36b0db7620e
diff --git a/modules/team_planner/app/contracts/team_planner/views/global_create_contract.rb b/modules/team_planner/app/contracts/team_planner/views/global_create_contract.rb
new file mode 100644
index 00000000000..8e9c08ea20c
--- /dev/null
+++ b/modules/team_planner/app/contracts/team_planner/views/global_create_contract.rb
@@ -0,0 +1,43 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+module TeamPlanner
+ module Views
+ class GlobalCreateContract < ::Queries::CreateContract
+ validate :validate_project_present
+
+ private
+
+ def validate_project_present
+ errors.add :project_id, :blank if model.project_id.blank?
+ end
+ end
+ end
+end
diff --git a/modules/team_planner/app/controllers/team_planner/team_planner_controller.rb b/modules/team_planner/app/controllers/team_planner/team_planner_controller.rb
index 17fec45a7fc..9d7ab3529d2 100644
--- a/modules/team_planner/app/controllers/team_planner/team_planner_controller.rb
+++ b/modules/team_planner/app/controllers/team_planner/team_planner_controller.rb
@@ -3,8 +3,9 @@ module ::TeamPlanner
include EnterpriseTrialHelper
include Layout
before_action :find_optional_project
- before_action :authorize, except: %i[overview new upsale]
- before_action :authorize_global, only: %i[overview new]
+ before_action :build_plan_view, only: %i[new]
+ before_action :authorize, except: %i[overview new create upsale]
+ before_action :authorize_global, only: %i[overview new create]
before_action :require_ee_token, except: %i[upsale]
before_action :find_plan_view, only: %i[destroy]
@@ -21,6 +22,21 @@ module ::TeamPlanner
def new; end
+ def create
+ service_result = create_service_class.new(user: User.current)
+ .call(plan_view_params)
+
+ @view = service_result.result
+
+ if service_result.success?
+ flash[:notice] = I18n.t(:notice_successful_create)
+ redirect_to project_team_planner_path(@project, @view.query)
+ else
+ @errors = service_result.errors
+ render action: :new
+ end
+ end
+
def show
render layout: 'angular/angular'
end
@@ -53,6 +69,18 @@ module ::TeamPlanner
private
+ def create_service_class
+ TeamPlanner::Views::GlobalCreateService
+ end
+
+ def plan_view_params
+ params.require(:query).permit(:name, :public, :starred).merge(project_id: @project&.id)
+ end
+
+ def build_plan_view
+ @view = Query.new
+ end
+
def find_plan_view
@view = Query
.visible(current_user)
diff --git a/modules/team_planner/app/services/team_planner/views/global_create_service.rb b/modules/team_planner/app/services/team_planner/views/global_create_service.rb
new file mode 100644
index 00000000000..cba31a3fa28
--- /dev/null
+++ b/modules/team_planner/app/services/team_planner/views/global_create_service.rb
@@ -0,0 +1,58 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+module TeamPlanner
+ module Views
+ class GlobalCreateService < ::Queries::CreateService
+ def initialize(user:,
+ contract_class: TeamPlanner::Views::GlobalCreateContract,
+ contract_options: nil)
+ super
+ end
+
+ def after_perform(call)
+ create_view_from_query(call)
+ end
+
+ def instance_class
+ ::Query
+ end
+
+ private
+
+ def create_view_from_query(call)
+ view_params = { query_id: call.result.id, type: 'team_planner' }
+
+ ::Views::CreateService.new(user: @user)
+ .call(view_params)
+ end
+ end
+ end
+end
diff --git a/modules/team_planner/app/services/team_planner/views/set_attributes_service.rb b/modules/team_planner/app/services/team_planner/views/set_attributes_service.rb
new file mode 100644
index 00000000000..4ee285a0aa7
--- /dev/null
+++ b/modules/team_planner/app/services/team_planner/views/set_attributes_service.rb
@@ -0,0 +1,36 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+module TeamPlanner
+ module Views
+ class SetAttributesService < ::Queries::SetAttributesService
+ end
+ end
+end
diff --git a/modules/team_planner/app/views/team_planner/team_planner/_form.html.erb b/modules/team_planner/app/views/team_planner/team_planner/_form.html.erb
new file mode 100644
index 00000000000..4f9d23ee791
--- /dev/null
+++ b/modules/team_planner/app/views/team_planner/team_planner/_form.html.erb
@@ -0,0 +1,91 @@
+<%#-- copyright
+OpenProject is an open source project management software.
+Copyright (C) 2012-2023 the OpenProject GmbH
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License version 3.
+
+OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+Copyright (C) 2006-2013 Jean-Philippe Lang
+Copyright (C) 2010-2013 the ChiliProject Team
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+See COPYRIGHT and LICENSE files for more details.
+
+++#%>
+
+<%= error_messages_for_contract @view, @errors %>
+
+<section class="form--section">
+
+ <div class="form--field -required">
+ <%= f.text_field :name,
+ label: Meeting.human_attribute_name(:title),
+ required: true,
+ size: 60,
+ container_class: '-wide' %>
+ </div>
+
+ <div class="form--field -required">
+ <label class="form--label" for="project_id"><%= Query.human_attribute_name(:project) %>:</label>
+ <div class="form--field-container">
+ <%= angular_component_tag 'op-project-autocompleter',
+ inputs: {
+ apiFilters: [['user_action', '=', ['team_planners/create']]],
+ name: 'project_id',
+ value: @project,
+ appendTo: 'body',
+ },
+ id: 'project_id',
+ class: 'form--select-container -wide remote-field--input',
+ data: {
+ 'qa-selector': 'project_id'
+ }
+ %>
+ </div>
+ <div class="form--field-instructions">
+ <p><%= t 'team_planner.help_text.project' %></p>
+ </div>
+ </div>
+
+ <div class="form--field">
+ <%= styled_label_tag 'query[public]',
+ Query.human_attribute_name(:public) %>
+ <div class="form--field-container">
+ <%= styled_check_box_tag 'query[public]',
+ '1',
+ @view.public
+ %>
+ </div>
+ <div class="form--field-instructions">
+ <p><%= t 'team_planner.help_text.public' %></p>
+ </div>
+ </div>
+
+ <div class="form--field">
+ <%= styled_label_tag 'query[starred]',
+ t('team_planner.label_favoured') %>
+ <div class="form--field-container">
+ <%= styled_check_box_tag 'query[starred]',
+ '1',
+ @view.starred
+ %>
+ </div>
+ <div class="form--field-instructions">
+ <p><%= t 'team_planner.help_text.favoured' %></p>
+ </div>
+ </div>
+</section>
diff --git a/modules/team_planner/app/views/team_planner/team_planner/new.html.erb b/modules/team_planner/app/views/team_planner/team_planner/new.html.erb
new file mode 100644
index 00000000000..6cf3efe54de
--- /dev/null
+++ b/modules/team_planner/app/views/team_planner/team_planner/new.html.erb
@@ -0,0 +1,37 @@
+<%#-- copyright
+OpenProject is an open source project management software.
+Copyright (C) 2012-2023 the OpenProject GmbH
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License version 3.
+
+OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+Copyright (C) 2006-2013 Jean-Philippe Lang
+Copyright (C) 2010-2013 the ChiliProject Team
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+See COPYRIGHT and LICENSE files for more details.
+
+++#%>
+
+<% html_title t('team_planner.label_new_team_planner') %>
+<%= toolbar title: t('team_planner.label_new_team_planner') %>
+<%= labelled_tabular_form_for @view, url: { controller: '/team_planner/team_planner', action: 'create' }, :html => {:id => 'team-planner-form'} do |f| -%>
+ <%= render :partial => 'form', :locals => {:f => f} %>
+ <%= styled_button_tag t(:button_create), class: '-highlight' %>
+ <%= link_to t(:button_cancel), { controller: 'team_planner/team_planner', action: 'overview' },
+ class: 'button' %>
+<% end %>
diff --git a/modules/team_planner/config/locales/en.yml b/modules/team_planner/config/locales/en.yml
index b749df5c23c..8d7becc5bae 100644
--- a/modules/team_planner/config/locales/en.yml
+++ b/modules/team_planner/config/locales/en.yml
@@ -6,9 +6,15 @@ en:
team_planner:
label_team_planner: "Team planner"
+ label_new_team_planner: "New team planner"
label_create_new_team_planner: "Create new team planner"
label_team_planner_plural: "Team planners"
label_assignees: "Assignees"
+ label_favoured: "Favoured"
+ help_text:
+ project: Team planners are always attached to a project. After creating a team planner you can add work packages from other projects to it.
+ public: Publish this view, allowing other users to access your view. Users with the 'Manage public views' permission can modify or remove public query. This does not affect the visibility of work package results in that view and depending on their permissions, users may see different results.
+ favoured: Mark this view as favourite and add to the saved views sidebar on the left.
upsale:
title: "Team planner"
description: "Get a complete overview of your team’s planning with Team Planner. Stretch, shorten and drag-and-drop work packages to modify dates, move them or change assignees."
diff --git a/modules/team_planner/config/routes.rb b/modules/team_planner/config/routes.rb
index 4c2ee8e52d7..99e645405c9 100644
--- a/modules/team_planner/config/routes.rb
+++ b/modules/team_planner/config/routes.rb
@@ -1,7 +1,7 @@
OpenProject::Application.routes.draw do
resources :team_planners,
controller: 'team_planner/team_planner',
- only: %i[] do
+ only: %i[create] do
collection do
get '/', to: 'team_planner/team_planner#overview'
get '/new', to: 'team_planner/team_planner#new'
diff --git a/modules/team_planner/lib/open_project/team_planner/engine.rb b/modules/team_planner/lib/open_project/team_planner/engine.rb
index ed233a56903..9919aa5d97a 100644
--- a/modules/team_planner/lib/open_project/team_planner/engine.rb
+++ b/modules/team_planner/lib/open_project/team_planner/engine.rb
@@ -33,7 +33,7 @@ module OpenProject::TeamPlanner
dependencies: %i[view_work_packages],
contract_actions: { team_planner: %i[read] }
permission :manage_team_planner,
- { 'team_planner/team_planner': %i[index show new destroy upsale] },
+ { 'team_planner/team_planner': %i[index show new create destroy upsale] },
dependencies: %i[view_team_planner add_work_packages edit_work_packages save_queries manage_public_queries],
contract_actions: { team_planner: %i[create update destroy] }
end
diff --git a/modules/team_planner/spec/contracts/views/team_planner_global_create_contract_spec.rb b/modules/team_planner/spec/contracts/views/team_planner_global_create_contract_spec.rb
new file mode 100644
index 00000000000..f366a9d5399
--- /dev/null
+++ b/modules/team_planner/spec/contracts/views/team_planner_global_create_contract_spec.rb
@@ -0,0 +1,46 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+require 'spec_helper'
+require 'contracts/shared/model_contract_shared_context'
+require 'contracts/queries/shared_contract_examples'
+
+RSpec.describe TeamPlanner::Views::GlobalCreateContract do
+ include_context 'ModelContract shared context'
+ include_context 'with queries contract'
+
+ describe 'validation' do
+ context 'if the project_id is nil' do
+ let(:project) { nil }
+
+ it_behaves_like 'contract is invalid', project_id: :blank
+ end
+ end
+end
diff --git a/modules/team_planner/spec/features/team_planner_global_create_spec.rb b/modules/team_planner/spec/features/team_planner_global_create_spec.rb
new file mode 100644
index 00000000000..a28aee7a241
--- /dev/null
+++ b/modules/team_planner/spec/features/team_planner_global_create_spec.rb
@@ -0,0 +1,129 @@
+# frozen_string_literal: true
+
+# -- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2023 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+# ++
+
+require 'spec_helper'
+require_relative 'shared_context'
+
+RSpec.describe 'Team Planner',
+ 'Creating a view from a Global Context',
+ :js,
+ :with_cuprite,
+ with_ee: %i[team_planner_view],
+ with_flag: { more_global_index_pages_active: true } do
+ include_context 'with team planner full access'
+
+ context 'within the overview page' do
+ before do
+ visit team_planners_path
+ end
+
+ context 'when clicking on the create button' do
+ before do
+ team_planner.click_on_create_button
+ end
+
+ it 'navigates to the global create form' do
+ expect(page).to have_current_path(new_team_planners_path)
+ expect(page).to have_content I18n.t('team_planner.label_new_team_planner')
+ end
+ end
+ end
+
+ context 'within the global create page' do
+ before do
+ visit new_team_planners_path
+ end
+
+ context 'with all fields set' do
+ before do
+ wait_for_reload # Halt until the project autocompleter is ready
+
+ team_planner.set_title('Gotham Renewal')
+ team_planner.set_project(project)
+ team_planner.set_public
+ team_planner.set_favoured
+ team_planner.click_on_submit
+
+ wait_for_reload
+ end
+
+ it 'creates a view and redirects me to it' do
+ expect(page).to have_text(I18n.t(:notice_successful_create))
+ expect(page).to have_current_path(project_team_planner_path(project, Query.last), ignore_query: true)
+ expect(page).to have_text('Gotham Renewal')
+ end
+ end
+
+ context 'when missing a required field' do
+ describe 'title' do
+ before do
+ wait_for_reload # Halt until the project autocompleter is ready
+
+ team_planner.set_project(project)
+ team_planner.click_on_submit
+ end
+
+ it 'renders a required attribute validation error' do
+ expect(Query.all).to be_empty
+
+ # Required HTML attribute just warns
+ expect(page).to have_current_path(new_team_planners_path)
+ end
+ end
+
+ describe 'project_id' do
+ before do
+ team_planner.set_title('Gotham Renewal')
+ team_planner.click_on_submit
+
+ wait_for_reload
+ end
+
+ it 'renders a required attribute validation error' do
+ expect(Query.all).to be_empty
+
+ expect(page).to have_text("Project can't be blank.")
+ end
+ end
+ end
+
+ describe 'cancel button' do
+ context "when it's clicked" do
+ before do
+ team_planner.click_on_cancel_button
+ end
+
+ it 'navigates back to the overview page' do
+ expect(page).to have_current_path(team_planners_path)
+ end
+ end
+ end
+ end
+end
diff --git a/modules/team_planner/spec/routing/team_planner_routing_spec.rb b/modules/team_planner/spec/routing/team_planner_routing_spec.rb
index 8f0283994c5..cc987f1ba6e 100644
--- a/modules/team_planner/spec/routing/team_planner_routing_spec.rb
+++ b/modules/team_planner/spec/routing/team_planner_routing_spec.rb
@@ -75,6 +75,12 @@ RSpec.describe 'Team planner routing' do
end
end
+ it 'routes to team_planner#create' do
+ expect(subject)
+ .to route(:post, '/team_planners')
+ .to(controller: 'team_planner/team_planner', action: :create)
+ end
+
it 'routes to team_planner#show with state' do
expect(subject)
.to route(:get, '/projects/foobar/team_planners/1234/details/555')
diff --git a/modules/team_planner/spec/services/team_planner/views/global_create_service_spec.rb b/modules/team_planner/spec/services/team_planner/views/global_create_service_spec.rb
new file mode 100644
index 00000000000..838d0ff18ba
--- /dev/null
+++ b/modules/team_planner/spec/services/team_planner/views/global_create_service_spec.rb
@@ -0,0 +1,66 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 the OpenProject GmbH
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License version 3.
+#
+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See COPYRIGHT and LICENSE files for more details.
+#++
+
+require 'spec_helper'
+
+RSpec.describe TeamPlanner::Views::GlobalCreateService, with_ee: %i[team_planner_view] do
+ shared_let(:project) { create(:project) }
+ shared_let(:user) { build_stubbed(:admin) }
+ shared_let(:instance) { described_class.new(user:) }
+
+ subject { instance.call(params) }
+
+ context 'with all valid params' do
+ let(:params) do
+ {
+ name: 'Gotham Renewal',
+ project_id: project.id,
+ public: true,
+ starred: false
+ }
+ end
+
+ it 'is successful' do
+ expect(subject).to be_success
+ end
+
+ it 'creates a team planner view and its query' do
+ view = subject.result
+ query = view.query
+
+ expect(view.type).to eq 'team_planner'
+
+ expect(query.name).to eq 'Gotham Renewal'
+ expect(query.project).to eql(project)
+ expect(query).to be_public
+ expect(query).not_to be_starred
+ end
+ end
+end
diff --git a/modules/team_planner/spec/support/pages/team_planner.rb b/modules/team_planner/spec/support/pages/team_planner.rb
index 0b25d2a96a4..533bb69293e 100644
--- a/modules/team_planner/spec/support/pages/team_planner.rb
+++ b/modules/team_planner/spec/support/pages/team_planner.rb
@@ -177,6 +177,39 @@ module Pages
end
end
+ def click_on_create_button
+ within '.toolbar-items' do
+ click_link 'Team planner'
+ end
+ end
+
+ def click_on_cancel_button
+ click_on 'Cancel'
+ end
+
+ def set_title(title)
+ fill_in 'Title', with: title
+ end
+
+ def set_project(project)
+ select_autocomplete(find('[data-qa-selector="project_id"]'),
+ query: project,
+ results_selector: 'body',
+ wait_for_fetched_options: false)
+ end
+
+ def set_public
+ check 'Public'
+ end
+
+ def set_favoured
+ check 'Favoured'
+ end
+
+ def click_on_submit
+ click_on 'Create'
+ end
+
def add_assignee(name)
click_add_user
page.find('[data-qa-selector="tp-add-assignee"] input')