Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion BrainPortal/app/controllers/userfiles_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,10 @@ def create #:nodoc:
rack_tempfile_size = upload_stream.tempfile.size

# Get the data provider for the destination files.
data_provider_id = params[:data_provider_id]
data_provider_id = params[:data_provider_id]

# Verify that the DP is accessible to the user - this will raise an exception otherwise
DataProvider.find_accessible_by_user(data_provider_id, current_user)
Copy link
Member

Choose a reason for hiding this comment

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

Please add a comment line just above this new line, something like:

# Verify that the DP is accessible to the user; this will raise an exception otherwise


# Where we'll keep a copy in the spawn() below
tmpcontentfile = "/tmp/#{Process.pid}-#{rand(10000).to_s}-#{basename}" # basename's extension is used later on
Expand Down
13 changes: 7 additions & 6 deletions BrainPortal/spec/controllers/userfiles_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,11 @@ class << file; attr_reader :tempfile; end

before(:each) do
session[:session_id] = 'session_id'
allow(controller).to receive(:current_user).and_return(admin)
allow(Message).to receive(:send_message)
allow(File).to receive(:delete)
allow(controller).to receive(:system)
allow(controller).to receive(:current_user).and_return(admin)
allow(Message).to receive(:send_message)
allow(File).to receive(:delete)
allow(controller).to receive(:system)
allow(DataProvider).to receive(:find_accessible_by_user).and_return(data_provider)
end

it "should redirect to index if the upload file is blank" do
Expand Down Expand Up @@ -300,7 +301,7 @@ class << file; attr_reader :tempfile; end
end

it "should display an error message" do
post :create, params: { :upload_file => mock_upload_stream, :archive => "save", userfile: userfile}
post :create, params: { :upload_file => mock_upload_stream, :archive => "save", userfile: userfile, :data_provider_id => data_provider.id}
expect(flash[:error]).to match(/File .+ could not be added./)
end
end
Expand All @@ -327,7 +328,7 @@ class << file; attr_reader :tempfile; end

it "should copy the file to the local cache" do
expect(mock_userfile).to receive(:cache_copy_from_local_file)
post :create, params: {:upload_file => mock_upload_stream, :archive => "save", userfile: userfile}
post :create, params: {:upload_file => mock_upload_stream, :archive => "save", userfile: userfile, :data_provider_id => data_provider.id}
end
end

Expand Down