workarea-api-admin 4.4.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/README.md +82 -0
- data/Rakefile +10 -0
- data/app/assets/images/workarea/api/admin/icons/api.svg +1 -0
- data/app/controllers/workarea/api/admin/application_controller.rb +73 -0
- data/app/controllers/workarea/api/admin/categories_controller.rb +305 -0
- data/app/controllers/workarea/api/admin/category_product_rules_controller.rb +232 -0
- data/app/controllers/workarea/api/admin/content_assets_controller.rb +299 -0
- data/app/controllers/workarea/api/admin/content_controller.rb +268 -0
- data/app/controllers/workarea/api/admin/discounts_controller.rb +271 -0
- data/app/controllers/workarea/api/admin/email_signups_controller.rb +108 -0
- data/app/controllers/workarea/api/admin/fulfillments_controller.rb +268 -0
- data/app/controllers/workarea/api/admin/inventory_skus_controller.rb +305 -0
- data/app/controllers/workarea/api/admin/navigation_menus_controller.rb +267 -0
- data/app/controllers/workarea/api/admin/navigation_taxons_controller.rb +305 -0
- data/app/controllers/workarea/api/admin/orders_controller.rb +160 -0
- data/app/controllers/workarea/api/admin/pages_controller.rb +305 -0
- data/app/controllers/workarea/api/admin/payment_profiles_controller.rb +305 -0
- data/app/controllers/workarea/api/admin/payment_transactions_controller.rb +108 -0
- data/app/controllers/workarea/api/admin/payments_controller.rb +115 -0
- data/app/controllers/workarea/api/admin/prices_controller.rb +232 -0
- data/app/controllers/workarea/api/admin/pricing_skus_controller.rb +305 -0
- data/app/controllers/workarea/api/admin/product_images_controller.rb +232 -0
- data/app/controllers/workarea/api/admin/products_controller.rb +305 -0
- data/app/controllers/workarea/api/admin/promo_code_lists_controller.rb +305 -0
- data/app/controllers/workarea/api/admin/recommendation_settings_controller.rb +122 -0
- data/app/controllers/workarea/api/admin/redirects_controller.rb +305 -0
- data/app/controllers/workarea/api/admin/releases_controller.rb +304 -0
- data/app/controllers/workarea/api/admin/saved_addresses_controller.rb +232 -0
- data/app/controllers/workarea/api/admin/saved_credit_cards_controller.rb +256 -0
- data/app/controllers/workarea/api/admin/shipping_rates_controller.rb +232 -0
- data/app/controllers/workarea/api/admin/shipping_services_controller.rb +299 -0
- data/app/controllers/workarea/api/admin/shippings_controller.rb +105 -0
- data/app/controllers/workarea/api/admin/swagger_controller.rb +41 -0
- data/app/controllers/workarea/api/admin/tax_categories_controller.rb +242 -0
- data/app/controllers/workarea/api/admin/tax_rates_controller.rb +292 -0
- data/app/controllers/workarea/api/admin/users_controller.rb +296 -0
- data/app/controllers/workarea/api/admin/variants_controller.rb +232 -0
- data/app/models/workarea/api/admin/bulk_upsert.rb +74 -0
- data/app/models/workarea/user.decorator +7 -0
- data/app/views/workarea/admin/users/_api_permissions.html.haml +6 -0
- data/app/workers/workarea/perform_api_bulk_upsert.rb +15 -0
- data/bin/rails +18 -0
- data/config/initializers/append_points.rb +4 -0
- data/config/initializers/config.rb +15 -0
- data/config/locales/en.yml +9 -0
- data/config/routes.rb +81 -0
- data/lib/workarea/api/admin.rb +21 -0
- data/lib/workarea/api/admin/engine.rb +14 -0
- data/lib/workarea/api/admin/swagger.rb +106 -0
- data/test/documentation/workarea/api/admin/categories_documentation_test.rb +106 -0
- data/test/documentation/workarea/api/admin/category_product_rules_documentation_test.rb +78 -0
- data/test/documentation/workarea/api/admin/content_assets_documentation_test.rb +94 -0
- data/test/documentation/workarea/api/admin/content_documentation_test.rb +87 -0
- data/test/documentation/workarea/api/admin/discounts_documentation_test.rb +85 -0
- data/test/documentation/workarea/api/admin/email_signups_documentation_test.rb +41 -0
- data/test/documentation/workarea/api/admin/fulfillment_documentation_test.rb +84 -0
- data/test/documentation/workarea/api/admin/inventory_skus_documentation_test.rb +95 -0
- data/test/documentation/workarea/api/admin/navigation_menus_documentation_test.rb +81 -0
- data/test/documentation/workarea/api/admin/navigation_taxons_documentation_test.rb +94 -0
- data/test/documentation/workarea/api/admin/orders_documentation_test.rb +65 -0
- data/test/documentation/workarea/api/admin/pages_documentation_test.rb +93 -0
- data/test/documentation/workarea/api/admin/payment_profiles_documentation_test.rb +98 -0
- data/test/documentation/workarea/api/admin/payment_transactions_documentation_test.rb +43 -0
- data/test/documentation/workarea/api/admin/payments_documentation_test.rb +41 -0
- data/test/documentation/workarea/api/admin/prices_documentation_test.rb +82 -0
- data/test/documentation/workarea/api/admin/pricing_skus_documentation_test.rb +95 -0
- data/test/documentation/workarea/api/admin/product_images_documentation_test.rb +101 -0
- data/test/documentation/workarea/api/admin/products_documentation_test.rb +96 -0
- data/test/documentation/workarea/api/admin/promo_code_lists_documentation_test.rb +94 -0
- data/test/documentation/workarea/api/admin/recommendation_settings_documentation_test.rb +37 -0
- data/test/documentation/workarea/api/admin/redirects_documentation_test.rb +96 -0
- data/test/documentation/workarea/api/admin/release_changes_documentation_test.rb +32 -0
- data/test/documentation/workarea/api/admin/releases_documentation_test.rb +93 -0
- data/test/documentation/workarea/api/admin/saved_addresses_documentation_test.rb +92 -0
- data/test/documentation/workarea/api/admin/saved_credit_cards_documentation_test.rb +86 -0
- data/test/documentation/workarea/api/admin/shipping_rates_documentation_test.rb +78 -0
- data/test/documentation/workarea/api/admin/shipping_services_documentation_test.rb +93 -0
- data/test/documentation/workarea/api/admin/shippings_documentation_test.rb +41 -0
- data/test/documentation/workarea/api/admin/tax_categories_documentation_test.rb +95 -0
- data/test/documentation/workarea/api/admin/tax_rates_documentation_test.rb +78 -0
- data/test/documentation/workarea/api/admin/users_documentation_test.rb +99 -0
- data/test/documentation/workarea/api/admin/variants_documentation_test.rb +80 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/config/manifest.js +4 -0
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/jobs/application_job.rb +2 -0
- data/test/dummy/app/mailers/.keep +0 -0
- data/test/dummy/app/mailers/application_mailer.rb +4 -0
- data/test/dummy/app/models/.keep +0 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +34 -0
- data/test/dummy/bin/update +29 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +25 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/cable.yml +9 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +55 -0
- data/test/dummy/config/environments/production.rb +86 -0
- data/test/dummy/config/environments/test.rb +43 -0
- data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/new_framework_defaults.rb +21 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/workarea.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/puma.rb +47 -0
- data/test/dummy/config/routes.rb +6 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/config/spring.rb +6 -0
- data/test/dummy/db/seeds.rb +2 -0
- data/test/dummy/log/.keep +0 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/test/dummy/public/apple-touch-icon.png +0 -0
- data/test/dummy/public/favicon.ico +1 -0
- data/test/integration/workarea/api/admin/audit_log_integration_test.rb +20 -0
- data/test/integration/workarea/api/admin/authentication_integration_test.rb +61 -0
- data/test/integration/workarea/api/admin/categories_integration_test.rb +64 -0
- data/test/integration/workarea/api/admin/category_product_rules_integration_test.rb +58 -0
- data/test/integration/workarea/api/admin/content_assets_integration_test.rb +65 -0
- data/test/integration/workarea/api/admin/content_integration_test.rb +59 -0
- data/test/integration/workarea/api/admin/discounts_integration_test.rb +64 -0
- data/test/integration/workarea/api/admin/email_signups_integration_test.rb +32 -0
- data/test/integration/workarea/api/admin/error_handling_integration_test.rb +16 -0
- data/test/integration/workarea/api/admin/fulfillments_integration_test.rb +62 -0
- data/test/integration/workarea/api/admin/inventory_skus_integration_test.rb +70 -0
- data/test/integration/workarea/api/admin/navigation_menus_integration_test.rb +54 -0
- data/test/integration/workarea/api/admin/navigation_taxons_integration_test.rb +63 -0
- data/test/integration/workarea/api/admin/orders_integration_test.rb +53 -0
- data/test/integration/workarea/api/admin/pages_integration_test.rb +64 -0
- data/test/integration/workarea/api/admin/payment_profiles_integration_test.rb +75 -0
- data/test/integration/workarea/api/admin/payment_transactions_integration_test.rb +45 -0
- data/test/integration/workarea/api/admin/payments_integration_test.rb +29 -0
- data/test/integration/workarea/api/admin/prices_integration_test.rb +55 -0
- data/test/integration/workarea/api/admin/pricing_skus_integration_test.rb +72 -0
- data/test/integration/workarea/api/admin/product_images_integration_test.rb +56 -0
- data/test/integration/workarea/api/admin/products_integration_test.rb +66 -0
- data/test/integration/workarea/api/admin/promo_code_lists_integration_test.rb +70 -0
- data/test/integration/workarea/api/admin/recommendation_settings_integration_test.rb +41 -0
- data/test/integration/workarea/api/admin/redirects_integration_test.rb +69 -0
- data/test/integration/workarea/api/admin/release_changes_integration_test.rb +32 -0
- data/test/integration/workarea/api/admin/releases_integration_test.rb +60 -0
- data/test/integration/workarea/api/admin/saved_addresses_integration_test.rb +70 -0
- data/test/integration/workarea/api/admin/saved_credit_cards_integration_test.rb +76 -0
- data/test/integration/workarea/api/admin/shipping_rates_integration_test.rb +54 -0
- data/test/integration/workarea/api/admin/shipping_services_integration_test.rb +64 -0
- data/test/integration/workarea/api/admin/shippings_integration_test.rb +34 -0
- data/test/integration/workarea/api/admin/tax_categories_integration_test.rb +64 -0
- data/test/integration/workarea/api/admin/tax_rates_integration_test.rb +66 -0
- data/test/integration/workarea/api/admin/users_integration_test.rb +67 -0
- data/test/integration/workarea/api/admin/variants_integration_test.rb +59 -0
- data/test/models/workarea/api/admin/bulk_upsert_test.rb +79 -0
- data/test/test_helper.rb +10 -0
- data/test/vcr_cassettes/product_image_from_url.yml +43 -0
- data/workarea-api-admin.gemspec +18 -0
- metadata +252 -0
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'workarea/api/documentation_test'
|
3
|
+
|
4
|
+
module Workarea
|
5
|
+
module Api
|
6
|
+
module Admin
|
7
|
+
class OrdersDocumentationTest < DocumentationTest
|
8
|
+
include Workarea::Admin::IntegrationTest
|
9
|
+
|
10
|
+
resource 'Orders'
|
11
|
+
|
12
|
+
def test_and_document_index
|
13
|
+
description 'Listing orders'
|
14
|
+
route admin_api.orders_path
|
15
|
+
parameter :page, 'Current page'
|
16
|
+
parameter :sort_by, 'Field on which to sort (see responses for possible values)'
|
17
|
+
parameter :sort_direction, 'Direction to sort (asc or desc)'
|
18
|
+
|
19
|
+
2.times { |i| create_placed_order(id: 1000 + i) }
|
20
|
+
|
21
|
+
record_request do
|
22
|
+
get admin_api.orders_path,
|
23
|
+
params: { page: 1, sort_by: 'created_at', sort_direction: 'desc ' }
|
24
|
+
|
25
|
+
assert_equal(200, response.status)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_and_document_filtered_index
|
30
|
+
description 'Viewing orders by date range'
|
31
|
+
route admin_api.orders_path
|
32
|
+
parameter :page, 'Current page'
|
33
|
+
parameter :sort_by, 'Field on which to sort (see responses for possible values)'
|
34
|
+
parameter :sort_direction, 'Direction to sort (asc or desc)'
|
35
|
+
parameter :placed_at_greater_than, 'Start of a placed_at date range'
|
36
|
+
parameter :placed_at_less_than, 'End of a placed_at date range'
|
37
|
+
|
38
|
+
3.times { |i| create_placed_order(id: 1000 + i, placed_at: i.weeks.ago) }
|
39
|
+
|
40
|
+
record_request do
|
41
|
+
get admin_api.orders_path,
|
42
|
+
params:
|
43
|
+
{ page: 1,
|
44
|
+
sort_by: 'created_at',
|
45
|
+
sort_direction: 'desc',
|
46
|
+
placed_at_greater_than: 2.weeks.ago - 1.day,
|
47
|
+
placed_at_less_than: 2.weeks.ago + 1.day }
|
48
|
+
|
49
|
+
assert_equal(200, response.status)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_and_document_show
|
54
|
+
description 'Showing an order'
|
55
|
+
route admin_api.order_path(':id')
|
56
|
+
|
57
|
+
record_request do
|
58
|
+
get admin_api.order_path(create_placed_order.id)
|
59
|
+
assert_equal(200, response.status)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'workarea/api/documentation_test'
|
3
|
+
|
4
|
+
module Workarea
|
5
|
+
module Api
|
6
|
+
module Admin
|
7
|
+
class PagesDocumentationTest < DocumentationTest
|
8
|
+
include Workarea::Admin::IntegrationTest
|
9
|
+
|
10
|
+
resource 'Pages'
|
11
|
+
|
12
|
+
def sample_attributes
|
13
|
+
create_page.as_json.except('_id', 'slug')
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_and_document_index
|
17
|
+
description 'Listing pages'
|
18
|
+
route admin_api.pages_path
|
19
|
+
parameter :page, 'Current page'
|
20
|
+
parameter :sort_by, 'Field on which to sort (see responses for possible values)'
|
21
|
+
parameter :sort_direction, 'Direction to sort (asc or desc)'
|
22
|
+
|
23
|
+
2.times { create_page }
|
24
|
+
|
25
|
+
record_request do
|
26
|
+
get admin_api.pages_path,
|
27
|
+
params: { page: 1, sort_by: 'created_at', sort_direction: 'desc' }
|
28
|
+
|
29
|
+
assert_equal(200, response.status)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_and_document_create
|
34
|
+
description 'Creating a page'
|
35
|
+
route admin_api.pages_path
|
36
|
+
|
37
|
+
record_request do
|
38
|
+
post admin_api.pages_path, params: sample_attributes, as: :json
|
39
|
+
assert_equal(201, response.status)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_and_document_show
|
44
|
+
description 'Showing a page'
|
45
|
+
route admin_api.page_path(':id')
|
46
|
+
|
47
|
+
record_request do
|
48
|
+
get admin_api.page_path(create_page.id)
|
49
|
+
assert_equal(200, response.status)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_and_document_update
|
54
|
+
description 'Updating a page'
|
55
|
+
route admin_api.page_path(':id')
|
56
|
+
|
57
|
+
record_request do
|
58
|
+
patch admin_api.page_path(create_page.id),
|
59
|
+
params: sample_attributes,
|
60
|
+
as: :json
|
61
|
+
|
62
|
+
assert_equal(204, response.status)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_and_document_bulk_upsert
|
67
|
+
description 'Bulk upserting pages'
|
68
|
+
route admin_api.bulk_pages_path
|
69
|
+
|
70
|
+
record_request do
|
71
|
+
patch admin_api.bulk_pages_path,
|
72
|
+
params: { pages: [sample_attributes] * 3 },
|
73
|
+
as: :json
|
74
|
+
|
75
|
+
assert_equal(204, response.status)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_and_document_destroy
|
80
|
+
description 'Removing a page'
|
81
|
+
route admin_api.page_path(':id')
|
82
|
+
|
83
|
+
page = create_page
|
84
|
+
|
85
|
+
record_request do
|
86
|
+
delete admin_api.page_path(page.id), as: :json
|
87
|
+
assert_equal(204, response.status)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'workarea/api/documentation_test'
|
3
|
+
|
4
|
+
module Workarea
|
5
|
+
module Api
|
6
|
+
module Admin
|
7
|
+
class PaymentProfilesDocumentationTest < DocumentationTest
|
8
|
+
include Workarea::Admin::IntegrationTest
|
9
|
+
|
10
|
+
resource 'Payment Profiles'
|
11
|
+
|
12
|
+
def sample_attributes
|
13
|
+
@sample_attributes ||= create_payment_profile.as_json.except('_id')
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_and_document_index
|
17
|
+
description 'Listing payment profiles'
|
18
|
+
route admin_api.payment_profiles_path
|
19
|
+
parameter :page, 'Current page'
|
20
|
+
parameter :sort_by, 'Field on which to sort (see responses for possible values)'
|
21
|
+
parameter :sort_direction, 'Direction to sort (asc or desc)'
|
22
|
+
|
23
|
+
2.times { |i| create_payment_profile(reference: i) }
|
24
|
+
|
25
|
+
record_request do
|
26
|
+
get admin_api.payment_profiles_path,
|
27
|
+
params: { page: 1, sort_by: 'created_at', sort_direction: 'desc' }
|
28
|
+
|
29
|
+
assert_equal(200, response.status)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_and_document_create
|
34
|
+
description 'Creating a payment profile'
|
35
|
+
route admin_api.payment_profiles_path
|
36
|
+
|
37
|
+
record_request do
|
38
|
+
data = sample_attributes.merge('reference' => Payment::Profile.count + 1)
|
39
|
+
post admin_api.payment_profiles_path,
|
40
|
+
params: { payment_profile: data },
|
41
|
+
as: :json
|
42
|
+
|
43
|
+
assert_equal(201, response.status)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_and_document_show
|
48
|
+
description 'Showing a payment profile'
|
49
|
+
route admin_api.payment_profile_path(':id')
|
50
|
+
|
51
|
+
record_request do
|
52
|
+
get admin_api.payment_profile_path(create_payment_profile.id)
|
53
|
+
assert_equal(200, response.status)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_and_document_update
|
58
|
+
description 'Updating a payment profiles'
|
59
|
+
route admin_api.payment_profile_path(':id')
|
60
|
+
|
61
|
+
record_request do
|
62
|
+
patch admin_api.payment_profile_path(create_payment_profile.id),
|
63
|
+
params: { payment_profile: { store_credit: 29 } },
|
64
|
+
as: :json
|
65
|
+
|
66
|
+
assert_equal(204, response.status)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_and_document_bulk_upsert
|
71
|
+
description 'Bulk upserting payment profiles'
|
72
|
+
route admin_api.bulk_payment_profiles_path
|
73
|
+
|
74
|
+
count = Payment::Profile.count + 1
|
75
|
+
data = Array.new(3) { sample_attributes.merge('reference' => count) }
|
76
|
+
|
77
|
+
record_request do
|
78
|
+
patch admin_api.bulk_payment_profiles_path,
|
79
|
+
params: { payment_profiles: data },
|
80
|
+
as: :json
|
81
|
+
|
82
|
+
assert_equal(204, response.status)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_and_document_destroy
|
87
|
+
description 'Removing a payment profile'
|
88
|
+
route admin_api.payment_profile_path(':id')
|
89
|
+
|
90
|
+
record_request do
|
91
|
+
delete admin_api.payment_profile_path(create_payment_profile.id)
|
92
|
+
assert_equal(204, response.status)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'workarea/api/documentation_test'
|
3
|
+
|
4
|
+
module Workarea
|
5
|
+
module Api
|
6
|
+
module Admin
|
7
|
+
class PaymentTransactionsDocumentationTest < DocumentationTest
|
8
|
+
include Workarea::Admin::IntegrationTest
|
9
|
+
|
10
|
+
resource 'Payment transactions'
|
11
|
+
|
12
|
+
def test_and_document_index
|
13
|
+
description 'Listing payment transactions'
|
14
|
+
route admin_api.payment_transactions_path
|
15
|
+
parameter :page, 'Current page'
|
16
|
+
parameter :sort_by, 'Field on which to sort (see responses for possible values)'
|
17
|
+
parameter :sort_direction, 'Direction to sort (asc or desc)'
|
18
|
+
|
19
|
+
2.times { |i| create_placed_order(id: 1000 + i) }
|
20
|
+
|
21
|
+
record_request do
|
22
|
+
get admin_api.payment_transactions_path,
|
23
|
+
params: { page: 1, sort_by: 'created_at', sort_direction: 'desc' }
|
24
|
+
|
25
|
+
assert_equal(200, response.status)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_and_document_show
|
30
|
+
description 'Showing a payment transaction'
|
31
|
+
route admin_api.payment_transaction_path(':id')
|
32
|
+
|
33
|
+
create_placed_order
|
34
|
+
|
35
|
+
record_request do
|
36
|
+
get admin_api.payment_transaction_path(Payment::Transaction.first.id)
|
37
|
+
assert_equal(200, response.status)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'workarea/api/documentation_test'
|
3
|
+
|
4
|
+
module Workarea
|
5
|
+
module Api
|
6
|
+
module Admin
|
7
|
+
class PaymentsDocumentationTest < DocumentationTest
|
8
|
+
include Workarea::Admin::IntegrationTest
|
9
|
+
|
10
|
+
resource 'Payments'
|
11
|
+
|
12
|
+
def test_and_document_index
|
13
|
+
description 'Listing payments'
|
14
|
+
route admin_api.payments_path
|
15
|
+
parameter :page, 'Current page'
|
16
|
+
parameter :sort_by, 'Field on which to sort (see responses for possible values)'
|
17
|
+
parameter :sort_direction, 'Direction to sort (asc or desc)'
|
18
|
+
|
19
|
+
2.times { |i| create_placed_order(id: 1000 + i) }
|
20
|
+
|
21
|
+
record_request do
|
22
|
+
get admin_api.payments_path,
|
23
|
+
params: { page: 1, sort_by: 'created_at', sort_direction: 'desc' }
|
24
|
+
|
25
|
+
assert_equal(200, response.status)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_and_document_show
|
30
|
+
description 'Showing an payment'
|
31
|
+
route admin_api.payment_path(':id')
|
32
|
+
|
33
|
+
record_request do
|
34
|
+
get admin_api.payment_path(create_placed_order.id)
|
35
|
+
assert_equal(200, response.status)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'workarea/api/documentation_test'
|
3
|
+
|
4
|
+
module Workarea
|
5
|
+
module Api
|
6
|
+
module Admin
|
7
|
+
class PricesDocumentationTest < DocumentationTest
|
8
|
+
include Workarea::Admin::IntegrationTest
|
9
|
+
|
10
|
+
resource 'Prices'
|
11
|
+
|
12
|
+
def pricing_sku
|
13
|
+
@pricing_sku ||= create_pricing_sku
|
14
|
+
end
|
15
|
+
|
16
|
+
def sample_attributes
|
17
|
+
{ regular: 15 }
|
18
|
+
end
|
19
|
+
|
20
|
+
def create_price
|
21
|
+
pricing_sku.prices.create!(sample_attributes)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_and_document_index
|
25
|
+
description 'Listing pricing sku prices'
|
26
|
+
route admin_api.pricing_sku_prices_path(':pricing_sku_id')
|
27
|
+
parameter :page, 'Current page'
|
28
|
+
parameter :sort_by, 'Field on which to sort (see responses for possible values)'
|
29
|
+
parameter :sort_direction, 'Direction to sort (asc or desc)'
|
30
|
+
|
31
|
+
2.times { create_price }
|
32
|
+
|
33
|
+
record_request do
|
34
|
+
get admin_api.pricing_sku_prices_path(pricing_sku.id),
|
35
|
+
params: { page: 1, sort_by: 'created_at', sort_direction: 'desc' }
|
36
|
+
|
37
|
+
assert_equal(200, response.status)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_and_document_create
|
42
|
+
description 'Creating a pricing sku price'
|
43
|
+
route admin_api.pricing_sku_prices_path(':pricing_sku_id')
|
44
|
+
|
45
|
+
record_request do
|
46
|
+
post admin_api.pricing_sku_prices_path(pricing_sku.id),
|
47
|
+
params: { price: sample_attributes },
|
48
|
+
as: :json
|
49
|
+
|
50
|
+
assert_equal(201, response.status)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def test_and_document_update
|
55
|
+
description 'Updating a pricing sku price'
|
56
|
+
route admin_api.pricing_sku_price_path(':pricing_sku_id', ':id')
|
57
|
+
|
58
|
+
price = create_price
|
59
|
+
|
60
|
+
record_request do
|
61
|
+
patch admin_api.pricing_sku_price_path(pricing_sku.id, price.id),
|
62
|
+
params: { price: { regular: 15 } }
|
63
|
+
|
64
|
+
assert_equal(204, response.status)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_and_document_destroy
|
69
|
+
description 'Removing a pricing sku price'
|
70
|
+
route admin_api.pricing_sku_price_path(':pricing_sku_id', ':id')
|
71
|
+
|
72
|
+
price = create_price
|
73
|
+
|
74
|
+
record_request do
|
75
|
+
delete admin_api.pricing_sku_price_path(pricing_sku.id, price.id)
|
76
|
+
assert_equal(204, response.status)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'workarea/api/documentation_test'
|
3
|
+
|
4
|
+
module Workarea
|
5
|
+
module Api
|
6
|
+
module Admin
|
7
|
+
class PricingSkusDocumentationTest < DocumentationTest
|
8
|
+
include Workarea::Admin::IntegrationTest
|
9
|
+
|
10
|
+
resource 'Pricing SKUs'
|
11
|
+
|
12
|
+
def sample_attributes
|
13
|
+
@sample_attributes ||= create_pricing_sku.as_json.except('_id')
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_and_document_index
|
17
|
+
description 'Listing pricing SKUs'
|
18
|
+
route admin_api.pricing_skus_path
|
19
|
+
parameter :page, 'Current page'
|
20
|
+
parameter :sort_by, 'Field on which to sort (see responses for possible values)'
|
21
|
+
parameter :sort_direction, 'Direction to sort (asc or desc)'
|
22
|
+
|
23
|
+
2.times { |i| create_pricing_sku(id: "SKU#{i}") }
|
24
|
+
|
25
|
+
record_request do
|
26
|
+
get admin_api.pricing_skus_path,
|
27
|
+
params: { page: 1, sort_by: 'created_at', sort_direction: 'desc' }
|
28
|
+
|
29
|
+
assert_equal(200, response.status)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_and_document_create
|
34
|
+
description 'Creating an pricing SKU'
|
35
|
+
route admin_api.pricing_skus_path
|
36
|
+
|
37
|
+
record_request do
|
38
|
+
post admin_api.pricing_skus_path,
|
39
|
+
params: { pricing_sku: sample_attributes.merge('_id' => 'SKU2') },
|
40
|
+
as: :json
|
41
|
+
|
42
|
+
assert_equal(201, response.status)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_and_document_show
|
47
|
+
description 'Showing an pricing SKU'
|
48
|
+
route admin_api.pricing_sku_path(':id')
|
49
|
+
|
50
|
+
record_request do
|
51
|
+
get admin_api.pricing_sku_path(create_pricing_sku.id)
|
52
|
+
assert_equal(200, response.status)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_and_document_update
|
57
|
+
description 'Updating an pricing SKU'
|
58
|
+
route admin_api.pricing_sku_path(':id')
|
59
|
+
|
60
|
+
record_request do
|
61
|
+
patch admin_api.pricing_sku_path(create_pricing_sku.id),
|
62
|
+
params: { pricing_sku: { discountable: false } },
|
63
|
+
as: :json
|
64
|
+
|
65
|
+
assert_equal(204, response.status)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_and_document_bulk_upsert
|
70
|
+
description 'Bulk upserting pricing SKUs'
|
71
|
+
route admin_api.bulk_pricing_skus_path
|
72
|
+
|
73
|
+
record_request do
|
74
|
+
data = Array.new(3) { sample_attributes.merge('_id' => Pricing::Sku.count) }
|
75
|
+
patch admin_api.bulk_pricing_skus_path,
|
76
|
+
params: { pricing_skus: data },
|
77
|
+
as: :json
|
78
|
+
|
79
|
+
assert_equal(204, response.status)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_and_document_destroy
|
84
|
+
description 'Removing an pricing SKU'
|
85
|
+
route admin_api.pricing_sku_path(':id')
|
86
|
+
|
87
|
+
record_request do
|
88
|
+
delete admin_api.pricing_sku_path(create_pricing_sku.id)
|
89
|
+
assert_equal(204, response.status)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|