-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add route and controller for allowing sysadmins to import projects fr…
…om Mediaflux (#1294)
- Loading branch information
1 parent
bf736f7
commit e5079c7
Showing
10 changed files
with
89 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
asset,path,creatorDomain,creatorUser,createdOn,quota,store,projectDirectory,title,description,dataSponsor,dataManager,dataUser,department,projectID | ||
4894926,/td-staging-001/tigerdata/lynchSample-09497,princeton,tigerdataapp,13-Nov-2024 14:04:17,500000000000,data,/td-staging-001/tigerdataNS/lynchSample-09497,"Project lynchSample 09497","Description of project lynchSample 09497",uid1,uid2,"uid3,uid4","23100",10.00000/1234-abcd | ||
4894935,/td-staging-001/tigerdata/GeophysicsSample2-01014,princeton,tigerdataapp,13-Nov-2024 14:06:26,500000000000,data,/td-staging-001/tigerdataNS/GeophysicsSample2-01014,"Project GeophysicsSample2 01014","Description of project GeophysicsSample2 01014",uid3,uid1,"","10003",10.00000/1234-efgh | ||
4897938,/td-staging-001/tigerdata/data-test-03857,princeton,tigerdataapp,24-Jan-2025 09:34:55,500000000000,data,/td-staging-001/tigerdataNS/data-test-03857,"Project data-test 03857","Description of project data-test 03857",uid4,uid5,"uid1,uid2","10003",10.00000/1234-ijkl | ||
4894926,/td-test-001/test/tigerdata/lynchSample-09497,princeton,tigerdataapp,13-Nov-2024 14:04:17,500000000000,data,//td-test-001/test/tigerdataNS/lynchSample-09497,"Project lynchSample 09497","Description of project lynchSample 09497",uid1,uid2,"uid3,uid4","23100",10.00000/1234-abcd | ||
4894935,/td-test-001/test/tigerdata/GeophysicsSample2-01014,princeton,tigerdataapp,13-Nov-2024 14:06:26,500000000000,data,//td-test-001/test/tigerdataNS/GeophysicsSample2-01014,"Project GeophysicsSample2 01014","Description of project GeophysicsSample2 01014",uid3,uid1,"","10003",10.00000/1234-efgh | ||
4897938,/td-test-001/test/tigerdata/data-test-03857,princeton,tigerdataapp,24-Jan-2025 09:34:55,500000000000,data,//td-test-001/test/tigerdataNS/data-test-03857,"Project data-test 03857","Description of project data-test 03857",uid4,uid5,"uid1,uid2","10003",10.00000/1234-ijkl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe "ProjectImports", type: :request do | ||
describe "POST /index" do | ||
it "redirects to sign in" do | ||
put project_import_path | ||
expect(response).to redirect_to new_user_session_path | ||
expect(flash[:alert]).to eq("You need to sign in or sign up before continuing.") | ||
end | ||
|
||
context "a signed in user" do | ||
let(:user) { FactoryBot.create :user } | ||
|
||
before do | ||
sign_in(user) | ||
end | ||
|
||
it "renders a successful response" do | ||
put project_import_path | ||
expect(response).to redirect_to(root_path) | ||
expect(flash[:alert]).to eq("Access Denied") | ||
end | ||
end | ||
|
||
context "a sysadmin user" do | ||
let(:user) { FactoryBot.create :sysadmin, mediaflux_session: SystemUser.mediaflux_session} | ||
|
||
before do | ||
sign_in(user) | ||
end | ||
|
||
it "renders a successful response" do | ||
new_project = FactoryBot.create(:approved_project, project_directory: "test-request") | ||
new_project.mediaflux_id = nil | ||
ProjectMediaflux.create!(project: new_project, user:) | ||
new_project.destroy | ||
|
||
expect{ put project_import_path }.to change { Project.count }.by(1) | ||
expect(response).not_to redirect_to(root_path) | ||
expect(flash[:alert]).to be_blank | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters