spree_channable 0.0.18.alpha

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.
Files changed (61) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +23 -0
  3. data/.rspec +3 -0
  4. data/.rubocop.yml +24 -0
  5. data/.travis.yml +35 -0
  6. data/Appraisals +27 -0
  7. data/Gemfile +17 -0
  8. data/LICENSE +29 -0
  9. data/README.md +56 -0
  10. data/Rakefile +21 -0
  11. data/app/assets/javascripts/spree/backend/spree_channable.js +2 -0
  12. data/app/assets/javascripts/spree/frontend/spree_channable.js +2 -0
  13. data/app/assets/stylesheets/spree/backend/spree_channable.css +4 -0
  14. data/app/assets/stylesheets/spree/frontend/spree_channable.css +4 -0
  15. data/app/controllers/spree/admin/channable_settings_controller.rb +14 -0
  16. data/app/controllers/spree/api/v1/channable_controller.rb +21 -0
  17. data/app/jobs/application_job.rb +7 -0
  18. data/app/jobs/spree_channable/order_import_job.rb +37 -0
  19. data/app/jobs/spree_channable/return_import_job.rb +36 -0
  20. data/app/models/channable_setting.rb +10 -0
  21. data/app/models/spree/order_decorator.rb +127 -0
  22. data/app/models/spree/product_decorator.rb +118 -0
  23. data/app/models/spree/reimbursement_decorator.rb +39 -0
  24. data/app/models/spree/shipment_decorator.rb +28 -0
  25. data/app/models/spree/shipment_handler_decorator.rb +11 -0
  26. data/app/models/spree/variant_decorator.rb +78 -0
  27. data/app/overrides/add_settings_to_admin_configurator.rb +32 -0
  28. data/app/overrides/order_index.rb +13 -0
  29. data/app/views/spree/admin/channable_settings/_form.html.erb +105 -0
  30. data/app/views/spree/admin/channable_settings/edit.html.erb +1 -0
  31. data/app/views/spree/admin/channable_settings/new.html.erb +1 -0
  32. data/app/views/spree/admin/orders/_index_channable_state_override.html.erb +7 -0
  33. data/app/views/spree/admin/orders/_index_channable_state_override_head.html.erb +1 -0
  34. data/bin/rails +8 -0
  35. data/config/locales/en.yml +5 -0
  36. data/config/routes.rb +18 -0
  37. data/db/migrate/20190710092345_create_channable_settings.rb +16 -0
  38. data/db/migrate/20190710103701_add_settings_to_settings_table.rb +9 -0
  39. data/db/migrate/20190710115409_add_order_columns.rb +9 -0
  40. data/db/migrate/20190711122425_set_order_connection_defaults.rb +5 -0
  41. data/db/migrate/20190711123402_add_channable_fields_to_shipping_methods.rb +8 -0
  42. data/db/migrate/20190711140015_add_payment_method_for_channable.rb +7 -0
  43. data/db/migrate/20190711145940_add_order_import_settings.rb +9 -0
  44. data/db/migrate/20190717120144_add_channable_id_to_return_authorisations.rb +5 -0
  45. data/gemfiles/spree_3_2.gemfile +10 -0
  46. data/gemfiles/spree_3_5.gemfile +10 -0
  47. data/gemfiles/spree_3_7.gemfile +10 -0
  48. data/gemfiles/spree_master.gemfile +10 -0
  49. data/lib/channable/client.rb +42 -0
  50. data/lib/channable/response.rb +15 -0
  51. data/lib/generators/spree_channable/install/install_generator.rb +20 -0
  52. data/lib/spree_channable/engine.rb +20 -0
  53. data/lib/spree_channable/factories.rb +6 -0
  54. data/lib/spree_channable/order_importer.rb +280 -0
  55. data/lib/spree_channable/return_importer.rb +63 -0
  56. data/lib/spree_channable/version.rb +18 -0
  57. data/lib/spree_channable.rb +36 -0
  58. data/spec/fixtures/invalid_channable_order.json +117 -0
  59. data/spec/fixtures/valid_channable_order.json +117 -0
  60. data/spree_channable.gemspec +50 -0
  61. metadata +451 -0
@@ -0,0 +1,39 @@
1
+ module Spree
2
+ module SpreeChannable
3
+ module ReimbursementDecorator
4
+ def send_reimbursement_email
5
+ super unless order.is_channable_order?
6
+ end
7
+
8
+ def reimburse_channable_order
9
+ return unless order.is_channable_order?
10
+
11
+ client = ::Channable::Client.new
12
+ client.return_update(customer_return.channable_return_id, channable_return)
13
+ end
14
+
15
+ def channable_return
16
+ {
17
+ status: channable_return_status
18
+ }.to_json
19
+ end
20
+
21
+ def channable_return_status
22
+ case reimbursement_status
23
+ when 'reimbursed'
24
+ 'accepted'
25
+ when 'errored'
26
+ 'cancelled'
27
+ else
28
+ 'accepted'
29
+ end
30
+ end
31
+
32
+ def self.prepended(base)
33
+ base.state_machine.after_transition to: :reimbursed, do: :reimburse_channable_order
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ Spree::Reimbursement.prepend(Spree::SpreeChannable::ReimbursementDecorator)
@@ -0,0 +1,28 @@
1
+ module Spree
2
+ module SpreeChannable
3
+ module ShipmentDecorator
4
+
5
+ def self.prepended(base)
6
+ base.state_machine.after_transition to: :shipped, do: :send_shipment_update
7
+ end
8
+
9
+ def send_shipment_update
10
+ return unless order.is_channable_order?
11
+
12
+ client = ::Channable::Client.new
13
+ client.shipment_update(order.channable_order_id, channable_shipment)
14
+ end
15
+
16
+ def channable_shipment
17
+ {
18
+ tracking_code: tracking,
19
+ tracking_url: tracking_url,
20
+ transporter: shipping_method.channable_transporter_code
21
+ }.to_json
22
+ end
23
+
24
+ end
25
+ end
26
+ end
27
+
28
+ Spree::Shipment.prepend(Spree::SpreeChannable::ShipmentDecorator)
@@ -0,0 +1,11 @@
1
+ module Spree
2
+ module SpreeChannable
3
+ module ShipmentHandlerDecorator
4
+ def send_shipped_email
5
+ super unless @shipment.order.is_channable_order?
6
+ end
7
+ end
8
+ end
9
+ end
10
+
11
+ Spree::ShipmentHandler.prepend(Spree::SpreeChannable::ShipmentHandlerDecorator)
@@ -0,0 +1,78 @@
1
+ module Spree
2
+ module SpreeChannable
3
+ module VariantDecorator
4
+
5
+ def self.same_product_colors(variant)
6
+ joins(option_values: :translations).where(spree_option_value_translations: {presentation: variant.option_value('color')}, product_id: variant.product_id).includes(:default_price, option_values: :option_type)
7
+ end
8
+
9
+ def to_channable_feed_entry
10
+ return nil if price.blank?
11
+
12
+ Nokogiri::XML::Builder.new do |xml|
13
+ xml.product {
14
+ xml.id id
15
+ xml.product_id product.id
16
+ xml.title "#{product.name}"
17
+ xml.description ActionController::Base.helpers.strip_tags(product.normalized_description)
18
+ xml.link URI.join(::SpreeChannable.configuration.host, "/#{::SpreeChannable.configuration.url_prefix}/" + product.slug).to_s
19
+ (xml.image_link URI.join(::SpreeChannable.configuration.image_host, get_images.first.attachment.url(:large)).to_s) unless get_images.empty?
20
+ xml.condition product.property('product_condition') || ::SpreeChannable.configuration.product_condition
21
+
22
+ xml.availability can_supply?
23
+ xml.stock total_on_hand
24
+ xml.price price
25
+ xml.sale_price respond_to?(:sale_price) ? (sale_price || price) : price
26
+
27
+ xml.gtin sku
28
+ xml.mpn sku
29
+ xml.sku sku
30
+
31
+ xml.brand product.property('brand') || ::SpreeChannable.configuration.brand
32
+
33
+ xml.categories do
34
+ product.taxons.each do |taxon|
35
+ xml.category taxon.self_and_ancestors.collect(&:name).join('|')
36
+ end
37
+ end
38
+
39
+ xml.currency Spree::Config.currency
40
+ xml.locale I18n.default_locale
41
+
42
+ option_values.each do |option_value|
43
+ xml.send(option_value.option_type.name, option_value.presentation)
44
+ end
45
+
46
+ # Property fields
47
+
48
+ xml.gender product.property('gender') || 'Not set'
49
+ xml.delivery_period product.property('delivery_period') || ::SpreeChannable.configuration.delivery_period
50
+ xml.material product.property('material') || 'Not set'
51
+ }
52
+ end.to_xml
53
+ end
54
+
55
+ def get_images
56
+ images = []
57
+ if ::SpreeChannable.configuration.use_variant_images
58
+ if self.class.respond_to?(:same_product_colors)
59
+ images = self.class.same_product_colors(self).flat_map(&:images)
60
+ else
61
+ self.images
62
+ end
63
+ else
64
+ self.product.images
65
+ end
66
+
67
+ if images.any?
68
+ images
69
+ else
70
+ self.product.images
71
+ end
72
+ end
73
+
74
+ end
75
+ end
76
+ end
77
+
78
+ Spree::Variant.prepend(Spree::SpreeChannable::VariantDecorator)
@@ -0,0 +1,32 @@
1
+ Deface::Override.new(
2
+ virtual_path: "spree/admin/shared/sub_menu/_configuration",
3
+ name: "add_channable_settings_configuration_menu",
4
+ insert_bottom: '[data-hook="admin_configurations_sidebar_menu"]',
5
+ text: '<%= configurations_sidebar_menu_item "Channable settings", spree.admin_channable_settings_path %>'
6
+ )
7
+
8
+ shipping_method_form = <<-ERB
9
+
10
+ <div data-hook="admin_shipping_method_form_channable_name" class="col-md-2">
11
+ <%= f.field_container :channable_channel_name, :class => ['form-group'] do %>
12
+ <%= f.label :channable_channel_name, Spree.t(:channable_channel_name) + '(s)' %>
13
+ <%= f.text_field :channable_channel_name, class: 'form-control', label: false %>
14
+ <%= f.error_message_on :channable_channel_name %>
15
+ <% end %>
16
+ </div>
17
+
18
+ <div data-hook="admin_shipping_method_form_channable_transporter_code" class="col-md-2">
19
+ <%= f.field_container :channable_transporter_code, :class => ['form-group'] do %>
20
+ <%= f.label :channable_transporter_code, Spree.t(:channable_transporter_code) %>
21
+ <%= f.text_field :channable_transporter_code, class: 'form-control', label: false %>
22
+ <%= f.error_message_on :channable_transporter_code %>
23
+ <% end %>
24
+ </div>
25
+ ERB
26
+
27
+ Deface::Override.new(
28
+ virtual_path: "spree/admin/shipping_methods/_form",
29
+ name: "add_channable_settings_to_shipping_methods",
30
+ insert_after: '[data-hook="admin_shipping_method_form_tracking_url_field"]',
31
+ text: shipping_method_form
32
+ )
@@ -0,0 +1,13 @@
1
+ Deface::Override.new(
2
+ virtual_path: 'spree/admin/orders/index',
3
+ name: 'add tradebyte order info header',
4
+ insert_after: '#listing_orders thead th:nth-last-child(3)',
5
+ partial: 'spree/admin/orders/index_channable_state_override_head'
6
+ )
7
+
8
+ Deface::Override.new(
9
+ virtual_path: 'spree/admin/orders/index',
10
+ name: 'add tradebyte order info',
11
+ insert_after: '#listing_orders tbody td:nth-last-child(3)',
12
+ partial: 'spree/admin/orders/index_channable_state_override'
13
+ )
@@ -0,0 +1,105 @@
1
+ <%= form_for [:admin, resource] do |f| %>
2
+ <div data-hook="">
3
+ <div class="row">
4
+ <div class="col-md-12">
5
+ <h2>Feed settings</h2>
6
+ </div>
7
+ <div class="col-md-6">
8
+ <div class="form-group">
9
+ <%= f.label :host %>
10
+ <%= f.text_field :host, class: 'form-control' %>
11
+ </div>
12
+ </div>
13
+ <div class="col-md-6">
14
+ <div class="form-group">
15
+ <%= f.label :url_prefix, 'Product url prefix (eg. /products)' %>
16
+ <%= f.text_field :url_prefix, class: 'form-control' %>
17
+ </div>
18
+ </div>
19
+ <div class="col-md-6">
20
+ <div class="form-group">
21
+ <%= f.label :image_host %>
22
+ <%= f.text_field :image_host, class: 'form-control' %>
23
+ </div>
24
+ </div>
25
+ <div class="col-md-6">
26
+ <div class="form-group">
27
+ <%= f.label :product_condition %>
28
+ <%= f.select :product_condition, options_for_select(ChannableSetting::PRODUCT_CONDITIONS), {}, class: 'form-control' %>
29
+ </div>
30
+ </div>
31
+ <div class="col-md-6">
32
+ <div class="form-group">
33
+ <%= f.label :brand %>
34
+ <%= f.text_field :brand, class: 'form-control' %>
35
+ </div>
36
+ </div>
37
+ <div class="col-md-6">
38
+ <div class="form-group">
39
+ <%= f.label :delivery_period %>
40
+ <%= f.text_field :delivery_period, class: 'form-control' %>
41
+ </div>
42
+ </div>
43
+
44
+ <div class="col-md-12">
45
+ <div class="form-check">
46
+ <%= f.check_box :use_variant_images, class: 'form-check-input' %>
47
+ <%= f.label :use_variant_images, 'Use images on the variant instead of all image', class: 'form-check-label' %>
48
+ </div>
49
+ </div>
50
+ </div>
51
+
52
+ <div class="row">
53
+ <div class="col-md-12">
54
+ <h2>Order settings</h2>
55
+ </div>
56
+ <div class="col-md-12">
57
+ <div class="form-group">
58
+ <%= f.label :channable_api_key %>
59
+ <%= f.text_field :channable_api_key, class: 'form-control' %>
60
+ </div>
61
+ </div>
62
+ <div class="col-md-6">
63
+ <div class="form-group">
64
+ <%= f.label :company_id %>
65
+ <%= f.text_field :company_id, class: 'form-control' %>
66
+ </div>
67
+ </div>
68
+ <div class="col-md-6">
69
+ <div class="form-group">
70
+ <%= f.label :project_id %>
71
+ <%= f.text_field :project_id, class: 'form-control' %>
72
+ </div>
73
+ </div>
74
+ <div class="col-md-6">
75
+ <div class="form-group">
76
+ <%= f.label :spree_stock_location_id, 'Stock location' %>
77
+ <%= f.select :spree_stock_location_id, options_from_collection_for_select(Spree::StockLocation.all, :id, :name, f.object.spree_stock_location_id), {}, class: 'form-control' %>
78
+ </div>
79
+ </div>
80
+ <div class="col-md-6">
81
+ <div class="form-group">
82
+ <%= f.label :spree_payment_method_id, 'Payment method' %>
83
+ <%= f.select :spree_payment_method_id, options_from_collection_for_select(Spree::PaymentMethod.all, :id, :name, f.object.spree_payment_method_id), {}, class: 'form-control' %>
84
+ </div>
85
+ </div>
86
+
87
+ <div class="col-md-6">
88
+ <div class="form-group">
89
+ <%= f.label :polling_interval, 'How often do we need to retrieve orders (minutes)' %>
90
+ <%= f.number_field :polling_interval, class: 'form-control' %>
91
+ </div>
92
+ </div>
93
+
94
+ <div class="col-md-12">
95
+ <div class="form-check">
96
+ <%= f.check_box :active, class: 'form-check-input' %>
97
+ <%= f.label :active, 'Connection active?', class: 'form-check-label' %>
98
+ </div>
99
+ </div>
100
+ </div>
101
+
102
+ </div>
103
+
104
+ <%= render "spree/admin/shared/#{resource.new_record? ? 'new' : 'edit'}_resource_links" %>
105
+ <% end %>
@@ -0,0 +1 @@
1
+ <%= render 'form', resource: @channable_setting %>
@@ -0,0 +1 @@
1
+ <%= render 'form', resource: @channable_setting %>
@@ -0,0 +1,7 @@
1
+ <td>
2
+ <% if order.is_channable_order? %>
3
+ <span class="label label-success">Channable order <%= order.channable_order_id %> <%= order.channable_channel_name %></span>
4
+ <% else %>
5
+ <span class="label label-success">Regular order</span>
6
+ <% end %>
7
+ </td>
@@ -0,0 +1 @@
1
+ <th><%= sort_link @search, :is_channable_order?, 'Type' %></th>
data/bin/rails ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" from the root of your extension
3
+
4
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
5
+ ENGINE_PATH = File.expand_path('../../lib/spree_channable/engine', __FILE__)
6
+
7
+ require 'rails/all'
8
+ require 'rails/engine/commands'
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
data/config/routes.rb ADDED
@@ -0,0 +1,18 @@
1
+ Spree::Core::Engine.add_routes do
2
+
3
+ namespace :admin do
4
+ resources :channable_settings
5
+ end
6
+
7
+ namespace :api do
8
+ namespace :v1 do
9
+ resources :channable, only: [] do
10
+ collection do
11
+ get :product_feed
12
+ get :variant_feed
13
+ end
14
+ end
15
+ end
16
+ end
17
+
18
+ end
@@ -0,0 +1,16 @@
1
+ class CreateChannableSettings < ActiveRecord::Migration[5.0]
2
+ def change
3
+ create_table :channable_settings do |t|
4
+
5
+ t.string :host
6
+ t.string :url_prefix
7
+ t.string :image_host
8
+ t.string :product_condition
9
+ t.string :brand
10
+ t.string :delivery_period
11
+ t.boolean :use_variant_images
12
+
13
+ t.timestamps
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,9 @@
1
+ class AddSettingsToSettingsTable < ActiveRecord::Migration[5.0]
2
+ def change
3
+ change_table :channable_settings do |t|
4
+ t.string :channable_api_key
5
+ t.string :company_id
6
+ t.string :project_id
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class AddOrderColumns < ActiveRecord::Migration[5.0]
2
+ def change
3
+ change_table :spree_orders do |t|
4
+ t.integer :channable_order_id
5
+ t.string :channable_channel_order_id
6
+ t.string :channable_channel_name
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ class SetOrderConnectionDefaults < ActiveRecord::Migration[5.0]
2
+ def change
3
+ add_column :channable_settings, :spree_stock_location_id, :integer
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ class AddChannableFieldsToShippingMethods < ActiveRecord::Migration[5.0]
2
+ def change
3
+ change_table :spree_shipping_methods do |t|
4
+ t.string :channable_channel_name
5
+ t.string :channable_transporter_code
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,7 @@
1
+ class AddPaymentMethodForChannable < ActiveRecord::Migration[5.0]
2
+ def change
3
+
4
+ Spree::PaymentMethod.find_or_create_by(name: 'Paid at channable', display_on: :back_end, type: 'Spree::PaymentMethod::Check', active: true)
5
+
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ class AddOrderImportSettings < ActiveRecord::Migration[5.0]
2
+ def change
3
+ change_table :channable_settings do |t|
4
+ t.integer :polling_interval, default: 30
5
+ t.integer :spree_payment_method_id
6
+ t.boolean :active, default: false
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ class AddChannableIdToReturnAuthorisations < ActiveRecord::Migration[5.0]
2
+ def change
3
+ add_column :spree_customer_returns, :channable_return_id, :integer
4
+ end
5
+ end
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gem 'rails-controller-testing'
6
+ gem 'spree_core', '~> 3.2.0'
7
+ gem 'spree_backend', '~> 3.2.0'
8
+ gem 'spree_auth_devise', '~> 3.4.0'
9
+
10
+ gemspec path: '../'
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gem 'rails-controller-testing'
6
+ gem 'spree_core', '~> 3.5.0'
7
+ gem 'spree_backend', '~> 3.5.0'
8
+ gem 'spree_auth_devise', '~> 3.4.0'
9
+
10
+ gemspec path: '../'
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gem 'rails-controller-testing'
6
+ gem 'spree_core', '~> 3.7.0'
7
+ gem 'spree_backend', '~> 3.7.0'
8
+ gem 'spree_auth_devise', '~> 3.5.0'
9
+
10
+ gemspec path: '../'
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gem 'rails-controller-testing'
6
+ gem 'spree_core', github: 'spree/spree', branch: 'master'
7
+ gem 'spree_backend', github: 'spree/spree', branch: 'master'
8
+ gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: 'master'
9
+
10
+ gemspec path: '../'
@@ -0,0 +1,42 @@
1
+ require 'httparty'
2
+
3
+ module Channable
4
+ class Client
5
+ include ::HTTParty
6
+
7
+ def initialize
8
+ self.class.base_uri "https://api.channable.com/v1/companies/#{SpreeChannable.configuration.company_id}/projects/#{SpreeChannable.configuration.project_id}"
9
+ self.class.headers 'Authorization' => "Bearer #{SpreeChannable.configuration.channable_api_key}"
10
+ self.class.headers 'Content-Type' => 'application/json'
11
+ end
12
+
13
+ def get_orders(start_date: 1.day.ago, offset: 0, limit: 100)
14
+ Channable::Response.new(self.class.get('/orders', query: {
15
+ limit: limit,
16
+ start_date: start_date.strftime('%Y-%m-%d'),
17
+ offset: offset
18
+ }))
19
+ end
20
+
21
+ def get_returns(start_date: 1.day.ago, offset: 0, limit: 100)
22
+ Channable::Response.new(self.class.get('/returns', query: {
23
+ limit: limit,
24
+ start_date: start_date,
25
+ offset: offset
26
+ }))
27
+ end
28
+
29
+ def return_update(return_id, return_body)
30
+ Channable::Response.new(self.class.post("/returns/#{return_id}/status", body: return_body))
31
+ end
32
+
33
+ def shipment_update(order_id, shipment_body)
34
+ Channable::Response.new(self.class.post("/orders/#{order_id}/shipment", body: shipment_body))
35
+ end
36
+
37
+ def cancellation_update(order_id)
38
+ Channable::Response.new(self.class.post("/orders/#{order_id}/cancel"))
39
+ end
40
+
41
+ end
42
+ end
@@ -0,0 +1,15 @@
1
+ module Channable
2
+ class Response
3
+
4
+ attr_reader :data
5
+ attr_reader :success
6
+ attr_reader :response
7
+
8
+ def initialize(response_data)
9
+ @response = response_data
10
+ @success = response_data.success?
11
+ @data = JSON.parse(response_data.body, object_class: OpenStruct)
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,20 @@
1
+ module SpreeChannable
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=spree_channable'
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,20 @@
1
+ module SpreeChannable
2
+ class Engine < Rails::Engine
3
+ require 'spree/core'
4
+ isolate_namespace Spree
5
+ engine_name 'spree_channable'
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
+ FactoryBot.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_channable/factories'
6
+ end