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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
[#64620] added controller tests
Eric Schubert0d3497d7e554
diff --git a/spec/controllers/types_controller_spec.rb b/spec/controllers/types_controller_spec.rbindex afc9d926514..a9fba4a36a6 100644--- a/spec/controllers/types_controller_spec.rb+++ b/spec/controllers/types_controller_spec.rb@@ -23,7 +23,7 @@## 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.+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.## See COPYRIGHT and LICENSE files for more details.#++@@ -226,27 +226,6 @@ RSpec.describe TypesController doit { expect(response.body).to have_css "input[@name='type[is_milestone]'][@value='1'][@checked='checked']" }end- describe "GET edit projects" do- render_views- let(:type) do- create(:type, name: "My type",- is_milestone: true,- projects: [project])- end-- before do- get "edit", params: { id: type.id, tab: :projects }- end-- it { expect(response).to have_http_status(:ok) }- it { expect(response).to render_template "edit" }- it { expect(response).to render_template "types/form/_projects" }-- it {- expect(response.body).to have_css "input[@name='type[project_ids][]'][@value='#{project.id}'][@checked='checked']"- }- end-describe "PATCH update" dolet(:project2) { create(:project) }let(:type) do@@ -293,30 +272,6 @@ RSpec.describe TypesController doit { expect(response).to have_http_status(:unprocessable_entity) }it { expect(response).to render_template "edit" }end-- describe "WITH projects removed" do- let(:params) do- { "id" => type.id,- "type" => { project_ids: [""] },- "tab" => "projects" }- end-- before do- patch :update, params:- end-- it { expect(response).to be_redirect }-- it do- expect(response).to(- redirect_to(edit_tab_type_path(id: type.id, tab: :projects))- )- end-- it "has no projects assigned" do- expect(Type.find_by(name: "My type").projects.count).to eq(0)- end- endenddescribe "POST move" dodiff --git a/spec/controllers/work_package_types/projects_tab_controller_spec.rb b/spec/controllers/work_package_types/projects_tab_controller_spec.rbnew file mode 100644index 00000000000..ab90aa9b858--- /dev/null+++ b/spec/controllers/work_package_types/projects_tab_controller_spec.rb@@ -0,0 +1,87 @@+# frozen_string_literal: true++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 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 WorkPackageTypes::ProjectsTabController do+ let(:project) { create(:project) }+ let(:type) { create(:type_bug) }++ before do+ login_as user+ end++ context "without admin access" do+ let(:user) { create :user }++ describe "GET edit" do+ before do+ get :edit, params: { type_id: type.id }+ end++ it { expect(response).to have_http_status(:forbidden) }+ end+ end++ context "with admin access" do+ let(:user) { create :admin }++ describe "GET edit" do+ before do+ get :edit, params: { type_id: type.id }+ end++ it { expect(response).to have_http_status(:ok) }+ it { expect(response).to render_template "edit" }+ end++ describe "PUT update" do+ let(:project_ids) { [project.id.to_s] }+ let(:params) do+ {+ "type_id" => type.id,+ "type" => { "project_ids" => project_ids.to_json }+ }+ end++ before do+ put :update, params:+ end++ it { expect(response).to redirect_to(edit_type_projects_path(type_id: type.id)) }++ context "if the project id does not exist" do+ let(:project_ids) { ["not_here"] }++ it { expect(response).to have_http_status(:unprocessable_entity) }+ end+ end+ end+end