Skip to content

Added v1 deallocate order spec #198

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 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 8 additions & 0 deletions app/models/deallocate_order.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require "flex_commerce_api/api_base"
module FlexCommerce
class DeallocateOrder < FlexCommerceApi::ApiBase
def self.table_name
"deallocate_order"
end
end
end
1 change: 1 addition & 0 deletions lib/flex_commerce.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ module V2
autoload :DataAttribute, File.join(gem_root, "app", "models", "data_attribute")
autoload :DataStoreRecord, File.join(gem_root, "app", "models", "data_store_record")
autoload :DataStoreType, File.join(gem_root, "app", "models", "data_store_type")
autoload :DeallocateOrder, File.join(gem_root, "app", "models", "deallocate_order")
autoload :DiscountSummary, File.join(gem_root, "app", "models", "discount_summary")
autoload :Email, File.join(gem_root, "app", "models", "email")
autoload :EwisOptIn, File.join(gem_root, "app", "models", "ewis_opt_in")
Expand Down
2 changes: 1 addition & 1 deletion lib/flex_commerce_api/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module FlexCommerceApi
VERSION = "0.8.3"
VERSION = "0.8.4"
end
60 changes: 60 additions & 0 deletions spec/integration/deallocate_order_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
require "spec_helper"
require "flex_commerce_api"
require "uri"

RSpec.describe FlexCommerce::DeallocateOrder do
# Global context for all specs - defines things you dont see defined in here
# such as flex_root_url, api_root, default_headers and page_size
# see api_globals.rb in spec/support for the source code
include_context "global context"

subject { described_class.create(order_id: 1) }

let(:headers) do
{
"Accept" => "application/vnd.api+json",
"Content-Type" => "application/vnd.api+json"}
}
end

context "when deallocating an order" do
before do
FlexCommerceApi.config.order_test_mode = false

request_body = {
data: {
type: "deallocate_order",
attributes: {
order_id: 1
}
}
}.to_json

stub_request(:post, "#{api_root}/deallocate_order.json_api")
.with(headers: headers, body: request_body)
.to_return do |request|
{
status: 201,
headers: headers,
body: {
data: {
id: "1",
type: "deallocate_order",
attributes: {
order_id: 1
}
}
}.to_json
}
end
end

it { is_expected.to be_a(described_class) }
it { is_expected.to have(0).errors }

# it "does not return errors" do
# expect(subject).to be_a described_class
# expect(subject.errors).to be_empty
# end
end
end