diff options
38 files changed, 51 insertions, 45 deletions
@@ -5,6 +5,10 @@ gem 'solidus', github: 'solidusio/solidus', branch: branch # Provides basic authentication functionality for testing parts of your engine gem 'solidus_auth_devise', '~> 1.0' +if branch != 'master' && branch < 'v2.0' + gem "rails_test_params_backport", group: :test +end + gem 'pg' gem 'mysql2' gem 'listen' diff --git a/app/controllers/solidus_subscriptions/api/v1/line_items_controller.rb b/app/controllers/solidus_subscriptions/api/v1/line_items_controller.rb index 45afe27..1fba77f 100644 --- a/app/controllers/solidus_subscriptions/api/v1/line_items_controller.rb +++ b/app/controllers/solidus_subscriptions/api/v1/line_items_controller.rb @@ -1,5 +1,5 @@ class SolidusSubscriptions::Api::V1::LineItemsController < Spree::Api::BaseController - before_filter :load_line_item, only: [:update, :destroy] + before_action :load_line_item, only: [:update, :destroy] wrap_parameters :subscription_line_item def update diff --git a/app/controllers/solidus_subscriptions/api/v1/subscriptions_controller.rb b/app/controllers/solidus_subscriptions/api/v1/subscriptions_controller.rb index 618cf6e..79d1f5f 100644 --- a/app/controllers/solidus_subscriptions/api/v1/subscriptions_controller.rb +++ b/app/controllers/solidus_subscriptions/api/v1/subscriptions_controller.rb @@ -1,5 +1,5 @@ class SolidusSubscriptions::Api::V1::SubscriptionsController < Spree::Api::BaseController - before_filter :load_subscription, only: [:cancel, :update, :skip] + before_action :load_subscription, only: [:cancel, :update, :skip] def update if @subscription.update(subscription_params) diff --git a/app/controllers/spree/admin/subscriptions_controller.rb b/app/controllers/spree/admin/subscriptions_controller.rb index 5078763..ae737a1 100644 --- a/app/controllers/spree/admin/subscriptions_controller.rb +++ b/app/controllers/spree/admin/subscriptions_controller.rb @@ -1,7 +1,7 @@ module Spree module Admin class SubscriptionsController < ResourceController - skip_before_filter :load_resource, only: :index + skip_before_action :load_resource, only: :index def index @search = SolidusSubscriptions::Subscription. diff --git a/app/models/solidus_subscriptions/line_item.rb b/app/models/solidus_subscriptions/line_item.rb index f014a02..33e9d82 100644 --- a/app/models/solidus_subscriptions/line_item.rb +++ b/app/models/solidus_subscriptions/line_item.rb @@ -30,7 +30,7 @@ module SolidusSubscriptions validates :subscribable_id, presence: :true validates :quantity, :interval_length, numericality: { greater_than: 0 } - before_save :update_actionable_date_if_interval_changed + before_update :update_actionable_date_if_interval_changed def next_actionable_date dummy_subscription.next_actionable_date diff --git a/db/migrate/20160825164850_create_solidus_subscriptions_subscriptions.rb b/db/migrate/20160825164850_create_solidus_subscriptions_subscriptions.rb index 5908d89..e736a86 100644 --- a/db/migrate/20160825164850_create_solidus_subscriptions_subscriptions.rb +++ b/db/migrate/20160825164850_create_solidus_subscriptions_subscriptions.rb @@ -1,4 +1,4 @@ -class CreateSolidusSubscriptionsSubscriptions < ActiveRecord::Migration +class CreateSolidusSubscriptionsSubscriptions < SolidusSupport::Migration[4.2] def change create_table :solidus_subscriptions_subscriptions do |t| t.date :actionable_date diff --git a/db/migrate/20160825173548_create_solidus_subscriptions_line_items.rb b/db/migrate/20160825173548_create_solidus_subscriptions_line_items.rb index d79408e..06141ab 100644 --- a/db/migrate/20160825173548_create_solidus_subscriptions_line_items.rb +++ b/db/migrate/20160825173548_create_solidus_subscriptions_line_items.rb @@ -1,4 +1,4 @@ -class CreateSolidusSubscriptionsLineItems < ActiveRecord::Migration +class CreateSolidusSubscriptionsLineItems < SolidusSupport::Migration[4.2] def change create_table :solidus_subscriptions_line_items do |t| t.references :spree_line_item, index: true, foreign_key: true, null: false diff --git a/db/migrate/20160825202248_create_solidus_subscriptions_installments.rb b/db/migrate/20160825202248_create_solidus_subscriptions_installments.rb index 784d184..8ec5d83 100644 --- a/db/migrate/20160825202248_create_solidus_subscriptions_installments.rb +++ b/db/migrate/20160825202248_create_solidus_subscriptions_installments.rb @@ -1,4 +1,4 @@ -class CreateSolidusSubscriptionsInstallments < ActiveRecord::Migration +class CreateSolidusSubscriptionsInstallments < SolidusSupport::Migration[4.2] def change create_table :solidus_subscriptions_installments do |t| t.references :subscription, index: true, null: false diff --git a/db/migrate/20160825211202_create_solidus_subscriptions_installment_details.rb b/db/migrate/20160825211202_create_solidus_subscriptions_installment_details.rb index 01583e6..d153738 100644 --- a/db/migrate/20160825211202_create_solidus_subscriptions_installment_details.rb +++ b/db/migrate/20160825211202_create_solidus_subscriptions_installment_details.rb @@ -1,4 +1,4 @@ -class CreateSolidusSubscriptionsInstallmentDetails < ActiveRecord::Migration +class CreateSolidusSubscriptionsInstallmentDetails < SolidusSupport::Migration[4.2] def change create_table :solidus_subscriptions_installment_details do |t| t.references :installment, null: false diff --git a/db/migrate/20160825214240_add_subscribable_to_spree_variants.rb b/db/migrate/20160825214240_add_subscribable_to_spree_variants.rb index b81f41f..a8fbe77 100644 --- a/db/migrate/20160825214240_add_subscribable_to_spree_variants.rb +++ b/db/migrate/20160825214240_add_subscribable_to_spree_variants.rb @@ -1,4 +1,4 @@ -class AddSubscribableToSpreeVariants < ActiveRecord::Migration +class AddSubscribableToSpreeVariants < SolidusSupport::Migration[4.2] def change add_column :spree_variants, :subscribable, :boolean, default: false end diff --git a/db/migrate/20160829201653_change_subscription_line_items_installments_to_max_installments.rb b/db/migrate/20160829201653_change_subscription_line_items_installments_to_max_installments.rb index cefbe50..702e120 100644 --- a/db/migrate/20160829201653_change_subscription_line_items_installments_to_max_installments.rb +++ b/db/migrate/20160829201653_change_subscription_line_items_installments_to_max_installments.rb @@ -1,4 +1,4 @@ -class ChangeSubscriptionLineItemsInstallmentsToMaxInstallments < ActiveRecord::Migration +class ChangeSubscriptionLineItemsInstallmentsToMaxInstallments < SolidusSupport::Migration[4.2] def change rename_column :solidus_subscriptions_line_items, :installments, :max_installments end diff --git a/db/migrate/20160902220242_remove_state_from_solidus_susbscriptions_installment_details.rb b/db/migrate/20160902220242_remove_state_from_solidus_susbscriptions_installment_details.rb index b609430..a7979e7 100644 --- a/db/migrate/20160902220242_remove_state_from_solidus_susbscriptions_installment_details.rb +++ b/db/migrate/20160902220242_remove_state_from_solidus_susbscriptions_installment_details.rb @@ -1,4 +1,4 @@ -class RemoveStateFromSolidusSusbscriptionsInstallmentDetails < ActiveRecord::Migration +class RemoveStateFromSolidusSusbscriptionsInstallmentDetails < SolidusSupport::Migration[4.2] def change remove_column :solidus_subscriptions_installment_details, :state, :string end diff --git a/db/migrate/20160902220604_add_successful_to_solidus_subscriptions_installment_details.rb b/db/migrate/20160902220604_add_successful_to_solidus_subscriptions_installment_details.rb index 80f66b8..3e32911 100644 --- a/db/migrate/20160902220604_add_successful_to_solidus_subscriptions_installment_details.rb +++ b/db/migrate/20160902220604_add_successful_to_solidus_subscriptions_installment_details.rb @@ -1,4 +1,4 @@ -class AddSuccessfulToSolidusSubscriptionsInstallmentDetails < ActiveRecord::Migration +class AddSuccessfulToSolidusSubscriptionsInstallmentDetails < SolidusSupport::Migration[4.2] def change add_column :solidus_subscriptions_installment_details, :success, :boolean end diff --git a/db/migrate/20160902221218_add_message_to_solidus_subscriptions_installment_details.rb b/db/migrate/20160902221218_add_message_to_solidus_subscriptions_installment_details.rb index 2f51273..829c1a2 100644 --- a/db/migrate/20160902221218_add_message_to_solidus_subscriptions_installment_details.rb +++ b/db/migrate/20160902221218_add_message_to_solidus_subscriptions_installment_details.rb @@ -1,4 +1,4 @@ -class AddMessageToSolidusSubscriptionsInstallmentDetails < ActiveRecord::Migration +class AddMessageToSolidusSubscriptionsInstallmentDetails < SolidusSupport::Migration[4.2] def change add_column :solidus_subscriptions_installment_details, :message, :string end diff --git a/db/migrate/20160922164101_add_interval_length_and_units_to_subscription_line_items.rb b/db/migrate/20160922164101_add_interval_length_and_units_to_subscription_line_items.rb index 4fcd0cb..d9c503e 100644 --- a/db/migrate/20160922164101_add_interval_length_and_units_to_subscription_line_items.rb +++ b/db/migrate/20160922164101_add_interval_length_and_units_to_subscription_line_items.rb @@ -1,4 +1,4 @@ -class AddIntervalLengthAndUnitsToSubscriptionLineItems < ActiveRecord::Migration +class AddIntervalLengthAndUnitsToSubscriptionLineItems < SolidusSupport::Migration[4.2] def change add_column :solidus_subscriptions_line_items, :interval_units, :integer add_column :solidus_subscriptions_line_items, :interval_length, :integer diff --git a/db/migrate/20161006191003_add_skip_count_to_solidus_subscriptions_subscriptions.rb b/db/migrate/20161006191003_add_skip_count_to_solidus_subscriptions_subscriptions.rb index c944f05..46e0c58 100644 --- a/db/migrate/20161006191003_add_skip_count_to_solidus_subscriptions_subscriptions.rb +++ b/db/migrate/20161006191003_add_skip_count_to_solidus_subscriptions_subscriptions.rb @@ -1,4 +1,4 @@ -class AddSkipCountToSolidusSubscriptionsSubscriptions < ActiveRecord::Migration +class AddSkipCountToSolidusSubscriptionsSubscriptions < SolidusSupport::Migration[4.2] def change add_column :solidus_subscriptions_subscriptions, :skip_count, :integer, default: 0, null: false end diff --git a/db/migrate/20161006191127_add_successive_skip_count_to_solidus_subscriptions_subscriptions.rb b/db/migrate/20161006191127_add_successive_skip_count_to_solidus_subscriptions_subscriptions.rb index bcef048..ef6ac4c 100644 --- a/db/migrate/20161006191127_add_successive_skip_count_to_solidus_subscriptions_subscriptions.rb +++ b/db/migrate/20161006191127_add_successive_skip_count_to_solidus_subscriptions_subscriptions.rb @@ -1,4 +1,4 @@ -class AddSuccessiveSkipCountToSolidusSubscriptionsSubscriptions < ActiveRecord::Migration +class AddSuccessiveSkipCountToSolidusSubscriptionsSubscriptions < SolidusSupport::Migration[4.2] def change add_column :solidus_subscriptions_subscriptions, :successive_skip_count, :integer, default: 0, null: false end diff --git a/db/migrate/20161014212649_allow_spree_line_item_id_to_be_null.rb b/db/migrate/20161014212649_allow_spree_line_item_id_to_be_null.rb index ebe3e7c..3c324f9 100644 --- a/db/migrate/20161014212649_allow_spree_line_item_id_to_be_null.rb +++ b/db/migrate/20161014212649_allow_spree_line_item_id_to_be_null.rb @@ -1,4 +1,4 @@ -class AllowSpreeLineItemIdToBeNull < ActiveRecord::Migration +class AllowSpreeLineItemIdToBeNull < SolidusSupport::Migration[4.2] def change change_column_null :solidus_subscriptions_line_items, :spree_line_item_id, true end diff --git a/db/migrate/20161017155749_add_order_id_to_solidus_subscriptions_installment_details.rb b/db/migrate/20161017155749_add_order_id_to_solidus_subscriptions_installment_details.rb index 4ea15e4..fc7d76f 100644 --- a/db/migrate/20161017155749_add_order_id_to_solidus_subscriptions_installment_details.rb +++ b/db/migrate/20161017155749_add_order_id_to_solidus_subscriptions_installment_details.rb @@ -1,4 +1,4 @@ -class AddOrderIdToSolidusSubscriptionsInstallmentDetails < ActiveRecord::Migration +class AddOrderIdToSolidusSubscriptionsInstallmentDetails < SolidusSupport::Migration[4.2] def change add_reference :solidus_subscriptions_installment_details, :order, index: true add_foreign_key :solidus_subscriptions_installment_details, :spree_orders, column: :order_id diff --git a/db/migrate/20161017175509_remove_order_id_from_solidus_subscriptions_installments.rb b/db/migrate/20161017175509_remove_order_id_from_solidus_subscriptions_installments.rb index 68e87e9..dc63f59 100644 --- a/db/migrate/20161017175509_remove_order_id_from_solidus_subscriptions_installments.rb +++ b/db/migrate/20161017175509_remove_order_id_from_solidus_subscriptions_installments.rb @@ -1,4 +1,4 @@ -class RemoveOrderIdFromSolidusSubscriptionsInstallments < ActiveRecord::Migration +class RemoveOrderIdFromSolidusSubscriptionsInstallments < SolidusSupport::Migration[4.2] def change remove_foreign_key :solidus_subscriptions_installments, column: :order_id remove_column :solidus_subscriptions_installments, :order_id, :integer diff --git a/db/migrate/20161017201944_add_subscription_order_to_spree_orders.rb b/db/migrate/20161017201944_add_subscription_order_to_spree_orders.rb index e6069ad..d6b0ee5 100644 --- a/db/migrate/20161017201944_add_subscription_order_to_spree_orders.rb +++ b/db/migrate/20161017201944_add_subscription_order_to_spree_orders.rb @@ -1,4 +1,4 @@ -class AddSubscriptionOrderToSpreeOrders < ActiveRecord::Migration +class AddSubscriptionOrderToSpreeOrders < SolidusSupport::Migration[4.2] def change add_column :spree_orders, :subscription_order, :boolean, default: false, null: false end diff --git a/db/migrate/20161221155142_add_store_to_solidus_subscriptions_subscriptions.rb b/db/migrate/20161221155142_add_store_to_solidus_subscriptions_subscriptions.rb index 06eed98..1808df6 100644 --- a/db/migrate/20161221155142_add_store_to_solidus_subscriptions_subscriptions.rb +++ b/db/migrate/20161221155142_add_store_to_solidus_subscriptions_subscriptions.rb @@ -1,4 +1,4 @@ -class AddStoreToSolidusSubscriptionsSubscriptions < ActiveRecord::Migration +class AddStoreToSolidusSubscriptionsSubscriptions < SolidusSupport::Migration[4.2] def change add_reference :solidus_subscriptions_subscriptions, :store, index: true add_foreign_key :solidus_subscriptions_subscriptions, :spree_stores, column: :store_id diff --git a/db/migrate/20161223152905_add_address_id_to_solidus_subscriptions_subscriptions.rb b/db/migrate/20161223152905_add_address_id_to_solidus_subscriptions_subscriptions.rb index 2b8412d..559846d 100644 --- a/db/migrate/20161223152905_add_address_id_to_solidus_subscriptions_subscriptions.rb +++ b/db/migrate/20161223152905_add_address_id_to_solidus_subscriptions_subscriptions.rb @@ -1,4 +1,4 @@ -class AddAddressIdToSolidusSubscriptionsSubscriptions < ActiveRecord::Migration +class AddAddressIdToSolidusSubscriptionsSubscriptions < SolidusSupport::Migration[4.2] def change add_reference :solidus_subscriptions_subscriptions, :shipping_address add_index :solidus_subscriptions_subscriptions, :shipping_address_id, name: :index_subscription_shipping_address_id diff --git a/db/migrate/20170106224713_change_line_item_max_installments_to_end_date.rb b/db/migrate/20170106224713_change_line_item_max_installments_to_end_date.rb index 9bfdcf7..e4a29dc 100644 --- a/db/migrate/20170106224713_change_line_item_max_installments_to_end_date.rb +++ b/db/migrate/20170106224713_change_line_item_max_installments_to_end_date.rb @@ -1,4 +1,4 @@ -class ChangeLineItemMaxInstallmentsToEndDate < ActiveRecord::Migration +class ChangeLineItemMaxInstallmentsToEndDate < SolidusSupport::Migration[4.2] def change remove_column :solidus_subscriptions_line_items, :max_installments add_column :solidus_subscriptions_line_items, :end_date, :date diff --git a/db/migrate/20170111224458_change_subscription_actionable_date_to_datetime.rb b/db/migrate/20170111224458_change_subscription_actionable_date_to_datetime.rb index 25792f2..41c8978 100644 --- a/db/migrate/20170111224458_change_subscription_actionable_date_to_datetime.rb +++ b/db/migrate/20170111224458_change_subscription_actionable_date_to_datetime.rb @@ -1,4 +1,4 @@ -class ChangeSubscriptionActionableDateToDatetime < ActiveRecord::Migration +class ChangeSubscriptionActionableDateToDatetime < SolidusSupport::Migration[4.2] def change change_column :solidus_subscriptions_subscriptions, :actionable_date, :datetime end diff --git a/db/migrate/20170111232801_change_inteval_actionable_date_to_datetime.rb b/db/migrate/20170111232801_change_inteval_actionable_date_to_datetime.rb index d33b6a5..7af9c52 100644 --- a/db/migrate/20170111232801_change_inteval_actionable_date_to_datetime.rb +++ b/db/migrate/20170111232801_change_inteval_actionable_date_to_datetime.rb @@ -1,4 +1,4 @@ -class ChangeIntevalActionableDateToDatetime < ActiveRecord::Migration +class ChangeIntevalActionableDateToDatetime < SolidusSupport::Migration[4.2] def change change_column :solidus_subscriptions_installments, :actionable_date, :datetime end diff --git a/db/migrate/20170112012407_add_config_options_to_subscriptions.rb b/db/migrate/20170112012407_add_config_options_to_subscriptions.rb index 6020179..b761e4f 100644 --- a/db/migrate/20170112012407_add_config_options_to_subscriptions.rb +++ b/db/migrate/20170112012407_add_config_options_to_subscriptions.rb @@ -1,4 +1,4 @@ -class AddConfigOptionsToSubscriptions < ActiveRecord::Migration +class AddConfigOptionsToSubscriptions < SolidusSupport::Migration[4.2] def change add_column :solidus_subscriptions_subscriptions, :interval_length, :integer add_column :solidus_subscriptions_subscriptions, :interval_units, :integer diff --git a/lib/solidus_subscriptions.rb b/lib/solidus_subscriptions.rb index 9fe0080..31bb464 100644 --- a/lib/solidus_subscriptions.rb +++ b/lib/solidus_subscriptions.rb @@ -1,4 +1,5 @@ require 'solidus' +require 'solidus_support' require "solidus_subscriptions/ability" require 'solidus_subscriptions/engine' require 'deface' diff --git a/solidus_subscriptions.gemspec b/solidus_subscriptions.gemspec index 54468d1..51154ab 100644 --- a/solidus_subscriptions.gemspec +++ b/solidus_subscriptions.gemspec @@ -17,6 +17,7 @@ Gem::Specification.new do |s| s.test_files = Dir['test/**/*'] s.add_dependency 'solidus' + s.add_dependency "solidus_support" s.add_dependency 'deface' s.add_dependency 'state_machines' s.add_dependency 'i18n' diff --git a/spec/controllers/orders/create_subscription_line_items_spec.rb b/spec/controllers/orders/create_subscription_line_items_spec.rb index 49aeb28..337e025 100644 --- a/spec/controllers/orders/create_subscription_line_items_spec.rb +++ b/spec/controllers/orders/create_subscription_line_items_spec.rb @@ -12,7 +12,7 @@ RSpec.describe Spree::Controllers::Orders::CreateSubscriptionLineItems, type: :c end describe 'POST /orders/populate' do - subject { post :populate, params } + subject { post :populate, params: params } let!(:variant) { create :variant } let(:params) { line_item_params } diff --git a/spec/controllers/solidus_subscriptions/api/v1/line_items_controller_spec.rb b/spec/controllers/solidus_subscriptions/api/v1/line_items_controller_spec.rb index 97cfe1d..d2025dd 100644 --- a/spec/controllers/solidus_subscriptions/api/v1/line_items_controller_spec.rb +++ b/spec/controllers/solidus_subscriptions/api/v1/line_items_controller_spec.rb @@ -16,7 +16,7 @@ RSpec.describe SolidusSubscriptions::Api::V1::LineItemsController, type: :contro token: user.spree_api_key } end - subject { post :update, params } + subject { post :update, params: params } context 'guest user' do let(:order) { create :order } @@ -87,7 +87,7 @@ RSpec.describe SolidusSubscriptions::Api::V1::LineItemsController, type: :contro describe "#destroy" do let(:params) { { id: line.id, order_id: order.id, token: user.spree_api_key } } - subject { delete :destroy, params } + subject { delete :destroy, params: params } context "when the order is not ours" do let(:order) { create :order, user: create(:user) } diff --git a/spec/controllers/solidus_subscriptions/api/v1/subscriptions_controller_spec.rb b/spec/controllers/solidus_subscriptions/api/v1/subscriptions_controller_spec.rb index bbdd756..a4f9e6d 100644 --- a/spec/controllers/solidus_subscriptions/api/v1/subscriptions_controller_spec.rb +++ b/spec/controllers/solidus_subscriptions/api/v1/subscriptions_controller_spec.rb @@ -32,7 +32,7 @@ RSpec.describe SolidusSubscriptions::Api::V1::SubscriptionsController, type: :co end describe 'PATCH :update' do - subject { patch :update, params } + subject { patch :update, params: params } let(:params) do { id: subscription.id, @@ -86,14 +86,14 @@ RSpec.describe SolidusSubscriptions::Api::V1::SubscriptionsController, type: :co describe "POST :skip" do let(:params) { { id: subscription.id, token: user.spree_api_key } } - subject { post :skip, params } + subject { post :skip, params: params } it_behaves_like "an authenticated subscription" end describe "POST :cancel" do let(:params) { { id: subscription.id, token: user.spree_api_key } } - subject { post :cancel, params } + subject { post :cancel, params: params } it_behaves_like "an authenticated subscription" end diff --git a/spec/controllers/spree/admin/subscriptions_controller_spec.rb b/spec/controllers/spree/admin/subscriptions_controller_spec.rb index a026cf5..442301a 100644 --- a/spec/controllers/spree/admin/subscriptions_controller_spec.rb +++ b/spec/controllers/spree/admin/subscriptions_controller_spec.rb @@ -17,7 +17,7 @@ RSpec.describe Spree::Admin::SubscriptionsController, type: :controller do end describe 'POST cancel' do - subject { delete :cancel, id: subscription.id } + subject { delete :cancel, params: { id: subscription.id } } context 'the subscription can be canceled' do let(:subscription) { create :subscription, :actionable } @@ -50,7 +50,7 @@ RSpec.describe Spree::Admin::SubscriptionsController, type: :controller do end describe 'POST activate' do - subject { post :activate, id: subscription.id } + subject { post :activate, params: { id: subscription.id } } context 'the subscription can be activated' do let(:subscription) { create :subscription, :canceled, :with_line_item } @@ -84,7 +84,7 @@ RSpec.describe Spree::Admin::SubscriptionsController, type: :controller do end describe 'POST skip' do - subject { post :skip, id: subscription.id } + subject { post :skip, params: { id: subscription.id } } let(:subscription) { create :subscription, :actionable, :with_line_item } let!(:expected_date) { subscription.next_actionable_date } diff --git a/spec/controllers/spree/api/line_items_controller_spec.rb b/spec/controllers/spree/api/line_items_controller_spec.rb index 3c9c13a..9a56129 100644 --- a/spec/controllers/spree/api/line_items_controller_spec.rb +++ b/spec/controllers/spree/api/line_items_controller_spec.rb @@ -6,7 +6,7 @@ RSpec.describe Spree::Api::LineItemsController, type: :controller do routes { Spree::Core::Engine.routes } describe 'POST :create' do - subject { post :create, params } + subject { post :create, params: params } let(:params) { line_item_params } let!(:variant) { create :variant } @@ -63,7 +63,7 @@ RSpec.describe Spree::Api::LineItemsController, type: :controller do end describe 'patch :update' do - subject { patch :create, params } + subject { patch :create, params: params } let(:params) { line_item_params } let!(:variant) { create :variant } diff --git a/spec/controllers/spree/api/orders_controller_spec.rb b/spec/controllers/spree/api/orders_controller_spec.rb index a81c672..fe15ede 100644 --- a/spec/controllers/spree/api/orders_controller_spec.rb +++ b/spec/controllers/spree/api/orders_controller_spec.rb @@ -10,8 +10,8 @@ RSpec.describe Spree::Api::OrdersController, type: :controller do describe 'patch /update' do subject(:subscription_line_items) do - patch( :update, params) - order.subscription_line_items(true) + patch :update, params: params + order.subscription_line_items.reload end before { stub_authentication! } diff --git a/spec/controllers/spree/api/users_controller_spec.rb b/spec/controllers/spree/api/users_controller_spec.rb index 62011d1..470c837 100644 --- a/spec/controllers/spree/api/users_controller_spec.rb +++ b/spec/controllers/spree/api/users_controller_spec.rb @@ -11,7 +11,7 @@ RSpec.describe Spree::Api::UsersController, type: :controller do let!(:subscription) { create :subscription, :with_line_item, user: user } describe 'patch /update' do - subject { patch :update, params } + subject { patch :update, params: params } let(:params) do { @@ -38,7 +38,7 @@ RSpec.describe Spree::Api::UsersController, type: :controller do it 'updates the subscription line items' do subject - line_item = subscription.line_items(true).first + line_item = subscription.line_items.reload.first expect(line_item).to have_attributes(line_item_attributes) end diff --git a/spec/models/solidus_subscriptions/checkout_spec.rb b/spec/models/solidus_subscriptions/checkout_spec.rb index 5e8cc0b..4a156e1 100644 --- a/spec/models/solidus_subscriptions/checkout_spec.rb +++ b/spec/models/solidus_subscriptions/checkout_spec.rb @@ -148,7 +148,7 @@ RSpec.describe SolidusSubscriptions::Checkout do subject details = installments.map do |installments| - installments.details(true).last + installments.details.reload.last end expect(details).to all be_failed && have_attributes( diff --git a/spec/requests/solidus_subscriptions/api/v1/subscriptions_spec.rb b/spec/requests/solidus_subscriptions/api/v1/subscriptions_spec.rb index 62723a8..5d90985 100644 --- a/spec/requests/solidus_subscriptions/api/v1/subscriptions_spec.rb +++ b/spec/requests/solidus_subscriptions/api/v1/subscriptions_spec.rb @@ -11,7 +11,7 @@ RSpec.describe "Subscription endpoints", type: :request do end it "returns the canceled record", :aggregate_failures do - post solidus_subscriptions.cancel_api_v1_subscription_path(subscription), token: user.spree_api_key + post solidus_subscriptions.cancel_api_v1_subscription_path(subscription), params: { token: user.spree_api_key } expect(json_resp["state"]).to eq "canceled" expect(json_resp["actionable_date"]).to be_nil end @@ -22,7 +22,7 @@ RSpec.describe "Subscription endpoints", type: :request do end it "returns the record pending cancellation", :aggregate_failures do - post solidus_subscriptions.cancel_api_v1_subscription_path(subscription), token: user.spree_api_key + post solidus_subscriptions.cancel_api_v1_subscription_path(subscription), params: { token: user.spree_api_key } expect(json_resp["state"]).to eq "pending_cancellation" end end @@ -36,7 +36,7 @@ RSpec.describe "Subscription endpoints", type: :request do let(:expected_date) { "2016-10-27T00:00:00.000Z" } it "returns the updated record", :aggregate_failures do - post solidus_subscriptions.skip_api_v1_subscription_path(subscription), token: user.spree_api_key + post solidus_subscriptions.skip_api_v1_subscription_path(subscription), params: { token: user.spree_api_key } expect(json_resp["actionable_date"]).to eq expected_date end end |