Skip to content

Upgrade extension to support rails 6 #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
6a0d1b0
Refacting code to be compatible with Zeitwerk
Jul 11, 2019
4d63824
Improve user and supplier model dependencies
softr8 Mar 20, 2020
b398f0f
Refactoring supplier ability
softr8 Mar 24, 2020
0577390
Bringing back shipment views
softr8 Mar 24, 2020
cdbaf8d
Remove double deface addition to admin products form
vzqzac Mar 26, 2020
39ece33
Merge pull request #3 from magma-labs/fix/product-suppliers-form
softr8 Mar 26, 2020
c8286a9
Fixing cancan ability to show stock locations for supplier admins
softr8 Mar 26, 2020
58f60fe
Merge pull request #4 from magma-labs/fix/customer_permissions_stock_…
softr8 Mar 26, 2020
4f7687f
Fix when an admin user save a supplier
SamBelmor Mar 23, 2020
576db3d
Add translations for marketplace
vzqzac Mar 26, 2020
1a3105e
Merge pull request #2 from SamBelmor/fix/save-suppliers
softr8 Mar 26, 2020
81df973
Fixing issue when editting suppliers
softr8 Mar 26, 2020
63f1791
Merge pull request #5 from magma-labs/add-translations
vzqzac Mar 26, 2020
8d0f7ad
Merge pull request #6 from magma-labs/fix/edit-supplier
softr8 Mar 27, 2020
8139432
Expiring product cache after assigning new supplier
softr8 Mar 30, 2020
97df5aa
Enable admin creation through association
mumoc Mar 31, 2020
a1c22cf
Adding image management abiliity to supplier role
softr8 Apr 8, 2020
22365c8
Allowing suppliers to manage variants
softr8 Apr 9, 2020
c982bc7
Allowing supplier_admin to perform full actions in orders
softr8 Apr 20, 2020
19c52a1
Adding more missing abilities to suplier admins
softr8 Apr 22, 2020
e6168c1
Add permission set if sales price extesion is present
softr8 Apr 29, 2020
78ef1c1
Suppliers should only see their variants in admin
softr8 May 14, 2020
d93ad3a
Fixing whitelisted ransackable attributes, it had only name
softr8 May 20, 2020
4b03a95
Destroying supplier variants and stock items when removing a supplier…
softr8 May 27, 2020
290ba82
Improving marketplace splitter
softr8 May 27, 2020
e9055ad
Improving checking in asset decorator
softr8 Jun 18, 2020
2b0937d
Create sample supplier users with role "supplier_admin" instead of re…
Jul 22, 2020
41eeb25
Merge pull request #9 from mayankdedhia/rails-6-support
softr8 Jul 24, 2020
7cc9288
Upgrade extension to support rails 6
Jul 24, 2020
e20d860
Remove unnecessary files
Jul 27, 2020
b061105
Merge pull request #10 from magma-labs/rails-6-support-test
softr8 Jul 28, 2020
07484e4
Remove users relations from Supplier
mumoc Aug 6, 2020
54bdead
Update supplier permission sets abilities
mumoc Aug 6, 2020
56f7fad
Allow Supplier Admin to manage Supplier Staff
mumoc Sep 11, 2020
27c6e7b
Update Staff Role Permissions
mumoc Sep 11, 2020
2379f02
refactor ability specs
ccarruitero Sep 16, 2020
ebaa0a8
Merge pull request #11 from magma-labs/admins-refactor
softr8 Sep 25, 2020
6db9dfc
Fixing rake sample data by updating relathionship names
softr8 Nov 2, 2020
12eed58
move module attribute outside singleton class
ccarruitero Dec 25, 2020
0da9780
Merge pull request #17 from magma-labs/mattribute
softr8 Jan 22, 2021
d2aeee1
Fix a typo in the setup instructions
stem Feb 20, 2021
1483273
Merge pull request #18 from stem/patch-1
ccarruitero Dec 14, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version: 2.1

orbs:
# Always take the latest version of the orb, this allows us to
# run specs against Solidus supported versions only without the need
# to change this configuration every time a Solidus version is released
# or goes EOL.
solidusio_extensions: solidusio/extensions@volatile

jobs:
run-specs-with-postgres:
executor: solidusio_extensions/postgres
steps:
- solidusio_extensions/run-tests
run-specs-with-mysql:
executor: solidusio_extensions/mysql
steps:
- solidusio_extensions/run-tests

workflows:
"Run specs on supported Solidus versions":
jobs:
- run-specs-with-postgres
- run-specs-with-mysql
"Weekly run specs against master":
triggers:
- schedule:
cron: "0 0 * * 4" # every Thursday
filters:
branches:
only:
- master
jobs:
- run-specs-with-postgres
- run-specs-with-mysql
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ pkg
*.swp
spec/dummy
spec/vcr_cassettes
spec/examples.txt
3 changes: 2 additions & 1 deletion .rspec
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
--format progress
--color
-r spec_helper
11 changes: 0 additions & 11 deletions .travis.yml

This file was deleted.

38 changes: 35 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,40 @@
source 'https://rubygems.org'
# frozen_string_literal: true

source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
gem "solidus", github: "solidusio/solidus", branch: branch
gem "solidus_auth_devise", github: "solidusio/solidus_auth_devise", branch: branch
gem 'solidus', github: 'solidusio/solidus', branch: branch

# Needed to help Bundler figure out how to resolve dependencies,
# otherwise it takes forever to resolve them.
# See https://github.com/bundler/bundler/issues/6677
gem 'rails', '>0.a'

# Provides basic authentication functionality for testing parts of your engine
gem 'solidus_auth_devise'

# gem 'solidus_reports', github: 'solidusio-contrib/solidus_reports'

case ENV['DB']
when 'mysql'
gem 'mysql2'
when 'postgresql'
gem 'pg'
else
gem 'sqlite3'
end

group :development, :test do
gem 'pry-rails'
gem 'byebug'
end

gemspec

# Use a local Gemfile to include development dependencies that might not be
# relevant for the project or for other contributors, e.g. pry-byebug.
#
# We use `send` instead of calling `eval_gemfile` to work around an issue with
# how Dependabot parses projects: https://github.com/dependabot/dependabot-core/issues/1658.
send(:eval_gemfile, 'Gemfile-local') if File.exist? 'Gemfile-local'
126 changes: 41 additions & 85 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,54 +1,50 @@
# Solidus Marketplace
# SolidusMarketplace

# NOTE: This gem is currently a work-in-progress.
Contributors are welcome to help us get this gem to a viable MVP.
We suggest installing [ZenHub](http://zenhub.com) in order to view/manage open issues.
This will give you a new tab in Github called "Boards", which provides a Kanban-style view of the project's issues.

# Overview
[![Build Status](https://travis-ci.org/jtapia/solidus_marketplace.svg?branch=master)](https://travis-ci.org/jtapia/solidus_marketplace)

This is marketplace implementation for solidus.

Basic functionality:
* Links products to one or more suppliers
* Once an order is placed:
* A shipment is created for the product's supplier
* The shipment is then sent to the store owner for fulfillment and to the supplier for visibility (via Email by default).
* The store owner fulfills orders. The supplier can view their shipments (read-only for now).

Installation
------------
Here's how to install solidus_marketplace into your existing spree site AFTER you've installed Spree:

Add the following to your Gemfile:
- Links products to one or more suppliers
- Once an order is placed:
- A shipment is created for the product's supplier
- The shipment is then sent to the store owner for fulfillment and to the supplier for visibility (via Email by default).
- The store owner fulfills orders. The supplier can view their shipments (read-only for now).

gem 'solidus_marketplace'
## Installation

Make your bundle happy:
Add this line to your application's Gemfile:

bundle install

Now run the generator:
```ruby
gem 'solidus_marketplace', github: 'jtapia/solidus_marketplace'
```

rails g solidus_marketplace:install
Then run the following:

(Optional) Run the generator for solidus_gateway to enable the use of Stripe or other payment providers
included with that extension:
```console
$ bundle install
$ bundle exec rails g solidus_marketplace:install
```

rails g solidus_gateway:install
(Optional) If you want to be able to see the reports, please add this line to your `Gemfile`:

Then migrate your database if you did not run during installation generator:
```ruby
gem 'solidus_reports', github: 'solidusio-contrib/solidus_reports'
```

bundle exec rake db:migrate
(Optional) If you want to use Stripe or other payment providers, please add this line to your `Gemfile`:

And reboot your server:
```ruby
gem 'solidus_gateway'
```

rails s
and run

You should be up and running now!
```ruby
rails g solidus_gateway:install
```

Sample Data
-----------
## Sample Data

If you'd like to generate sample data, use the included rake tasks:

Expand All @@ -59,65 +55,25 @@ rake spree_sample:suppliers # Create sample suppliers and randomly link
rake spree_sample:marketplace_orders # Create sample marketplace orders
```

This will include a new role (supplier_admin) and 2 new users in addition to the default '[email protected]' user provided by solidus.
This will include a new role (supplier_admin) and 2 new users in addition to the default `[email protected]` user provided by solidus.

Those users have the following email/password/roles

* [email protected] / test123 / admin
* [email protected] / test123 / supplier_admin

Demo
----
- [email protected] / test123 / admin
- [email protected] / test123 / supplier_admin

You can easily use the spec/dummy app as a demo of solidus_marketplace. Just `cd` to where you develop and run:
## Testing

```shell
git clone git://github.com/boomerdigital/solidus_marketplace.git
cd solidus_marketplace
bundle install
bundle exec rake test_app
cd spec/dummy
rake db:migrate db:seed spree_sample:load spree_sample:suppliers spree_sample:marketplace_orders
rails s
```

Testing
-------

Be sure to bundle your dependencies and then create a dummy test app for the specs to run against.

```shell
brew install geckodriver
Run the following to automatically build a dummy app and run the tests:

bundle
bundle exec rake test_app
bundle exec rspec spec
```console
$ bundle exec rake
```

Todo
----

* See open issues here: [open issues](https://github.com/boomerdigital/solidus_marketplace/issues)

Contributing
------------

In the spirit of [free software](http://www.fsf.org/licensing/essays/free-sw.html), **everyone** is encouraged to help improve this project.

Here are some ways *you* can contribute:
## Contributing

* by using prerelease versions
* by reporting [bugs](https://github.com/boomerdigital/solidus_marketplace/issues)
* by suggesting new features
* by [translating to a new language](https://github.com/boomerdigital/solidus_marketplace/tree/master/config/locales)
* by writing or editing documentation
* by writing specifications
* by writing code (*no patch is too small*: fix typos, add comments, clean up inconsistent whitespace)
* by refactoring code
* by resolving [issues](https://github.com/boomerdigital/solidus_marketplace/issues)
* by reviewing patches
Bug reports and pull requests are welcome on GitHub at https://github.com/solidusio-contrib/solidus_abandoned_carts.

Donating
--------
## License

Copyright (c) 2016-2017 Boomer Digital, released under the [New BSD License](https://github.com/boomerdigital/solidus_marketplace/tree/master/LICENSE).
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
14 changes: 11 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
# frozen_string_literal: true

require 'bundler'
Bundler::GemHelper.install_tasks

require 'rspec/core/rake_task'
require 'spree/testing_support/common_rake'
require 'spree/testing_support/extension_rake'

RSpec::Core::RakeTask.new

task :default => [:spec]
task :default do
if Dir["spec/dummy"].empty?
Rake::Task[:test_app].invoke
Dir.chdir("../../")
end
Rake::Task[:spec].invoke
end

desc 'Generates a dummy app for testing'
task :test_app do
ENV['LIB_NAME'] = 'solidus_marketplace'
Rake::Task['common:test_app'].invoke 'Spree::User'
Rake::Task['extension:test_app'].invoke
end
6 changes: 0 additions & 6 deletions Versionfile

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1 +1 @@
Spree.routes.suppliers_search = Spree.pathFor('api/suppliers')
suppliers_search = Spree.pathFor('api/suppliers')
82 changes: 41 additions & 41 deletions app/assets/javascripts/spree/backend/suppliers_autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,52 @@ $.fn.supplierAutocomplete = function () {
'use strict';

this.select2({
placeholder: Spree.translations.supplier_placeholder,
multiple: true,
initSelection: function (element, callback) {
var ids = element.val(),
count = ids.split(",").length;
placeholder: Spree.translations.supplier_placeholder,
multiple: true,
initSelection: function (element, callback) {
var ids = element.val(),
count = ids.split(",").length;

Spree.ajax({
type: "GET",
url: Spree.routes.suppliers_search,
data: {
ids: ids,
per_page: count
},
success: function (data) {
callback(data['suppliers']);
}
});
},
ajax: {
url: Spree.routes.suppliers_search,
datatype: 'json',
data: function (term, page) {
return {
per_page: 50,
page: page,
q: {
name_cont: term
},
token: Spree.api_key
};
Spree.ajax({
type: "GET",
url: suppliers_search,
data: {
ids: ids,
per_page: count
},
results: function (data, page) {
var more = page < data.pages;
return {
results: data['suppliers'],
more: more
};
success: function (data) {
callback(data['suppliers']);
}
});
},
ajax: {
url: suppliers_search,
datatype: 'json',
data: function (term, page) {
return {
per_page: 50,
page: page,
q: {
name_cont: term
},
token: Spree.api_key
};
},
formatResult: function (supplier, container, query, escapeMarkup) {
return escapeMarkup(supplier.name);
},
formatSelection: function (supplier, container, escapeMarkup) {
return escapeMarkup(supplier.name);
results: function (data, page) {
var more = page < data.pages;
return {
results: data['suppliers'],
more: more
};
}
});
},
formatResult: function (supplier, container, query, escapeMarkup) {
return escapeMarkup(supplier.name);
},
formatSelection: function (supplier, container, escapeMarkup) {
return escapeMarkup(supplier.name);
}
});
};

$(document).ready(function () {
Expand Down
Loading