Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add route and controller for allowing sysadmins to import projects from Mediaflux #1294

Merged
merged 1 commit into from
Feb 7, 2025

Conversation

carolyncole
Copy link
Member

refs #1272

@coveralls
Copy link

coveralls commented Feb 7, 2025

Coverage Status

coverage: 84.345% (+0.07%) from 84.278%
when pulling b4a2cb3 on project-import
into bf736f7 on main.

@@ -45,10 +45,8 @@ def create_test_root_namespace(user)

# When connect_to_mediaflux is true reset the mediaflux server and make sure it is setup for the tests
RSpec.configure do |config|
config.before(:each) do |ex|
if ex.metadata[:connect_to_mediaflux]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are connecting to mediaflux in any test now, so we should clean mediaflux before any test

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

Copy link
Contributor

@JaymeeH JaymeeH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 🟢

Comment on lines +2 to +11
class ProjectImportController < ApplicationController
def run
if current_user.eligible_sysadmin?
ProjectImport.run_with_report(mediaflux_session: current_user.mediaflux_session)
else
flash[:alert] = I18n.t(:access_denied)
redirect_to root_path
end
end
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏿

flash[:alert] = "Access Denied"
flash[:alert] = I18n.t(:access_denied)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this is for accessibility?

Comment on lines +22 to +25
# skip projects not part of the current namespace in dev & test mode since we have both mediaflux instances in one server
if Rails.env.development? || Rails.env.test?
next unless project_metadata["path"].starts_with?(Rails.configuration.mediaflux["api_root_collection_namespace"])
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is neat 👍🏿

Comment on lines +44 to +55
describe "##run_with_report" do
let (:user) {FactoryBot.create :sysadmin, mediaflux_session: SystemUser.mediaflux_session}
it "creates projects for project in Mediaflux" do
new_project = FactoryBot.create(:approved_project, project_directory: "test-request-service")
new_project.mediaflux_id = nil
ProjectMediaflux.create!(project: new_project, user:)
new_project.destroy

expect{ described_class.run_with_report(mediaflux_session: user.mediaflux_session) }.to change { Project.count }.by(1)
end

end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏿

@@ -45,10 +45,8 @@ def create_test_root_namespace(user)

# When connect_to_mediaflux is true reset the mediaflux server and make sure it is setup for the tests
RSpec.configure do |config|
config.before(:each) do |ex|
if ex.metadata[:connect_to_mediaflux]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@JaymeeH JaymeeH merged commit e5079c7 into main Feb 7, 2025
2 checks passed
@JaymeeH JaymeeH deleted the project-import branch February 7, 2025 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants