effective_orders 2.1.15 → 2.1.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ca6da0e977e0e456567e46e5a8eab5f9c5e252fd
4
- data.tar.gz: 54827af9c1c203e8ce15b9b2632fe910694e4e29
3
+ metadata.gz: c64d51c4326b5857b31313d877c0058c0c9b64e1
4
+ data.tar.gz: 926b603e981b5da23d2b13ffec658b4818180ab1
5
5
  SHA512:
6
- metadata.gz: 7766acc4e55e0ebaf3373c5ed61265fba588e82ee3ab3fc0d864626f3c0f7a9560f8baaafbac9d9c74fabe8f0d5236b62524f3aabe2da22fc4d7fc53604fa1ce
7
- data.tar.gz: 804471f7cb3c239c76825c1882731de30036fd9745da792cfd0c87964e44c21669be97056a5632fa9d1c345e9ae8dfa840d4c91fb3bdf7b57b08cad82fe60c4f
6
+ metadata.gz: 8d9c2b16a7977b527613b415ced35c1749e1ef256f183175f3ff6135f1f296750e64d36c7611831d236d8231bd5472608662469dbad85814d2c6e43b6beda3d8
7
+ data.tar.gz: 7a4a1957c65e0bcc72251903d1b1f8b62318bc0cbd461b31a3d8835840e8a283aa2bdc39f2870dfdd15ba0180a57dc7ec345d2cbf3c300ab71ae4f2a24e2edd0
data/README.md CHANGED
@@ -12,11 +12,7 @@ Has Order History, My Purchases, My Sales and Admin screens.
12
12
 
13
13
  ## Getting Started
14
14
 
15
- Check your ruby version. As of the 2.0 branch, effective_orders requires a minimum ruby version of `2.1`:
16
-
17
- ```console
18
- ruby -v
19
- ```
15
+ Please first install the [effective_addresses](https://github.com/code-and-effect/effective_addresses) and [effective_datatables](https://github.com/code-and-effect/effective_datatables) gems.
20
16
 
21
17
  Add to your Gemfile:
22
18
 
@@ -645,6 +641,19 @@ and then in the view:
645
641
  render_datatable @datatable
646
642
  ```
647
643
 
644
+ ## Rake Tasks
645
+
646
+ ### Overwrite order item titles
647
+
648
+ When an order is purchased, the `title()` of each `acts_as_purchasable` object is saved to the database.
649
+
650
+ If you change the output of `acts_as_purchasable`.`title`, any existing order items will remain unchanged.
651
+
652
+ Run this script to overwrite all saved order item titles with the current `acts_as_purchasable`.`title`.
653
+
654
+ ```ruby
655
+ rake effective_orders:overwrite_order_item_titles
656
+ ```
648
657
 
649
658
  ## Testing in Development
650
659
 
@@ -1,6 +1,6 @@
1
1
  module Admin
2
2
  class CustomersController < ApplicationController
3
- before_filter :authenticate_user! # This is devise, ensure we're logged in.
3
+ respond_to?(:before_action) ? before_action(:authenticate_user!) : before_filter(:authenticate_user!) # Devise
4
4
 
5
5
  layout (EffectiveOrders.layout.kind_of?(Hash) ? EffectiveOrders.layout[:admin_customers] : EffectiveOrders.layout)
6
6
 
@@ -1,6 +1,6 @@
1
1
  module Admin
2
2
  class OrderItemsController < ApplicationController
3
- before_filter :authenticate_user! # This is devise, ensure we're logged in.
3
+ respond_to?(:before_action) ? before_action(:authenticate_user!) : before_filter(:authenticate_user!) # Devise
4
4
 
5
5
  layout (EffectiveOrders.layout.kind_of?(Hash) ? EffectiveOrders.layout[:admin_orders] : EffectiveOrders.layout)
6
6
 
@@ -1,6 +1,6 @@
1
1
  module Admin
2
2
  class OrdersController < ApplicationController
3
- before_filter :authenticate_user! # This is devise, ensure we're logged in.
3
+ respond_to?(:before_action) ? before_action(:authenticate_user!) : before_filter(:authenticate_user!) # Devise
4
4
 
5
5
  layout (EffectiveOrders.layout.kind_of?(Hash) ? EffectiveOrders.layout[:admin_orders] : EffectiveOrders.layout)
6
6
 
@@ -16,10 +16,18 @@ module Effective
16
16
  layout (EffectiveOrders.layout.kind_of?(Hash) ? EffectiveOrders.layout[:orders] : EffectiveOrders.layout)
17
17
 
18
18
  if defined?(Devise)
19
- before_filter :authenticate_user!, except: [:paypal_postback, :ccbill_postback]
19
+ if respond_to?(:before_action)
20
+ before_action :authenticate_user!, except: [:paypal_postback, :ccbill_postback]
21
+ else
22
+ before_filter :authenticate_user!, except: [:paypal_postback, :ccbill_postback]
23
+ end
20
24
  end
21
25
 
22
- before_filter :set_page_title, except: [:show]
26
+ if respond_to?(:before_action)
27
+ before_action :set_page_title, except: [:show]
28
+ else
29
+ before_filter :set_page_title, except: [:show]
30
+ end
23
31
 
24
32
  # This is the entry point for the "Checkout" buttons
25
33
  def new
@@ -4,7 +4,11 @@ module Effective
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  included do
7
- skip_before_filter :verify_authenticity_token, only: [:ccbill_postback]
7
+ if respond_to?(:skip_before_action)
8
+ skip_before_action :verify_authenticity_token, only: [:ccbill_postback]
9
+ else
10
+ skip_before_filter :verify_authenticity_token, only: [:ccbill_postback]
11
+ end
8
12
  end
9
13
 
10
14
  def ccbill_postback
@@ -4,7 +4,11 @@ module Effective
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  included do
7
- prepend_before_filter :find_authenticity_token_from_moneris, only: [:moneris_postback]
7
+ if respond_to?(:prepend_before_action)
8
+ prepend_before_action :find_authenticity_token_from_moneris, only: [:moneris_postback]
9
+ else
10
+ prepend_before_filter :find_authenticity_token_from_moneris, only: [:moneris_postback]
11
+ end
8
12
  end
9
13
 
10
14
  def moneris_postback
@@ -4,7 +4,11 @@ module Effective
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  included do
7
- skip_before_filter :verify_authenticity_token, :only => [:paypal_postback]
7
+ if respond_to?(:skip_before_action)
8
+ skip_before_action :verify_authenticity_token, :only => [:paypal_postback]
9
+ else
10
+ skip_before_filter :verify_authenticity_token, :only => [:paypal_postback]
11
+ end
8
12
  end
9
13
 
10
14
  def paypal_postback
@@ -4,7 +4,11 @@ module Effective
4
4
  extend ActiveSupport::Concern
5
5
 
6
6
  included do
7
- prepend_before_filter :set_stripe_connect_state_params, :only => [:stripe_connect_redirect_uri]
7
+ if respond_to?(:prepend_before_action)
8
+ prepend_before_action :set_stripe_connect_state_params, :only => [:stripe_connect_redirect_uri]
9
+ else
10
+ prepend_before_filter :set_stripe_connect_state_params, :only => [:stripe_connect_redirect_uri]
11
+ end
8
12
  end
9
13
 
10
14
  # So this is the postback after Stripe does its oAuth authentication
@@ -5,8 +5,8 @@ module Effective
5
5
 
6
6
  layout (EffectiveOrders.layout.kind_of?(Hash) ? EffectiveOrders.layout[:subscriptions] : EffectiveOrders.layout)
7
7
 
8
- before_filter :authenticate_user!
9
- before_filter :assign_customer
8
+ respond_to?(:before_action) ? before_action(:authenticate_user!) : before_filter(:authenticate_user!) # Devise
9
+ respond_to?(:before_action) ? before_action(:assign_customer) : before_filter(:assign_customer)
10
10
 
11
11
  # This is a 'My Subscriptions' page
12
12
  def index
@@ -274,23 +274,23 @@ module Effective
274
274
  end
275
275
 
276
276
  def save_billing_address?
277
- ::ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include?(self.save_billing_address)
277
+ truthy?(self.save_billing_address)
278
278
  end
279
279
 
280
280
  def save_shipping_address?
281
- ::ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include?(self.save_shipping_address)
281
+ truthy?(self.save_shipping_address)
282
282
  end
283
283
 
284
284
  def send_payment_request_to_buyer?
285
- ::ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include?(self.send_payment_request_to_buyer)
285
+ truthy?(self.send_payment_request_to_buyer)
286
286
  end
287
287
 
288
288
  def send_mark_as_paid_email_to_buyer?
289
- ::ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include?(self.send_mark_as_paid_email_to_buyer)
289
+ truthy?(self.send_mark_as_paid_email_to_buyer)
290
290
  end
291
291
 
292
292
  def skip_buyer_validations?
293
- ::ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include?(self.skip_buyer_validations)
293
+ truthy?(self.skip_buyer_validations)
294
294
  end
295
295
 
296
296
  def billing_name
@@ -457,5 +457,14 @@ module Effective
457
457
  return false
458
458
  end
459
459
  end
460
+
461
+ def truthy?(value)
462
+ if defined?(::ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES) # Rails <5
463
+ ::ActiveRecord::ConnectionAdapters::Column::TRUE_VALUES.include?(value)
464
+ else
465
+ ActiveRecord::Type::Boolean.new.cast(value)
466
+ end
467
+ end
468
+
460
469
  end
461
470
  end
@@ -1,6 +1,4 @@
1
1
  %p.text-right
2
2
  = form.button :submit, 'Save', data: { disable_with: 'Saving...' }
3
3
  = form.button :submit, 'Save and Add New', data: { disable_with: 'Saving...' }
4
- - unless params[:action] == 'mark_as_paid'
5
- = form.button :submit, 'Save and Mark as Paid', data: { disable_with: 'Saving...' }
6
4
  = link_to 'Cancel', effective_orders.admin_orders_path
@@ -45,7 +45,7 @@ EffectiveOrders.setup do |config|
45
45
  config.active_admin_namespace = :admin # Passed internally to ActiveAdmin.register
46
46
 
47
47
  # Use effective_obfuscation gem to change order.id into a seemingly random 10-digit number
48
- config.obfuscate_order_ids = true
48
+ config.obfuscate_order_ids = false
49
49
 
50
50
  # Silence the price deprecation warnings
51
51
  config.silence_deprecation_warnings = false
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '2.1.15'.freeze
2
+ VERSION = '2.1.16'.freeze
3
3
  end
@@ -15,6 +15,10 @@ module EffectiveOrders
15
15
  end
16
16
  end
17
17
 
18
+ def install_effective_addresses
19
+ run "rails generate effective_addresses:install"
20
+ end
21
+
18
22
  def copy_initializer
19
23
  template ('../' * 3) + 'config/effective_orders.rb', 'config/initializers/effective_orders.rb'
20
24
  end
@@ -0,0 +1,28 @@
1
+ namespace :effective_orders do
2
+ desc 'Overwrite all order item titles with current acts_as_purchasable object title'
3
+ task overwrite_order_item_titles: :environment do
4
+ puts 'WARNING: this task will overwrite all existing order items with new titles. Proceed? (y/n)'
5
+ (puts 'Aborted' and exit) unless STDIN.gets.chomp.downcase == 'y'
6
+
7
+ Effective::OrderItem.transaction do
8
+ begin
9
+
10
+ Effective::OrderItem.includes(:purchasable).find_each do |order_item|
11
+ new_title = order_item.purchasable.title
12
+
13
+ unless new_title
14
+ raise "acts_as_purchasable object #{order_item.purchasable_type.try(:classify)}<#{order_item.purchasable_id}>.title() from Effective::OrderItem<#{order_item.id}> cannot be nil."
15
+ end
16
+
17
+ order_item.update_column(:title, new_title) # This intentionally skips validation
18
+ end
19
+
20
+ puts 'Successfully updated all order item titles.'
21
+ rescue => e
22
+ puts "An error has occurred: #{e.message}"
23
+ puts "(effective_orders) Rollback. No order item titles have been changed."
24
+ raise ActiveRecord::Rollback
25
+ end
26
+ end
27
+ end
28
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_orders
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.15
4
+ version: 2.1.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-11 00:00:00.000000000 Z
11
+ date: 2016-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -384,6 +384,7 @@ files:
384
384
  - lib/generators/effective_orders/upgrade_from1x_generator.rb
385
385
  - lib/generators/effective_orders/upgrade_price_column_generator.rb
386
386
  - lib/generators/templates/effective_orders_mailer_preview.rb
387
+ - lib/tasks/effective_orders_tasks.rake
387
388
  - spec/controllers/admin/orders_controller_spec.rb
388
389
  - spec/controllers/carts_controller_spec.rb
389
390
  - spec/controllers/ccbill_orders_controller_spec.rb