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

WIP: Merge ical_spec into calendar_sharing_spec

Mir Bhatia55e12029cbd9
diff --git a/modules/calendar/spec/features/calendar_sharing_spec.rb b/modules/calendar/spec/features/calendar_sharing_spec.rb
index b8767f297a3..336933927ef 100644
--- a/modules/calendar/spec/features/calendar_sharing_spec.rb
+++ b/modules/calendar/spec/features/calendar_sharing_spec.rb
@@ -66,9 +66,60 @@ RSpec.describe 'Calendar sharing via ical', js: true do
public: false)
end
+ context 'without sufficient permissions' do
+ let(:saved_query) do
+ create(:query_with_view_work_packages_calendar,
+ user: user_without_sharing_permission,
+ project:,
+ public: false)
+ end
+
+ before do
+ login_as user_without_sharing_permission
+ calendar.visit!
+ end
+
+ context 'on persisted calendar query' do
+ before do
+ saved_query
+
+ visit project_calendars_path(project)
+
+ within '#content' do
+ click_link saved_query.name
+ end
+
+ loading_indicator_saveguard
+ end
+
+ it 'shows disabled sharing menu item' do
+ binding.pry
+
+ # wait for settings button to become visible
+ expect(page).to have_selector("#work-packages-settings-button")
+
+ # click on settings button
+ page.find_by_id('work-packages-settings-button').click
+
+ # expect disabled sharing menu item
+ within "#settingsDropdown" do
+ # expect(page).to have_button("Subscribe to iCalendar", disabled: true) # disabled selector not working
+ expect(page).to have_selector(".menu-item.inactive", text: "Subscribe to iCalendar")
+ page.click_button("Subscribe to iCalendar")
+
+ # modal should not be shown
+ expect(page).not_to have_selector('.spot-modal--header', text: "Subscribe to iCalendar")
+ end
+ end
+ end
+ end
+
+ # Add in - 2) Go to the settings page, enable the setting
+
+
context 'with sufficient permissions', with_settings: { ical_enabled: true } do
before do
- login_as user_with_sharing_permission
+ login_as user_with_sharing_permission # do this manually via settings page
calendar.visit!
end
@@ -232,52 +283,6 @@ RSpec.describe 'Calendar sharing via ical', js: true do
end
end
- context 'without sufficient permissions' do
- let(:saved_query) do
- create(:query_with_view_work_packages_calendar,
- user: user_without_sharing_permission,
- project:,
- public: false)
- end
-
- before do
- login_as user_without_sharing_permission
- calendar.visit!
- end
-
- context 'on persisted calendar query' do
- before do
- saved_query
-
- visit project_calendars_path(project)
-
- within '#content' do
- click_link saved_query.name
- end
-
- loading_indicator_saveguard
- end
-
- it 'shows disabled sharing menu item' do
- # wait for settings button to become visible
- expect(page).to have_selector("#work-packages-settings-button")
-
- # click on settings button
- page.find_by_id('work-packages-settings-button').click
-
- # expect disabled sharing menu item
- within "#settingsDropdown" do
- # expect(page).to have_button("Subscribe to iCalendar", disabled: true) # disabled selector not working
- expect(page).to have_selector(".menu-item.inactive", text: "Subscribe to iCalendar")
- page.click_button("Subscribe to iCalendar")
-
- # modal should not be shown
- expect(page).not_to have_selector('.spot-modal--header', text: "Subscribe to iCalendar")
- end
- end
- end
- end
-
# helper methods
def open_sharing_modal
diff --git a/spec/features/calendars/ical_spec.rb b/spec/features/calendars/ical_spec.rb
deleted file mode 100644
index 6ebd0e0a310..00000000000
--- a/spec/features/calendars/ical_spec.rb
+++ /dev/null
@@ -1,108 +0,0 @@
-#-- 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 'iCal functionality', js: true, selenium: true do
- # steps to do:
- # 1) With setting not enabled, go to calendar page and see that it cannot be shared
- # 2) Go to the settings page, enable the setting
- # 3) Go back to to the calendar page and see that it can be shared now
-
- shared_let(:project) { create(:project) }
- shared_let(:user) do
- create(:admin,
- member_in_project: project,
- member_with_permissions: %i[view_work_packages view_calendar manage_calendars])
- end
- # shared_let(:user) do
- # create(:user,
- # member_in_project: project,
- # member_with_permission: %i[view_work_packages view_calendar manage_calendars])
- # end
-
- before do
- login_as(user)
- end
-
- it "doesn't let a user share calendars without the setting being enabled" do
- visit project_path(project)
-
- within '#main-menu' do
- click_link 'Calendars'
- end
-
- click_link "Create new calendar"
-
- expect(page).to have_selector("#work-packages-settings-button")
-
- page.find_by_id('work-packages-settings-button').click
- page.click_button("Save")
-
- fill_in 'Name', with: 'cal1'
- find('.button', text: 'Save').click
-
- expect(page)
- .to have_content "Successful creation."
-
- page.find_by_id('work-packages-settings-button').click
-
-
- within "#settingsDropdown" do
- expect(page).to have_selector(".menu-item.inactive", text: "Subscribe to iCalendar")
- page.click_button("Subscribe to iCalendar")
-
- expect(page).not_to have_selector('.spot-modal--header', text: "Subscribe to iCalendar")
- end
- end
-
- it 'navigates to iCal settings and enables the setting' do
- visit admin_index_path
-
- within '.menu-blocks--container' do
- click_link 'Calendars and dates'
- end
-
- expect(page).to have_selector(".title-container", text: "Working days")
- click_link 'iCalendar'
-
- expect(page)
- .to have_field('Enable iCalendar subscriptions', checked: false)
-
- check 'Enable iCalendar subscriptions'
-
- click_button 'Save'
-
- expect(page)
- .to have_content "Successful update."
-
- expect(page)
- .to have_field('Enable iCalendar subscriptions', checked: true)
- end
-
-end
diff --git a/spec/support/shared/require_admin.rb b/spec/support/shared/require_admin.rb
new file mode 100644
index 00000000000..e17061cb670
--- /dev/null
+++ b/spec/support/shared/require_admin.rb
@@ -0,0 +1,46 @@
+#-- 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.
+#++
+
+def require_admin_and_render_template(path)
+ describe 'GET #show' do
+ subject { get 'show' }
+
+ describe 'permissions' do
+ let(:fetch) { subject }
+
+ it_behaves_like 'a controller action with require_admin'
+ end
+
+ it 'renders the API settings template' do
+ subject
+
+ expect(response).to be_successful
+ expect(response).to render_template "admin/settings/#{path}/show", 'layouts/admin'
+ end
+ end
+end