diff options
author | Alex Blackie <alex@alexblackie.com> | 2016-09-23 09:56:22 -0700 |
---|---|---|
committer | Alex Blackie <alex@alexblackie.com> | 2016-09-23 11:54:14 -0700 |
commit | 27f39118c775c336f213e258a38de8de9b60d313 (patch) | |
tree | 983ee660fd5bced284bf878a2264c09537a625b8 /spec/controllers | |
parent | e2d602ebd0b0789399a71ec03e94b05bc9e7d9eb (diff) |
Add destroy endpoint for subscription line items
Allows you to remove subscription line items from an order.
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/solidus_subscriptions/api/v1/line_items_controller_spec.rb | 23 |
1 files changed, 22 insertions, 1 deletions
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 1fdcb36..e09255c 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 @@ -6,8 +6,9 @@ RSpec.describe SolidusSubscriptions::Api::V1::LineItemsController, type: :contro let!(:user) { create(:user) } before { user.generate_spree_api_key! } + let(:line) { create :subscription_line_item, order: order } + describe "#update" do - let(:line) { create :subscription_line_item, order: order } let(:params) do { id: line.id, @@ -47,4 +48,24 @@ RSpec.describe SolidusSubscriptions::Api::V1::LineItemsController, type: :contro it { is_expected.to be_unauthorized } end end + + describe "#destroy" do + let(:params) { { id: line.id, order_id: order.id, token: user.spree_api_key } } + subject { delete :destroy, params } + + context "when the order is not ours" do + let(:order) { create :order, user: create(:user) } + it { is_expected.to be_unauthorized } + end + + context "when the order is finalised" do + let(:order) { create :completed_order_with_totals, user: user } + it { is_expected.to be_bad_request } + end + + context "when the order is ours and incomplete" do + let(:order) { create :order, user: user } + it { is_expected.to be_success } + end + end end |