spree_taxon_group 3.0.0.beta
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 +14 -0
- data/.hound.yml +21 -0
- data/.rspec +3 -0
- data/.rubocop.yml +8 -0
- data/.travis.yml +11 -0
- data/CONTRIBUTING.md +83 -0
- data/Gemfile +5 -0
- data/Guardfile +9 -0
- data/LICENSE.md +26 -0
- data/README.md +54 -0
- data/Rakefile +21 -0
- data/app/controllers/spree/admin/taxon_groups_controller.rb +13 -0
- data/app/helpers/spree/frontend_helper_decorator.rb +10 -0
- data/app/models/spree/taxon_decorator.rb +4 -0
- data/app/models/spree/taxon_group.rb +8 -0
- data/app/models/spree/taxon_group_membership.rb +9 -0
- data/app/overrides/add_taxon_groups_under_taxon_in_products_in_admin_sidebar_menu.rb +6 -0
- data/app/views/spree/admin/taxon_groups/_form.html.erb +58 -0
- data/app/views/spree/admin/taxon_groups/_list.html.erb +21 -0
- data/app/views/spree/admin/taxon_groups/edit.html.erb +5 -0
- data/app/views/spree/admin/taxon_groups/index.html.erb +18 -0
- data/app/views/spree/admin/taxon_groups/new.html.erb +5 -0
- data/bin/rails +7 -0
- data/config/locales/en.yml +18 -0
- data/config/routes.rb +5 -0
- data/db/migrate/20151004162900_create_spree_taxon_groups.rb +12 -0
- data/db/migrate/20151004173034_create_spree_taxon_group_memberships.rb +12 -0
- data/lib/generators/spree_taxon_group/install/install_generator.rb +30 -0
- data/lib/spree_taxon_group/engine.rb +20 -0
- data/lib/spree_taxon_group/version.rb +18 -0
- data/lib/spree_taxon_group.rb +2 -0
- data/spec/models/spree/taxon_group_spec.rb +5 -0
- data/spec/spec_helper.rb +93 -0
- data/spree_taxon_group.gemspec +26 -0
- metadata +94 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: edbcdb30355927cc63a0209509ee3d5855f6da5f
|
|
4
|
+
data.tar.gz: 7ce4725f2c0cff3bbb507b4ae8974d3b6c0d0929
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: b9dba5719377369616674ccdf087acb4ef1e1e053df0d2f319fd5a858a17e66e1d94dddfea5e380b803ed2180d9bddd0aa03e819e8f25dfdbf033fe5d32186f2
|
|
7
|
+
data.tar.gz: 9f1a1819ebe53daaea7c0490b11ea9f623ef23098530bb07f43835a13cc805550fbd4cdfe7806946fabee6ab428dea43942e13652f046ceb33cecccc422eb3ec
|
data/.gitignore
ADDED
data/.hound.yml
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
---
|
|
2
|
+
# Too picky.
|
|
3
|
+
LineLength:
|
|
4
|
+
Enabled: false
|
|
5
|
+
|
|
6
|
+
# This should truly be on for well documented gems.
|
|
7
|
+
Documentation:
|
|
8
|
+
Enabled: false
|
|
9
|
+
|
|
10
|
+
# Neatly aligned code is to swell.
|
|
11
|
+
SingleSpaceBeforeFirstArg:
|
|
12
|
+
Enabled: false
|
|
13
|
+
|
|
14
|
+
# Don't mess with RSpec DSL.
|
|
15
|
+
Blocks:
|
|
16
|
+
Exclude:
|
|
17
|
+
- 'spec/**/*'
|
|
18
|
+
|
|
19
|
+
# Avoid contradictory style rules by enforce single quotes.
|
|
20
|
+
StringLiterals:
|
|
21
|
+
EnforcedStyle: single_quotes
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
*(Originally copied from [Spree Static Content's Contribution guidelines](https://github.com/spree-contrib/spree_static_content/blob/master/CONTRIBUTING.md)*
|
|
4
|
+
|
|
5
|
+
Spree Taxon Group is an open source project and we encourage contributions. Please see the [contributors guidelines](http://spreecommerce.com/documentation/contributing_to_spree.html) for more information before contributing.
|
|
6
|
+
|
|
7
|
+
In the spirit of [free software][1], **everyone** is encouraged to help improve this project.
|
|
8
|
+
|
|
9
|
+
Here are some ways *you* can contribute:
|
|
10
|
+
|
|
11
|
+
* by using prerelease versions
|
|
12
|
+
* by reporting [bugs][2]
|
|
13
|
+
* by suggesting new features
|
|
14
|
+
* by writing [translations][3]
|
|
15
|
+
* by writing or editing documentation
|
|
16
|
+
* by writing specifications
|
|
17
|
+
* by writing code (*no patch is too small*: fix typos, add comments, clean up inconsistent whitespace)
|
|
18
|
+
* by refactoring code
|
|
19
|
+
* by resolving [issues][2]
|
|
20
|
+
* by reviewing patches
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Filing an issue
|
|
25
|
+
|
|
26
|
+
When filing an issue on this extension, please first do these things:
|
|
27
|
+
|
|
28
|
+
* Verify you can reproduce this issue in a brand new application.
|
|
29
|
+
* Run through the steps to reproduce the issue again.
|
|
30
|
+
|
|
31
|
+
In the issue itself please provide:
|
|
32
|
+
|
|
33
|
+
* A comprehensive list of steps to reproduce the issue.
|
|
34
|
+
* What you're *expecting* to happen compared with what's *actually* happening.
|
|
35
|
+
* The version of Spree *and* the version of Rails.
|
|
36
|
+
* A list of all extensions.
|
|
37
|
+
* Any relevant stack traces ("Full trace" preferred)
|
|
38
|
+
* Your `Gemfile`
|
|
39
|
+
|
|
40
|
+
In 99% of cases, this information is enough to determine the cause and solution to the problem that is being described.
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## Pull requests
|
|
45
|
+
|
|
46
|
+
We gladly accept pull requests to fix bugs and, in some circumstances, add new features to this extension.
|
|
47
|
+
|
|
48
|
+
Here's a quick guide:
|
|
49
|
+
|
|
50
|
+
1. Fork the repo.
|
|
51
|
+
|
|
52
|
+
2. Run the tests. We only take pull requests with passing tests, and it's great to know that you have a clean slate.
|
|
53
|
+
|
|
54
|
+
3. Create new branch then make changes and add tests for your changes. Only refactoring and documentation changes require no new tests. If you are adding functionality or fixing a bug, we need tests!
|
|
55
|
+
|
|
56
|
+
4. Push to your fork and submit a pull request. If the changes will apply cleanly to the latest stable branches and master branch, you will only need to submit one pull request.
|
|
57
|
+
|
|
58
|
+
At this point you're waiting on us. We may suggest some changes or improvements or alternatives.
|
|
59
|
+
|
|
60
|
+
Some things that will increase the chance that your pull request is accepted, taken straight from the Ruby on Rails guide:
|
|
61
|
+
|
|
62
|
+
* Use Rails idioms and helpers.
|
|
63
|
+
* Include tests that fail without your code, and pass with it.
|
|
64
|
+
* Update the documentation, the surrounding one, examples elsewhere, guides, whatever is affected by your contribution.
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
## TL;DR
|
|
69
|
+
|
|
70
|
+
* Fork the repo
|
|
71
|
+
* Clone your repo
|
|
72
|
+
* Run `bundle install`
|
|
73
|
+
* Run `bundle exec rake test_app` to create the test application in `spec/dummy`
|
|
74
|
+
* Make your changes
|
|
75
|
+
* Ensure specs pass by running `bundle exec rspec spec`
|
|
76
|
+
* Ensure all syntax ok by running `rubocop .`
|
|
77
|
+
* Submit your pull request
|
|
78
|
+
|
|
79
|
+
And in case we didn't emphasize it enough: **we love tests!**
|
|
80
|
+
|
|
81
|
+
[1]: http://www.fsf.org/licensing/essays/free-sw.html
|
|
82
|
+
[2]: https://github.com/whelton/spree_taxon_group/issues
|
|
83
|
+
[3]: https://github.com/whelton/spree_taxon_group/tree/master/config/locales
|
data/Gemfile
ADDED
data/Guardfile
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
guard 'rspec', cmd: 'bundle exec rspec' do
|
|
2
|
+
watch('spec/spec_helper.rb') { 'spec' }
|
|
3
|
+
watch('config/routes.rb') { 'spec/controllers' }
|
|
4
|
+
watch('app/controllers/application_controller.rb') { 'spec/controllers' }
|
|
5
|
+
watch(%r{^spec/(.+)_spec\.rb$}) { |m| "spec/#{m[1]}_spec.rb"}
|
|
6
|
+
watch(%r{^app/(.+)_decorator\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
|
7
|
+
watch(%r{^(app|lib)/(.+)(\.rb|\.erb)$}) { |m| "spec/#{m[2]}_spec.rb" }
|
|
8
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb" }
|
|
9
|
+
end
|
data/LICENSE.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
Copyright (c) 2008-2015 James Whelton and contributors.
|
|
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,54 @@
|
|
|
1
|
+
# Spree Taxon Group
|
|
2
|
+
|
|
3
|
+
Easily create and manage groups of taxons, irrespective of their parent or children taxons/taxonomies.
|
|
4
|
+
Useful if you need flexible taxon usage, for example a group of taxons for featured categories from different parent taxon/taxonomies.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
If you want a taxon tree, similar to `taxons_tree` in the default spree sidebar. You can use the helper `taxon_group_tree`:
|
|
11
|
+
|
|
12
|
+
```html
|
|
13
|
+
<nav id="featured-categories" class="sidebar-item" data-hook>
|
|
14
|
+
<% featured = Spree::TaxonGroup.find_by_name('featured') %>
|
|
15
|
+
<% cache [I18n.locale, featured] do %>
|
|
16
|
+
<h4 class='taxon-group-root'><%= Spree.t(:shop_by_taxon_group, :taxon_group => featured.name) %></h4>
|
|
17
|
+
<%= taxon_group_tree(featured, @taxon) %>
|
|
18
|
+
<% end %>
|
|
19
|
+
</nav>
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
## Basic Installation
|
|
25
|
+
|
|
26
|
+
Add to your `Gemfile`:
|
|
27
|
+
|
|
28
|
+
```ruby
|
|
29
|
+
gem 'spree_taxon_group', github: 'whelton/spree_taxon_group', branch: 'master'
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Run:
|
|
33
|
+
|
|
34
|
+
```sh
|
|
35
|
+
bundle && bundle exec rails g spree_taxon_group:install
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
That's it!
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Contributing
|
|
43
|
+
|
|
44
|
+
See corresponding [guidelines][1] and check out the [issues][2].
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
Copyright (c) 2015 [James Whelton][3] and [contributors][4], released under the [New BSD License][5]
|
|
49
|
+
|
|
50
|
+
[1]: https://github.com/whelton/spree_taxon_group/blob/master/CONTRIBUTING.md
|
|
51
|
+
[2]: https://github.com/whelton/spree_taxon_group/issues
|
|
52
|
+
[3]: https://github.com/whelton
|
|
53
|
+
[4]: https://github.com/whelton/spree_taxon_group/graphs/contributors
|
|
54
|
+
[5]: https://github.com/whelton/spree_taxon_group/blob/master/LICENSE.md
|
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_taxon_group'
|
|
20
|
+
Rake::Task['extension:test_app'].invoke
|
|
21
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Spree::FrontendHelper.class_eval do
|
|
2
|
+
def taxon_group_tree(taxon_group, current_taxon)
|
|
3
|
+
content_tag :div, class: 'list-group' do
|
|
4
|
+
taxon_group.taxons.map do |taxon|
|
|
5
|
+
css_class = (current_taxon.eql? taxon) ? 'list-group-item active' : 'list-group-item'
|
|
6
|
+
link_to(taxon.name, seo_url(taxon), class: css_class)
|
|
7
|
+
end.join("\n").html_safe
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<% content_for :page_actions do %>
|
|
2
|
+
<%= button_link_to Spree.t(:back_to_resource_list, resource: plural_resource_name(Spree::TaxonGroup)), spree.admin_taxon_groups_path, icon: 'arrow-left', class: 'btn-primary' %>
|
|
3
|
+
<% end %>
|
|
4
|
+
|
|
5
|
+
<%= form_for [:admin, resource] do |f| %>
|
|
6
|
+
|
|
7
|
+
<div class="row" data-hook="admin_page_form_fields">
|
|
8
|
+
<div class="form-group">
|
|
9
|
+
<%= f.label :name, Spree.t(:name) %> <span class="required">*</span>
|
|
10
|
+
<%= f.text_field :name, class: 'form-control' %>
|
|
11
|
+
<%= f.error_message_on :name %>
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
<div class="row" data-hook="admin_page_form_fields">
|
|
16
|
+
<div class="form-group">
|
|
17
|
+
<table class="table table-hover">
|
|
18
|
+
<thead>
|
|
19
|
+
<tr data-hook="taxons_header">
|
|
20
|
+
<th></th>
|
|
21
|
+
<th><%= Spree.t(:taxon_name) %></th>
|
|
22
|
+
<th><%= Spree.t(:path) %></th>
|
|
23
|
+
</tr>
|
|
24
|
+
</thead>
|
|
25
|
+
<tbody>
|
|
26
|
+
<% @taxons.each do |taxon| %>
|
|
27
|
+
<tr id="<%= spree_dom_id(taxon) %>" data-hook="taxons_row">
|
|
28
|
+
<td><%= check_box_tag("taxon_group[taxon_ids][]", taxon.id, taxon.id.in?(resource.taxons.pluck(:id))) %></td>
|
|
29
|
+
<td><%= taxon.name %></td>
|
|
30
|
+
<td><%= taxon_path taxon %></td>
|
|
31
|
+
</tr>
|
|
32
|
+
<% end %>
|
|
33
|
+
<% if @taxons.empty? %>
|
|
34
|
+
<tr data-hook="taxons_none"><td colspan="3"><%= Spree.t(:none) %>.</td></tr>
|
|
35
|
+
<% end %>
|
|
36
|
+
</tbody>
|
|
37
|
+
</table>
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
<script>
|
|
42
|
+
$(function() {
|
|
43
|
+
// Checks a taxon's row checkbox on click
|
|
44
|
+
$('[data-hook="taxons_row"]').on('click', function(e) {
|
|
45
|
+
|
|
46
|
+
if ($(event.target).context.type == 'checkbox' ) {
|
|
47
|
+
return; // Do nothing (checkbox)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
var checkbox = $(this).children('td:first').children('input');
|
|
51
|
+
checkbox.prop("checked", !checkbox.prop("checked"));
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<%= render "spree/admin/shared/#{resource.new_record? ? 'new' : 'edit'}_resource_links" %>
|
|
57
|
+
|
|
58
|
+
<% end %>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<table class="table sortable" id='listing_taxon_groups' data-hook>
|
|
2
|
+
<thead>
|
|
3
|
+
<tr data-hook="taxon_groups_header">
|
|
4
|
+
<th><%= Spree.t(:name) %></th>
|
|
5
|
+
<th><%= Spree.t(:taxon_count) %></th>
|
|
6
|
+
<th class="actions"></th>
|
|
7
|
+
</tr>
|
|
8
|
+
</thead>
|
|
9
|
+
<tbody>
|
|
10
|
+
<% @taxon_groups.each do |taxon_group| %>
|
|
11
|
+
<tr id="<%= spree_dom_id taxon_group %>" data-hook="taxon_groups_row">
|
|
12
|
+
<td><%= taxon_group.name %></td>
|
|
13
|
+
<td><%= taxon_group.taxons.count %></td>
|
|
14
|
+
<td class="actions actions-2 text-right">
|
|
15
|
+
<%= link_to_edit taxon_group.id, no_text: true %>
|
|
16
|
+
<%= link_to_delete taxon_group, no_text: true %>
|
|
17
|
+
</td>
|
|
18
|
+
</tr>
|
|
19
|
+
<% end %>
|
|
20
|
+
</tbody>
|
|
21
|
+
</table>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<% content_for :page_title do %>
|
|
2
|
+
<%= plural_resource_name(Spree::TaxonGroup) %>
|
|
3
|
+
<% end %>
|
|
4
|
+
|
|
5
|
+
<% content_for :page_actions do %>
|
|
6
|
+
<%= button_link_to Spree.t(:new_taxon_group), new_object_url, class: "btn-success", icon: 'add', id: 'admin_new_taxon_group_link' %>
|
|
7
|
+
<% end %>
|
|
8
|
+
|
|
9
|
+
<% if @taxon_groups.any? %>
|
|
10
|
+
<div id="list-taxon-groups" data-hook>
|
|
11
|
+
<%= render 'list' %>
|
|
12
|
+
</div>
|
|
13
|
+
<% else %>
|
|
14
|
+
<div class="alert alert-info no-objects-found">
|
|
15
|
+
<%= Spree.t(:no_resource_found, resource: plural_resource_name(Spree::TaxonGroup)) %>,
|
|
16
|
+
<%= link_to Spree.t(:add_one), new_object_url %>!
|
|
17
|
+
</div>
|
|
18
|
+
<% 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_taxon_group/engine', __FILE__)
|
|
5
|
+
|
|
6
|
+
require 'rails/all'
|
|
7
|
+
require 'rails/engine/commands'
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
en:
|
|
3
|
+
activerecord:
|
|
4
|
+
attributes:
|
|
5
|
+
spree/taxon_group:
|
|
6
|
+
name: Taxon Group
|
|
7
|
+
models:
|
|
8
|
+
spree/taxon_group:
|
|
9
|
+
one: Taxon Group
|
|
10
|
+
other: Taxon Groups
|
|
11
|
+
spree:
|
|
12
|
+
admin:
|
|
13
|
+
tab:
|
|
14
|
+
taxon_groups: Taxon Groups
|
|
15
|
+
new_taxon_group: "New Taxon Group"
|
|
16
|
+
edit_taxon_group: "Edit Taxon Group"
|
|
17
|
+
taxon_count: "Taxon Count"
|
|
18
|
+
shop_by_taxon_group: Shop by %{taxon_group}
|
data/config/routes.rb
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
class CreateSpreeTaxonGroupMemberships < ActiveRecord::Migration
|
|
2
|
+
def self.up
|
|
3
|
+
create_table :spree_taxon_group_memberships do |t|
|
|
4
|
+
t.integer :taxon_group_id
|
|
5
|
+
t.integer :taxon_id
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def self.down
|
|
10
|
+
drop_table :spree_taxon_group_memberships
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
module SpreeTaxonGroup
|
|
2
|
+
module Generators
|
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
|
4
|
+
class_option :auto_run_migrations, type: :boolean, default: false
|
|
5
|
+
|
|
6
|
+
def add_javascripts
|
|
7
|
+
# append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require spree/frontend/spree_taxon_group\n"
|
|
8
|
+
# append_file 'vendor/assets/javascripts/spree/backend/all.js', "//= require spree/backend/spree_taxon_group\n"
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def add_stylesheets
|
|
12
|
+
# inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require spree/frontend/spree_taxon_group\n", :before => /\*\//, :verbose => true
|
|
13
|
+
# inject_into_file 'vendor/assets/stylesheets/spree/backend/all.css', " *= require spree/backend/spree_taxon_group\n", :before => /\*\//, :verbose => true
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def add_migrations
|
|
17
|
+
run 'bundle exec rake railties:install:migrations FROM=spree_taxon_group'
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def run_migrations
|
|
21
|
+
run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask 'Would you like to run the migrations now? [Y/n]')
|
|
22
|
+
if run_migrations
|
|
23
|
+
run 'bundle exec rake db:migrate'
|
|
24
|
+
else
|
|
25
|
+
puts 'Skipping rake db:migrate, don\'t forget to run it!'
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module SpreeTaxonGroup
|
|
2
|
+
class Engine < Rails::Engine
|
|
3
|
+
require 'spree/core'
|
|
4
|
+
isolate_namespace Spree
|
|
5
|
+
engine_name 'spree_taxon_group'
|
|
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,18 @@
|
|
|
1
|
+
module SpreeTaxonGroup
|
|
2
|
+
module_function
|
|
3
|
+
|
|
4
|
+
# Returns the version of the currently loaded SpreeTaxonGroup as a
|
|
5
|
+
# <tt>Gem::Version</tt>.
|
|
6
|
+
def version
|
|
7
|
+
Gem::Version.new VERSION::STRING
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
module VERSION
|
|
11
|
+
MAJOR = 3
|
|
12
|
+
MINOR = 0
|
|
13
|
+
TINY = 0
|
|
14
|
+
PRE = 'beta'
|
|
15
|
+
|
|
16
|
+
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
|
|
17
|
+
end
|
|
18
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
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_taxon_group/factories.rb
|
|
34
|
+
require 'spree_taxon_group/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
|
+
# == Requests support
|
|
51
|
+
#
|
|
52
|
+
# Adds convenient methods to request Spree's controllers
|
|
53
|
+
# spree_get :index
|
|
54
|
+
config.include Spree::TestingSupport::ControllerRequests, type: :controller
|
|
55
|
+
|
|
56
|
+
# == Mock Framework
|
|
57
|
+
#
|
|
58
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
|
59
|
+
#
|
|
60
|
+
# config.mock_with :mocha
|
|
61
|
+
# config.mock_with :flexmock
|
|
62
|
+
# config.mock_with :rr
|
|
63
|
+
config.mock_with :rspec
|
|
64
|
+
config.color = true
|
|
65
|
+
|
|
66
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
|
67
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
|
68
|
+
|
|
69
|
+
# Capybara javascript drivers require transactional fixtures set to false, and we use DatabaseCleaner
|
|
70
|
+
# to cleanup after each test instead. Without transactional fixtures set to false the records created
|
|
71
|
+
# to setup a test will be unavailable to the browser, which runs under a separate server instance.
|
|
72
|
+
config.use_transactional_fixtures = false
|
|
73
|
+
|
|
74
|
+
# Ensure Suite is set to use transactions for speed.
|
|
75
|
+
config.before :suite do
|
|
76
|
+
DatabaseCleaner.strategy = :transaction
|
|
77
|
+
DatabaseCleaner.clean_with :truncation
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Before each spec check if it is a Javascript test and switch between using database transactions or not where necessary.
|
|
81
|
+
config.before :each do
|
|
82
|
+
DatabaseCleaner.strategy = RSpec.current_example.metadata[:js] ? :truncation : :transaction
|
|
83
|
+
DatabaseCleaner.start
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# After each spec clean the database.
|
|
87
|
+
config.after :each do
|
|
88
|
+
DatabaseCleaner.clean
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
config.fail_fast = ENV['FAIL_FAST'] || false
|
|
92
|
+
config.order = 'random'
|
|
93
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib/', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
|
|
4
|
+
|
|
5
|
+
require 'spree_taxon_group/version'
|
|
6
|
+
|
|
7
|
+
Gem::Specification.new do |s|
|
|
8
|
+
s.platform = Gem::Platform::RUBY
|
|
9
|
+
s.name = 'spree_taxon_group'
|
|
10
|
+
s.version = SpreeTaxonGroup.version
|
|
11
|
+
s.summary = 'Extension to create and manage groups of taxons'
|
|
12
|
+
s.description = s.summary
|
|
13
|
+
s.required_ruby_version = '>= 2.0.0'
|
|
14
|
+
|
|
15
|
+
s.author = 'James Whelton'
|
|
16
|
+
s.email = 'james@whelton.io'
|
|
17
|
+
s.homepage = 'https://github.com/whelton/spree_taxon_group'
|
|
18
|
+
s.license = 'BSD-3'
|
|
19
|
+
|
|
20
|
+
s.files = `git ls-files`.split("\n")
|
|
21
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
22
|
+
s.require_path = 'lib'
|
|
23
|
+
s.requirements << 'none'
|
|
24
|
+
|
|
25
|
+
s.add_dependency 'spree_core', '~> 3.1.0.beta'
|
|
26
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: spree_taxon_group
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 3.0.0.beta
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- James Whelton
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2015-10-04 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.1.0.beta
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 3.1.0.beta
|
|
27
|
+
description: Extension to create and manage groups of taxons
|
|
28
|
+
email: james@whelton.io
|
|
29
|
+
executables: []
|
|
30
|
+
extensions: []
|
|
31
|
+
extra_rdoc_files: []
|
|
32
|
+
files:
|
|
33
|
+
- ".gitignore"
|
|
34
|
+
- ".hound.yml"
|
|
35
|
+
- ".rspec"
|
|
36
|
+
- ".rubocop.yml"
|
|
37
|
+
- ".travis.yml"
|
|
38
|
+
- CONTRIBUTING.md
|
|
39
|
+
- Gemfile
|
|
40
|
+
- Guardfile
|
|
41
|
+
- LICENSE.md
|
|
42
|
+
- README.md
|
|
43
|
+
- Rakefile
|
|
44
|
+
- app/controllers/spree/admin/taxon_groups_controller.rb
|
|
45
|
+
- app/helpers/spree/frontend_helper_decorator.rb
|
|
46
|
+
- app/models/spree/taxon_decorator.rb
|
|
47
|
+
- app/models/spree/taxon_group.rb
|
|
48
|
+
- app/models/spree/taxon_group_membership.rb
|
|
49
|
+
- app/overrides/add_taxon_groups_under_taxon_in_products_in_admin_sidebar_menu.rb
|
|
50
|
+
- app/views/spree/admin/taxon_groups/_form.html.erb
|
|
51
|
+
- app/views/spree/admin/taxon_groups/_list.html.erb
|
|
52
|
+
- app/views/spree/admin/taxon_groups/edit.html.erb
|
|
53
|
+
- app/views/spree/admin/taxon_groups/index.html.erb
|
|
54
|
+
- app/views/spree/admin/taxon_groups/new.html.erb
|
|
55
|
+
- bin/rails
|
|
56
|
+
- config/locales/en.yml
|
|
57
|
+
- config/routes.rb
|
|
58
|
+
- db/migrate/20151004162900_create_spree_taxon_groups.rb
|
|
59
|
+
- db/migrate/20151004173034_create_spree_taxon_group_memberships.rb
|
|
60
|
+
- lib/generators/spree_taxon_group/install/install_generator.rb
|
|
61
|
+
- lib/spree_taxon_group.rb
|
|
62
|
+
- lib/spree_taxon_group/engine.rb
|
|
63
|
+
- lib/spree_taxon_group/version.rb
|
|
64
|
+
- spec/models/spree/taxon_group_spec.rb
|
|
65
|
+
- spec/spec_helper.rb
|
|
66
|
+
- spree_taxon_group.gemspec
|
|
67
|
+
homepage: https://github.com/whelton/spree_taxon_group
|
|
68
|
+
licenses:
|
|
69
|
+
- BSD-3
|
|
70
|
+
metadata: {}
|
|
71
|
+
post_install_message:
|
|
72
|
+
rdoc_options: []
|
|
73
|
+
require_paths:
|
|
74
|
+
- lib
|
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
76
|
+
requirements:
|
|
77
|
+
- - ">="
|
|
78
|
+
- !ruby/object:Gem::Version
|
|
79
|
+
version: 2.0.0
|
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
|
+
requirements:
|
|
82
|
+
- - ">"
|
|
83
|
+
- !ruby/object:Gem::Version
|
|
84
|
+
version: 1.3.1
|
|
85
|
+
requirements:
|
|
86
|
+
- none
|
|
87
|
+
rubyforge_project:
|
|
88
|
+
rubygems_version: 2.4.5
|
|
89
|
+
signing_key:
|
|
90
|
+
specification_version: 4
|
|
91
|
+
summary: Extension to create and manage groups of taxons
|
|
92
|
+
test_files:
|
|
93
|
+
- spec/models/spree/taxon_group_spec.rb
|
|
94
|
+
- spec/spec_helper.rb
|