-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support CarrierWave 2.0 multiple file upload's keep, append and reord…
…er feature Refs. carrierwaveuploader/carrierwave#2401
- Loading branch information
Showing
23 changed files
with
337 additions
and
46 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
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
10 changes: 6 additions & 4 deletions
10
app/views/rails_admin/main/_form_multiple_file_upload.html.haml
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,48 @@ | ||
require 'spec_helper' | ||
|
||
describe 'MultipleCarrierwave field', type: :request, active_record: true do | ||
subject { page } | ||
before do | ||
RailsAdmin.config FieldTest do | ||
edit do | ||
field :carrierwave_assets | ||
end | ||
end | ||
end | ||
|
||
it 'supports uploading multiple files' do | ||
visit new_path(model_name: 'field_test') | ||
attach_file "Carrierwave assets", [file_path('test.jpg'), file_path('test.png')] | ||
click_button 'Save' | ||
expect(FieldTest.first.carrierwave_assets.map { |image| File.basename(image.url) }).to match_array ['test.jpg', 'test.png'] | ||
end | ||
|
||
context 'when working with existing files' do | ||
let(:field_test) { FactoryBot.create(:field_test, carrierwave_assets: ['test.jpg', 'test.png'].map { |img| File.open(file_path(img)) }) } | ||
|
||
it 'supports appending a file', js: true do | ||
visit edit_path(model_name: 'field_test', id: field_test.id) | ||
attach_file "Carrierwave assets", [file_path('test.gif')] | ||
click_button 'Save' | ||
field_test.reload | ||
expect(field_test.carrierwave_assets.map { |image| File.basename(image.url) }).to eq ['test.jpg', 'test.png', 'test.gif'] | ||
end | ||
|
||
it 'supports deleting a file', js: true do | ||
visit edit_path(model_name: 'field_test', id: field_test.id) | ||
click_link 'Delete carrierwave assets #1' | ||
click_button 'Save' | ||
field_test.reload | ||
expect(field_test.carrierwave_assets.map { |image| File.basename(image.url) }).to eq ['test.png'] | ||
end | ||
|
||
it 'supports reordering files', js: true do | ||
visit edit_path(model_name: 'field_test', id: field_test.id) | ||
page.execute_script File.read(File.expand_path('../../../support/jquery.simulate.drag-sortable.js', __FILE__)) | ||
page.execute_script %{$(".ui-sortable-handle:first-child").simulateDragSortable({ move: 1});} | ||
click_button 'Save' | ||
field_test.reload | ||
expect(field_test.carrierwave_assets.map { |image| File.basename(image.url) }).to eq ['test.png', 'test.jpg'] | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
def file_path(*paths) | ||
File.expand_path(File.join(File.dirname(__FILE__), '../fixtures', *paths)) | ||
end |
Oops, something went wrong.