solidus_asset_variant_options 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.rspec +1 -0
- data/Gemfile +10 -0
- data/LICENSE +26 -0
- data/README.md +55 -0
- data/Rakefile +21 -0
- data/app/controllers/spree/admin/images_controller_decorator.rb +14 -0
- data/app/helpers/spree/admin/images_helper_decorator.rb +11 -0
- data/app/models/spree/image_decorator.rb +10 -0
- data/app/models/spree/product_decorator.rb +7 -0
- data/app/models/spree/variant_decorator.rb +4 -0
- data/app/models/spree/variant_image.rb +13 -0
- data/app/overrides/spree/admin/images/_form/replace_variant_select_with_multi_select.html.erb.deface +15 -0
- data/app/overrides/spree/products/_thumbnails/replace_thumbnail_classes_with_classes_including_variant_ids.html.erb.deface +20 -0
- data/bin/rails +7 -0
- data/circle.yml +6 -0
- data/config/locales/en.yml +5 -0
- data/config/routes.rb +3 -0
- data/db/migrate/20131212185245_create_spree_assets_variants.rb +8 -0
- data/db/migrate/20140115160024_add_id_to_spree_assets_variants.rb +6 -0
- data/db/migrate/20140411185638_add_position_to_spree_assets_variants.rb +5 -0
- data/lib/generators/solidus_asset_variant_options/install/install_generator.rb +20 -0
- data/lib/solidus_asset_variant_options.rb +1 -0
- data/lib/spree_asset_variant_options.rb +2 -0
- data/lib/spree_asset_variant_options/engine.rb +22 -0
- data/lib/spree_asset_variant_options/factories.rb +2 -0
- data/solidus_asset_variant_options.gemspec +31 -0
- data/spec/helpers/spree/admin/images_helper_decorator_spec.rb +24 -0
- data/spec/models/spree/image_decorator_spec.rb +23 -0
- data/spec/models/spree/product_decorator_spec.rb +21 -0
- data/spec/models/spree/variant_decorator_spec.rb +38 -0
- data/spec/spec_helper.rb +60 -0
- data/spec/support/images/green.jpeg +0 -0
- metadata +215 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ee127972622ae9236a5f62a6ee8e8c95e6c8634b
|
4
|
+
data.tar.gz: 7ecf27a0bc64d7354c4959d7caf33d5dddb2efa3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1caa57e9ecb6a0dcf2e563e5369facbf420702d9e73726b7d89741a50d32f09c0ca7ec25061545adb837218bb052650349116e427090dcaafbb40a8d8f980942
|
7
|
+
data.tar.gz: 41e1f69f073159c7fe059e36a1374a295f4d40df45cc2de2e05fdac127741ca309af86be2f44f05231a4a9429a4d8ab5bc07154fb346ac618c0322b321a7ef87
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
Copyright (c) 2013 Bonobos, Inc.
|
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,55 @@
|
|
1
|
+
Solidus Asset Variant Options
|
2
|
+
=============================
|
3
|
+
|
4
|
+
Adds the ability for admins to use the same image asset for multiple variants.
|
5
|
+
Originally a fork of [jpdesigndev/spree_asset_variant_options](https://github.com/jpdesigndev/spree_asset_variant_options).
|
6
|
+
|
7
|
+
[](https://circleci.com/gh/solidusio/solidus_asset_variant_options/tree/master)
|
8
|
+
|
9
|
+
Installation
|
10
|
+
------------
|
11
|
+
|
12
|
+
Add solidus_asset_variant_options to your Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem "solidus_asset_variant_options"
|
16
|
+
```
|
17
|
+
|
18
|
+
Bundle your dependencies and run the installation generator:
|
19
|
+
|
20
|
+
```shell
|
21
|
+
bundle
|
22
|
+
bundle exec rails g solidus_asset_variant_options:install
|
23
|
+
```
|
24
|
+
|
25
|
+
Since this extension changes the way images are associated, if you've got any
|
26
|
+
existing ones you'll need to add the association back in. This can be
|
27
|
+
accomplished by running:
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
Spree::Image.find_each do |image|
|
31
|
+
if image.viewable_type == "Spree::Variant"
|
32
|
+
image.variants << image.viewable
|
33
|
+
end
|
34
|
+
end
|
35
|
+
```
|
36
|
+
|
37
|
+
Afterwards it is recommended to consolidate the images in the admin.
|
38
|
+
|
39
|
+
Testing
|
40
|
+
-------
|
41
|
+
|
42
|
+
First bundle your dependencies, then run `rake`. `rake` will default to
|
43
|
+
building the dummy app if it does not exist, then it will run specs. The dummy
|
44
|
+
app can be regenerated by using `rake test_app`.
|
45
|
+
|
46
|
+
```shell
|
47
|
+
bundle exec rake
|
48
|
+
```
|
49
|
+
|
50
|
+
When testing your applications integration with this extension you may use it's factories.
|
51
|
+
Simply add this require statement to your spec_helper:
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
require "spree_asset_variant_options/factories"
|
55
|
+
```
|
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"] = "solidus_asset_variant_options"
|
20
|
+
Rake::Task["extension:test_app"].invoke
|
21
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
Spree::Admin::ImagesController.class_eval do
|
2
|
+
create.before :set_variants
|
3
|
+
update.before :set_variants
|
4
|
+
|
5
|
+
private
|
6
|
+
|
7
|
+
def set_variants
|
8
|
+
@image.variant_ids = viewable_ids
|
9
|
+
end
|
10
|
+
|
11
|
+
def viewable_ids
|
12
|
+
params[:image][:viewable_ids].reject(&:blank?)
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
Spree::Admin::ImagesHelper.class_eval do
|
2
|
+
alias :original_options_text_for :options_text_for
|
3
|
+
|
4
|
+
def options_text_for image
|
5
|
+
if image.variants.any?
|
6
|
+
image.variants.map { |variant| variant.sku_and_options_text }.join('; ')
|
7
|
+
else
|
8
|
+
original_options_text_for image
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
Spree::Image.class_eval do
|
2
|
+
attr_accessor :viewable_ids
|
3
|
+
|
4
|
+
has_many :variant_images, class_name: '::Spree::VariantImage'
|
5
|
+
has_many :variants, through: :variant_images
|
6
|
+
|
7
|
+
def variant_html_classes
|
8
|
+
variant_ids.map { |variant| "tmb-#{variant}"}.join(" ")
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Spree
|
2
|
+
class VariantImage < ActiveRecord::Base
|
3
|
+
self.table_name = :spree_assets_variants
|
4
|
+
belongs_to :image, class_name: 'Spree::Image'
|
5
|
+
belongs_to :variant, class_name: 'Spree::Variant', touch: true
|
6
|
+
|
7
|
+
scope :with_position, -> { where("position IS NOT NULL") }
|
8
|
+
default_scope -> { order("#{self.table_name}.position") }
|
9
|
+
|
10
|
+
# on create only just in case there are some lingering in the system
|
11
|
+
validates_uniqueness_of :image_id, scope: :variant_id, on: :create
|
12
|
+
end
|
13
|
+
end
|
data/app/overrides/spree/admin/images/_form/replace_variant_select_with_multi_select.html.erb.deface
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
<!-- replace 'erb[loud]:contains("f.select :viewable_id")' -->
|
2
|
+
<%= f.hidden_field :viewable_id, value: 1 %>
|
3
|
+
<%= f.select :viewable_ids, options_for_select(@variants, @image.variant_ids), {}, {multiple: true, :class => 'select2 fullwidth'} %>
|
4
|
+
|
5
|
+
<%# Keeping this script tag in the view for now. %>
|
6
|
+
<script>
|
7
|
+
$('#image_viewable_ids')
|
8
|
+
.on('change', function() {
|
9
|
+
$('#image_viewable_id').val($(this).val()[0]);
|
10
|
+
})
|
11
|
+
.select2({
|
12
|
+
allowClear: true,
|
13
|
+
dropdownAutoWidth: true
|
14
|
+
});
|
15
|
+
</script>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<!-- replace '#product-thumbnails' -->
|
2
|
+
<%# no need for thumbnails unless there is more than one image %>
|
3
|
+
<% if (@product.images + @product.variant_images).uniq.size > 1 %>
|
4
|
+
<ul id="product-thumbnails" class="thumbnails inline" data-hook>
|
5
|
+
<% @product.images.each do |i| %>
|
6
|
+
<li class='tmb-all <%= i.variant_html_classes %>'>
|
7
|
+
<%= link_to(image_tag(i.attachment.url(:mini)), i.attachment.url(:product)) %>
|
8
|
+
</li>
|
9
|
+
<% end %>
|
10
|
+
|
11
|
+
<% if @product.has_variants? %>
|
12
|
+
<% @product.variant_images.each do |i| %>
|
13
|
+
<% next if @product.images.include?(i) %>
|
14
|
+
<li class='vtmb <%= i.variant_html_classes %>'>
|
15
|
+
<%= link_to(image_tag(i.attachment.url(:mini)), i.attachment.url(:product)) %>
|
16
|
+
</li>
|
17
|
+
<% end %>
|
18
|
+
<% end %>
|
19
|
+
</ul>
|
20
|
+
<% 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_asset_variant_options/engine', __FILE__)
|
5
|
+
|
6
|
+
require 'rails/all'
|
7
|
+
require 'rails/engine/commands'
|
data/circle.yml
ADDED
data/config/routes.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
module SolidusAssetVariantOptions
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
class_option :auto_run_migrations, type: :boolean, default: false
|
5
|
+
|
6
|
+
def add_migrations
|
7
|
+
run 'bundle exec rake railties:install:migrations FROM=solidus_asset_variant_options'
|
8
|
+
end
|
9
|
+
|
10
|
+
def run_migrations
|
11
|
+
run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask 'Would you like to run the migrations now? [Y/n]')
|
12
|
+
if run_migrations
|
13
|
+
run 'bundle exec rake db:migrate'
|
14
|
+
else
|
15
|
+
puts 'Skipping rake db:migrate, don\'t forget to run it!'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "spree_asset_variant_options"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module SpreeAssetVariantOptions
|
2
|
+
class Engine < Rails::Engine
|
3
|
+
require "spree/core"
|
4
|
+
isolate_namespace Spree
|
5
|
+
engine_name "solidus_asset_variant_options"
|
6
|
+
|
7
|
+
config.autoload_paths += %W(#{config.root}/lib)
|
8
|
+
|
9
|
+
# use rspec for tests
|
10
|
+
config.generators do |g|
|
11
|
+
g.test_framework :rspec
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.activate
|
15
|
+
Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator*.rb")) do |c|
|
16
|
+
Rails.configuration.cache_classes ? require(c) : load(c)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
config.to_prepare &method(:activate).to_proc
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.platform = Gem::Platform::RUBY
|
5
|
+
s.name = "solidus_asset_variant_options"
|
6
|
+
s.version = "1.0.0"
|
7
|
+
s.summary = "Allow an image to belong to multiple Spree::Variant models"
|
8
|
+
s.description =
|
9
|
+
"Spree makes it tedious to upload the same image across" \
|
10
|
+
"multiple variants. This gem solves the problem."
|
11
|
+
s.required_ruby_version = ">= 2.1"
|
12
|
+
|
13
|
+
s.author = "Solidus Team"
|
14
|
+
s.email = "contact@solidus.io"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.require_path = "lib"
|
19
|
+
s.requirements << "none"
|
20
|
+
|
21
|
+
s.add_dependency "solidus", [">= 1.0.0", "< 1.2.0"]
|
22
|
+
|
23
|
+
s.add_development_dependency "rspec-rails", "~> 2.13"
|
24
|
+
s.add_development_dependency "simplecov"
|
25
|
+
s.add_development_dependency "sqlite3"
|
26
|
+
s.add_development_dependency "sass-rails"
|
27
|
+
s.add_development_dependency "coffee-rails"
|
28
|
+
s.add_development_dependency "database_cleaner"
|
29
|
+
s.add_development_dependency "factory_girl"
|
30
|
+
s.add_development_dependency "ffaker"
|
31
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spree::Admin::ImagesHelper do
|
4
|
+
let(:image) { create :image }
|
5
|
+
let(:variant_small) { create :base_variant }
|
6
|
+
let(:variant_big) { create :base_variant }
|
7
|
+
|
8
|
+
before do
|
9
|
+
image.variant_ids = [variant_small.id, variant_big.id]
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#options_text_for' do
|
13
|
+
before do
|
14
|
+
viewable = double('viewable')
|
15
|
+
allow(viewable).to receive(:is_master?) { false }
|
16
|
+
allow(image).to receive(:viewable) { viewable }
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'returns list of classes for variants' do
|
20
|
+
skip
|
21
|
+
expect(options_text_for(image)).to eq("tmb-#{variant_small.id} tmb-#{variant_big.id}")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spree::Image do
|
4
|
+
let(:image) { create :image }
|
5
|
+
let(:variant_small) { create :base_variant }
|
6
|
+
let(:variant_big) { create :base_variant }
|
7
|
+
|
8
|
+
before do
|
9
|
+
image.variant_ids = [variant_small.id, variant_big.id]
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#variant_html_classes' do
|
13
|
+
it 'returns list of classes for variants' do
|
14
|
+
expect(image.variant_html_classes).to eq("tmb-#{variant_small.id} tmb-#{variant_big.id}")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe 'variant relationship' do
|
19
|
+
it "should have many variants" do
|
20
|
+
expect(image.variants.size).to eq(2)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spree::Product do
|
4
|
+
let(:product) { create :product }
|
5
|
+
let(:variant) { create :base_variant, product: product }
|
6
|
+
let(:image_green) { create :image, viewable_type: 'Spree::Variant' }
|
7
|
+
let(:image_blue) { create :image, viewable_type: 'Spree::Variant' }
|
8
|
+
|
9
|
+
before do
|
10
|
+
variant.images << image_green
|
11
|
+
variant.images << image_blue
|
12
|
+
variant.save
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#variant_images' do
|
16
|
+
it 'returns unique list of variant images' do
|
17
|
+
expect(product.reload.variant_images.size).to eq(2)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Spree::Variant do
|
4
|
+
let(:variant) { create :base_variant }
|
5
|
+
let(:image_green) { create :image }
|
6
|
+
let(:image_blue) { create :image }
|
7
|
+
|
8
|
+
before do
|
9
|
+
variant.images << image_green
|
10
|
+
variant.images << image_blue
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'variant relationship' do
|
14
|
+
it "should have many images" do
|
15
|
+
expect(variant.images.size).to eq(2)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe 'images are ordered by variant image positions' do
|
20
|
+
it "returns the images ordered by variant image position" do
|
21
|
+
variant.variant_images.where(image: image_blue).first.update_attributes(position: 0)
|
22
|
+
variant.variant_images.where(image: image_green).first.update_attributes(position: 1)
|
23
|
+
|
24
|
+
expect(variant.images.first).to eq image_blue
|
25
|
+
expect(variant.images.last).to eq image_green
|
26
|
+
|
27
|
+
variant.variant_images.where(image: image_blue).first.update_attributes(position: 1)
|
28
|
+
variant.variant_images.where(image: image_green).first.update_attributes(position: 0)
|
29
|
+
|
30
|
+
expect(variant.images.first).to eq image_green
|
31
|
+
expect(variant.images.last).to eq image_blue
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
it "cannot associate itself to the same image twice" do
|
36
|
+
expect { variant.images << image_green }.to raise_error ActiveRecord::RecordInvalid, /Image has already been taken/
|
37
|
+
end
|
38
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,60 @@
|
|
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
|
+
|
20
|
+
require "database_cleaner"
|
21
|
+
require "ffaker"
|
22
|
+
|
23
|
+
require "spree/testing_support/factories"
|
24
|
+
require "spree_asset_variant_options/factories"
|
25
|
+
|
26
|
+
Dir[File.join(File.dirname(__FILE__), "support/**/*.rb")].each { |f| require f }
|
27
|
+
|
28
|
+
RSpec.configure do |config|
|
29
|
+
config.infer_spec_type_from_file_location!
|
30
|
+
config.mock_with :rspec
|
31
|
+
|
32
|
+
config.color = true
|
33
|
+
config.order = "random"
|
34
|
+
|
35
|
+
config.expose_current_running_example_as :example
|
36
|
+
config.fail_fast = ENV["FAIL_FAST"] || false
|
37
|
+
|
38
|
+
config.filter_run focus: true
|
39
|
+
config.run_all_when_everything_filtered = true
|
40
|
+
config.use_transactional_fixtures = false
|
41
|
+
|
42
|
+
config.include FactoryGirl::Syntax::Methods
|
43
|
+
|
44
|
+
# Ensure Suite is set to use transactions for speed.
|
45
|
+
config.before :suite do
|
46
|
+
DatabaseCleaner.strategy = :transaction
|
47
|
+
DatabaseCleaner.clean_with :truncation
|
48
|
+
end
|
49
|
+
|
50
|
+
# Before each spec check if it is a Javascript test and switch between using database transactions or not where necessary.
|
51
|
+
config.before :each do |example|
|
52
|
+
DatabaseCleaner.strategy = example.metadata[:js] ? :truncation : :transaction
|
53
|
+
DatabaseCleaner.start
|
54
|
+
end
|
55
|
+
|
56
|
+
# After each spec clean the database.
|
57
|
+
config.after :each do
|
58
|
+
DatabaseCleaner.clean
|
59
|
+
end
|
60
|
+
end
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,215 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: solidus_asset_variant_options
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Solidus Team
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: solidus
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.0.0
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.2.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.0.0
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.2.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rspec-rails
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '2.13'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '2.13'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: simplecov
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: sqlite3
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: sass-rails
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: coffee-rails
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: database_cleaner
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: factory_girl
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '0'
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: ffaker
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
type: :development
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
description: Spree makes it tedious to upload the same image acrossmultiple variants.
|
146
|
+
This gem solves the problem.
|
147
|
+
email: contact@solidus.io
|
148
|
+
executables: []
|
149
|
+
extensions: []
|
150
|
+
extra_rdoc_files: []
|
151
|
+
files:
|
152
|
+
- ".gitignore"
|
153
|
+
- ".rspec"
|
154
|
+
- Gemfile
|
155
|
+
- LICENSE
|
156
|
+
- README.md
|
157
|
+
- Rakefile
|
158
|
+
- app/controllers/spree/admin/images_controller_decorator.rb
|
159
|
+
- app/helpers/spree/admin/images_helper_decorator.rb
|
160
|
+
- app/models/spree/image_decorator.rb
|
161
|
+
- app/models/spree/product_decorator.rb
|
162
|
+
- app/models/spree/variant_decorator.rb
|
163
|
+
- app/models/spree/variant_image.rb
|
164
|
+
- app/overrides/spree/admin/images/_form/replace_variant_select_with_multi_select.html.erb.deface
|
165
|
+
- app/overrides/spree/products/_thumbnails/replace_thumbnail_classes_with_classes_including_variant_ids.html.erb.deface
|
166
|
+
- bin/rails
|
167
|
+
- circle.yml
|
168
|
+
- config/locales/en.yml
|
169
|
+
- config/routes.rb
|
170
|
+
- db/migrate/20131212185245_create_spree_assets_variants.rb
|
171
|
+
- db/migrate/20140115160024_add_id_to_spree_assets_variants.rb
|
172
|
+
- db/migrate/20140411185638_add_position_to_spree_assets_variants.rb
|
173
|
+
- lib/generators/solidus_asset_variant_options/install/install_generator.rb
|
174
|
+
- lib/solidus_asset_variant_options.rb
|
175
|
+
- lib/spree_asset_variant_options.rb
|
176
|
+
- lib/spree_asset_variant_options/engine.rb
|
177
|
+
- lib/spree_asset_variant_options/factories.rb
|
178
|
+
- solidus_asset_variant_options.gemspec
|
179
|
+
- spec/helpers/spree/admin/images_helper_decorator_spec.rb
|
180
|
+
- spec/models/spree/image_decorator_spec.rb
|
181
|
+
- spec/models/spree/product_decorator_spec.rb
|
182
|
+
- spec/models/spree/variant_decorator_spec.rb
|
183
|
+
- spec/spec_helper.rb
|
184
|
+
- spec/support/images/green.jpeg
|
185
|
+
homepage:
|
186
|
+
licenses: []
|
187
|
+
metadata: {}
|
188
|
+
post_install_message:
|
189
|
+
rdoc_options: []
|
190
|
+
require_paths:
|
191
|
+
- lib
|
192
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
193
|
+
requirements:
|
194
|
+
- - ">="
|
195
|
+
- !ruby/object:Gem::Version
|
196
|
+
version: '2.1'
|
197
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
202
|
+
requirements:
|
203
|
+
- none
|
204
|
+
rubyforge_project:
|
205
|
+
rubygems_version: 2.2.5
|
206
|
+
signing_key:
|
207
|
+
specification_version: 4
|
208
|
+
summary: Allow an image to belong to multiple Spree::Variant models
|
209
|
+
test_files:
|
210
|
+
- spec/helpers/spree/admin/images_helper_decorator_spec.rb
|
211
|
+
- spec/models/spree/image_decorator_spec.rb
|
212
|
+
- spec/models/spree/product_decorator_spec.rb
|
213
|
+
- spec/models/spree/variant_decorator_spec.rb
|
214
|
+
- spec/spec_helper.rb
|
215
|
+
- spec/support/images/green.jpeg
|