spree_product_documents 3.0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +7 -0
- data/LICENSE +26 -0
- data/README.md +59 -0
- data/Rakefile +21 -0
- data/app/controllers/spree/admin/documents_controller.rb +37 -0
- data/app/models/spree/app_configuration_decorator.rb +3 -0
- data/app/models/spree/document.rb +35 -0
- data/app/models/spree/product_decorator.rb +6 -0
- data/app/models/spree/variant_decorator.rb +3 -0
- data/app/overrides/product_document_tab.rb +9 -0
- data/app/views/spree/admin/documents/_form.html.erb +18 -0
- data/app/views/spree/admin/documents/edit.html.erb +28 -0
- data/app/views/spree/admin/documents/index.html.erb +58 -0
- data/app/views/spree/admin/documents/new.html.erb +17 -0
- data/bin/rails +7 -0
- data/config/locales/en.yml +19 -0
- data/config/locales/es.yml +19 -0
- data/config/routes.rb +12 -0
- data/lib/spree_product_documents.rb +3 -0
- data/lib/spree_product_documents/engine.rb +20 -0
- data/lib/spree_product_documents/factories.rb +6 -0
- data/spec/spec_helper.rb +87 -0
- data/spree_product_documents.gemspec +20 -0
- metadata +95 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fe10d60b9a8e89c7be81c84b906647acba479fc1
|
4
|
+
data.tar.gz: dfc001f17a02919eb1cbaf88588e66a113a5fbf9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c5a908e9f111e9f75f6535f2533c0948614f9bd488c38c0dd3f64650c417bd71bcee930a576be60cc8a54afd4219ec3be65f09ad4bbc0667eba3579977c197f5
|
7
|
+
data.tar.gz: dbfc1a4aa850c383ed1f5855d7623bbb883e3ec4cb4ee72820cab9c5f23aea80ea5c71fbfabb98f6e08c90c757e170569916e56ef079277f797fe3d506ed6f45
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
Copyright (c) 2015 Tania Rubio
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without modification,
|
5
|
+
are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
* Redistributions of source code must retain the above copyright notice,
|
8
|
+
this list of conditions and the following disclaimer.
|
9
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
10
|
+
this list of conditions and the following disclaimer in the documentation
|
11
|
+
and/or other materials provided with the distribution.
|
12
|
+
* Neither the name Spree nor the names of its contributors may be used to
|
13
|
+
endorse or promote products derived from this software without specific
|
14
|
+
prior written permission.
|
15
|
+
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
18
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
19
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
20
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
21
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
22
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
23
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
24
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
25
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
26
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
SpreeProductDocuments
|
2
|
+
=====================
|
3
|
+
|
4
|
+
Spree_product_documents is an Spree extension to attach documents related to a Product. Spree::Document class inherits from Spree::Resource and use spree_assets table, so no additional tables or assets are required.
|
5
|
+
|
6
|
+
This extension is heavily inspired in https://github.com/mosaic/spree_product_documents but has been adapted in order to work with Spree 2.4-stable branch.
|
7
|
+
|
8
|
+
Installation
|
9
|
+
------------
|
10
|
+
|
11
|
+
Add spree_product_documents to your Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'spree_product_documents'
|
15
|
+
```
|
16
|
+
|
17
|
+
Bundle your dependencies and run the installation generator:
|
18
|
+
|
19
|
+
```shell
|
20
|
+
bundle
|
21
|
+
```
|
22
|
+
|
23
|
+
No generator is needed as no additional assets or tables are required.
|
24
|
+
|
25
|
+
|
26
|
+
Configuration
|
27
|
+
-------
|
28
|
+
|
29
|
+
Currently, this extension supports **application/pdf** and **application/zip** content types. If you wish to support other content_types, you can create a new app_configuration_decorator.rb and override defined ones:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
Spree::AppConfiguration.class_eval do
|
33
|
+
preference :allowed_document_content_types, :array, :default => %w(application/pdf application/zip)
|
34
|
+
end
|
35
|
+
```
|
36
|
+
and be sure to restart your server.
|
37
|
+
|
38
|
+
After installation, a new tab "Documents" will appear in product tabs. It works exactly the same as images, you can attach as many documents as you want, related to a product or a specific variant.
|
39
|
+
Bear in mind that, nowadays, this extension does not include any overrides in the frontend.
|
40
|
+
|
41
|
+
|
42
|
+
Testing
|
43
|
+
-------
|
44
|
+
|
45
|
+
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. The dummy app can be regenerated by using `rake test_app`.
|
46
|
+
|
47
|
+
```shell
|
48
|
+
bundle
|
49
|
+
bundle exec rake
|
50
|
+
```
|
51
|
+
|
52
|
+
When testing your applications integration with this extension you may use it's factories.
|
53
|
+
Simply add this require statement to your spec_helper:
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
require 'spree_product_documents/factories'
|
57
|
+
```
|
58
|
+
|
59
|
+
Copyright (c) 2015 Tania Rubio <taniarubiov@gmail.com>, released under the New BSD License
|
data/Rakefile
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
require 'spree/testing_support/extension_rake'
|
6
|
+
|
7
|
+
RSpec::Core::RakeTask.new
|
8
|
+
|
9
|
+
task :default do
|
10
|
+
if Dir["spec/dummy"].empty?
|
11
|
+
Rake::Task[:test_app].invoke
|
12
|
+
Dir.chdir("../../")
|
13
|
+
end
|
14
|
+
Rake::Task[:spec].invoke
|
15
|
+
end
|
16
|
+
|
17
|
+
desc 'Generates a dummy app for testing'
|
18
|
+
task :test_app do
|
19
|
+
ENV['LIB_NAME'] = 'spree_product_documents'
|
20
|
+
Rake::Task['extension:test_app'].invoke
|
21
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Spree
|
2
|
+
module Admin
|
3
|
+
class DocumentsController < ResourceController
|
4
|
+
before_action :load_data
|
5
|
+
|
6
|
+
create.before :set_viewable
|
7
|
+
update.before :set_viewable
|
8
|
+
|
9
|
+
def index
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def location_after_destroy
|
15
|
+
admin_product_documents_url(@product)
|
16
|
+
end
|
17
|
+
|
18
|
+
def location_after_save
|
19
|
+
admin_product_documents_url(@product)
|
20
|
+
end
|
21
|
+
|
22
|
+
def load_data
|
23
|
+
@product = Product.friendly.find(params[:product_id])
|
24
|
+
@variants = @product.variants.collect do |variant|
|
25
|
+
[variant.sku_and_options_text, variant.id]
|
26
|
+
end
|
27
|
+
@variants.insert(0, [Spree.t(:all), @product.master.id])
|
28
|
+
end
|
29
|
+
|
30
|
+
def set_viewable
|
31
|
+
@document.viewable_type = 'Spree::Variant'
|
32
|
+
@document.viewable_id = params[:document][:viewable_id]
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Spree
|
2
|
+
class Document < Asset
|
3
|
+
validate :no_attachment_errors
|
4
|
+
|
5
|
+
has_attached_file :attachment,
|
6
|
+
default_style: :product,
|
7
|
+
url: '/spree/products/:id/:basename.:extension',
|
8
|
+
path: ':rails_root/public/spree/products/:id/:basename.:extension',
|
9
|
+
convert_options: { all: '-strip -auto-orient -colorspace sRGB' }
|
10
|
+
|
11
|
+
ALLOWED_CONTENT_TYPES = Spree::Config[:allowed_document_content_types]
|
12
|
+
|
13
|
+
validates_attachment :attachment,
|
14
|
+
:presence => true,
|
15
|
+
:content_type => { :content_type => ALLOWED_CONTENT_TYPES}
|
16
|
+
|
17
|
+
before_post_process :skip_thumbnail_creation
|
18
|
+
|
19
|
+
|
20
|
+
# if there are errors from the plugin, then add a more meaningful message
|
21
|
+
def no_attachment_errors
|
22
|
+
unless attachment.errors.empty?
|
23
|
+
# uncomment this to get rid of the less-than-useful interim messages
|
24
|
+
# errors.clear
|
25
|
+
errors.add :attachment, "Paperclip returned errors for file '#{attachment_file_name}' - check ImageMagick installation or image source file."
|
26
|
+
false
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
def skip_thumbnail_creation
|
32
|
+
return false if ALLOWED_CONTENT_TYPES.include?(attachment_content_type)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Deface::Override.new(:virtual_path => "spree/admin/shared/_product_tabs",
|
2
|
+
:name => "admin_product_document_tab",
|
3
|
+
:original => '10edf2223cf4fe1ebcd351beb56472f5b623ea6b',
|
4
|
+
:insert_after => "ul[data-hook=admin_product_tabs] > li:first",
|
5
|
+
:text => "
|
6
|
+
<%= content_tag :li, :class => ('active' if current == 'Documents') do %>
|
7
|
+
<%= link_to_with_icon 'file', I18n.t('spree.admin.tab.documents'), admin_product_documents_path(@product) %>
|
8
|
+
<% end if can?(:admin, Spree::Document) %>
|
9
|
+
")
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<div data-hook="admin_document_form_fields" class="row">
|
2
|
+
<div class="col-md-6">
|
3
|
+
<div data-hook="file" class="form-group">
|
4
|
+
<%= f.label :attachment, Spree.t(:filename) %>
|
5
|
+
<%= f.file_field :attachment %>
|
6
|
+
</div>
|
7
|
+
<div data-hook="variant" class="form-group">
|
8
|
+
<%= f.label :viewable_id, Spree::Variant.model_name.human %>
|
9
|
+
<%= f.select :viewable_id, @variants, {}, {:class => 'select2'} %>
|
10
|
+
</div>
|
11
|
+
</div>
|
12
|
+
<div data-hook="alt_text" class="col-md-6">
|
13
|
+
<div class="form-group">
|
14
|
+
<%= f.label :alt, Spree.t(:alt_text) %>
|
15
|
+
<%= f.text_area :alt, :rows => 4, :class => 'form-control' %>
|
16
|
+
</div>
|
17
|
+
</div>
|
18
|
+
</div>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<%= render :partial => 'spree/admin/shared/sub_menu/product' %>
|
2
|
+
|
3
|
+
<%= render :partial => 'spree/admin/shared/product_tabs', :locals => { :current => 'Documents' } %>
|
4
|
+
|
5
|
+
<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @document } %>
|
6
|
+
|
7
|
+
<% content_for :page_actions do %>
|
8
|
+
<%= button_link_to Spree.t(:back_to_documents_list), admin_product_documents_url(@product), :icon => 'arrow-left' %>
|
9
|
+
<% end %>
|
10
|
+
|
11
|
+
<%= form_for [:admin, @product, @document], :html => { :multipart => true } do |f| %>
|
12
|
+
<fieldset data-hook="edit_document">
|
13
|
+
<legend align="center"><%= @document.attachment_file_name%></legend>
|
14
|
+
<div data-hook="thumbnail" class="field alpha three columns align-center">
|
15
|
+
<%= f.label Spree.t(:document) %><br>
|
16
|
+
<%= link_to @document.attachment.url, @document.attachment.url(:product) %>
|
17
|
+
</div>
|
18
|
+
<div class="nine columns omega">
|
19
|
+
<%= render :partial => 'form', :locals => { :f => f } %>
|
20
|
+
</div>
|
21
|
+
<div class="clear"></div>
|
22
|
+
<div class="form-buttons filter-actions actions" data-hook="buttons">
|
23
|
+
<%= button Spree.t('actions.update'), 'refresh' %>
|
24
|
+
<span class="or"><%= Spree.t(:or) %></span>
|
25
|
+
<%= link_to Spree.t('actions.cancel'), admin_product_documents_url(@product), :id => 'cancel_link', :class => 'button' %>
|
26
|
+
</div>
|
27
|
+
</fieldset>
|
28
|
+
<% end %>
|
@@ -0,0 +1,58 @@
|
|
1
|
+
<%= render :partial => 'spree/admin/shared/sub_menu/product' %>
|
2
|
+
|
3
|
+
<%= render :partial => 'spree/admin/shared/product_tabs', :locals => {:current => 'Documents'} %>
|
4
|
+
|
5
|
+
<% content_for :page_actions do %>
|
6
|
+
<%= button_link_to(Spree.t(:new_document), spree.new_admin_product_document_url(@product), { class: "btn-success", icon: 'add', id: 'new_document_link' }) if can? :create, Spree::Document %>
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<div id="documents" data-hook></div>
|
10
|
+
|
11
|
+
<% unless @product.documents.any? || @product.variant_documents.any? %>
|
12
|
+
<div class="alert alert-warning">
|
13
|
+
<%= Spree.t(:no_resource_found, resource: plural_resource_name(Spree::Document)) %>.
|
14
|
+
</div>
|
15
|
+
<% else %>
|
16
|
+
<table class="table sortable" data-hook="documents_table" data-sortable-link="<%= update_positions_admin_product_documents_url(@product) %>">
|
17
|
+
<colgroup>
|
18
|
+
<col style="width: 5%">
|
19
|
+
<col style="width: 25%">
|
20
|
+
<% if @product.has_variants? %>
|
21
|
+
<col style="width: 25%">
|
22
|
+
<% end %>
|
23
|
+
<col style="width: 30%">
|
24
|
+
<col style="width: 15%">
|
25
|
+
</colgroup>
|
26
|
+
<thead>
|
27
|
+
<tr data-hook="documents_header">
|
28
|
+
<th colspan="2"><%= Spree.t(:document_url) %></th>
|
29
|
+
<% if @product.has_variants? %>
|
30
|
+
<th><%= Spree::Variant.model_name.human %></th>
|
31
|
+
<% end %>
|
32
|
+
<th><%= Spree.t(:alt_text) %></th>
|
33
|
+
<th class="actions"></th>
|
34
|
+
</tr>
|
35
|
+
</thead>
|
36
|
+
|
37
|
+
<tbody>
|
38
|
+
<% (@product.variant_documents).each do |document| %>
|
39
|
+
<tr id="<%= spree_dom_id document %>" data-hook="documents_row" class="<%= cycle('odd', 'even')%>">
|
40
|
+
<td class="no-border">
|
41
|
+
<span class="handle"></span>
|
42
|
+
</td>
|
43
|
+
<td>
|
44
|
+
<%= link_to document.attachment_file_name, document.attachment.url(:product) %>
|
45
|
+
</td>
|
46
|
+
<% if @product.has_variants? %>
|
47
|
+
<td><%= options_text_for(document) %></td>
|
48
|
+
<% end %>
|
49
|
+
<td><%= document.alt %></td>
|
50
|
+
<td class="actions actions-2 text-right">
|
51
|
+
<%= link_to_with_icon('edit', Spree.t(:edit), spree.edit_admin_product_document_url(@product, document), class: 'btn btn-primary btn-sm', no_text: true, data: { action: 'edit' }) if can? :edit, document %>
|
52
|
+
<%= link_to_delete document, { :url => admin_product_document_url(@product, document), :no_text => true } if can? :destroy, document %>
|
53
|
+
</td>
|
54
|
+
</tr>
|
55
|
+
<% end %>
|
56
|
+
</tbody>
|
57
|
+
</table>
|
58
|
+
<% end %>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<%= render :partial => 'spree/admin/shared/sub_menu/product' %>
|
2
|
+
|
3
|
+
<%= render :partial => 'spree/admin/shared/product_tabs', :locals => { :current => 'Documents' } %>
|
4
|
+
|
5
|
+
<%= form_for [:admin, @product, @document], :html => { :multipart => true } do |f| %>
|
6
|
+
<fieldset data-hook="new_document">
|
7
|
+
<legend align="center"><%= Spree.t(:new_document) %></legend>
|
8
|
+
|
9
|
+
<%= render :partial => 'form', :locals => { :f => f } %>
|
10
|
+
|
11
|
+
<div class="form-actions" data-hook="buttons">
|
12
|
+
<%= button Spree.t('actions.update'), 'refresh' %>
|
13
|
+
<span class="or"><%= Spree.t(:or) %></span>
|
14
|
+
<%= button_link_to Spree.t('actions.cancel'), spree.admin_product_documents_url(@product), icon: 'delete', id: 'cancel_link' %>
|
15
|
+
</div>
|
16
|
+
</fieldset>
|
17
|
+
<% end %>
|
data/bin/rails
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
2
|
+
|
3
|
+
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
4
|
+
ENGINE_PATH = File.expand_path('../../lib/spree_product_documents/engine', __FILE__)
|
5
|
+
|
6
|
+
require 'rails/all'
|
7
|
+
require 'rails/engine/commands'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
en:
|
2
|
+
activerecord:
|
3
|
+
models:
|
4
|
+
spree/document:
|
5
|
+
one: Document
|
6
|
+
other: Documents
|
7
|
+
attributes:
|
8
|
+
spree/document:
|
9
|
+
attachment_content_type: Document type
|
10
|
+
attachment: Document
|
11
|
+
spree:
|
12
|
+
document: Document
|
13
|
+
document_url: Document URL
|
14
|
+
back_to_documents_list: Back to documents list
|
15
|
+
no_documents_found: No documents found
|
16
|
+
new_document: New document
|
17
|
+
admin:
|
18
|
+
tab:
|
19
|
+
documents: Documents
|
@@ -0,0 +1,19 @@
|
|
1
|
+
es:
|
2
|
+
activerecord:
|
3
|
+
models:
|
4
|
+
spree/document:
|
5
|
+
one: Documento
|
6
|
+
other: Documentos
|
7
|
+
attributes:
|
8
|
+
spree/document:
|
9
|
+
attachment_content_type: Tipo de documento
|
10
|
+
attachment: Documento
|
11
|
+
spree:
|
12
|
+
document: Documento
|
13
|
+
document_url: Enlace al documento
|
14
|
+
back_to_documents_list: Volver a la lista de documentos
|
15
|
+
no_documents_found: No se han encontrado documentos
|
16
|
+
new_document: Nuevo documento
|
17
|
+
admin:
|
18
|
+
tab:
|
19
|
+
documents: Documentos
|
data/config/routes.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
module SpreeProductDocuments
|
2
|
+
class Engine < Rails::Engine
|
3
|
+
require 'spree/core'
|
4
|
+
isolate_namespace Spree
|
5
|
+
engine_name 'spree_product_documents'
|
6
|
+
|
7
|
+
# use rspec for tests
|
8
|
+
config.generators do |g|
|
9
|
+
g.test_framework :rspec
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.activate
|
13
|
+
Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
|
14
|
+
Rails.configuration.cache_classes ? require(c) : load(c)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
config.to_prepare &method(:activate).to_proc
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
# Define your Spree extensions Factories within this file to enable applications, and other extensions to use and override them.
|
3
|
+
#
|
4
|
+
# Example adding this to your spec_helper will load these Factories for use:
|
5
|
+
# require 'spree_product_documents/factories'
|
6
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
# Run Coverage report
|
2
|
+
require 'simplecov'
|
3
|
+
SimpleCov.start do
|
4
|
+
add_filter 'spec/dummy'
|
5
|
+
add_group 'Controllers', 'app/controllers'
|
6
|
+
add_group 'Helpers', 'app/helpers'
|
7
|
+
add_group 'Mailers', 'app/mailers'
|
8
|
+
add_group 'Models', 'app/models'
|
9
|
+
add_group 'Views', 'app/views'
|
10
|
+
add_group 'Libraries', 'lib'
|
11
|
+
end
|
12
|
+
|
13
|
+
# Configure Rails Environment
|
14
|
+
ENV['RAILS_ENV'] = 'test'
|
15
|
+
|
16
|
+
require File.expand_path('../dummy/config/environment.rb', __FILE__)
|
17
|
+
|
18
|
+
require 'rspec/rails'
|
19
|
+
require 'database_cleaner'
|
20
|
+
require 'ffaker'
|
21
|
+
|
22
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
23
|
+
# in spec/support/ and its subdirectories.
|
24
|
+
Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
|
25
|
+
|
26
|
+
# Requires factories and other useful helpers defined in spree_core.
|
27
|
+
require 'spree/testing_support/authorization_helpers'
|
28
|
+
require 'spree/testing_support/capybara_ext'
|
29
|
+
require 'spree/testing_support/controller_requests'
|
30
|
+
require 'spree/testing_support/factories'
|
31
|
+
require 'spree/testing_support/url_helpers'
|
32
|
+
|
33
|
+
# Requires factories defined in lib/spree_product_documents/factories.rb
|
34
|
+
require 'spree_product_documents/factories'
|
35
|
+
|
36
|
+
RSpec.configure do |config|
|
37
|
+
config.include FactoryGirl::Syntax::Methods
|
38
|
+
|
39
|
+
# Infer an example group's spec type from the file location.
|
40
|
+
config.infer_spec_type_from_file_location!
|
41
|
+
|
42
|
+
# == URL Helpers
|
43
|
+
#
|
44
|
+
# Allows access to Spree's routes in specs:
|
45
|
+
#
|
46
|
+
# visit spree.admin_path
|
47
|
+
# current_path.should eql(spree.products_path)
|
48
|
+
config.include Spree::TestingSupport::UrlHelpers
|
49
|
+
|
50
|
+
# == Mock Framework
|
51
|
+
#
|
52
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
53
|
+
#
|
54
|
+
# config.mock_with :mocha
|
55
|
+
# config.mock_with :flexmock
|
56
|
+
# config.mock_with :rr
|
57
|
+
config.mock_with :rspec
|
58
|
+
config.color = true
|
59
|
+
|
60
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
61
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
62
|
+
|
63
|
+
# Capybara javascript drivers require transactional fixtures set to false, and we use DatabaseCleaner
|
64
|
+
# to cleanup after each test instead. Without transactional fixtures set to false the records created
|
65
|
+
# to setup a test will be unavailable to the browser, which runs under a separate server instance.
|
66
|
+
config.use_transactional_fixtures = false
|
67
|
+
|
68
|
+
# Ensure Suite is set to use transactions for speed.
|
69
|
+
config.before :suite do
|
70
|
+
DatabaseCleaner.strategy = :transaction
|
71
|
+
DatabaseCleaner.clean_with :truncation
|
72
|
+
end
|
73
|
+
|
74
|
+
# Before each spec check if it is a Javascript test and switch between using database transactions or not where necessary.
|
75
|
+
config.before :each do
|
76
|
+
DatabaseCleaner.strategy = RSpec.current_example.metadata[:js] ? :truncation : :transaction
|
77
|
+
DatabaseCleaner.start
|
78
|
+
end
|
79
|
+
|
80
|
+
# After each spec clean the database.
|
81
|
+
config.after :each do
|
82
|
+
DatabaseCleaner.clean
|
83
|
+
end
|
84
|
+
|
85
|
+
config.fail_fast = ENV['FAIL_FAST'] || false
|
86
|
+
config.order = "random"
|
87
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
Gem::Specification.new do |s|
|
3
|
+
s.platform = Gem::Platform::RUBY
|
4
|
+
s.name = 'spree_product_documents'
|
5
|
+
s.version = '3.0.0.1'
|
6
|
+
s.summary = 'Add documents assets to products'
|
7
|
+
s.description = 'Currently supports PDF and ZIP files'
|
8
|
+
s.required_ruby_version = '>= 1.9.3'
|
9
|
+
|
10
|
+
s.author = 'Tania Rubio'
|
11
|
+
s.email = 'taniarubiov@gmail.com'
|
12
|
+
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
+
s.require_path = 'lib'
|
16
|
+
s.requirements << 'none'
|
17
|
+
|
18
|
+
s.add_dependency 'spree_core', '~> 3.0.0'
|
19
|
+
s.add_dependency 'spree_backend', '~> 3.0.0'
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: spree_product_documents
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tania Rubio
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: spree_core
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: spree_backend
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.0.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.0.0
|
41
|
+
description: Currently supports PDF and ZIP files
|
42
|
+
email: taniarubiov@gmail.com
|
43
|
+
executables: []
|
44
|
+
extensions: []
|
45
|
+
extra_rdoc_files: []
|
46
|
+
files:
|
47
|
+
- Gemfile
|
48
|
+
- LICENSE
|
49
|
+
- README.md
|
50
|
+
- Rakefile
|
51
|
+
- app/controllers/spree/admin/documents_controller.rb
|
52
|
+
- app/models/spree/app_configuration_decorator.rb
|
53
|
+
- app/models/spree/document.rb
|
54
|
+
- app/models/spree/product_decorator.rb
|
55
|
+
- app/models/spree/variant_decorator.rb
|
56
|
+
- app/overrides/product_document_tab.rb
|
57
|
+
- app/views/spree/admin/documents/_form.html.erb
|
58
|
+
- app/views/spree/admin/documents/edit.html.erb
|
59
|
+
- app/views/spree/admin/documents/index.html.erb
|
60
|
+
- app/views/spree/admin/documents/new.html.erb
|
61
|
+
- bin/rails
|
62
|
+
- config/locales/en.yml
|
63
|
+
- config/locales/es.yml
|
64
|
+
- config/routes.rb
|
65
|
+
- lib/spree_product_documents.rb
|
66
|
+
- lib/spree_product_documents/engine.rb
|
67
|
+
- lib/spree_product_documents/factories.rb
|
68
|
+
- spec/spec_helper.rb
|
69
|
+
- spree_product_documents.gemspec
|
70
|
+
homepage:
|
71
|
+
licenses: []
|
72
|
+
metadata: {}
|
73
|
+
post_install_message:
|
74
|
+
rdoc_options: []
|
75
|
+
require_paths:
|
76
|
+
- lib
|
77
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 1.9.3
|
82
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
|
+
requirements:
|
84
|
+
- - ">="
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
requirements:
|
88
|
+
- none
|
89
|
+
rubyforge_project:
|
90
|
+
rubygems_version: 2.2.2
|
91
|
+
signing_key:
|
92
|
+
specification_version: 4
|
93
|
+
summary: Add documents assets to products
|
94
|
+
test_files:
|
95
|
+
- spec/spec_helper.rb
|