-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
b417d62
to
1cf034d
Compare
1cf034d
to
29fa7cc
Compare
29fa7cc
to
b4a2cb3
Compare
@@ -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] |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 🟢
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
# 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is neat 👍🏿
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 |
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
refs #1272