solidus_product_attachments 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 81568f1eb44e9f922a8e4cf8efb1eb937312f5b3
4
- data.tar.gz: 016454e4c6177400aa57c74e29857df7efe2e6df
3
+ metadata.gz: 80cc02a5360a349128560bfc8a7fb742e3f18051
4
+ data.tar.gz: 36ba3e7e2e45ff76dad104f33f9152896b27637c
5
5
  SHA512:
6
- metadata.gz: 60156a9faa53d99e2f6d0a2e3ad0fd9d106fb295deb7865a8a55cf09c848b961721dfd9747318f0a2f34f17a7badd0faed39a97fbf8440a045b651893812c89d
7
- data.tar.gz: d7da787ea96e2e931766815ad7048f271b1515fd60e8f52927e561b1de653dd7bcd2fe9ef701a2ddae95313e0148fbc070d0b08439421ca8fec5e7af1983699a
6
+ metadata.gz: 13dc6e736815335271c75da5513cf1d8a061ff7b72d77ece199f15c18b0225fb3dbe311c29cffee6c11e52d4ff70532bf964f4b6ff645fb8d06c6e4ad01f6fd8
7
+ data.tar.gz: 6f40d2cb9a434aeb58d1aa5cbfd408e002b1d4ae0e9336940370fe0bf06d3b3093e1a1ced4c514852e736b1abba587ee64fbfda07d60ff899e7f0f096eedb6e5
data/README.md CHANGED
@@ -1,15 +1,13 @@
1
- SolidusProductAttachments
2
- =========================
1
+ # Solidus Product Attachments
3
2
 
4
- Allows the administrator to add attachments to a product/variant.
3
+ This Solidus extension allows the administrator to upload PDF files to a product or to a variant.
5
4
 
6
5
  [![Build Status](https://semaphoreci.com/api/v1/projects/c5f055f7-da80-440c-9f7b-c9c6c4a87bfa/2535219/shields_badge.svg)](https://semaphoreci.com/renuo/solidus_product_attachments)
6
+ [![Gem Version](https://badge.fury.io/rb/solidus_product_attachments.svg)](https://badge.fury.io/rb/solidus_product_attachments)
7
7
 
8
+ ## Installation
8
9
 
9
- Installation
10
- ------------
11
-
12
- Add solidus_product_attachments to your Gemfile:
10
+ Add `solidus_product_attachments` to your `Gemfile`:
13
11
 
14
12
  ```ruby
15
13
  gem 'solidus_product_attachments'
@@ -22,21 +20,55 @@ bundle
22
20
  bundle exec rails g solidus_product_attachments:install
23
21
  ```
24
22
 
25
- Testing
26
- -------
23
+ ## Usage
24
+
25
+ ### Backend
26
+
27
+ The usage of this extension is made very easy. All you have to do is to include it in your `Gemfile` and run the installer. After doing this, you can go to a product's page in the admin view and you'll notice a new `Documents` tab.
28
+
29
+ <img width="1205" alt="Product documents tab" src="https://user-images.githubusercontent.com/31915276/53641672-f26efc00-3c2f-11e9-841d-687e7c849957.png">
30
+
31
+ The functionality of the documents upload is very similar to the images upload. You can upload a document per drag and drop or you can choose a file manually.
32
+
33
+ ### Frontend
34
+
35
+ This extension does not come with a frontend implementation of a download option for the users. It's completely up to you
36
+ to add it, but you can inspire yourself from the following example:
27
37
 
28
- First bundle your dependencies, then run `rake`. `rake` will default to building the dummy app if it does not exist, then it will run specs, and [Rubocop](https://github.com/bbatsov/rubocop) static code analysis. The dummy app can be regenerated by using `rake test_app`.
38
+ <img width="205" alt="Download option example" src="https://user-images.githubusercontent.com/31915276/53641960-c738dc80-3c30-11e9-82ef-df730bd0e357.png">
39
+
40
+ And the code (only for the product downloads, without css):
41
+
42
+ ```erb
43
+ <% if @product.attachments.any? %>
44
+ <div class="product-downloads">
45
+ <h2>I18n.t('spree.product_download_title')</h2>
46
+ <ul class="unstyled">
47
+ <% @product.attachments.each do |attachment| %>
48
+ <li>
49
+ <%= link_to attachment.alt.presence || attachment.attachment_file_name, attachment.attachment.url, target: '_blank' %>
50
+ </li>
51
+ <% end %>
52
+ </ul>
53
+ </div>
54
+ <% end %>
55
+ ```
56
+
57
+ ## Testing
58
+
59
+ First bundle your dependencies, then run `bundle exec rake`. This command will default to building the dummy app if it does not exist, then it will run the specs and [Rubocop](https://github.com/bbatsov/rubocop) static code analysis. The dummy app can be regenerated by using `bundle exec rake test_app`.
29
60
 
30
61
  ```shell
31
62
  bundle
32
63
  bundle exec rake
33
64
  ```
34
65
 
35
- When testing your applications integration with this extension you may use it's factories.
36
- Simply add this require statement to your spec_helper:
66
+ When testing your application's integration with this extension, you may use its factories. In order to do this, simply add this require statement to your spec_helper:
37
67
 
38
68
  ```ruby
39
69
  require 'solidus_product_attachments/factories'
40
70
  ```
41
71
 
42
- Copyright (c) 2019 [Renuo AG](https://www.renuo.ch/en), released under the New BSD License
72
+ ## Copyright
73
+
74
+ Copyright (c) 2019 [Renuo AG](https://www.renuo.ch/en), released under the New BSD License.
@@ -4,7 +4,9 @@ module Spree
4
4
  attachment_updated_at id position type].freeze
5
5
  PERMITTED_ATTACHMENT_ATTRIBUTES = %i[alt attachment position viewable_id viewable_type].freeze
6
6
 
7
- has_attached_file :attachment
7
+ has_attached_file :attachment,
8
+ url: '/spree/attachments/:id/:basename.:extension',
9
+ path: ':rails_root/public/spree/attachments/:id/:basename.:extension'
8
10
 
9
11
  validate :no_attachment_errors
10
12
  validates_attachment :attachment, content_type: { content_type: 'application/pdf' }
@@ -0,0 +1,5 @@
1
+ require 'factory_bot'
2
+
3
+ Dir["#{File.dirname(__FILE__)}/factories/**"].each do |f|
4
+ require File.expand_path(f)
5
+ end
@@ -0,0 +1,7 @@
1
+ require_relative '../support/assets'
2
+
3
+ FactoryBot.define do
4
+ factory :attachment, class: Spree::Attachment do
5
+ attachment { fake_attachment }
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ def fake_attachment
2
+ Rack::Test::UploadedFile.new(File.join(__dir__, '..', 'fixtures', 'test_file.pdf'), 'application/pdf')
3
+ end
@@ -1,3 +1,3 @@
1
1
  module SolidusProductAttachments
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_product_attachments
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Renuo AG
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-28 00:00:00.000000000 Z
11
+ date: 2019-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deface
@@ -247,6 +247,10 @@ files:
247
247
  - lib/generators/solidus_product_attachments/install/install_generator.rb
248
248
  - lib/solidus_product_attachments.rb
249
249
  - lib/solidus_product_attachments/engine.rb
250
+ - lib/solidus_product_attachments/testing_support/factories.rb
251
+ - lib/solidus_product_attachments/testing_support/factories/attachments.rb
252
+ - lib/solidus_product_attachments/testing_support/fixtures/test_file.pdf
253
+ - lib/solidus_product_attachments/testing_support/support/assets.rb
250
254
  - lib/solidus_product_attachments/version.rb
251
255
  homepage: https://www.renuo.ch
252
256
  licenses: