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

Mir Bhatiac5e2bc7da345
diff --git a/modules/calendar/spec/features/calendar_sharing_spec.rb b/modules/calendar/spec/features/calendar_sharing_spec.rb
index c7af407f06b..cab73e0dcec 100644
--- a/modules/calendar/spec/features/calendar_sharing_spec.rb
+++ b/modules/calendar/spec/features/calendar_sharing_spec.rb
@@ -32,7 +32,7 @@ require_relative './shared_context'
RSpec.describe 'Calendar sharing via ical', js: true do
include_context 'with calendar full access'
- # let(:status) { create(:default_status) }
+ shared_let(:status) { create(:default_status) }
let(:user_with_sharing_permission) do
create(:user,
@@ -61,7 +61,7 @@ RSpec.describe 'Calendar sharing via ical', js: true do
])
end
- let(:admin) do
+ shared_let(:admin) do
create(:admin,
member_in_project: project)
end
@@ -73,51 +73,51 @@ RSpec.describe 'Calendar sharing via ical', js: true do
public: false)
end
- context 'without sufficient permissions and the ical_enabled setting enabled', with_settings: { ical_enabled: true } do
- let(:saved_query) do
- create(:query_with_view_work_packages_calendar,
- user: user_without_sharing_permission,
- project:,
- public: false)
- end
+ # context 'without sufficient permissions and the ical_enabled setting enabled', with_settings: { ical_enabled: true } 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
+ # before do
+ # login_as user_without_sharing_permission
+ # calendar.visit!
+ # end
- context 'on persisted calendar query' do
- before do
- saved_query
+ # context 'on persisted calendar query' do
+ # before do
+ # saved_query
- visit project_calendars_path(project)
+ # visit project_calendars_path(project)
- within '#content' do
- click_link saved_query.name
- end
+ # within '#content' do
+ # click_link saved_query.name
+ # end
- loading_indicator_saveguard
- 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")
+ # 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
+ # # 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")
+ # # 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
+ # # modal should not be shown
+ # expect(page).not_to have_selector('.spot-modal--header', text: "Subscribe to iCalendar")
+ # end
+ # end
+ # end
+ # end
context 'with sufficient permissions and the ical_enabled setting enabled', with_settings: { ical_enabled: true } do
before do
@@ -125,45 +125,45 @@ RSpec.describe 'Calendar sharing via ical', js: true do
calendar.visit!
end
- context 'on not persisted calendar query' do
- # add "manage_calendars" permission to user for this context
- # in order to enable creating a new calendar on the UI.
- # this permission is not mandatory for the actual feature
- let(:user_with_sharing_permission) do
- create(:user,
- firstname: 'Bernd',
- member_in_project: project,
- member_with_permissions: %w[
- view_work_packages
- save_queries
- view_calendar
- manage_calendars
- share_calendars
- ])
- end
-
- it 'shows disabled sharing menu item' do
- visit project_calendars_path(project)
-
- click_link "Create new calendar"
-
- # 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
+ # context 'on not persisted calendar query' do
+ # # add "manage_calendars" permission to user for this context
+ # # in order to enable creating a new calendar on the UI.
+ # # this permission is not mandatory for the actual feature
+ # let(:user_with_sharing_permission) do
+ # create(:user,
+ # firstname: 'Bernd',
+ # member_in_project: project,
+ # member_with_permissions: %w[
+ # view_work_packages
+ # save_queries
+ # view_calendar
+ # manage_calendars
+ # share_calendars
+ # ])
+ # end
+
+ # it 'shows disabled sharing menu item' do
+ # visit project_calendars_path(project)
+
+ # click_link "Create new calendar"
+
+ # # 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
context 'on persisted calendar query' do
before do
@@ -178,29 +178,25 @@ RSpec.describe 'Calendar sharing via ical', js: true do
loading_indicator_saveguard
end
- it 'shows an active menu item' do
- # wait for settings button to become visible
- expect(page).to have_selector("#work-packages-settings-button")
+ # it 'shows an active 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
+ # # click on settings button
+ # page.find_by_id('work-packages-settings-button').click
- # expect active sharing menu item
- within "#settingsDropdown" do
- expect(page).to have_selector(".menu-item", text: "Subscribe to iCalendar")
- end
- end
+ # # expect active sharing menu item
+ # within "#settingsDropdown" do
+ # expect(page).to have_selector(".menu-item", text: "Subscribe to iCalendar")
+ # end
+ # end
context 'when ical sharing is disabled globally' do
- current_user { admin }
-
it 'navigates to iCal settings and disables the setting as an admin' do
-
+ login_as admin
visit admin_index_path
- binding.pry
-
within '.menu-blocks--container' do
click_link 'Calendars and dates'
end
@@ -211,18 +207,24 @@ RSpec.describe 'Calendar sharing via ical', js: true do
expect(page)
.to have_field('Enable iCalendar subscriptions', checked: true)
+ binding.pry # Why can this be accessed? current_user is not admin?
+
uncheck 'settings[ical_enabled]'
click_button 'Save'
expect(page)
.to have_content "Successful update."
- end
- current_user { user_with_sharing_permission }
+ expect(page)
+ .to have_field('Enable iCalendar subscriptions', checked: false)
- it 'shows a disabled menu item' do
+ binding.pry # Setting reverts
+ end
+
+ it 'shows a disabled menu item' do
+ login_as user_with_sharing_permission
saved_query
visit project_calendars_path(project)
@@ -251,77 +253,77 @@ RSpec.describe 'Calendar sharing via ical', js: true do
end
end
- it 'shows a sharing modal' do
- open_sharing_modal
+ # it 'shows a sharing modal' do
+ # open_sharing_modal
- expect(page).to have_selector('.spot-modal--header', text: "Subscribe to iCalendar")
- end
+ # expect(page).to have_selector('.spot-modal--header', text: "Subscribe to iCalendar")
+ # end
- it 'closes the sharing modal when closed by user by clicking the close button' do
- open_sharing_modal
+ # it 'closes the sharing modal when closed by user by clicking the close button' do
+ # open_sharing_modal
- expect(page).to have_selector('.spot-modal--header', text: "Subscribe to iCalendar")
+ # expect(page).to have_selector('.spot-modal--header', text: "Subscribe to iCalendar")
- click_button "Cancel"
+ # click_button "Cancel"
- expect(page).not_to have_selector('.spot-modal--header', text: "Subscribe to iCalendar")
- end
+ # expect(page).not_to have_selector('.spot-modal--header', text: "Subscribe to iCalendar")
+ # end
- it 'successfully requests a new tokenized iCalendar URL when a unique name is provided' do
- open_sharing_modal
+ # it 'successfully requests a new tokenized iCalendar URL when a unique name is provided' do
+ # open_sharing_modal
- fill_in "Token name", with: "A token name"
+ # fill_in "Token name", with: "A token name"
- click_button "Copy URL"
+ # click_button "Copy URL"
- # implicitly testing for success -> modal is closed and fallback message is shown
- expect(page).not_to have_selector('.spot-modal--header', text: "Subscribe to iCalendar")
- expect(page).to have_content("/projects/#{saved_query.project.id}/calendars/#{saved_query.id}/ical?ical_token=")
+ # # implicitly testing for success -> modal is closed and fallback message is shown
+ # expect(page).not_to have_selector('.spot-modal--header', text: "Subscribe to iCalendar")
+ # expect(page).to have_content("/projects/#{saved_query.project.id}/calendars/#{saved_query.id}/ical?ical_token=")
- # explictly testing for success message is not working in test env, probably
- # due to missing clipboard permissions of the headless browser
- #
- # expect(page).to have_content("URL copied to clipboard")
+ # # explictly testing for success message is not working in test env, probably
+ # # due to missing clipboard permissions of the headless browser
+ # #
+ # # expect(page).to have_content("URL copied to clipboard")
- # TODO: Not able to test if the URL was actuall copied to the clipboard
- # Tried following without success
- # https://copyprogramming.com/howto/emulating-a-clipboard-copy-paste-with-selinum-capybara
- end
+ # # TODO: Not able to test if the URL was actuall copied to the clipboard
+ # # Tried following without success
+ # # https://copyprogramming.com/howto/emulating-a-clipboard-copy-paste-with-selinum-capybara
+ # end
- it 'validates the presence of a name' do
- open_sharing_modal
+ # it 'validates the presence of a name' do
+ # open_sharing_modal
- # fill_in "Token name", with: "A token name"
+ # # fill_in "Token name", with: "A token name"
- click_button "Copy URL"
+ # click_button "Copy URL"
- # modal is still shown and error message is shown
- expect(page).to have_selector('.spot-modal--header', text: "Subscribe to iCalendar")
- expect(page).to have_content("Name is mandatory")
- end
+ # # modal is still shown and error message is shown
+ # expect(page).to have_selector('.spot-modal--header', text: "Subscribe to iCalendar")
+ # expect(page).to have_content("Name is mandatory")
+ # end
- it 'validates the uniqueness of a name' do
- open_sharing_modal
+ # it 'validates the uniqueness of a name' do
+ # open_sharing_modal
- fill_in "Token name", with: "A token name"
+ # fill_in "Token name", with: "A token name"
- click_button "Copy URL"
+ # click_button "Copy URL"
- expect(page).not_to have_selector('.spot-modal--header', text: "Subscribe to iCalendar")
- expect(page).to have_content("/projects/#{saved_query.project.id}/calendars/#{saved_query.id}/ical?ical_token=")
+ # expect(page).not_to have_selector('.spot-modal--header', text: "Subscribe to iCalendar")
+ # expect(page).to have_content("/projects/#{saved_query.project.id}/calendars/#{saved_query.id}/ical?ical_token=")
- # do the same thing again, now expect validation error
+ # # do the same thing again, now expect validation error
- open_sharing_modal
+ # open_sharing_modal
- fill_in "Token name", with: "A token name" # same name for same user and same query -> not allowed
+ # fill_in "Token name", with: "A token name" # same name for same user and same query -> not allowed
- click_button "Copy URL"
+ # click_button "Copy URL"
- # modal is still shown and error message is shown
- expect(page).to have_selector('.spot-modal--header', text: "Subscribe to iCalendar")
- expect(page).to have_content("Name is already in use")
- end
+ # # modal is still shown and error message is shown
+ # expect(page).to have_selector('.spot-modal--header', text: "Subscribe to iCalendar")
+ # expect(page).to have_content("Name is already in use")
+ # end
end
end