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

[#53058] Nudge user to login to storage upon project storage edit

Kabiru Mwenja0323e6ca192e
diff --git a/modules/storages/app/controllers/storages/admin/project_storages_controller.rb b/modules/storages/app/controllers/storages/admin/project_storages_controller.rb
index 9f97c9e249a..313a04dadf1 100644
--- a/modules/storages/app/controllers/storages/admin/project_storages_controller.rb
+++ b/modules/storages/app/controllers/storages/admin/project_storages_controller.rb
@@ -143,8 +143,9 @@ class Storages::Admin::ProjectStoragesController < Projects::SettingsController
.call(permitted_storage_settings_params)
if service_result.success?
+ @project_storage = service_result.result
flash[:notice] = I18n.t(:notice_successful_update)
- redirect_to project_settings_project_storages_path
+ redirect_to_project_storages_path_with_oauth_access_grant_confirmation
else
@project_storage = @object
render "/storages/project_settings/edit"
diff --git a/modules/storages/spec/features/storages/project_settings/oauth_access_grant_spec.rb b/modules/storages/spec/features/storages/project_settings/oauth_access_grant_spec.rb
index bdbc78c1306..b97dad68ff5 100644
--- a/modules/storages/spec/features/storages/project_settings/oauth_access_grant_spec.rb
+++ b/modules/storages/spec/features/storages/project_settings/oauth_access_grant_spec.rb
@@ -86,4 +86,22 @@ RSpec.describe "OAuth Access Grant Nudge upon adding a storage to a project",
"redirect_uri=#{redirect_uri}&response_type=code&state=#{nonce}")
end
end
+
+ it "edits a storage, nudges the project admin to grant OAuth access" do
+ project_storage = create(:project_storage, project:, storage:)
+
+ visit edit_project_settings_project_storage_path(project_id: project, id: project_storage)
+
+ expect(page).to have_text("Edit the file storage to this project")
+
+ click_on "Save"
+
+ within_test_selector("oauth-access-grant-nudge-modal") do
+ expect(page).to be_axe_clean
+ expect(page).to have_text("One more step...")
+ click_on("Login")
+ wait_for(page).to have_current_path("/index.php/apps/oauth2/authorize?client_id=#{storage.oauth_client.client_id}&" \
+ "redirect_uri=#{redirect_uri}&response_type=code&state=#{nonce}")
+ end
+ end
end