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

remove/replace/reactivate specs disabled by former plugins

ulferts3f9126a9e859
diff --git a/modules/costs/spec/disabled_specs.rb b/modules/costs/spec/disabled_specs.rb
deleted file mode 100644
index 3735a080ac9..00000000000
--- a/modules/costs/spec/disabled_specs.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) 2012-2020 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-2017 Jean-Philippe Lang
-# Copyright (C) 2010-2013 the ChiliProject Team
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# See docs/COPYRIGHT.rdoc for more details.
-#++
-
-require 'rspec/example_disabler'
-
-RSpec::ExampleDisabler.disable_example('WorkPackagesController index with valid query settings passed to front-end client visible attributes all attributes visible', 'plugin openproject-costs changes behavior')
-RSpec::ExampleDisabler.disable_example('API::V3::WorkPackages::WorkPackageRepresenter generation spentTime content time entry with multiple hours', 'plugin openproject-costs changes behavior')
-RSpec::ExampleDisabler.disable_example('API::V3::WorkPackages::WorkPackageRepresenter generation spentTime content no time entry', 'plugin openproject-costs changes behavior')
-RSpec::ExampleDisabler.disable_example('API::V3::WorkPackages::WorkPackageRepresenter generation spentTime content time entry with single hour', 'plugin openproject-costs changes behavior')
-
-RSpec::ExampleDisabler.disable_example('API::V3::WorkPackages::Schema::WorkPackageSchemaRepresenter generation spentTime not allowed to view time entries does not show spentTime', 'plugin openproject-costs causes unexpected message')
diff --git a/modules/costs/spec/models/work_package/cost_eager_loading_spec.rb b/modules/costs/spec/models/work_package/cost_eager_loading_spec.rb
index d419f1c8442..7dcf23b89a6 100644
--- a/modules/costs/spec/models/work_package/cost_eager_loading_spec.rb
+++ b/modules/costs/spec/models/work_package/cost_eager_loading_spec.rb
@@ -34,18 +34,18 @@ describe WorkPackage, 'cost eager loading', type: :model do
end
let(:role) do
FactoryBot.create(:role,
- permissions: [:view_work_packages,
- :view_cost_entries,
- :view_cost_rates,
- :view_time_entries,
- :log_time,
- :log_costs,
- :view_hourly_rates])
+ permissions: [:view_work_packages,
+ :view_cost_entries,
+ :view_cost_rates,
+ :view_time_entries,
+ :log_time,
+ :log_costs,
+ :view_hourly_rates])
end
let(:user) do
FactoryBot.create(:user,
- member_in_project: project,
- member_through_role: role)
+ member_in_project: project,
+ member_through_role: role)
end
let(:cost_type) do
@@ -56,38 +56,38 @@ describe WorkPackage, 'cost eager loading', type: :model do
end
let(:cost_entry1) do
FactoryBot.create(:cost_entry,
- cost_type: cost_type,
- user: user,
- work_package: work_package,
- project: project)
+ cost_type: cost_type,
+ user: user,
+ work_package: work_package,
+ project: project)
end
let(:cost_entry2) do
FactoryBot.create(:cost_entry,
- cost_type: cost_type,
- user: user,
- work_package: work_package,
- project: project)
+ cost_type: cost_type,
+ user: user,
+ work_package: work_package,
+ project: project)
end
let(:time_entry1) do
FactoryBot.create(:time_entry,
- user: user,
- project: project,
- work_package: work_package)
+ user: user,
+ project: project,
+ work_package: work_package)
end
let(:time_entry2) do
FactoryBot.create(:time_entry,
- user: user,
- project: project,
- work_package: work_package)
+ user: user,
+ project: project,
+ work_package: work_package)
end
let(:user_rates) do
FactoryBot.create(:hourly_rate,
- user: user,
- project: project)
+ user: user,
+ project: project)
end
let(:cost_rate) do
FactoryBot.create(:cost_rate,
- cost_type: cost_type)
+ cost_type: cost_type)
end
context "combining core's and cost's eager loading" do
diff --git a/modules/reporting/spec/disabled_specs.rb b/modules/reporting/spec/disabled_specs.rb
deleted file mode 100644
index cd1d8709610..00000000000
--- a/modules/reporting/spec/disabled_specs.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) 2012-2020 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-2017 Jean-Philippe Lang
-# Copyright (C) 2010-2013 the ChiliProject Team
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# See docs/COPYRIGHT.rdoc for more details.
-#++
-
-require 'rspec/example_disabler'
-
-RSpec::ExampleDisabler.disable_example('Top menu items as a user with permissions displays all options', 'plugin openproject-reporting removes the menu item')
-RSpec::ExampleDisabler.disable_example('Top menu items as an admin visits the time sheet page', 'plugin openproject-reporting removes the menu item')
-RSpec::ExampleDisabler.disable_example('Top menu items as an admin displays all items', 'plugin openproject-reporting removes the menu item')
-RSpec::ExampleDisabler.disable_example('Top menu items Modules as an admin visits the time sheet page', 'plugin openproject-reporting removes the menu item')
-RSpec::ExampleDisabler.disable_example('Top menu items Modules as an admin displays all items', 'plugin openproject-reporting removes the menu item')
-RSpec::ExampleDisabler.disable_example('Top menu items Modules as a user with permissions displays all options', 'plugin openproject-reporting removes the menu item')
diff --git a/modules/reporting/spec/features/top_menu_item_spec.rb b/modules/reporting/spec/features/top_menu_item_spec.rb
new file mode 100644
index 00000000000..5de35551dfa
--- /dev/null
+++ b/modules/reporting/spec/features/top_menu_item_spec.rb
@@ -0,0 +1,105 @@
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2020 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-2017 Jean-Philippe Lang
+# Copyright (C) 2010-2013 the ChiliProject Team
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# See docs/COPYRIGHT.rdoc for more details.
+#++
+
+require 'spec_helper'
+
+feature 'Top menu items', js: true do
+ let(:user) { FactoryBot.create :user }
+ let(:open_menu) { true }
+
+ def has_menu_items?(*labels)
+ within '#top-menu' do
+ labels.each do |l|
+ expect(page).to have_link(l)
+ end
+ end
+ end
+
+ def expect_no_menu_item(*labels)
+ within '#top-menu' do
+ labels.each do |l|
+ expect(page).not_to have_link(l)
+ end
+ end
+ end
+
+ def click_link_in_open_menu(title)
+ # if the menu is not completely expanded (e.g. if the frontend thread is too fast),
+ # the click might be ignored
+
+ within '.drop-down.open ul[aria-expanded=true]' do
+ expect(page).not_to have_selector('[style~=overflow]')
+
+ page.find_link(title).find('span').click
+ end
+ end
+
+ before do |ex|
+ allow(User).to receive(:current).and_return user
+ FactoryBot.create(:anonymous_role)
+ FactoryBot.create(:non_member)
+
+ if ex.metadata.key?(:allowed_to)
+ allow(user).to receive(:allowed_to?).and_return(ex.metadata[:allowed_to])
+ end
+
+ visit root_path
+ top_menu.click if open_menu
+ end
+
+ describe 'Modules' do
+ !let(:top_menu) { find(:css, "[title=#{I18n.t('label_modules')}]") }
+
+ let(:reporting_item) { I18n.t('cost_reports_title') }
+
+ context 'as an admin' do
+ let(:user) { FactoryBot.create :admin }
+
+ it 'displays reporting item' do
+ has_menu_items?(reporting_item)
+ end
+
+ it 'visits the reporting page' do
+ click_link_in_open_menu(reporting_item)
+ expect(page).to have_current_path(url_for(controller: '/cost_reports', action: 'index', project_id: nil, only_path: true))
+ end
+ end
+
+ context 'as a regular user' do
+ it 'has no menu item' do
+ expect_no_menu_item reporting_item
+ end
+ end
+
+ context 'as a user with permissions', allowed_to: true do
+ it 'displays all options' do
+ has_menu_items?(reporting_item)
+ end
+ end
+ end
+end
diff --git a/spec/features/menu_items/top_menu_item_spec.rb b/spec/features/menu_items/top_menu_item_spec.rb
index cdfe91c4bf5..e2b92c98d8f 100644
--- a/spec/features/menu_items/top_menu_item_spec.rb
+++ b/spec/features/menu_items/top_menu_item_spec.rb
@@ -72,18 +72,14 @@ feature 'Top menu items', js: true, selenium: true do
let(:news_item) { I18n.t('label_news_plural') }
let(:time_entries_item) { I18n.t('label_time_sheet_menu') }
+ let(:reporting_item) { I18n.t('cost_reports_title') }
let(:all_items) { [news_item, time_entries_item] }
context 'as an admin' do
let(:user) { FactoryBot.create :admin }
it 'displays all items' do
- has_menu_items?(time_entries_item, news_item)
- end
-
- it 'visits the time sheet page' do
- click_link_in_open_menu(time_entries_item)
- expect(page).to have_current_path(time_entries_path)
+ has_menu_items?(reporting_item, news_item)
end
it 'visits the news page' do
@@ -100,7 +96,7 @@ feature 'Top menu items', js: true, selenium: true do
context 'as a user with permissions', allowed_to: true do
it 'displays all options' do
- has_menu_items?(time_entries_item, news_item)
+ has_menu_items?(reporting_item, news_item)
end
end
diff --git a/spec/lib/api/v3/work_packages/work_package_representer_spec.rb b/spec/lib/api/v3/work_packages/work_package_representer_spec.rb
index f9fe2120262..6571b910941 100644
--- a/spec/lib/api/v3/work_packages/work_package_representer_spec.rb
+++ b/spec/lib/api/v3/work_packages/work_package_representer_spec.rb
@@ -52,7 +52,6 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do
start_date: start_date,
due_date: due_date,
done_ratio: 50,
- estimated_hours: 6.0,
parent: parent,
type: type,
project: project,
@@ -234,29 +233,8 @@ describe ::API::V3::WorkPackages::WorkPackageRepresenter do
end
describe 'spentTime' do
- describe '#content' do
- context 'no view_time_entries permission' do
- let(:permissions) { all_permissions - [:view_time_entries] }
-
- it { is_expected.not_to have_json_path('spentTime') }
- end
-
- context 'no time entry' do
- it { is_expected.to be_json_eql('PT0S'.to_json).at_path('spentTime') }
- end
-
- context 'time entry with single hour' do
- let(:spent_hours) { 1.0 }
-
- it { is_expected.to be_json_eql('PT1H'.to_json).at_path('spentTime') }
- end
-
- context 'time entry with multiple hours' do
- let(:spent_hours) { 42.5 }
-
- it { is_expected.to be_json_eql('P1DT18H30M'.to_json).at_path('spentTime') }
- end
- end
+ # spentTime is completely overwritten by costs
+ # TODO: move specs from costs to here
end
describe 'percentageDone' do